/* ==========================================================================
   JEU 05 : INTERVALLES MUSICAUX (STYLES SPÉCIFIQUES)
   ========================================================================== */

/* ==========================================================================
   1. LAYOUT & STRUCTURE
   ========================================================================== */

.game-container {
    width: 100%; height: 100%;
    padding: 1.5rem; 
    box-sizing: border-box;
    flex: 1; /* AJOUT CRITIQUE : force le conteneur à remplir le plateau */
    display: flex; flex-direction: column;
    justify-content: space-between; /* Espacement optimal */
    align-items: center;
    position: relative; z-index: 2; /* Remplacement du absolute */
    transition: opacity 0.3s ease;
}

#game-over-overlay.visible ~ .game-container { 
    opacity: 0; pointer-events: none; 
}

.game-header > *, .game-actions-row > *, .settings-btn, .icon-btn, .score-box { 
    pointer-events: auto; 
}

.game-center-wrapper {
    flex-grow: 1; width: 100%;
    display: flex; flex-direction: column;
    align-items: center; 
    justify-content: center; /* Centré au lieu de flex-start pour un meilleur équilibre */
    min-height: 0;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.blurred { filter: blur(15px); opacity: 0.3; pointer-events: none; }

#status-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    cursor: pointer;
}
#status-overlay.hidden { display: none !important; opacity: 0; }

.status-main-text {
    font-family: var(--font-heading); 
    font-size: 5.5rem; 
    font-weight: 500; 
    color: var(--text-primary); 
    letter-spacing: -4px; 
    line-height: 1; 
    transition: opacity 0.2s;
}

.status-sub-text {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-top: 1.5rem;
    font-family: var(--font-body); font-size: 1.1rem;
    color: var(--text-secondary); font-weight: 500;
    text-transform: uppercase; letter-spacing: 1px;
}

.status-sub-text svg {
    width: 24px; height: 24px;
    color: var(--text-primary); 
}

.game-board:fullscreen .status-main-text { font-size: 8.5rem; }
.game-board:fullscreen .status-sub-text { font-size: 1.5rem; margin-top: 2rem; }
.game-board:fullscreen .status-sub-text svg { width: 32px; height: 32px; }

/* FIX : Forcer l'annulation des transitions globales sur les icônes des boutons */
.icon-btn, 
.settings-btn, 
.icon-btn svg, 
.settings-btn svg,
.back-btn,
.back-btn svg {
    transition: none !important;
    animation: none !important;
}

/* ==========================================================================
   2. ZONE DE JEU (LECTEUR & REPONSES)
   ========================================================================== */

.main-play-area { 
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    flex-grow: 1; 
    width: 100%;
}

.replay-circle {
    width: 140px; height: 140px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    background: var(--bg-main);
    border: 2px solid var(--border-color); 
    border-radius: var(--radius-md); 
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
    transition: all 0.2s;
}

.replay-circle svg { width: 70px; height: 70px; display: block; transition: none !important; }

.replay-circle:hover {
    border-color: var(--accent-color); color: var(--accent-color);
    transform: scale(1.05);
}

.replay-circle.playing {
    border-color: var(--accent-color); color: var(--accent-color);
    animation: pulseSound 1s infinite;
}

.replay-circle.disabled {
    opacity: 0.5; pointer-events: none;
    filter: grayscale(1); transform: scale(0.95);
}

.status-text {
    margin-top: 2rem; min-height: 2rem;
    font-family: var(--font-heading); font-size: 1.4rem;
    text-transform: uppercase; letter-spacing: 2px;
    color: var(--text-secondary); font-weight: 500;
    text-align: center;
}

.answers-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 15px; width: 100%; max-width: 800px;
    margin-top: 0; margin-bottom: 0 !important;
}

.answer-btn {
    height: 100%; padding: 16px 10px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 5px; cursor: pointer;
    background: var(--bg-main); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); color: var(--text-primary);
    transition: all 0.15s; user-select: none;
}

