/* ==========================================================================
   HEXAGRID - FEUILLE DE STYLE PRINCIPALE
   ========================================================================== */

/* --- 1. VARIABLES & POLICES --- */
:root {
    --bg-main: #f8f9fa;
    --border-dark: #1e293b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --text-main: #0f172a;
    --text-muted: #64748b;
	--blue-color: #006bb3;
	--green-color: #007852;
}

@font-face {
    font-family: 'Caracteres L1';
    src: url('caracteres-l1.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Caracteres L4';
    src: url('caracteres-l4.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* --- 2. BASE DE LA PAGE --- */
html, body {
    /* Bloque l'effet élastique/rebond sur mobile */
    overscroll-behavior-y: none;
    /* Prévient les sauts de page bizarres lors des rafraîchissements */
    scroll-behavior: smooth;
}

/* Supprimer le flash gris/bleu tactile natif (iOS/Android) --- */
* {
    -webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: manipulation;
	-webkit-user-select: none; /* Safari / iOS (le plus important ici) */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE / Edge */
    user-select: none;         /* Standard */
}

input, textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

/* --- 3. EN-TÊTE ET BARRE DE STATUT --- */
.header-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 8px; 
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    margin-bottom: 4px; 
}

.national-sign {
    background-color: var(--blue-color); 
    background-image: repeating-linear-gradient(
        to bottom, transparent, transparent 26px,
        rgba(0, 0, 0, 0.08) 26px, rgba(0, 0, 0, 0.08) 27px  
    );
    color: #ffffff;
    border: 3px solid var(--blue-color); 
    border-radius: 8px;
    box-shadow: inset 0 0 0 3px #ffffff, 0 4px 6px rgba(0,0,0,0.15);
    padding: 8px 40px; 
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 16px; 
    width: 100%; 
    box-sizing: border-box; 
    margin: 0 0 8px 0; 
    position: relative; 
}

.sign-text-container {
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: center;
}

.national-sign h1 {
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-weight: normal;
    font-size: 2.2rem;
    text-transform: uppercase;
    letter-spacing: 6px; 
    margin: 0; 
    line-height: 1;
}

.sign-logo-img {
    width: 55px; 
    height: auto;
    filter: brightness(0) invert(1) drop-shadow(0 2px 3px rgba(0,0,0,0.15)); 
}

.status-bar {
    display: flex;
    flex-wrap: nowrap; 
    align-items: center;
    width: 100%;
    margin-bottom: 4px; 
    padding: 0 4px;
    box-sizing: border-box;
    gap: 12px; 
}

.status-bar::before {
    content: '';
    display: block;
    flex-shrink: 0; 
    width: 32px; 
    height: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='46' fill='%23006bb3' stroke='%23ffffff' stroke-width='4'/%3E%3Cpath d='M45 25 L70 50 L45 75' fill='none' stroke='%23ffffff' stroke-width='10' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cline x1='25' y1='50' x2='68' y2='50' stroke='%23ffffff' stroke-width='10' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

#scoring-rule-container {
    flex: 1 1 0%; 
    min-width: 0; 
    background-color: var(--green-color); 
    border: 2px solid #ffffff; 
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.15); 
    margin: 0;
    animation: attentionSeeker 0.8s ease-in-out 0.5s; 
}

#scoring-rule {
    display: block; 
    white-space: normal; 
    word-wrap: break-word;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.75rem; 
    font-weight: 600; 
    color: #ffffff; 
    line-height: 1.3;
    text-align: center; 
}

@keyframes attentionSeeker {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-2deg) scale(1.02); }
    50% { transform: rotate(2deg) scale(1.02); }
    75% { transform: rotate(-1deg) scale(1.01); }
}

/* --- 4. LA GRILLE DE JEU --- */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr; 
    gap: 4px; 
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.cell {
    border-radius: 12px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2px;
    word-wrap: break-word;
    hyphens: auto;
	-webkit-tap-highlight-color: transparent;
    outline: none;
}

