/* Importation de la police Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* =================================================================
   1. VARIABLES ET BASE
   ================================================================= */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #e74c3c;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dee2e6;
    --shadow: 0 4px 15px rgba(0,0,0,0.1);
    --radius: 12px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text);
    margin: 0; padding: 0;
    display: flex; justify-content: center;
    min-height: 100vh;
    transition: background-color 0.3s ease; /* Pour l'effet vert/rouge */
}

/* --- FLASH BACKGROUNDS (Bonne/Mauvaise réponse) --- */
body.bg-success { background-color: #d4edda !important; }
body.bg-danger { background-color: #f8d7da !important; }

.main-container { width: 100%; max-width: 1200px; padding: 20px; }

/* =================================================================
   2. PAGE D'ACCUEIL
   ================================================================= */
.menu-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 30px; background: var(--bg-card); padding: 20px 30px;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-header h1 { margin: 0; font-size: 1.5rem; }
#progress{margin: 0;}

.lang-selector { display: flex; gap: 10px; }
.lang-btn {
    padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
    background: white; text-decoration: none; color: var(--text);
    font-weight: 600; cursor: pointer; transition: 0.2s;
}
.lang-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Raccourcis */
.category-shortcuts {
    background: white; padding: 15px; border-radius: var(--radius);
    margin-bottom: 30px; box-shadow: var(--shadow); position: sticky;
    top: 10px; z-index: 100;
}
.shortcuts-wrapper { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.shortcut-link {
    text-decoration: none; background: var(--bg-body); padding: 6px 15px;
    border-radius: 20px; font-size: 0.85rem; color: var(--text);
    font-weight: 500; border: 1px solid transparent; transition: 0.2s;
}
.shortcut-link:hover { border-color: var(--primary); color: var(--primary); background: white; }

/* Liste Jeux */
.cat-title {
    font-size: 1.5rem; margin-bottom: 20px; color: var(--text);
    border-left: 5px solid var(--primary); padding-left: 15px;
}
.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

.menu-btn {
    background: var(--bg-card); border-radius: var(--radius); padding: 20px;
    text-decoration: none; color: var(--text); display: flex; flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s; box-shadow: var(--shadow);
    border: 1px solid transparent; min-height: 140px; justify-content: space-between;
    position: relative; /* Important pour la flèche absolue */
}
.menu-btn:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); border-color: var(--primary); }

/* Flèche sur la carte (Restaurée) */
.arrow {
    position: absolute; bottom: 20px; right: 20px;
    font-size: 1.2rem; color: var(--primary); opacity: 0.3; transition: 0.3s;
}
.menu-btn:hover .arrow { opacity: 1; transform: translateX(5px); }

.game-name-wrapper { display: flex; justify-content: space-between; align-items: flex-start; width: 100%; margin-bottom: 5px; }
.game-name { font-weight: 700; font-size: 1.1rem; }
.control-link {
    font-size: 0.75rem; color: var(--text-light); text-decoration: none;
    background-color: rgba(0,0,0,0.05); padding: 2px 8px; border-radius: 4px;
    font-family: monospace; border: 1px solid transparent;
}
.control-link:hover { background-color: white; border-color: var(--primary); color: var(--primary); }

.game-subtitle { display: block; color: var(--text-light); font-size: 0.9rem; margin-bottom: 10px; }
.stars { color: var(--warning); margin-left: 5px; }

.game-info-line {
    display: flex; align-items: center;
    font-size: 0.85rem; color: var(--text-light);
}

/* Pastilles Score */
.mini-scores { display: flex; gap: 6px; margin-top: 10px; }
.score-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%;
    background-color: #e0e0e0; color: var(--text-light);
    font-size: 0.75rem; font-weight: 700;
}
.score-dot.high { background-color: var(--success); color: white; }

/* Résultats utilisateur sur la carte */
.results-container {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--bg-body);
}
.res-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

/* =================================================================
   3. STRUCTURE DU JEU
   ================================================================= */
.quiz-container { 
    background-color: var(--bg-card);
    border-radius: var(--radius); box-shadow: var(--shadow); 
    overflow: hidden; display: flex; flex-direction: column; min-height: 85vh; 
}
.quiz-header { 
    height: 70px; padding: 0 25px; display: flex; 
    justify-content: space-between; align-items: center; 
    border-bottom: 2px solid var(--bg-body); 
}
.quiz-header h1 { font-size: 1.2rem; margin: 0; color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 15px; }

.nav-btn {
    background: white; border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 12px; cursor: pointer; font-size: 1.2rem; transition: 0.2s;
    display: flex; align-items: center; color: var(--text); text-decoration: none;
}
.nav-btn:hover { background: var(--bg-body); }

.quiz-main-content { display: flex; flex: 1; }

.media-side {
    flex: 6; display: flex; 
    align-items: center; justify-content: center; padding: 20px; 
    position: relative; border-right: 1px solid var(--border);
    max-height: 80vh;
}

