body {
    font-family: 'Press Start 2P', cursive;
    background-color: #3a3a3a;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px 0;
    overflow-x: hidden;
}

#game-container {
    width: 90%;
    max-width: 800px;
    background-color: #5a5a5a;
    border: 5px solid #2a2a2a;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    position: relative; /* Essentiel pour que les .screen soient positionnés par rapport à lui */
}

header {
    margin-bottom: 15px;
    border-bottom: 3px solid #2a2a2a;
    padding-bottom: 10px;
    position: relative; /* Pour le contexte d'empilement, au cas où */
    z-index: 5; /* Inférieur aux écrans */
}

header h1 {
    margin: 0 0 10px 0;
    color: #FFA500;
    font-size: 2em;
}

#score-board {
    font-size: 0.9em;
}

#game-area {
    width: 100%;
    height: 500px;
    background-color: #87CEEB;
    border: 3px solid #2a2a2a;
    position: relative;
    overflow: hidden;
    margin: 0 auto 15px auto;
    border-radius: 5px;
    z-index: 5;  /* Inférieur aux écrans */
}

#player-line {
    position: absolute;
    bottom: 35px;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: #D2691E;
    z-index: 1;
}

#character {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    z-index: 2;
}

.word-block, .letter-block {
    position: absolute;
    padding: 8px 12px;
    background-color: #A9A9A9;
    border: 2px solid #696969;
    box-shadow: 3px 3px 0px #404040;
    color: #1e1e1e;
    font-size: 1.2em;
    border-radius: 3px;
    white-space: nowrap;
    transition: top 0.1s linear;
}

.letter-block {
    font-size: 1.3em;
    text-align: center;
    min-width: 30px;
}

.word-block.active-target {
    background-color: #90EE90;
    border-color: #3CB371;
    box-shadow: 3px 3px 0px #2E8B57;
}

.word-block .typed-char {
    color: #FFA500;
    font-weight: bold;
}

.screen {
    position: absolute; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(42, 42, 42, 0.97); 
    display: none; /* Caché par défaut */
    flex-direction: column;
    align-items: center;
    justify-content: center; /* ** CORRECTION CLÉ : Remettre pour centrer le contenu des écrans modaux ** */
    z-index: 10; 
    padding: 20px; 
    box-sizing: border-box;
    overflow-y: auto; 
}

#start-screen.active, 
#game-over-screen.active, 
#pause-overlay.active {
    display: flex !important; /* Forcer l'affichage quand .active est là */
}

/* Permettre à #start-screen de ne pas centrer verticalement si son contenu est long */
#start-screen {
    justify-content: flex-start; /* Pour que le contenu de start-screen commence en haut */
}


#start-screen > h2 {
    margin-top: 10px;
    margin-bottom: 20px; 
}

#start-screen > p:nth-of-type(1) { 
    margin-bottom: 15px; 
}


#mode-selection {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mode-button {
    padding: 10px 15px;
    font-size: 0.9em;
    background-color: #777;
    border: 2px solid #555;
    box-shadow: 2px 2px 0px #333;
}
.mode-button.selected {
    background-color: #4CAF50;
    border-color: #388E3C;
    box-shadow: 2px 2px 0px #2E8B57;
}
.mode-button:hover:not(.selected) {
    background-color: #888;
}

#mode-description {
    /* min-height: 3.5em; */ 
    margin-bottom: 20px; 
    font-size: 0.85em;
    color: #ccc;
    width: 80%;
    max-width: 500px;
    line-height: 1.6; 
}

#start-game-button { 
    margin-top: 0; 
    margin-bottom: 25px; 
}


button { 
    font-family: 'Press Start 2P', cursive;
    padding: 10px 18px;
    background-color: #4CAF50;
    color: white;
    border: 2px solid #388E3C;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    box-shadow: 2px 2px 0px #2E7D32;
    transition: background-color 0.2s;
}
button:hover {
    background-color: #66BB6A;
}
button:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

.controls-info {
    margin-top: 0; 
    padding: 10px;
    border: 1px dashed #777;
    border-radius: 5px;
    background-color: rgba(0,0,0,0.2);
    width: 80%;
    max-width: 500px;
}
.controls-info p {
    font-size: 0.8em;
    margin-bottom: 8px;
}

#typed-indicator-container {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 5px;
    font-size: 0.9em;
    min-height: 1.5em;
    position: relative;
    z-index: 5;
}
#typed-indicator-text {
    color: #FFA500;
    font-weight: bold;
}