.answer-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.btn-name { font-family: var(--font-body); font-weight: 500; font-size: 0.95rem; text-align: center; }
.ratio-text { font-family: 'Space Grotesk', monospace; font-size: 0.8rem; opacity: 0.6; }

.btn-correct { 
    background-color: var(--accent-color) !important; 
    color: white !important; 
    border-color: var(--accent-color) !important; 
}
.btn-wrong { 
    background-color: var(--accent-color-secondary) !important; 
    color: white !important; 
    border-color: var(--accent-color-secondary) !important; 
    animation: shake 0.4s; 
}


/* ==========================================================================
   3. UI HEADER (SCORE & VIES)
   ========================================================================== */

.score-box { 
    flex-direction: column; 
    width: 72px; /* Calibré sur .icon-btn */
    height: 72px;
    min-width: unset;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}
.stat-box {
    font-family: var(--font-heading); color: var(--text-primary);
    font-size: 1.8rem; font-weight: 500; line-height: 1;
}
.label-small {
    font-size: 0.75rem; text-transform: uppercase;
    color: var(--text-secondary); font-weight: 700;
}

.lives-display {
    display: flex; align-items: flex-start; justify-content: center;
    gap: 8px; height: 100%; padding-top: 5px;
}

.lives-display span {
    font-size: 3.5rem; font-weight: 600; line-height: 1;
    color: var(--text-primary);
}

#lives-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* NOUVEAU STYLE CŒURS AVEC DÉGRADÉ SVG ET OMBRE PORTÉE */
.heart-icon {
    height: 5.5vh; 
    width: auto;
    min-height: 40px; 
    max-height: 55px;
    overflow: visible !important;
    transition: all 0.3s;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* L'ombre portée */
}
/* Gestion du cœur vide quand on perd une vie */
.heart-icon.heart-lost .heart-bg {
    fill: var(--border-color) !important; /* Rétablit la marque sombre */
}

.heart-icon.heart-lost .heart-overlay {
    fill: transparent !important; /* Enlève le dégradé brillant */
}

.heart-icon.heart-lost {
    opacity: 0.5; 
    transform: scale(0.9);
    filter: none; /* Enlève l'ombre quand la vie est perdue */
}

/* ==========================================================================
   4. ACTIONS & SETTINGS
   ========================================================================== */

.game-actions-row { 
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto; 
    margin-bottom: 0; 
}

.mode-switch-wrapper {
    display: flex; position: relative; background-color: var(--bg-main);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    padding: 4px; margin-bottom: 1.5rem;
}
.mode-switch-wrapper input[type="radio"] { display: none; }
.mode-switch-wrapper label {
    flex: 1; text-align: center; padding: 10px 0; font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem;
    color: var(--text-secondary); cursor: pointer; z-index: 2; margin: 0; transition: color 0.3s ease; text-transform: uppercase; letter-spacing: 1px;
}
.mode-switch-wrapper input:checked + label { color: var(--text-primary); }
.mode-slider {
    position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px);
    background-color: var(--card-bg); border-radius: 6px; z-index: 1;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.mode-switch-wrapper input[value="sandbox"]:checked ~ .mode-slider { transform: translateX(100%); }

select {
    background-color: var(--bg-main); color: var(--text-primary);
    border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius-md);
    font-family: var(--font-body); font-size: 1rem; cursor: pointer; outline: none; width: 100%; max-width: 140px;
}
select:focus { border-color: var(--accent-color); box-shadow: 0 0 0 2px var(--accent-glow); }


/* ==========================================================================
   5. UI RESULTATS ET GRAPHIQUES (RANKED / SANDBOX)
   ========================================================================== */

.results-view { width: 100%; display: flex; flex-direction: column; align-items: center; }
.results-view.hidden { display: none !important; }

/* MODIFIÉ : Retrait des marges massives et harmonisation */
.centered-score-item { text-align: center; margin-bottom: 3rem; }