.image-container { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#main-image {
    background: #fff;
    max-width: 100%; max-height: 100%; object-fit: contain;
    border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.image-context-label {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: rgba(0,0,0,0.7); color: white;
    padding: 10px 0; text-align: center;
    font-size: 1.4rem; font-weight: 700;
    border-radius: 0 0 8px 8px; z-index: 2;
}

.options-side { 
    flex: 4; padding: 30px; display: flex; 
    flex-direction: column; justify-content: center; position: relative; 
}
.options-side h2 { text-align: center; margin-bottom: 20px; }

/* =================================================================
   4. MODE SEC (GRILLE & CURSEUR)
   ================================================================= */
.words-container { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; }
.word-input-display {
    font-size: 1.8rem; font-weight: 800; border-bottom: 4px solid var(--primary);
    min-width: 40px; text-align: center; padding: 5px; color: var(--text);
}
.word-separator { font-size: 1.8rem; font-weight: 800; color: var(--primary); align-self: flex-end; }

/* Curseur phase initiale (Mode Sec) */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--text);
    animation: blink-caret 1s infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

/* Bouton de validation intégré au texte */
.validate-btn-inline {
    width: 42px; height: 50px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: transparent;
    color: #94a3b8;
    font-size: 1.4rem;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: 8px;
    transition: all 0.2s;
    vertical-align: middle;
}
.validate-btn-inline:hover { border-color: #cbd5e1; color: #64748b; }

/* Réactivité aux états du jeu (Succès/Erreur) */
body.bg-success .validate-btn-inline { 
    background: var(--success); 
    border-color: var(--success); 
    color: white; 
    transform: scale(1.1);
}
body.bg-danger .validate-btn-inline { background: var(--danger); border-color: var(--danger); color: white; }

/* Changement d'icône via CSS pour robustesse */
.validate-btn-inline i::before { content: "\f00c"; } /* Check par défaut */
body.bg-danger .validate-btn-inline i::before { content: "\f00d"; } /* Xmark si erreur */

/* Grille de lettres */
.letter-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 20px 0; }

.letter-box {
    width: 42px; height: 50px; 
    border: 2px solid #cbd5e1; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 700; background: white;
    text-transform: uppercase; transition: all 0.2s;
    position: relative; color: var(--text);
}

