body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    
    /* GESTION DE LA PAGE */
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
    
    /* FLEXBOX : COLONNE ET ALIGNEMENT HAUT */
    display: flex;
    flex-direction: column; /* Empile verticalement */
    align-items: center;    /* Centre horizontalement */
    justify-content: flex-start; /* Colle tout en haut */
    
    padding-top: 30px; /* Espace au dessus du titre */
    padding-bottom: 40px;
}

.container {
    width: 95%;
    max-width: 400px;
    padding: 0 10px;
    
    /* On s'assure que le contenu du conteneur est centré */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center; 
}

h1 { 
    color: #e94560;
    margin-top: 0; 
    margin-bottom: 20px;
    font-size: 2rem;
    
    /* FORCE L'ALIGNEMENT DU TITRE */
    display: block;
    width: 100%;      /* Prend toute la largeur */
    text-align: center; /* Centre le texte dans ce bloc */
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.5s; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    border: none;
    font-size: 1.2rem;
    text-align: center;
    box-sizing: border-box;
}

.btn {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-meneur { background-color: #f1c40f; color: #1a1a2e; }
.btn-joueur { background-color: #e94560; color: white; }
.btn-action { background-color: #0f3460; color: white; border: 1px solid #16213e; }
.btn-back { background-color: transparent; color: #888; border: 1px solid #888; margin-top: 20px;}

#debug-area {
    margin-top: 20px;
    font-family: monospace;
    color: #00ff00;
    font-size: 0.9rem;
}

/* Style de la liste des joueurs */
.player-list {
    background: #16213e;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* Résultats de recherche (liste déroulante) */
.search-results {
    position: absolute;
    background: #fff;
    color: #000;
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    text-align: left;
    display: none; /* Caché par défaut */
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}
.search-item:hover { background-color: #ddd; }

/* Badges des cartes sélectionnées */
.roles-container {
    display: flex;
    flex-direction: column; /* Liste verticale */
    gap: 8px; /* Espace entre les lignes */
    justify-content: flex-start;
    margin: 15px 0;
    width: 100%;
}

.selected-card-item {
    background-color: #e94560;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 1rem;
    display: flex;
    justify-content: space-between; /* Ecarte le nom et l'icone */
    align-items: center;
    animation: fadeIn 0.3s;
    border: 1px solid #c0392b;
}

.card-name-span {
    cursor: pointer;
    flex-grow: 1; /* Prend toute la place */
    text-align: left;
}

.card-name-span:hover {
    text-decoration: line-through; /* Indique qu'on va supprimer */
    opacity: 0.8;
}

.card-info-btn {
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,0.4);
}

.card-info-btn:hover {
    transform: scale(1.2);
}

.role-badge {
    background-color: #e94560;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    animation: fadeIn 0.3s;
}

.role-badge:hover { background-color: #c0392b; text-decoration: line-through; }

/* --- JEU JOUEUR - ANIMATION 3D --- */
.card-container {
    perspective: 1000px;
    -webkit-perspective: 1000px; /* INDISPENSABLE POUR IPHONE/MOBILE */
    width: 250px;
    height: 350px;
    margin: 20px auto;
    cursor: pointer;
    /* Empêche le tapotement bleu sur mobile */
    -webkit-tap-highlight-color: transparent; 
}

/* Le conteneur qui va réellement tourner */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d; /* INDISPENSABLE POUR IPHONE/MOBILE */
}

/* La classe qui sera ajoutée par le JS */
.card-inner.flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg); /* INDISPENSABLE POUR IPHONE/MOBILE */
}

/* Style commun aux deux faces */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    
    /* Cache la face arrière quand elle est retournée */
    backface-visibility: hidden; 
    -webkit-backface-visibility: hidden; /* INDISPENSABLE POUR IPHONE/MOBILE */
    
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    overflow: hidden;
    background-color: #1a1a2e;
    
    /* Fix pour certains bugs graphiques sur mobile */
    -webkit-transform: translate3d(0,0,0);
}

.card-face img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block; /* Évite les espaces blancs fantômes */
}

/* Style spécifique : Face avant (celle du rôle) */
.card-front {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg); /* INDISPENSABLE */
}

/* Style spécifique : Face arrière (dos de carte) */
.card-back {
    transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg); /* Parfois nécessaire pour fixer la position */
}

/* --- MISE À JOUR STYLE MORT --- */
.card-inner.is-dead .card-face {
    filter: grayscale(100%) brightness(0.7);
}

/* Le conteneur ne gère que le blocage du clic */
.card-inner.is-dead {
    pointer-events: none;
}

.role-desc {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 1rem;
    line-height: 1.4;
    min-height: 80px;
}

/* --- JEU MENEUR --- */
.night-list {
    list-style: none;
    padding: 0;
    text-align: left;
}

.night-list li {
    background: #0f3460;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 5px;
    border-left: 5px solid #f1c40f;
    font-size: 1.1rem;
}

/* Style pour le joueur mort */
.is-dead {
    filter: grayscale(100%); /* Tout en noir et blanc */
    opacity: 0.6;
    pointer-events: none; /* Empêche de cliquer/retourner la carte */
}

/* Petit ajustement pour le bouton mort */
#btn-kill {
    width: auto; 
    padding: 8px 20px; 
    border-radius: 20px; 
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}
#btn-kill:hover {
    background-color: #e94560;
    color: white;
}

/* --- STYLE MAIRE --- */
#mayor-badge {
    width: 60px;
    height: auto;
    margin-bottom: -15px; /* Chevauche un peu la carte */
    z-index: 10;
    position: relative;
    filter: drop-shadow(0 0 5px gold);
    animation: popIn 0.5s;
}

@keyframes popIn {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* --- MODALE SUCCESSION --- */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #16213e;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #f1c40f;
    width: 80%;
    max-width: 300px;
}

.succession-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: #0f3460;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}
.succession-btn:hover { background: #e94560; }

/* --- STYLE NOUVELLE LUNE --- */
.new-moon-card {
    background-color: #202529;
    color: #ecf0f1;
    width: 220px;
    margin: 10px auto;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #9b59b6;
    position: relative;
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.5);
    animation: flipIn 0.5s ease-out;
}

@keyframes flipIn {
    from { transform: rotateY(90deg); opacity: 0; }
    to { transform: rotateY(0); opacity: 1; }
}

.btn-close-nm {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
}
.btn-close-nm:hover { color: white; }