.centered-score-item .res-label { font-size: 1.2rem; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; opacity: 0.7; display: block; margin-bottom: 0.8rem; }

.big-score-container { display: flex; align-items: baseline; justify-content: center; position: relative; }

#results-ranked .res-value.big, #results-sandbox .res-value.big { 
    font-size: 5.5rem; font-weight: 700; line-height: 1; font-family: var(--font-heading); 
}

.score-unit { font-size: 1.4rem; color: var(--accent-color); margin-left: 8px; font-family: var(--font-heading); font-weight: 500; }

.distribution-chart-container {
    position: relative; width: 100%; max-width: 650px; height: 180px;
    margin: 1.5rem 0 2rem 0;
    border-bottom: 2px solid var(--border-color); cursor: crosshair;
}
.curve-svg { width: 100%; height: 100%; overflow: visible; }
.axis-label { position: absolute; bottom: -25px; font-family: var(--font-body); font-size: 0.8rem; color: var(--text-secondary); }
.axis-label.left { left: 0; }
.axis-label.right { right: 0; }

.hover-line {
    position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text-primary);
    transform: translateX(-50%); pointer-events: none; opacity: 0.3; z-index: 3; transition: opacity 0.2s ease;
}
.chart-tooltip {
    position: absolute; top: -55px; transform: translateX(-50%); background: var(--card-bg); border: 1px solid var(--border-color);
    padding: 6px 12px; border-radius: var(--radius-md); font-family: var(--font-body); font-size: 0.9rem; color: var(--text-primary); pointer-events: none;
    white-space: nowrap; z-index: 10; box-shadow: var(--shadow-card); text-align: center; line-height: 1.4; transition: opacity 0.2s ease, visibility 0.2s ease;
}
.hover-line.hidden, .chart-tooltip.hidden { opacity: 0 !important; visibility: hidden !important; }

.score-marker {
    position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center;
    transform: translateX(-50%); pointer-events: none; transition: left 0.5s ease-out;
}
.marker-line { width: 2px; height: 100%; border-left: 2px dashed currentColor; }
.marker-label { position: absolute; font-family: var(--font-heading); font-size: 0.8rem; font-weight: 700; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; }
.marker-current { color: var(--accent-color); z-index: 2; }
.marker-current .marker-label { bottom: 100%; margin-bottom: 5px; background: var(--bg-main); border: 1px solid currentColor;}
.marker-best { color: var(--text-tertiary); z-index: 1; opacity: 1;}
.marker-best .marker-label { top: 100%; margin-top: 5px; color: var(--text-secondary); }

/* --- Stats Sandbox --- */
.sandbox-stats {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; 
    margin: 1.5rem 0 0.5rem 0; width: 100%; max-width: 600px;
}
.stat-box-small {
    background: transparent; border: 1px solid var(--border-color); padding: 12px 20px;
    border-radius: var(--radius-md); display: flex; flex-direction: column; align-items: center; min-width: 120px;
}
.stat-title { font-family: var(--font-heading); font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.stat-value { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 600; color: var(--text-primary); }

/* --- Graphique en Barres Sandbox --- */
.history-chart {
    display: flex; align-items: stretch; justify-content: center; gap: 16px;
    height: 120px; width: max-content; max-width: 100%; margin: 0 auto;
    padding: 0 60px; border-bottom: 2px solid var(--border-color);
    overflow-x: auto; scrollbar-width: none; 
}
.history-chart::-webkit-scrollbar { display: none; }
.history-bar-wrapper {
    display: flex; flex-direction: column; align-items: center;
    justify-content: flex-end; height: 100%; position: relative; flex-shrink: 1;
}
.history-bar {
    width: 45px; background-color: var(--accent-color);
    opacity: 0.8; border-radius: 6px 6px 0 0; position: relative;
    transition: none !important;
}
.bar-label {
    font-size: 0.85rem; font-family: var(--font-body);
    color: var(--text-primary); margin-bottom: 6px; font-weight: 600;
}
.bar-index {
    position: absolute; top: 100%; margin-top: 6px;
    font-size: 0.8rem; font-family: var(--font-heading); color: var(--text-secondary);
}

#restart-btn { margin-top: 2rem; }

/* Bouton pour quitter le plein écran */
.exit-fs-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: none; 
    padding: 8px;
    z-index: 10000;
    transition: color var(--transition-fast);
}
.exit-fs-btn svg { width: 32px; height: 32px; }
.exit-fs-btn:hover { color: var(--accent-color-secondary); }
.game-board:fullscreen .exit-fs-btn { display: block; }

