body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #05050a; /* Fond sombre étoilé */
    background-image: url('../assets/fond/background_etoiles.png');
    background-size: cover;
    background-position: center;
    overflow: hidden; /* Empêche les barres de défilement */
    transition: background-image 1s ease-in-out, background-color 1s ease-in-out;
}

body.level-2 {
    background-color: #2c003e;
}

body.level-3 {
    background-color: #1a252c;
}

body.level-4 {
    background-color: #3b0000;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

/* --- UI Modal de Question --- */
.hidden {
    display: none !important;
}

#player-turn-ui {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: #000000;
    border: 4px solid #ffffff;
    padding: 15px 25px;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    box-shadow: 6px 6px 0px rgba(0,0,0,0.8);
    image-rendering: pixelated;
    transition: border-color 0.3s;
}

/* --- Écran de Démarrage --- */
#start-screen-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 5vh 0;
    overflow-y: auto;
    z-index: 2000;
    font-family: 'Press Start 2P', monospace;
}

#home-screen-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1500;
    font-family: 'Press Start 2P', monospace;
}

.start-modal {
    background: #000000;
    border: 6px solid #ffffff;
    padding: 40px;
    text-align: center;
    color: #ffffff;
    box-shadow: 10px 10px 0px rgba(0,0,0,1);
    max-width: 80%;
    margin: auto;
}

.start-title {
    color: #ffd700;
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 4px 4px 0px #d63031;
}

.start-modal p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 30px;
}

.player-select-btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.player-btn {
    background: #333333;
    border: 4px solid #ffffff;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    padding: 15px 20px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #555555;
    transition: transform 0.1s;
}

.player-btn:hover {
    background: #555555;
    box-shadow: 2px 2px 0px #888888;
    transform: translate(2px, 2px);
}

.player-btn:active {
    box-shadow: 0px 0px 0px #888888;
    transform: translate(4px, 4px);
}

/* --- Indicateur de Niveau Actuel --- */
#level-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: #000000;
    border: 4px solid #ffffff;
    padding: 15px 20px;
    color: #ffd700;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    box-shadow: 6px 6px 0px rgba(0,0,0,0.8);
    image-rendering: pixelated;
}

/* --- Panneau de Statistiques Modale --- */
#player-stats-panel, #rules-panel, #categories-panel {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 5vh 0;
    overflow-y: auto;
    z-index: 2500;
}

.stats-modal {
    background: #000000;
    border: 6px solid #3498db;
    padding: 30px;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    box-shadow: 10px 10px 0px rgba(0,0,0,1);
    width: 80%;
    max-width: 650px;
    margin: auto;
}

#stats-player-title {
    color: #3498db;
    font-size: 1.2rem;
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
    text-shadow: 2px 2px 0px #000;
    border-bottom: 2px dashed #ffffff;
    padding-bottom: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 5px 10px;
    border-left: 4px solid;
    background: #111;
}

.stat-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-values {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

.stat-percent {
    width: 45px;
    text-align: right;
}

.stat-count {
    width: 75px;
    text-align: right;
}

.close-stats-btn {
    background: #e74c3c;
    border: 4px solid #c0392b;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    padding: 10px 20px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    margin-top: 25px;
    width: 100%;
    transition: transform 0.1s;
}
.close-stats-btn:hover {
    background: #c0392b;
}
.close-stats-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000;
}

/* --- Modale de Victoire --- */
#victory-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 5vh 0;
    overflow-y: auto;
    z-index: 2500;
    font-family: 'Press Start 2P', monospace;
}

.victory-modal {
    background: #000000;
    border: 6px solid #f1c40f;
    padding: 40px;
    text-align: center;
    color: #ffffff;
    box-shadow: 10px 10px 0px rgba(0,0,0,1);
    max-width: 80%;
    margin: auto;
}

.victory-title {
    color: #f1c40f;
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 4px 4px 0px #d35400;
}

#victory-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

#victory-stats-recap {
    background: #222;
    border: 4px dashed #555;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
}

#victory-stats-recap h3 {
    margin-top: 0;
    text-align: center;
    color: #ffd700;
    font-size: 0.9rem;
}

#recap-stats-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.next-level-btn {
    background: #27ae60;
    border: 4px solid #ffffff;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    padding: 15px 30px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #1e8449;
    transition: transform 0.1s;
}

.next-level-btn:hover {
    background: #2ecc71;
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #1e8449;
}

.next-level-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px #1e8449;
}

#dice-result-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: #000000;
    border: 4px solid #ffffff;
    padding: 15px 20px;
    color: #f1c40f;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    box-shadow: 6px 6px 0px rgba(0,0,0,0.8);
    image-rendering: pixelated;
}

#question-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.question-modal {
    box-sizing: border-box;
    background: #000000;
    border: 6px solid #ffffff;
    border-radius: 0px;
    padding: 25px;
    width: 700px;
    max-width: 85%;
    color: white;
    font-family: 'Press Start 2P', monospace;
    text-align: center;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.8);
    image-rendering: pixelated;
}

#question-theme {
    margin-top: 0;
    color: #f1c40f;
    text-transform: uppercase;
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0px #333;
}

#question-text {
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.5;
    margin-bottom: 30px;
}

#answers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.answer-btn {
    background-color: #2c3e50;
    color: #ecf0f1;
    border: 4px solid #ecf0f1;
    padding: 15px;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 1rem;
    line-height: 1.4;
    border-radius: 0px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    transition: transform 0.1s;
}

.answer-btn:hover {
    background-color: #34495e;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000;
}

.answer-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000;
}

