* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f4f4f4;
    overflow: hidden; /* Évite le défilement indésirable */
}

#app {
    flex: 1;
    position: relative;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
}

.player-icon {
    position: absolute;
    top: 10px;
    margin-top: 15px;
    width: 80px;
    height: 80px;
    object-fit: contain;
    z-index: 1;
    opacity: 0.8; /* Transparence pour ne pas dominer */
}


#players {
    width: 100vw;
    height: 100vh;
    display: grid;
    z-index: 1;
}

.player {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 48px;
    background: white;
    text-align: center;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;  
}

#players[data-count="1"] {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
#players[data-count="2"] {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, 1fr);
}
#players[data-count="3"],
#players[data-count="4"] {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
#players[data-count="5"] {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 1fr);
}
#players[data-count="6"] {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* Pour 3 ou 5 joueurs : faire occuper 2 ou 3 colonnes */
#players[data-count="3"] .player.wide {
    grid-column: span 2;
}

#players[data-count="5"] .player.wide {
    grid-column: span 1; /* ou 2 ou 3 si tu veux les ajuster selon ton besoin visuel */
}

/* Remplacer la section pour 5 joueurs */
#players[data-count="5"] {
    grid-template-columns: repeat(6, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

#players[data-count="5"] .player.top {
    grid-column: span 2; /* Chaque joueur en haut occupe 2 colonnes */
}

#players[data-count="5"] .player.bottom {
    grid-column: span 3 !important; /* Chaque joueur en bas occupe 3 colonnes */
}
.player::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Motif SVG de bruit subtil */
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100" fill-opacity=".1"%3E%3Ccircle cx="50" cy="50" r="2" fill="white"/%3E%3C/svg%3E');
    background-repeat: repeat;
    z-index: -1; /* Derrière tout le contenu */
    opacity: 0.5; /* Texture subtile */
}
/* Classes pour chaque couleur */
.player.color-0 { /* Blanc */
    background-color: rgba(245, 245, 245, 0.9); /* Couleur de base */
}

.player.color-1 { /* Noir */
    background-color: rgba(74, 74, 74, 0.9);
}

.player.color-2 { /* Rouge */
    background-color: rgba(204, 51, 51, 0.9);
}

.player.color-3 { /* Vert */
    background-color: rgba(51, 153, 51, 0.9);
}

.player.color-4 { /* Bleu */
    background-color: rgba(51, 102, 204, 0.9);
}

.player.color-5 { /* Incolore */
    background-color: rgba(204, 204, 204, 0.9);
}

/* Effet au survol */
.player:hover::before {
    opacity: 0.6; /* Texture légèrement plus visible au survol */
}

.player h2 {
    z-index: 1;
    margin: 0;
    padding: 0;
    font-size: 125px;
    color: #000; /* Couleur du texte, ajustez si nécessaire */
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5); /* Ombre pour lisibilité */
    pointer-events: none; /* Évite que le texte bloque les clics */

}

.player .life-controls {
    display: flex;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.life-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
    pointer-events: none; /* pour ne pas bloquer le clic sur h2 */
}

.life-controls button {
    pointer-events: auto; /* réactive les boutons */
    width: 50px;
    height: 100%;
    font-size: 36px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.life-controls button:hover {
    background: rgba(0, 0, 0, 0.2);
}

.player button {
    flex: 1;
    font-size: 36px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.player-icon[src=""] {
    display: none; /* Masquer si l'image est absente */
}

.player button:hover {
    background: rgba(0, 0, 0, 0.2);
}

.player button.minus {
    padding-left: -220px;
    font-size: 80px;
    background: none;
}

.player button.plus {
    margin-left: 220px;
    font-size: 80px;
    background: none;
}


#menu {
    position: fixed;
    top: 0;
    left: -100%; /* Caché par défaut */
    width: 380px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: left 0.3s ease;
    padding: 20px;
}

#menu.open {
    left: 0; /* Visible quand ouvert */
    overflow-y: auto;
}

#menu h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
}
.menu-content {
    overflow-y: auto;
}

.controls {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-content: center;
    align-items: center;
    gap: 80px;
    margin-top: 80px;
    margin-bottom: 80px;
}

.controls button, .controls select {
    padding: 8px 16px;
    margin: 0 5px;
    font-size: 16px;
    cursor: pointer;
}

.history {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
}

.history h2 {
    margin-bottom: 10px;
}

.history ul {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.history li {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

#menu-toggle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: url('https://upload.wikimedia.org/wikipedia/en/a/aa/Magic_the_gathering-card_back.jpg') center/cover no-repeat;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#menu-toggle:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Styles pour chaque nombre de joueurs */
@media (min-width: 600px) {
    /* 2 joueurs : l'un au-dessus de l'autre, 100% width */
    #players.players-2 {
        flex-direction: column;
    }
    #players.players-2 .player {
        width: 100%;
        height: 50%;
    }

    /* 3 joueurs : 1 en haut (100%), 2 en bas (50% chacun) */
    #players.players-3 {
        flex-direction: column;
    }
    #players.players-3 .player.top {
        width: 100%;
        height: 50%;
        order: -1; /* Place en haut */
    }
    #players.players-3 .player.bottom {
        width: 50%;
        height: 50%;
        flex: 0 0 50%;
    }
    #players.players-3 .bottom-row {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 50%;
    }

    /* 4 joueurs : 2 en haut (50%), 2 en bas (50%) */
    #players.players-4 {
        flex-direction: column;
    }
    #players.players-4 .player {
        width: 50%;
        height: 50%;
        flex: 0 0 50%;
    }
    #players.players-4 .top-row, #players.players-4 .bottom-row {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 50%;
    }

    /* 5 joueurs : 2 en haut (50%), 3 en bas (33.33%) */
    #players.players-5 {
        flex-direction: column;
    }
    #players.players-5 .player.top {
        width: 50%;
        height: 50%;
        flex: 0 0 50%;
    }
    #players.players-5 .player.bottom {
        width: 33.33%;
        height: 50%;
        flex: 0 0 33.33%;
    }
    #players.players-5 .top-row, #players.players-5 .bottom-row {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 50%;
    }

    /* 6 joueurs : 3 en haut (33.33%), 3 en bas (33.33%) */
    #players.players-6 {
        flex-direction: column;
    }
    #players.players-6 .player {
        width: 33.33%;
        height: 50%;
        flex: 0 0 33.33%;
    }
    #players.players-6 .top-row, #players.players-6 .bottom-row {
        display: flex;
        flex-direction: row;
        width: 100%;
        height: 50%;
    }
}

@media (max-width: 1000px) {

    .player.top,
    .player.bottom {
        transform: none; /* Annule toute rotation spécifique aux joueurs */
    }

    .player .plus {
        margin-left: 0px !important;
    }
    .player h2 {
        font-size: 60px; /* Ajuste pour mobile */
    }

    .player-icon {
        width: 40px; /* Ajuste la taille de l'icône */
        height: 40px;
    }

    .life-controls {
        font-size: 24px;
        gap: 70px;
    }
}