/* ==========================================================================
   6. ANIMATIONS & RESPONSIVE
   ========================================================================== */

@keyframes pulseSound { 
    0% { box-shadow: 0 0 0 0 var(--accent-glow); } 
    70% { box-shadow: 0 0 0 30px rgba(0,0,0,0); } 
    100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } 
}
@keyframes shake { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-5px); } 
    75% { transform: translateX(5px); } 
}

/* NOUVEAU : Forcer l'occupation de tout l'espace sur Desktop / grands écrans */
.game-page .main-content {
    display: flex;
    flex-direction: column;
}

.game-board {
    flex: 1 0 auto; 
    display: flex;
    flex-direction: column;
    min-height: 600px;
    margin-bottom: 0 !important; 
}

/* FIX OVERLAY DESKTOP : Plus d'espace ! */
#game-over-overlay .overlay-content {
    height: auto;
    min-height: 100%;
    padding: 4rem 0; 
}

/* Overrides Mode Plein Écran */
.game-board:fullscreen .replay-circle { width: 180px; height: 180px; }
.game-board:fullscreen .replay-circle svg { width: 90px; height: 90px; }
.game-board:fullscreen .answers-grid { max-width: 1100px; gap: 20px; }
.game-board:fullscreen .answer-btn { padding: 24px 15px; }
.game-board:fullscreen .btn-name { font-size: 1.1rem; }
.game-board:fullscreen .status-text { font-size: 2rem; margin-top: 0 !important; }

@media (max-width: 900px) { 
    .status-main-text { font-size: 5rem; } 
}

