/* ==========================================================================
   VARIABLES - Charte SYGNEX Premium Noir & Or
   ========================================================================== */
:root {
    --bg-dark: transparent;
    --bg-panel: #111111;
    --text-main: #f5f5f5;
    --text-muted: #999999;
    
    --gold-primary: #d4af37;
    --gold-light: #f3e5ab;
    --gold-dark: #997a00;
    
    --border-radius: 4px;
    --transition-speed: 0.3s;
    
    --board-size: 100%;
    --max-board-size: 600px;
    --square-size: calc(var(--max-board-size) / 10);
}

/* ==========================================================================
   RESET & CONTAINERS (Isolation stricte pour éviter les débordements visuels)
   ========================================================================== */
#sygnex-dames-container {
    margin-top: 20px;
    margin-bottom: 20px;
    color: var(--text-main);
    font-family: inherit;
    line-height: 1.5;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Empêche tout élément extérieur de déborder */
    position: relative;
    z-index: 2;
}

#sygnex-dames-container * {
    box-sizing: border-box;
}

#sygnex-dames-container h2 {
    color: var(--gold-primary);
    border-bottom: 1px solid var(--gold-dark);
    padding-bottom: 6px;
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--gold-dark);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    position: relative;
}

/* ==========================================================================
   BOUTONS & INPUTS
   ========================================================================== */
.btn {
    display: inline-block;
    background-color: var(--gold-primary);
    color: #000;
    border: 1px solid var(--gold-primary);
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-align: center;
}

.btn:hover {
    background-color: var(--gold-light);
    border-color: var(--gold-light);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

#sygnex-dames-container input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    background-color: #000;
    border: 1px solid var(--gold-dark);
    color: var(--text-main);
    border-radius: var(--border-radius);
    font-size: 1rem;
    margin-bottom: 15px;
}

#sygnex-dames-container input[type="text"]:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

/* ==========================================================================
   FENÊTRE MODALE (MODE D'EMPLOI)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-panel);
    border: 2px solid var(--gold-primary);
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    position: relative;
    padding: 0;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--gold-primary);
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
}

.close-btn:hover {
    color: var(--gold-light);
    transform: scale(1.1);
}

.rules-scroll-area {
    max-height: 85vh;
    overflow-y: auto;
    padding: 30px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-primary) var(--bg-panel);
}

.rules-scroll-area::-webkit-scrollbar {
    width: 8px;
}
.rules-scroll-area::-webkit-scrollbar-track {
    background: var(--bg-panel);
}
.rules-scroll-area::-webkit-scrollbar-thumb {
    background-color: var(--gold-primary);
    border-radius: 4px;
}

.rules-scroll-area ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.rules-scroll-area li {
    margin-bottom: 5px;
}

/* ==========================================================================
   TABLEAU DE CLASSEMENT
   ========================================================================== */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.95rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.leaderboard-table th {
    background-color: rgba(212, 175, 55, 0.1);
    color: var(--gold-primary);
}

/* ==========================================================================
   PLATEAU 3D ET MÉCANIQUE DE ROTATION
   ========================================================================== */
.dames-board-wrapper {
    position: relative;
    width: 100%;
    max-width: var(--max-board-size);
    aspect-ratio: 1 / 1;
    perspective: 1200px;
    margin: 40px auto;
    background: transparent; /* Suppression de tout fond parasite */
    overflow: visible;
}

.dames-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    border: 12px solid #0a0a0a;
    border-radius: 6px;
    box-shadow: 0 30px 50px rgba(0, 0, 0, 0.9), 0 0 20px rgba(212, 175, 55, 0.2);
    
    transform-style: preserve-3d;
    transform: rotateX(40deg) rotateZ(0deg);
    transition: transform 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.dames-board.rotated {
    transform: rotateX(40deg) rotateZ(180deg);
}

/* ==========================================================================
   CASES DU DAMIER
   ========================================================================== */
.square {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-sizing: border-box;
}

.square.dark { 
    background-color: #222; 
    border: 1px solid #1a1a1a;
}
.square.light { 
    background-color: #d4af37;
    opacity: 0.8;
}

.square.selected { box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.8); border: 2px solid #fff; }
.square.valid-move { box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.7); background-color: rgba(0, 255, 0, 0.2) !important; }
.square.valid-capture { box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.8); background-color: rgba(255, 0, 0, 0.3) !important; }

/* ==========================================================================
   PIONS ET AVATARS DYNAMIQUES
   ========================================================================== */
.pawn {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: absolute;
    background-size: cover;
    background-position: center;
    box-shadow: 0 6px 10px rgba(0,0,0,0.8), inset 0 -4px 5px rgba(0,0,0,0.5), inset 0 2px 5px rgba(255,255,255,0.3);
    pointer-events: none; 
    transition: top 0.4s ease, left 0.4s ease, transform 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.pawn.human {
    background-color: #555;
    border: 3px solid #888;
}

.pawn.ai {
    background-color: var(--gold-primary);
    border: 3px solid var(--gold-light);
}

.pawn.king::after {
    content: '👑';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

.dames-board.rotated .pawn {
    transform: rotateZ(-180deg);
}

/* ==========================================================================
   CIMETIÈRES (Affichage des jetons perdus)
   ========================================================================== */
.cemetery {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 120px;
    min-height: 30px;
    align-items: center;
    padding: 2px;
}

.cemetery .pawn {
    position: relative !important;
    width: 24px !important;
    height: 24px !important;
    top: auto !important;
    left: auto !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    transform: none !important;
}

/* ==========================================================================
   RESPONSIVE (Adaptation Mobile)
   ========================================================================== */
@media (max-width: 768px) {
    .dames-hud {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .dames-board {
        transform: rotateX(25deg) rotateZ(0deg);
    }
    
    .dames-board.rotated {
        transform: rotateX(25deg) rotateZ(180deg);
    }
    
    .pawn.king::after {
        font-size: 1rem;
    }
}