.answer-btn.correct {
    background-color: #27ae60;
    border-color: #2ecc71;
    color: white;
}

.answer-btn.wrong {
    background-color: #c0392b;
    border-color: #e74c3c;
    color: white;
}

#explanation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 10px;
}

#explanation-text {
    font-family: 'Arial', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    text-align: center;
    background: #111;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 0px;
    border: 4px solid #555;
    margin: 0;
}

/* --- NOUVELLE MODALE QUESTION RPG --- */
#rpg-question-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.4); /* Fond plus léger pour laisser voir le jeu */
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Alignement en bas */
    z-index: 1000;
}

#rpg-dialogue-container {
    display: flex;
    width: 95%;
    max-width: 1000px;
    margin-bottom: 20px;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.8);
    background-color: #000; /* Fond noir pour garantir que rien ne passe à travers */
}

#rpg-character-portrait {
    width: 200px;
    flex-shrink: 0; /* Empêche l'image de se faire écraser par le texte */
    min-height: 250px;
    background-color: #333;
    border: 6px solid #fff;
    border-right: none;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Pseudo-élément pour symboliser un avatar en attendant */
#rpg-character-portrait::after {
    content: "?";
    font-family: 'Press Start 2P', monospace;
    font-size: 5rem;
    color: rgba(255, 255, 255, 0.2);
}

#rpg-dialogue-box {
    flex-grow: 1;
    background: #000;
    border: 6px solid #fff;
    padding: 20px;
    color: white;
    font-family: 'Press Start 2P', monospace;
    image-rendering: pixelated;
    display: flex;
    flex-direction: column;
}

#rpg-question-theme {
    margin-top: 0;
    color: #f1c40f;
    text-transform: uppercase;
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0px #333;
    margin-bottom: 15px;
    border-bottom: 2px dashed #444;
    padding-bottom: 10px;
}

#rpg-question-text {
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.5;
    margin-bottom: 20px;
    text-align: left;
}

#rpg-answers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: auto; /* Pousse les boutons vers le bas s'il y a de l'espace */
}

#rpg-explanation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

#rpg-explanation-text {
    font-family: 'Arial', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    text-align: left;
    background: #111;
    color: #ecf0f1;
    padding: 15px;
    border: 4px solid #555;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

/* --- Hamburger Menu (Style Jeu Vidéo) --- */
#top-menu-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 3000;
}

#hamburger-btn {
    background: #f1c40f;
    color: #000000;
    border: 4px solid #ffffff;
    padding: 10px 15px;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 6px 6px 0px rgba(0,0,0,1);
    transition: transform 0.1s;
}

#hamburger-btn:hover {
    background: #f39c12;
}

#hamburger-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0px rgba(0,0,0,1);
}

#hamburger-btn .burger-icon {
    font-size: 1.8rem;
    line-height: 1;
}

#hamburger-btn i {
    font-weight: 900;
    font-style: normal;
}

#dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 15px;
    background: #000000;
    border: 4px solid #ffffff;
    width: 320px;
    box-shadow: 10px 10px 0px rgba(0,0,0,1);
    overflow: hidden;
}

#dropdown-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#dropdown-menu li {
    padding: 15px 20px;
    color: white;
    font-size: 0.8rem;
    font-family: 'Press Start 2P', monospace;
    border-bottom: 4px solid #333333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color 0.2s, padding-left 0.2s;
}

#dropdown-menu li:last-child {
    border-bottom: none;
}

#dropdown-menu li:hover {
    background-color: #333333;
    padding-left: 25px; /* Petit effet de glissement au hover */
    color: #f1c40f;
}

.menu-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

/* --- Setup UI (Sélection Joueurs & Catégories) --- */
.setup-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px dashed #333;
}
.setup-section:last-of-type {
    border-bottom: none;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    background: #111;
    border: 2px solid #555;
    margin-top: 15px;
}

.category-btn {
    background: #222;
    border: 2px solid #444;
    color: #ccc;
    font-family: 'Arial', sans-serif;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.category-btn:hover {
    background: #333;
    border-color: #fff;
    color: #fff;
}

.category-btn.selected {
    background: #27ae60;
    border-color: #2ecc71;
    color: #fff;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.category-btn:disabled:not(.selected) {
    opacity: 0.5;
    cursor: not-allowed;
}

.start-game-btn {
    background: #f39c12;
    border: 4px solid #f1c40f;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 1rem;
    padding: 15px 30px;
    cursor: pointer;
    box-shadow: 4px 4px 0px #d35400;
    transition: transform 0.1s;
    margin-top: 20px;
}
.start-game-btn:hover:not(:disabled) {
    background: #f1c40f;
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #d35400;
}
.start-game-btn:disabled {
    background: #555;
    border-color: #777;
    color: #999;
    box-shadow: 4px 4px 0px #333;
    cursor: not-allowed;
}
.player-btn.selected {
    background: #3498db;
    border-color: #2980b9;
    color: #fff;
}

/* --- Media Queries pour Petits Écrans --- */
@media (max-width: 768px) {
    #level-indicator { font-size: 0.7rem; padding: 10px; top: 10px; left: 10px; }
    #player-stats-panel, #rules-panel, #categories-panel { font-size: 0.5rem; }
    .stat-row { font-size: 0.5rem; }
    .question-modal { padding: 15px; }
    #question-text { font-size: 0.9rem; margin-bottom: 15px; }
    .answer-btn { font-size: 0.8rem; padding: 10px; }
    #hamburger-btn { font-size: 0.6rem; padding: 5px 10px; top: 10px; right: 10px; }
    .menu-icon { font-size: 1.1rem; }
}