/* --- NOUVEAU TABLEAU DE BORD (3 PANNEAUX SUPERPOSÉS) --- */
.dashboard-board {
    background-color: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    padding: 1px;
}

.panel-date, .panel-err, .panel-score {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px; /* Un petit peu plus de radius */
    border: 2px solid #ffffff; /* Bordure blanche par défaut (pour le bleu) */
    box-shadow: 0 2px 4px rgba(0,0,0,0.15); /* Ombre légèrement renforcée pour détacher le blanc */
    width: 100%;
    box-sizing: border-box;
}

.panel-date {
    background-color: var(--blue-color); 
    color: #ffffff; 
    font-family: 'Caracteres L4', 'Courier New', monospace;
    font-size: 0.6rem;
    flex: 1; 
}

.panel-err {
    background-color: var(--blue-color); 
    color: #ffffff; 
    font-family: 'Caracteres L4', 'Courier New', monospace;
    font-size: 0.65rem;
    flex: 1; 
    /* Ajout de border-color dans la transition pour un effet fluide */
    transition: background-color 0.3s, color 0.3s, border-color 0.3s; 
}

.panel-err.has-errors {
    background-color: #facc15; 
    color: #1e293b; 
    border-color: #1e293b; /* La bordure repasse en sombre avec le fond jaune */
}

.panel-score {
    background-color: var(--blue-color);
    color: #ffffff;
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9rem;
    flex: 2; 
    letter-spacing: 0.5px;
}

#score-display {
    margin-right: 4px;
}

.header-cell {
    background-color: #ffffff; 
    color: #1e293b; 
    border: 2px solid #1e293b; 
    box-shadow: 0 3px 5px rgba(0,0,0,0.1); 
    border-radius: 12px; 
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-weight: normal; 
    font-size: 0.65rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px; 
    line-height: 1.2;
    padding: 6px 4px; 
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    overflow: hidden; 
    /* Interdit au navigateur de couper les mots avec un tiret */
    hyphens: none;
    -webkit-hyphens: none; 
}

.playable {
    background-color: #f8fafc; 
    border: 3px solid #e2e8f0; 
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.03); 
    box-sizing: border-box; 
    aspect-ratio: 1 / 1; 
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    position: relative; 
}

/* --- LE COMPTEUR DE RÉPONSES POSSIBLES --- */
.possible-answers-count {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    color: #94a3b8; 
    pointer-events: none; 
	font-style: italic;
}

.game-over-empty .possible-answers-count {
    display: none;
}

@media (hover: hover) {
    .playable:hover {
        background-color: #e0f2fe; 
        border-color: #bae6fd;
    }
}

/* NOUVEAU : Force l'état "survol" quand la case est sélectionnée (sécurisé pour mobile) */
.playable.active-cell {
    background-color: #e0f2fe !important; 
    border-color: #bae6fd !important;
}

.correct {
    background-color: #ffffff; 
    border: 3px solid #ffffff; 
    border-radius: 12px;
    box-sizing: border-box;
    box-shadow: inset 0 0 0 3px #dc2626, 0 4px 6px rgba(0, 0, 0, 0.15);
    cursor: default;
    aspect-ratio: 1 / 1;
    padding: 10px 4px 4px 4px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative; 
    overflow: visible; 
}

.game-over-empty {
    background-color: #ffffff; 
    border: 3px solid #ffffff; 
    border-radius: 12px;
    box-shadow: inset 0 0 0 3px #1e293b, 0 4px 6px rgba(0, 0, 0, 0.15);
    background-image: linear-gradient(
        to top left, 
        transparent calc(50% - 5px), 
        #dc2626 calc(50% - 5px),     
        #dc2626 calc(50% + 5px),     
        transparent calc(50% + 5px)  
    );
    cursor: pointer;
    aspect-ratio: 1 / 1;
}