@media (max-width: 700px) {
    .score-box { 
        width: 60px !important; 
        height: 60px !important; 
        min-width: unset !important; 
        padding: 0 !important; 
    }
    .answers-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .stat-box { font-size: 1.5rem; }
    .game-container { padding-bottom: 3rem; }
    
    .status-main-text { font-size: 4rem; }
    .status-sub-text { font-size: 0.9rem; flex-wrap: wrap; }
    
    #results-ranked .res-value.big, #results-sandbox .res-value.big { font-size: 4.5rem; }
    .score-unit { font-size: 1.2rem; }
    .distribution-chart-container { height: 140px; margin-top: 1.5rem; margin-bottom: 2.5rem; }
    
    #restart-btn { margin-top: 1rem; }
    
    .sandbox-stats { gap: 0.5rem; margin: 1.5rem 0 1rem 0; flex-direction: column; align-items: center; }
    .stat-box-small { padding: 10px; min-width: 100px; }
    .stat-value { font-size: 1.2rem; }

    .history-chart { gap: 8px; height: 100px; padding: 0 40px; }
    .history-bar { width: 35px; }
    .bar-label { font-size: 0.75rem; }


    .game-page .replay-circle {
        width: 100px !important;
        height: 100px !important;
    }
    .game-page .replay-circle svg {
        width: 50px !important;
        height: 50px !important;
    }

    /* 2. Rapprocher le texte de statut (Correct/Faux) */
    .game-page .status-text {
        margin-top: 1rem !important;
        font-size: 1.2rem !important;
        min-height: 1.5rem !important;
    }

    /* 3. Compacter la grille des réponses (3 colonnes pour gagner de la place en hauteur) */
    .game-page .answers-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    /* 4. Réduire la taille de la police et les marges internes des boutons */
    .game-page .answer-btn {
        padding: 8px 4px !important;
        gap: 2px !important;
    }
    .game-page .btn-name {
        font-size: 0.8rem !important;
    }
    .game-page .ratio-text {
        font-size: 0.7rem !important;
    }

    /* 5. NEUTRALISER LE GROSSISSEMENT PLEIN ÉCRAN SUR MOBILE */
    .game-page .game-board:fullscreen .replay-circle {
        width: 100px !important;
        height: 100px !important;
    }
    .game-page .game-board:fullscreen .replay-circle svg {
        width: 50px !important;
        height: 50px !important;
    }
    .game-page .game-board:fullscreen .answers-grid {
        gap: 8px !important;
    }
    .game-page .game-board:fullscreen .answer-btn {
        padding: 8px 4px !important;
    }
    .game-page .game-board:fullscreen .btn-name {
        font-size: 0.8rem !important;
    }
    .game-page .game-board:fullscreen .status-text {
        font-size: 1.2rem !important;
        margin-top: 1rem !important;
    }

    /* 6. Enlever l'espace vide autour du bouton sonore */
    .game-page .main-play-area {
        flex-grow: 0 !important; /* Empêche la zone de s'étirer verticalement */
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }
    
    /* 7. Recentrer l'ensemble (bouton + grille) au milieu de l'écran */
    .game-page .game-center-wrapper {
        justify-content: center !important;
    }

    /* FIX 1 : Main Content aligné en HAUT (Mobile) */
    .game-page .main-content {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important; 
        height: auto !important; 
        min-height: calc(100svh - 80px) !important;
        padding-top: 80px !important;
        padding-bottom: 0 !important; 
        padding-left: 0 !important; 
        padding-right: 0 !important;
    }

    /* FIX 2 : Plateau remplit tout jusqu'au footer */
    .game-board { 
        flex: 1 1 100% !important;     
        display: flex !important;      
        flex-direction: column !important; 
        height: auto !important;
        min-height: calc(100svh - 80px) !important; 
        max-height: none !important;
        margin: 0 !important;          
        border-radius: 0;              
    }

    /* FIX 3 : Overlay de fin avec padding réel (Scroll possible si petit écran) */
    #game-over-overlay { overflow-y: auto !important; }
    #game-over-overlay .overlay-content {
        height: auto !important;
        min-height: 100% !important;
        padding: 4rem 0 3rem 0 !important; 
        justify-content: center !important;
        gap: 2.5rem !important;
    }

    /* Ajustement du padding quand on passe en plein écran ou faux plein écran */
    .game-page .game-board:fullscreen .game-container,
    .ios-fullscreen .game-container {
        padding-top: 3rem !important; 
        padding-bottom: 2rem !important;
    }
}

/* ==========================================================================
   7. FALLBACK PLEIN ECRAN (BULLDOZER)
   ========================================================================== */

/* Fullscreen Natif PC : Fixe les bases */
.game-board:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    background-color: var(--bg-main);
    display: flex !important;
    flex-direction: column !important;
}

.ios-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
    border: none !important;
    background-color: var(--bg-main) !important;
    display: flex !important;
    flex-direction: column !important; /* CRITIQUE : Empêche l'écrasement de la zone de jeu */
}

.ios-fullscreen .exit-fs-btn { display: block !important; }
.ios-fullscreen ~ * #icon-expand { display: none !important; }
.ios-fullscreen ~ * #icon-compress { display: block !important; }

/* ==========================================================================
   AFFICHAGE DU NOUVEAU RECORD
   ========================================================================== */
.new-record, 
#new-record-msg {
    color: var(--record-color, #FFA914) !important;
}

.new-record svg {
    color: var(--record-color, #FFA914) !important;
}

.input-select, select {
    background-color: var(--bg-main); color: var(--text-primary);
    border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius-md);
    font-family: var(--font-body); font-size: 0.95rem; cursor: pointer; outline: none;
    width: auto; min-width: 140px; max-width: 200px;
    text-align: center;
    text-align-last: center;
}