/* États des cases */
.letter-box.filled { border-color: var(--primary); background: #ebf8ff; }
.letter-box.correct-fixed { background-color: var(--success); border-color: var(--success); color: white; }
.letter-box.hint-ghost { background-color: white; border: 2px dashed #bdc3c7; color: #bdc3c7; }
.letter-box.space { background: none; border: none; width: 15px; }

/* Lettres révélées (non trouvées) */
.letter-box.revealed-missed {
    background-color: #f39c12; /* Orange */
    border-color: #f39c12;
    color: white;
    transform: scale(0);
    animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Animation Indice (Bleu -> Clignote -> Vert) */
@keyframes blink-hint {
    0%, 40% { background-color: var(--primary); border-color: var(--primary); color: white; transform: scale(1.1); }
    20%, 60% { background-color: white; border-color: var(--primary); color: var(--primary); transform: scale(1); }
    100% { background-color: var(--success); border-color: var(--success); color: white; transform: scale(1); }
}
.letter-box.hint-anim {
    animation: blink-hint 1.2s forwards;
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- CURSEUR CLIGNOTANT (Restauré) --- */
.letter-box.active-cursor { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2); }
.letter-box.active-cursor::after {
    content: ''; position: absolute; height: 60%; width: 2px;
    background-color: var(--text); animation: blink-caret 1s infinite;
}
@keyframes blink-caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Bouton Passer */
.skip-btn {
    background-color: transparent; border: 2px solid var(--text-light);
    color: var(--text-light); padding: 8px 20px; border-radius: 20px;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center; gap: 8px; margin: 0;
}
.skip-btn:hover { background-color: var(--bg-body); border-color: var(--text); color: var(--text); }

/* Input Technique */
#hidden-input {
    position: absolute; opacity: 0; width: 1px; height: 1px;
    bottom: 0; left: 50%; z-index: -1;
}

/* Feedback et Indices */
.feedback-message { min-height: 25px; text-align: center; font-weight: bold; margin-top: 0; color: var(--danger); }
.last-attempt-display { min-height: 40px; margin-bottom: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.analysis-row { display: flex; gap: 5px; justify-content: center; }
.ana-letter {
    width: 30px; height: 35px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: white; font-size: 1rem;
}
.ana-correct { background-color: var(--success); }
.ana-misplaced { background-color: var(--primary); }
.ana-wrong { background-color: var(--danger); }

/* --- CONTROLES BAS (Mode Sec) --- */
.bottom-controls {
    display: flex; align-items: flex-start;
    margin-top: 20px; width: 100%;
}
.controls-left {
    display: flex; flex-direction: column; align-items: center;
    width: 50%;
}
.controls-right {
    display: flex; justify-content: center;
    width: 50%;
}
.attempt-indicator {
    font-size: 0.85rem;
    color: #95a5a6;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 10px 0 4px 0;
}

/* =================================================================
   5. RÉSULTATS (Bilan final) - Restauré
   ================================================================= */
.summary-content { padding: 30px; max-width: 800px; margin: 0 auto; }
.summary-header { text-align: center; margin-bottom: 40px; }

/* Rangs de résultats (Titres) */
.champion {
    font-weight: 900; font-size: 3.2rem;
    /* Gradient Or contrasté (Ocre -> Jaune -> Ocre) */
    background: linear-gradient(90deg, #b8860b 0%, #f1c40f 50%, #b8860b 100%);
    background-size: 200% auto; 
    background-clip: text; 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
    animation: shine 3s linear infinite;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.perfect {
    font-weight: 900; font-size: 4rem;
    /* Gradient Violet/Bleu profond très lisible */
    background: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
    background-clip: text; -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    animation: pulse-perfect 2s infinite;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.2));
}

/* Autres rangs (ajoutés pour cohérence) */
.gold { font-weight: 800; font-size: 3rem; color: #d35400; } /* Orange foncé */
.silver { font-weight: 800; font-size: 3rem; color: #57606f; } /* Gris foncé */
.standard { font-weight: 800; font-size: 2.8rem; color: var(--primary); }

@keyframes shine { to { background-position: 200% center; } }
@keyframes pulse-perfect { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.result-item {
    display: flex; align-items: center; background: white; padding: 15px;
    margin-bottom: 12px; border-radius: 10px; border-left: 6px solid var(--success);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.result-item.wrong { border-left-color: var(--danger); }
.res-img-container { width: 80px; height: 80px; flex-shrink: 0; margin-right: 20px; }
.res-img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }

.summary-footer { display: flex; gap: 15px; justify-content: center; margin-top: 30px; padding-bottom: 40px; }
.nav-btn-large {
    display: inline-flex; align-items: center; gap: 10px; padding: 12px 24px;
    border-radius: var(--radius); background-color: var(--primary); color: white;
    text-decoration: none; font-weight: 600; border: none; cursor: pointer; transition: 0.2s;
}
.nav-btn-large.secondary { background-color: var(--text-light); }

.txt-correct { color: var(--success); font-weight: bold; }
.txt-wrong { color: var(--danger); font-weight: bold; }

/* CountDown */
#countdown-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(46, 144, 241, 0.95); display: none; 
    justify-content: center; align-items: center; z-index: 9999;
}
#countdown-number { font-size: 10rem; color: white; font-weight: 900; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* QCM Options */
#options { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; }
.option-btn {
    background: white; border: 2px solid var(--border); border-radius: 12px;
    padding: 15px; font-size: 1.1rem; font-weight: 600; color: var(--text);
    cursor: pointer; transition: all 0.2s; 
}
.option-btn:hover { background: #e3f2fd; border-color: var(--primary); transform: translateY(-2px); }
.option-btn.correct { background-color: var(--success); border-color: var(--success); color: white; }
.option-btn.wrong { background-color: var(--danger); border-color: var(--danger); color: white; }

/* =================================================================
   6. OPTIMISATION MOBILE
   ================================================================= */
.mobile-only { display: none; }
.desktop-only { display: flex; }

.mobile-menu {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 10000;
    display: flex; justify-content: flex-end;
}
.mobile-menu.hidden { display: none; }
.mobile-menu-content {
    background: white; width: 70%; max-width: 300px; height: 100%;
    padding: 20px; display: flex; flex-direction: column; gap: 15px;
}
.menu-item-btn {
    background: none; border: none; text-align: left; font-size: 1.1rem;
    padding: 10px; cursor: pointer; color: var(--text); text-decoration: none;
}
.lang-selector-mobile { display: flex; flex-direction: column; gap: 8px; }

/* Responsive Mobile (< 850px) */
@media (max-width: 850px) {
    .main-container { padding: 0; }
    .quiz-container { background-color:transparent;min-height: 100vh; border-radius: 0; }

    .mobile-only { display: flex; }
    .desktop-only { display: none; }
    .quiz-header { padding: 5px 15px; height: 50px; }
    .quiz-header h1 { font-size: 1rem; padding: 1em 0 0; }
    
    .quiz-main-content { flex-direction: column; }
    
    /* Image FIXE sur mobile (35% de la hauteur), ne rétrécit pas */
    .media-side { 
        flex: none; 
        height: 55vh; 
        min-height: 180px; 
        width: 100%; 
        border-right: none; 
        border-bottom: 1px solid var(--border); 
        padding: 5px; 
    }
    
    /* Options remplit le reste */
    .options-side { 
        flex: 1; width: 100%; padding: 10px; 
        justify-content: flex-start;
        gap: 5px;
    }
    .options-side h2 { font-size: 1rem;}
    
    .letter-grid { gap: 4px; margin: 5px 0; }
    .letter-box { width: 32px; height: 40px; font-size: 1.2rem; }
    
    #options { grid-template-columns: 1fr; gap: 8px; }
    .option-btn {width: calc(100% - 30px);}
}