/* Textes à l'intérieur des cases */
.dept-name { font-size: 0.7rem; font-weight: bold; line-height: 1.1; margin-bottom: 1px;}
.cell-data { font-size: 0.55rem; font-weight: normal; margin-top: 1px; color: #475569;}
.cell-pts { font-size: 0.6rem; color: #065f46; background: #d1fae5; padding: 2px 4px; border-radius: 6px; margin-top: 2px; font-weight: bold;}

.correct .dept-name {
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    text-transform: uppercase;
    font-size: 0.75rem; 
    letter-spacing: 0.5px;
    color: #1e293b; 
    line-height: 1.1;
    margin-bottom: 2px;
    word-break: break-word; 
    hyphens: auto; 
    max-width: 95%; 
}

.correct .cell-data {
    font-family: 'Caracteres L4', 'Courier New', monospace;
    font-weight: normal;
    font-size: 0.75rem; 
    color: #475569; 
    margin-bottom: 4px; 
}

.correct .cell-pts {
    position: absolute;
    top: -15px; 
    left: 50%;
    transform: translateX(-50%); 
    background-color: #facc15; 
    color: #1e293b; 
    padding: 2px 10px;
    border-radius: 6px 6px 0 0; 
    border: 1px solid #1e293b; 
    border-bottom: none; 
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-style: normal; 
    font-weight: normal; 
    font-size: 0.8rem; 
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    z-index: 10; 
    margin-top: 0; 
}

#message {
    text-align: center;
    margin-top: 6px;
    font-size: 1rem;
    padding: 0 10px;
    line-height: 1.3;
}

/* --- 5. MODALES ET RECHERCHE --- */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(3px); 
    align-items: center; 
    justify-content: center; 
}

.modal-content { 
    background-color: #ffffff; 
    padding: 20px 24px; /* On réduit un peu l'espace intérieur haut/bas (était à 24px) */
    border-radius: 8px; 
    border: 2px solid #1e293b; 
    width: 90%; 
    max-width: 400px; 
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25); 
    display: flex; 
    flex-direction: column; 
    max-height: 94vh; /* On passe de 85vh à 94vh */
    max-height: 94dvh; /* Pareil ici pour iOS */
    box-sizing: border-box; 
    overflow-y: auto; 
}

/* Modale de recherche : plaquée en haut pour fuir le clavier tactile */
.search-modal-content { 
    position: relative; 
    align-self: flex-start; 
    margin-top: 15px; /* Marge très fine en haut */
    max-height: calc(100vh - 30px); 
    max-height: calc(100dvh - 30px);
    overflow: hidden; 
    padding-bottom: 20px;
}

/* Modale de résultats : un peu plus centrée/aérée */
.results-modal-content { 
    position: relative; 
    align-self: flex-start; 
    margin-top: 40px; 
    margin-bottom: 40px; /* Assure le décollement en bas pour le flexbox */
    max-height: calc(100vh - 80px); /* 40px en haut + 40px en bas = 80px */
    max-height: calc(100dvh - 80px); /* L'équivalent pour Safari iOS */
    overflow: hidden; 
    padding-bottom: 20px;
}

.modal-content h2 { 
    margin: 0 0 20px 0; 
    text-align: center; 
    background-color: var(--blue-color); 
    color: #ffffff;
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif; 
    font-weight: normal;
    font-size: 1.25rem; 
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 10px 15px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #ffffff; 
    border: 1px solid var(--blue-color);
}

.modal-criteria-display { 
    text-align: center; 
    background-color: #ffffff; 
    color: #1e293b; 
    border: 2px solid #1e293b; 
    border-radius: 8px; 
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-weight: normal; 
    font-size: 0.85rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px; 
    line-height: 1.3;
    padding: 12px 10px; 
    margin-bottom: 15px; 
}

#search-input { 
    width: 100%; 
    padding: 12px; 
    border: 2px solid #1e293b; 
    border-radius: 6px; 
    font-size: 1rem; 
    margin-bottom: 12px; 
    box-sizing: border-box; 
    outline: none; 
    background-color: #f8fafc;
}
#search-input:focus { 
    border-color: var(--blue-color); 
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 107, 179, 0.15);
}