#start-game-button:disabled {
    background-color: #9E9E9E;
    border-color: #757575;
    box-shadow: 2px 2px 0px #616161;
    cursor: not-allowed;
}

#pause-overlay {
    background-color: rgba(0, 0, 0, 0.85);
}
#pause-overlay h2 { /* S'assurer que ce style n'est pas écrasé */
    color: #FFA500;
    margin-bottom: 15px;
}
#pause-overlay p {
    color: #e0e0e0;
}


#game-over-screen h2 { /* S'assurer que ce style n'est pas écrasé */
    color: #FFA500;
    margin-bottom: 15px;
}
#game-over-screen p {
    color: #e0e0e0;
}


/* Styles pour les Meilleurs Scores */
#highscores-container {
    margin-top: 25px; 
    padding: 15px;
    border: 2px solid #777; 
    border-radius: 8px; 
    background-color: rgba(0,0,0,0.25); 
    width: 95%;
    max-width: 700px; 
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3); 
}
#highscores-container > h3 { 
    margin-top: 0;
    margin-bottom: 15px;
    color: #FFA500;
    font-size: 1.1em; 
}
.highscores-columns {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    flex-wrap: wrap;
}
.highscore-column {
    flex-basis: 45%;
    min-width: 250px;
    background-color: rgba(255,255,255,0.05);
    padding: 10px 10px 10px 15px; 
    border-radius: 5px;
    box-sizing: border-box;
}
.highscore-column h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #F0E68C;
    font-size: 1em;
    text-decoration: underline;
}
#highscores-list-words, #highscores-list-letters {
    list-style-type: decimal;
    list-style-position: inside;
    padding-left: 0; 
    margin: 0;
    text-align: left;
    font-size: 0.8em;
}
#highscores-list-words li, #highscores-list-letters li {
    margin-bottom: 6px;
    line-height: 1.4;
    color: #e0e0e0;
}
#highscores-list-words li .pseudo, 
#highscores-list-letters li .pseudo {
    color: #90EE90;
    font-weight: bold;
}
#highscores-list-words li .mode,
#highscores-list-letters li .mode {
    font-style: italic;
    color: #b0b0b0;
    font-size: 0.85em;
}


/* Styles pour l'écran Game Over / Sauvegarde score */
#save-score-section {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
#player-pseudo {
    font-family: 'Press Start 2P', cursive;
    padding: 8px 10px;
    border: 2px solid #777;
    background-color: #333;
    color: #e0e0e0;
    border-radius: 3px;
    text-align: center;
    font-size: 0.9em;
    width: 70%;
    max-width: 250px;
}
#player-pseudo::placeholder {
    color: #888;
}
#save-score-button {
    font-size: 0.9em;
    padding: 10px 15px;
}

/* Responsive */
@media (max-width: 768px) {
    #game-area { height: 400px; }
    .highscore-column h4 { font-size: 0.9em; }
    #highscores-list-words, #highscores-list-letters { font-size: 0.75em; }
}

@media (max-width: 480px) {
    body { padding-top: 10px; }
    #game-container { width: 95%; padding: 10px; }
    header h1 { font-size: 1.2em; }
    #score-board { font-size: 0.7em; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 8px; }
    #score-board > span { margin: 0; }
    #mode-display { white-space: nowrap; }
    .word-block, .letter-block { font-size: 0.9em; padding: 5px 8px; }
    .letter-block { font-size: 1em; min-width: 20px; }
    #game-area { height: 350px; }
    #player-line { bottom: 30px; }
    #character { font-size: 20px; }
    button { font-size: 0.8em; padding: 8px 12px; }
    .screen h2 { font-size: 1.3em; }
    .screen p { font-size: 0.75em; max-width: 90%; }
    .controls-info { margin-top: 0; width: 90%; } 
    #mode-description { width: 90%; margin-bottom: 15px; } 
    #mode-selection { flex-direction: column; gap: 10px; margin-bottom: 15px; } 
    #typed-indicator-container { font-size: 0.8em; }
    #highscores-container { width: 95%; padding: 10px; margin-top: 20px;}  
    #highscores-container > h3 { font-size: 1.1em; margin-bottom: 10px;}
    .highscores-columns { flex-direction: column; gap: 10px; }
    .highscore-column { flex-basis: auto; min-width: 0; padding: 8px 8px 8px 12px; }
    .highscore-column h4 { font-size: 0.9em; }
    #highscores-list-words, #highscores-list-letters { font-size: 0.7em; padding-left: 0;}
    #start-game-button { margin-bottom: 20px; } 
}