* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Thème sombre */
    background-color: #121212; 
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    max-width: 850px;
    width: 100%;
    text-align: center;
    position: relative; /* Ajouté pour que le modal absolu se cale bien dessus */
}

/* === TYPOGRAPHIE ET TITRES === */
@keyframes flottement {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

h1 { 
    color: #ff9800; 
    font-size: 2.8em; 
    margin-bottom: 20px; 
    /* Effet Glow Orange */
    text-shadow: 0 0 10px rgba(255, 152, 0, 0.6), 0 0 25px rgba(255, 152, 0, 0.4);
    /* Effet Flottement */
    animation: flottement 3.5s ease-in-out infinite;
}
h2 { color: #e0e0e0; margin-top: 0; }
h3 { color: #aaaaaa; }

.grand-texte { font-size: 3em; font-weight: bold; margin: 20px 0; color: #ff9800; }
.grand-texte-carte { font-weight: bold; color: #ff9800; font-size: 1.5em; }

/* === MENU PRINCIPAL === */
#menu-principal p { font-size: 1.2em; margin-bottom: 30px; }

.boutons-menu { 
    display: flex; 
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px; 
    max-width: 500px; 
    margin: 0 auto;
}

button {
    /* Style bouton de base */
    border: none;
    border-radius: 12px;
    background-color: #333;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
}

button:hover { 
    background-color: #ff9800; 
    color: #1e1e1e; 
    transform: translateY(-2px); 
}

/* Application du format Carré 2x2 aux boutons du menu principal */
.boutons-menu button {
    width: calc(50% - 10px); /* 2 colonnes avec l'espace (gap) déduit */
    aspect-ratio: 1; /* Force le bouton à être un carré parfait */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.boutons-menu button:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 8px 15px rgba(255, 152, 0, 0.3); /* Glow survol */
}

.emoji { font-size: 2.5em; margin-bottom: 10px; }

/* Correction pour les autres boutons du site (Retour, Valider...) */
.btn-retour, .zone-saisie button {
    padding: 12px 25px;
    font-size: 16px;
    width: auto;
}

/* === EN-TÊTE JEU === */
.en-tete-jeu { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; border-bottom: 1px solid #333; padding-bottom: 15px; }
.btn-retour { background-color: transparent; color: #ff9800; border: 1px solid #ff9800; padding: 8px 15px; font-size: 14px; }
.btn-retour:hover { background-color: #ff9800; color: #1e1e1e; }

/* Modification de la zone de saisie pour l'autocomplétion */
.input-wrapper {
    position: relative;
    width: 60%;
}

input[type="text"] {
    padding: 15px;
    font-size: 18px;
    width: 100%; /* Prend maintenant 100% de l'input-wrapper */
    background-color: #2c2c2c;
    border: 2px solid #444;
    color: white;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus { border-color: #ff9800; }

/* Style du menu déroulant d'autocomplétion */
.suggestions-container {
    position: absolute;
    top: calc(100% + 4px); /* Juste en dessous de l'input */
    left: 0;
    width: 100%;
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 100;
    display: none; /* Masqué par défaut */
    box-shadow: 0 8px 15px rgba(0,0,0,0.5);
    text-align: left;
}

.suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    color: #e0e0e0;
    border-bottom: 1px solid #3d3d3d;
    font-size: 16px;
    transition: background 0.1s;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover {
    background-color: #ff9800;
    color: #1e1e1e;
    font-weight: bold;
}

input[type="text"]:focus { border-color: #ff9800; }

.zone-saisie { margin-bottom: 20px; display: flex; justify-content: center; gap: 10px; }
.zone-saisie button { background-color: #ff9800; color: #1e1e1e; }
.zone-saisie button:hover { background-color: #e68900; }

.succes { color: #4caf50; font-weight: bold; font-size: 1.2em; }
.erreur { color: #f44336; font-weight: bold; font-size: 1.2em; }

/* === INFO CARTE (TIMER, ERREURS, COMPTEUR) === */
.info-carte { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
.compteur { 
    background: #333; 
    padding: 8px 15px; 
    border-radius: 20px; 
    font-weight: bold; 
    color: #ff9800; 
    width: fit-content; /* Empêche la barre grise de s'étirer */
}
.stats-ligne { display: flex; gap: 20px; font-weight: bold; color: #ff9800; font-family: monospace; font-size: 1.1em; }


/* === STYLES CARTE SVG (MODE SOMBRE) === */
#conteneur-carte svg { 
    width: 100%; 
    max-height: 600px; 
    height: auto; 
    /* Ombre globale derrière la carte pour la détacher du fond */
    filter: drop-shadow(0px 10px 15px rgba(0,0,0,0.8));
}

#conteneur-carte path {
    fill: #3d3d3d; /* Un gris un peu plus clair que le fond */
    stroke: #121212; /* Bordures noires pour bien découper */
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.2s ease;
}

#conteneur-carte path:hover { fill: #666; }

/* Nouvelles couleurs de réussite selon la performance */
#conteneur-carte path.trouve-parfait { fill: #4caf50 !important; cursor: default; } /* Vert : 0 faute */
#conteneur-carte path.trouve-moyen { fill: #ff9800 !important; cursor: default; }   /* Orange : 1-3 fautes */
/* Animation de clignotement rouge */
@keyframes clignotement-rouge {
    0%   { fill: #3d3d3d; }
    20%  { fill: #f44336; }
    40%  { fill: #3d3d3d; }
    60%  { fill: #f44336; }
    80%  { fill: #3d3d3d; }
    100% { fill: #f44336; }
}

#conteneur-carte path.trouve-echec { 
    cursor: default; 
    transition: none; /* Désactive la transition douce pour un vrai effet de clignotement sec */
    /* On laisse l'animation s'occuper de la couleur ! */
    animation: clignotement-rouge 1.8s forwards; 
}
#conteneur-carte path.erreur-carte { fill: #f44336 !important; }

/* Style pour les numéros qui s'affichent sur la carte */
.label-numero {
    fill: white;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none; /* Pour ne pas gêner les clics sur les départements voisins */
    text-shadow: 1px 1px 2px black;
    alignment-baseline: middle;
    text-anchor: middle;
}

/* === MODAL ET POPUPS === */
.popup-nom {
    position: fixed;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
    animation: fadeUpOut 2s forwards;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

@keyframes fadeUpOut {
    0% { opacity: 0; transform: translateY(0); }
    15% { opacity: 1; transform: translateY(-10px); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-30px); }
}

/* Modal de fin de partie */
.modal {
    position: absolute; /* Modifié de fixed à absolute pour rester dans le conteneur */
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    z-index: 2000;
}

.modal-content {
    background: #1e1e1e;
    padding: 40px;
    border-radius: 15px;
    border: 2px solid #ff9800;
    text-align: center;
}

.stats-finales {
    margin: 20px 0;
    font-size: 1.4em;
    color: #ff9800;
}

.btn-orange { background-color: #ff9800 !important; color: #1e1e1e !important; }

/* Nouvelle barre de statistiques globale */
.info-partie { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 25px; 
    flex-wrap: wrap; 
    gap: 10px; 
    background: #2c2c2c; 
    padding: 15px 20px; 
    border-radius: 10px; 
    border-left: 4px solid #ff9800; 
}

/* Style de la consigne sur la carte */
.consigne-carte { text-align: center; margin-bottom: 15px; }

/* Style du message de solution automatique (Quiz Texte) */
.message-info-precedent { 
    color: #ff9800; 
    font-weight: bold; 
    font-size: 1.1em;
    margin-top: 15px; 
    min-height: 25px; 
    font-style: italic; 
}