.results-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    overflow-y: auto; /* C'est uniquement la liste qui scroll ! */
    flex-grow: 1; 
    min-height: 0; /* Astuce Flexbox INDISPENSABLE pour que la liste s'écrase et active le scroll */
}
.results-list li { padding: 12px 10px; border-bottom: 1px solid #e2e8f0; cursor: pointer; font-size: 0.95rem; }
.results-list li:last-child { border-bottom: none; }
.results-list li:hover { background-color: #f8fafc; }

#final-results-list li { 
    padding: 8px 0; 
    border-bottom: 1px solid #e2e8f0;
    cursor: default;
}
#final-results-list li:last-child { border-bottom: none; }
#final-results-list li:hover { background-color: transparent; }

.user-highlight { 
    background-color: #eff6ff !important; 
    border-left: 4px solid var(--blue-color) !important; 
    border-radius: 4px;
    padding: 8px 0 8px 8px !important;
    margin: 0 0 0 -12px !important; 
}

.used-dept { color: var(--text-muted); cursor: not-allowed !important; }
.used-badge { font-size: 0.75rem; background: #fee2e2; color: var(--error-color); padding: 2px 6px; border-radius: 12px; }

.welcome-modal-content { 
    max-width: 420px; 
    text-align: left; 
    overflow: hidden; /* Empêche le scroll global pour fixer le bouton en bas */
    padding-bottom: 20px;
}
.welcome-text { 
    overflow-y: auto; 
    min-height: 0; /* Astuce Flexbox vitale pour activer le scroll interne */
    flex-grow: 1; 
    padding-right: 5px; /* Évite que la barre de scroll chevauche le texte */
}
.welcome-text p { font-size: 0.88rem; line-height: 1.45; margin: 0 0 10px 0; color: var(--text-main); }
.welcome-footer { 
    margin-top: 15px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%; 
    gap: 10px; 
    flex-shrink: 0; /* Protège le bouton d'être écrasé si l'écran est minuscule */
}

/* --- 6. BOUTONS & ANIMATIONS --- */
.btn-close { 
    width: 100%; 
    padding: 12px; 
    margin-top: 8px; 
    background-color: #475569; 
    color: white; 
    border: 1px solid #475569; 
    border-radius: 6px; 
    font-size: 1rem; 
    font-weight: bold; 
    cursor: pointer; 
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background-color 0.1s;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 2px 4px rgba(0,0,0,0.1);
}
.btn-close:hover { background-color: #1e293b; }

#play-btn, #close-about-modal, #close-legal-modal, #close-results-modal, #close-install-modal {
    background-color: var(--green-color);
    border-color: var(--green-color);
}
#play-btn:hover, #close-about-modal:hover, #close-legal-modal:hover, #close-results-modal:hover, #close-install-modal:hover {
    background-color: #005c3e;
}

.error-animation { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; border-color: var(--error-color) !important; background-color: #fef2f2 !important; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }

/* --- 7. PIED DE PAGE : IMAGE + PANNEAUX INDÉPENDANTS --- */
.footer-container {
    width: 100%;
    display: flex;
    flex-direction: column; /* Force l'affichage en colonne pour empiler les liens et le copyright */
    justify-content: center;
    align-items: center; 
    gap: 10px; /* Laisse un peu d'air entre les boutons et le texte */
    margin-top: 6px; 
    margin-bottom: 6px; 
}

/* Style de la mention de copyright */
.footer-copyright {
    font-size: 0.65rem;
    color: #94a3b8; /* Un gris discret (var(--text-muted) éclairci) */
    text-align: center;
    letter-spacing: 0.5px;
}

.footer-image {
    height: 30px; 
    width: auto; 
    object-fit: contain;
    border-radius: 2px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.footer-links {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    align-items: center;
    gap: 6px; 
}

.footer-links a {
    background-color: #ffffff;
    border: 2px solid var(--blue-color); 
    border-radius: 6px;
    padding: 6px 10px; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: 'Caracteres L1', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.65rem; 
    color: #1e293b;
    text-transform: uppercase;
    text-decoration: none;
    letter-spacing: 0.5px;
    transition: background-color 0.1s, color 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
    outline: none;
}

.footer-links a:hover {
    background-color: #f8fafc;
    color: var(--blue-color);
}

/* --- 8. MEDIA QUERY (POUR PC ET GRANDES TABLETTES) --- */
@media (min-width: 500px) {
    .grid { gap: 8px; }
    .national-sign { padding: 12px 45px; gap: 20px; }
    .sign-logo-img { width: 70px; }
    .national-sign h1 { font-size: 2.8rem; }
    .header-cell { font-size: 0.85rem; padding: 8px;  border: 3px solid #ffffff; 
    box-shadow: inset 0 0 0 3px #1e293b, 0 3px 5px rgba(0,0,0,0.1); }
    .correct {     box-shadow: inset 0 0 0 5px #dc2626, 0 4px 6px rgba(0, 0, 0, 0.15); }
	.correct .dept-name { font-size: 0.95rem; margin-bottom: 2px; }
    .correct .cell-data { font-size: 0.85rem; } 
    .correct .cell-pts { font-size: 0.9rem; margin-top: 3px; }
    #scoring-rule { font-size: 0.85rem; padding: 4px 8px; }
    #message { margin-top: 10px; font-size: 1.1rem;}
    
    .footer-container { margin-top: 10px; margin-bottom: 10px; }
    .footer-links a { font-size: 0.85rem; } 
    
    .panel-date { font-size: 0.75rem; }
    .panel-err { font-size: 0.8rem; }
    .panel-score { font-size: 1.25rem; }
}

/* --- 9. CARTE DES RÉSULTATS --- */
#map-container {
    width: 100%;
    max-width: 320px; /* Taille optimale pour laisser de la place à la liste */
    margin: 0 auto 15px auto;
    display: block;
    flex-shrink: 0;
}

#map-container svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

#map-container svg,
#map-container path {
    -webkit-tap-highlight-color: transparent; /* Désactive le carré natif sur mobile */
    outline: none;
}

#map-container path {
    fill: #e2e8f0; /* Couleur par défaut des départements neutres (gris clair) */
    stroke: #ffffff;
    stroke-width: 0.5px;
    transition: fill 0.3s, filter 0.2s;
    cursor: pointer;
}

/* --- ÉTATS DE SURVOL (:hover) ET SÉLECTION (.highlighted) COHÉRENTS --- */

/* 1. Départements NEUTRES (aucun critère) -> GRIS */
#map-container path:not(.match-row):not(.match-col):not([data-pts]).highlighted,
#map-container path:not(.match-row):not(.match-col):not([data-pts]):hover {
    fill: #94a3b8 !important; /* Un gris moyen pour se détacher proprement du fond clair */
    stroke: #ffffff !important;
    stroke-width: 1px !important;
}

/* 2. Départements LIGNE SEULE -> ORANGE PLEIN */
#map-container path.match-row.highlighted,
#map-container path.match-row:hover {
    fill: #ca8a04 !important; /* Même orange que tes hachures horizontales, mais en fond plein */
    stroke: #ffffff !important;
    stroke-width: 1px !important;
}

