
/* JEU 5 JOUEURS - PENTAGONE */
#game-container { position: relative; width: 1100px; height: 750px; background: radial-gradient(#16a085, #2c3e50); border-radius: 20px; box-shadow: 0 0 50px black; }

.player-label { position: absolute; background: rgba(0,0,0,0.6); padding: 5px 15px; border-radius: 20px; display: flex; align-items: center; border: 2px solid transparent; }
.player-label.active-turn { border-color: #f1c40f; box-shadow: 0 0 15px #f1c40f; }
.player-label.is-taker { border-color: #e74c3c; } /* Preneur en Rouge */
.player-label.is-partner { border-color: #3498db; } /* Partenaire en Bleu */

/* Positions relatives (0 = Moi) */
.p-bottom { bottom: 10px; left: 50%; transform: translateX(-50%); }
.p-right-bottom { bottom: 35%; right: 20px; }
.p-right-top { top: 30%; right: 160px; }
.p-left-top { top: 30%; left: 160px; }
.p-left-bottom { bottom: 35%; left: 20px; }

/* Table Cards */
/* Table Cards - Zone étendue à tout l'écran pour positionnement relatif aux joueurs */
.table-center { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: 10;
}

.card-slot { 
    position: absolute; 
    width: 60px; 
    height: 100px; 
    display: flex;
    justify-content: center;
    align-items: center;
}

/* MOI (Bas) - Carte au dessus de la main */
.slot-bottom { 
    bottom: 220px; 
    left: 50%; 
    transform: translateX(-50%); 
}

/* JOUEUR DROITE BAS - Carte à sa gauche */
.slot-right-bottom { 
    bottom: 35%; 
    right: 250px; 
    transform: translateY(20px); /* Ajustement pour centrer verticalement avec le pseudo */
}

/* JOUEUR DROITE HAUT - Carte à sa gauche */
.slot-right-top { 
    top: 30%; 
    right: 375px; 
    transform: translateY(-20px);
}

/* JOUEUR GAUCHE HAUT - Carte à sa droite */
.slot-left-top { 
    top: 30%; 
    left: 375px; 
    transform: translateY(-20px);
}

/* JOUEUR GAUCHE BAS - Carte à sa droite */
.slot-left-bottom { 
    bottom: 35%; 
    left: 250px; 
    transform: translateY(20px);
}

/* MAIN DU JOUEUR (15 cartes) */
#my-hand { 
    bottom: 30px;
    width: 100%;
    justify-content: center;
    height: 140px;
    overflow: visible;
}

.card { 
    width: 60px; 
    height: 100px; 
    border-radius: 6px; 
    
    /* GESTION DE L'ÉVENTAIL */
    margin: 0 -5px; 
    transform-origin: 50% 150%; 
    transform: rotate(var(--rot, 0deg)) translateY(var(--y, 0px));
}

.card:hover { 
    transform: rotate(var(--rot, 0deg)) translateY(-15px) scale(1.1); 
    margin: 0 5px; 
}

.card.selected { 
    border: 2px solid #f1c40f; 
    box-shadow: 0 0 10px #f1c40f;
    transform: rotate(var(--rot, 0deg)) translateY(-5px);
}

/* Style spécifique Atouts */
.card.trump { 
    color: #d35400; 
    border: 1px solid #e67e22; 
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.top-left { top: 2px; left: 2px; }
.bottom-right { bottom: 2px; right: 2px; transform: rotate(180deg); }


/* Style Atouts (Numéro encerclé) */
.card.trump .card-center {
    font-size: 1.6em;
    font-weight: bold;
    border: 2px solid currentColor;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.3);
}
.bottom-right { align-self: flex-end; transform: rotate(180deg); }
.trump-num { border: 1px solid #d35400; border-radius: 50%; width: 35px; height: 35px; display: flex; justify-content: center; align-items: center; }

/* Controles */
.control-panel { position: absolute; top: 15%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.9); padding: 20px; border-radius: 10px; text-align: center; z-index: 50; }
.suit-selector { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }
.suit-btn { 
    font-size: 2em;
    background: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 5px; cursor:
    pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}
.suit-btn.red { color: red; } .suit-btn.black { color: black; }

#bidding-controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    background: rgba(0,0,0,0.8);
    padding: 10px;
    border-radius: 10px;
}

/* Animation de fin de pli */
.card-fly-animation {
    transition: all 0.8s ease-in-out !important;
    z-index: 1000 !important;
}

/* Scoreboard Styles */
.scoreboard-container { width: 100%; text-align: center; color: #2c3e50; }
.scoreboard-container h2 { margin-top: 0; color: #2c3e50; }

.round-summary { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
    background: #ecf0f1; 
    padding: 15px; 
    border-radius: 10px; 
    margin-bottom: 20px;
    text-align: left;
}
.summary-item { font-size: 0.9em; }
.score-delta { font-weight: bold; font-size: 1.2em; text-align: center; grid-column: span 3; margin-top: 5px; }

.modal-box { max-height: 65vh; overflow-y: auto; }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.score-table th { background: #34495e; color: white; padding: 10px; }
.score-table td { padding: 10px; border-bottom: 1px solid #bdc3c7; }
.score-table tr.is-me { background: #fff9c4; font-weight: bold; }

.total-score { font-size: 1.2em; font-weight: bold; }
.round-delta { font-size: 0.9em; margin-left: 8px; }

.positive { color: #27ae60; }
.negative { color: #c0392b; }
.neutral { color: #7f8c8d; }

.scoreboard-actions { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }
.waiting-msg { font-style: italic; color: #7f8c8d; }

/* Indicateur Roi Appelé (Haut Gauche) */
#called-king-container {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    font-size: 0.8em;
    z-index: 15;
    border: 1px solid rgba(255,255,255,0.2);
}

#called-king-container .card {
    transform: scale(0.8); /* Un peu plus petit que les cartes de jeu */
    margin: 0;
    cursor: default;
    box-shadow: none;
}

/* --- POSITIONS 4 JOUEURS (Carré) --- */

/* Joueurs */
.p-right { 
    top: 50%; 
    right: 20px; 
    transform: translateY(-50%); 
}

.p-left { 
    top: 50%; 
    left: 20px; 
    transform: translateY(-50%); 
}

.p-top { 
    top: 20px; 
    left: 50%; 
    transform: translateX(-50%); 
}
/* .p-bottom est déjà défini plus haut */


/* Slots Cartes (Table) */
.slot-right { 
    top: 50%; 
    right: 250px; 
    transform: translateY(-50%); 
}

.slot-left { 
    top: 50%; 
    left: 250px; 
    transform: translateY(-50%); 
}

.slot-top { 
    top: 180px; 
    left: 50%; 
    transform: translateX(-50%); 
}

/* --- ADAPTATION MOBILE (RESPONSIVE) --- */
@media (max-width: 900px) {

    #game-container {
        width: 100vw;
        height: 100vh;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: radial-gradient(circle at center, #16a085, #2c3e50);
        overflow: hidden;
    }

    #screen-game {
        padding-top: 40px;
        height: 92vh;
    }

    #my-hand {
        height: 140px; /* Hauteur fixe suffisante */
        bottom: 5px;
        width: 100%;
        
        /* FLEXBOX CONFIG POUR SCROLL */
        flex-wrap: nowrap !important; /* CRUCIAL : Empêche le retour à la ligne */
        justify-content: flex-start; /* Aligne à gauche pour le scroll */
        align-items: center; /* Centre verticalement */
        
        overflow-x: auto; /* Active le scroll horizontal */
        overflow-y: hidden;
        
        padding-left: 5px; /* Espace au début pour attraper la 1ère carte */
        padding-right: 20px;
        
        /* Fond dégradé pour bien voir les cartes par rapport au tapis */
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
        z-index: 100;
    }

    #my-hand .card {
        flex: 0 0 auto; /* Empêche les cartes de s'écraser */
        width: 60px; /* Taille confortable pour le tactile */
        height: 90px;
        
        margin: 0 !important;
        margin-right: -22px !important; /* Chevauchement : on voit juste l'index */
        transform: none !important; /* Annule la rotation "éventail" du JS */
        
        box-shadow: -3px 0 5px rgba(0,0,0,0.4); /* Ombre à gauche pour détacher la carte de la précédente */
        border: 1px solid #ccc;
    }

    #my-hand .card:last-child { margin-right: 20px !important; }

    #my-hand .card:hover, #my-hand .card.selected {
        transform: translateY(-25px) !important;
        margin-right: 5px !important; /* S'écarte un peu pour être visible */
        z-index: 1000 !important;
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    }
    
    .card-corner { font-size: 0.8em; padding: 2px; }
    .card-center { 
        font-size: 1.5em !important;
        width: 30px !important;
        height: 30px !important;
    }
    .trump-num { width: 25px; height: 25px; font-size: 0.9em; border-width: 1px; }

    .player-label {
        padding: 4px 0;
        font-size: 0.75em;
        background: rgba(0,0,0,0.7);
        max-width: 90px;
        white-space: nowrap;
    }
    
    .player-avatar { width: 22px; height: 22px; font-size: 0.8em; line-height: 22px; }
    .player-info { overflow: hidden; }
    .player-name { text-overflow: ellipsis; overflow: hidden; }

    /* Positions Joueurs */
    .p-left.active-turn, .p-right.active-turn{ transform: scale(0.9);}
    .p-bottom { bottom: 120px; transform: translateX(-50%) scale(0.9);} /* Moi (juste au dessus de la main) */
    .p-left{ top: 150px; left: 0; transform: scale(0.9); }
    .p-left-bottom { bottom: 160px; left: -5px; transform: scale(0.9); }
    .p-left-top { top: 35px; left: -5px; transform: scale(0.9); }
    
    .p-top { top: 10px; left: 50%; transform: translateX(-50%) scale(0.9); }
    
    .p-right { top: 150px; right: 0; transform: scale(0.9); }
    .p-right-top { top: 35px; right: -5px; transform: scale(0.9); }
    .p-right-bottom { bottom: 160px; right: -5px; transform: scale(0.9); }

    /* Positions Slots Cartes (Table) - Rapprochés du centre */
    .card-slot { transform: scale(0.85); } /* Cartes jouées un peu plus petites */
    
    .slot-bottom { bottom: 150px; left: 50%; transform: translateX(-50%) scale(0.85); }
    
    .slot-left { top: 37%; right: 230px; left:unset}
    .slot-left-bottom { bottom: 44%; left: 15%; transform: translateY(20px) scale(0.85); }
    .slot-left-top { top: 20%; left: 15%; transform: translateY(-20px) scale(0.85); }
    
    .slot-top {top: 50px; left: 50%; transform: translateX(-50%) scale(0.85); }
    
    .slot-right {top: 37%; left: 230px;}
    .slot-right-top { top: 20%; right: 15%; transform: translateY(-20px) scale(0.85); }
    .slot-right-bottom { bottom: 44%; right: 15%; transform: translateY(20px) scale(0.85); }


    .control-panel, #bidding-controls {
        width: 95%;
        top: 33%;
        transform: translate(-50%, -50%);
        z-index: 200;
    }

    #bidding-controls {
        flex-direction: row;
        gap: 5px;
    }
    
    #bidding-controls button {
        flex: 1 1 40%;
        font-size: 0.85em;
        padding: 10px 5px;
    }

    #ecart-controls { top: 40%; }
    #cards-to-drop { font-size: 1.2em; }

    #permanent-scoreboard { display: none !important; }
    
    #game-announcer {
        top: 5px;
        font-size: 1em;
        width: 90%;
        padding: 5px;
    }

    #score-content { width: 98%; padding: 10px; max-height: 90vh; }
    .calc-details { font-size: 0.8em; padding: 10px; }
    .score-table th, .score-table td { padding: 5px; font-size: 0.8em; }
    
    #btn-quit-game {
        top: -10px !important;
        left: 5px !important;
        right: unset;
        font-size: 0.8em;
        padding: 5px 10px;
    }
    
    #called-king-container {
        top: 50px; 
        left: 50%;
        transform: scale(0.8) translateX(-50%);
        transform-origin: bottom left;
    }

    .sound-btn{
        top: -12px;
        right: 5px;
    }
}