/* 3. Départements COLONNE SEULE -> BLEU PLEIN */
#map-container path.match-col.highlighted,
#map-container path.match-col:hover {
    fill: var(--blue-color) !important; /* Même bleu que ton thème et tes hachures verticales */
    stroke: #ffffff !important;
    stroke-width: 1px !important;
}

/* 4. Départements VALIDES (Les deux critères) -> COULEUR CONSERVÉE */
#map-container path:not(.match-row):not(.match-col)[data-pts].highlighted,
#map-container path:not(.match-row):not(.match-col)[data-pts]:hover {
    stroke: var(--border-dark) !important; /* Bordure sombre pour faire jaillir la couleur du score */
    stroke-width: 1.5px !important;
}

/* Application dynamique des hachures SVG (état normal au repos) */
.match-row { fill: url(#hachure-row) !important; }
.match-col { fill: url(#hachure-col) !important; }

/* Info-bulle dynamique */
.map-tooltip {
    position: fixed; /* Suit le curseur sur tout l'écran */
    background-color: rgba(15, 23, 42, 0.95);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none; /* Crucial : évite que la souris n'accroche l'info-bulle */
    z-index: 2000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    line-height: 1.3;
    text-align: center;
    transform: translate(-50%, -100%);
    margin-top: -15px; /* Décalage au-dessus du curseur */
}

.map-tooltip strong {
    color: #facc15;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 4px;
}

/* =========================================
   ANIMATIONS DES MODALES ET TRANSITIONS
========================================= */

/* --- 1. ANIMATIONS D'OUVERTURE --- */
@keyframes fadeInOverlay {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes popInModal {
    0% { opacity: 0; transform: scale(0.9) translateY(15px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal.opening {
    animation: fadeInOverlay 0.2s ease-out forwards;
}

.modal.opening .modal-content {
    animation: popInModal 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}


/* --- 2. ANIMATIONS DE FERMETURE --- */
@keyframes fadeOutOverlay {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes popOutModal {
    0% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.9) translateY(15px); }
}

.modal.closing {
    animation: fadeOutOverlay 0.2s ease-in forwards;
}

.modal.closing .modal-content {
    animation: popOutModal 0.2s ease-in forwards;
}


/* --- 3. TRANSITION VUE LISTE / VUE CARTE --- */
@keyframes fadeInView {
    0% { opacity: 0; transform: translateY(5px); }
    100% { opacity: 1; transform: translateY(0); }
}

#map-container, #final-results-list, #header-list-view, #header-map-view {
    animation: fadeInView 0.3s ease-out;
}

/* --- TOAST FUN FACT (Style Panneau Touristique H11) --- */
#fact-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    width: calc(100% - 20px); /* Même marge de 10px à gauche et à droite que le panneau du haut */
    max-width: 450px; /* Aligné sur la largeur max standard de tes blocs de jeu */
    background-color: #5B3C24; /* Marron officiel autoroute */
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 8px;
    padding: 15px 20px;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden; 
    box-sizing: border-box; /* Indispensable pour garder la jauge bien alignée en bas */
}

#fact-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- Barre de progression du Toast --- */
#toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 5px;
    background-color: #f1c40f; /* Jaune vif */
    width: 100%;
}

/* --- Effets d'appui tactile (équivalent hover sur mobile) --- */

/* Pour les cases de la grille */
.playable:active {
    background-color: #e0f2fe !important; 
    border-color: #bae6fd !important;
    transition: none; /* Retire la transition pour un feedback instantané sous le doigt */
}

/* Pour les liens du footer (Mentions légales, Comment jouer) */
.footer-links a:active {
    background-color: #f8fafc;
    color: var(--blue-color);
}

/* Pour les boutons classiques et dynamiques (Partager, Fermer) */
button:active {
    filter: brightness(0.9);
    transform: scale(0.98); /* Petit effet d'enfoncement très "app native" */
}

#toggle-view-link {
    transition: transform 0.1s ease, background-color 0.1s ease !important;
}

#toggle-view-link:active {
    background-color: #e2e8f0 !important; /* Un gris un poil plus foncé */
    transform: scale(0.95) !important; /* Léger enfoncement */
}

.game-over-empty {
    transition: transform 0.1s ease, filter 0.1s ease;
}

.game-over-empty:active {
    transform: scale(0.96);
    filter: brightness(0.92); /* Assombrit légèrement la case et ses hachures rouges */
}

/* 2. Les cases correctes (cliquables à la fin pour voir les autres réponses possibles) */
.correct {
    transition: transform 0.1s ease, filter 0.1s ease;
}

.correct:active {
    transform: scale(0.96);
    filter: brightness(0.96); /* Effet un peu plus subtil sur le fond blanc */
}

.status-bar {
    position: relative; /* Indispensable pour confiner la div invisible à l'intérieur */
}

#reset-easter-egg {
    position: absolute;
    top: 0;
    left: 0;
    width: 45px; /* À ajuster pour recouvrir parfaitement ton ::before */
    height: 100%;
    cursor: default; /* On garde le curseur normal pour le côté secret ! */
    z-index: 10;
}