/* 
=================================================================
🎯 CHESS MASTER PRO - PIÈCES UNIFORMES STYLE CHESS.COM
=================================================================
Pièces noires et blanches identiques en couleur pleine
================================================================= 
*/

:root {
    /* 🌙 MODE SOMBRE BLEU */
    --fond-principal: #1a1f36;          /* Bleu très foncé */
    --fond-secondaire: #242b4d;         /* Bleu foncé */
    --fond-carte: #2d3561;              /* Bleu moyen foncé */
    --fond-hover: #384175;              /* Bleu hover */

    /* 🎨 PIÈCES IDENTIQUES COULEUR PLEINE */
    --blanc-piece: #ffffff;             /* Blanc pur pour les pièces blanches */
    --noir-piece: #4a4a4a;              /* Gris foncé pour les pièces noires */

    /* Cases du plateau */
    --case-claire: #ecdab9;             /* Beige clair */
    --case-sombre: #ae8a56;             /* Marron */

    /* Interface */
    --texte-principal: #ffffff;          /* Blanc pour le texte */
    --texte-secondaire: #b8c5d6;        /* Bleu clair */
    --texte-desactive: #7a8aa3;         /* Gris bleu */
    --bordure: #4a5578;                 /* Bordure bleu foncé */
    --accent: #7fa650;                  /* Vert chess.com */
    --accent-hover: #8fb961;            /* Vert hover */
    --rouge: #e74c3c;                   /* Rouge pour échec */
    --jaune: #f1c40f;                   /* Jaune pour sélection */
    --orange: #f39c12;                  /* Orange */

    /* 📏 Espacements */
    --xs: 4px;
    --sm: 8px;
    --md: 16px;
    --lg: 24px;
    --xl: 32px;

    /* 📐 Tailles */
    --case: 70px;
    --piece: 56px;
    --plateau: 560px;

    /* ⏱️ Transitions */
    --rapide: 0.15s;
    --normal: 0.25s;
    --lent: 0.5s;

    /* 🌫️ Ombres mode sombre */
    --ombre-sm: 0 2px 4px rgba(0,0,0,0.3);
    --ombre-md: 0 4px 8px rgba(0,0,0,0.4);
    --ombre-lg: 0 8px 20px rgba(0,0,0,0.5);
}

/* 📱 Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--fond-principal);
    color: var(--texte-principal);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 🏗️ Structure modifiée */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--md);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Nouvelle structure : contrôles + plateau + captures */
.game-area {
    display: grid;
    grid-template-columns: 300px 1fr 250px;
    gap: var(--xl);
    height: 100%;
    align-items: center;
    width: 100%;
}

/* 📋 Panneaux mode sombre */
.control-panel {
    height: fit-content;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.control-panel::-webkit-scrollbar {
    display: none;
}

.panel {
    background: var(--fond-carte);
    border: 1px solid var(--bordure);
    border-radius: 12px;
    box-shadow: var(--ombre-sm);
    margin-bottom: var(--md);
    padding: var(--lg);
}

.panel h3 {
    margin-bottom: var(--md);
    font-size: 18px;
    color: var(--texte-principal);
    font-weight: 700;
    border-bottom: 2px solid var(--accent);
    padding-bottom: var(--sm);
}

.panel h4 {
    margin-bottom: var(--md);
    font-size: 16px;
    color: var(--texte-principal);
    font-weight: 600;
}

.panel h5 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--sm);
    color: var(--texte-secondaire);
}

/* 📝 Formulaires mode sombre */
.form-group {
    margin-bottom: var(--md);
}

.form-group label {
    display: block;
    margin-bottom: var(--sm);
    font-weight: 700;
    font-size: 14px;
    color: var(--texte-principal);
}

.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--bordure);
    border-radius: 8px;
    background: var(--fond-secondaire);
    color: var(--texte-principal);
    transition: all var(--rapide);
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(127, 166, 80, 0.2);
}

.form-group select option {
    background: var(--fond-secondaire);
    color: var(--texte-principal);
}

/* 🔘 Boutons mode sombre */
.btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--normal);
    border: none;
    margin-bottom: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--accent);
    color: var(--texte-principal);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--ombre-md);
}

.btn-secondary {
    background: var(--fond-secondaire);
    color: var(--texte-principal);
    border: 2px solid var(--bordure);
}

.btn-secondary:hover {
    background: var(--fond-hover);
    border-color: var(--accent);
}

/* 📊 Statut mode sombre */
.game-status {
    margin-top: var(--lg);
    padding-top: var(--lg);
    border-top: 2px solid var(--bordure);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--md);
}

.status-label {
    font-size: 14px;
    color: var(--texte-principal);
    font-weight: 700;
}

.status {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 12px;
    background: var(--accent);
    color: var(--texte-principal);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 💬 Messages mode sombre */
.game-messages {
    max-height: 120px;
    overflow-y: auto;
    margin-top: var(--md);
    scrollbar-width: none;
}

.game-messages::-webkit-scrollbar {
    display: none;
}

.game-messages p {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: var(--sm);
    padding: var(--sm) 12px;
    background: rgba(127, 166, 80, 0.15);
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    color: var(--texte-principal);
}

/* ♟️ Plateau mode sombre */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.board-wrapper {
    display: grid;
    grid-template-columns: 35px var(--plateau) 35px;
    grid-template-rows: var(--plateau) 35px;
    gap: 0;
    background: var(--fond-carte);
    border-radius: 16px;
    padding: var(--lg);
    box-shadow: var(--ombre-lg);
    border: 3px solid var(--bordure);
}

/* 🔤 Coordonnées mode sombre */
.rank-labels.file-left {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    font-size: 14px;
    font-weight: 800;
    color: var(--texte-secondaire);
}

.empty-space {
    grid-column: 3;
    grid-row: 1;
}

.file-labels.rank-bottom {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 14px;
    font-weight: 800;
    color: var(--texte-secondaire);
}

/* 🏁 Plateau */
.board {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(8, var(--case));
    grid-template-rows: repeat(8, var(--case));
    border: 3px solid var(--bordure);
    border-radius: 8px;
    overflow: hidden;
}

/* ⬜ Cases */
.square {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all var(--rapide);
    position: relative;
    width: var(--case);
    height: var(--case);
}

.square.square-light {
    background-color: var(--case-claire);
}

.square.square-dark {
    background-color: var(--case-sombre);
}

.square.square-selected {
    background-color: var(--jaune) !important;
    box-shadow: inset 0 0 0 3px var(--orange) !important;
}

.square.square-possible-move {
    background-color: rgba(127, 166, 80, 0.4) !important;
}

.square.square-possible-move::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--accent);
    border: 2px solid rgba(127, 166, 80, 0.8);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.square.square-last-move {
    background-color: rgba(241, 196, 15, 0.3) !important;
    box-shadow: inset 0 0 0 2px rgba(241, 196, 15, 0.6) !important;
}

.square.square-in-check {
    background-color: rgba(231, 76, 60, 0.8) !important;
    animation: alerte-echec 1s ease-in-out infinite;
    border: 3px solid var(--rouge) !important;
}

@keyframes alerte-echec {
    0%, 100% { 
        background-color: rgba(231, 76, 60, 0.8) !important;
        opacity: 1;
    }
    50% { 
        background-color: rgba(231, 76, 60, 0.4) !important;
        opacity: 0.7;
    }
}

.square:hover {
    background-color: rgba(127, 166, 80, 0.2) !important;
    transform: scale(1.02);
}

/* 
♛ PIÈCES UNIFORMES STYLE CHESS.COM - CORRECTION COMPLÈTE
================================================================= 
LES DEUX COULEURS ONT EXACTEMENT LE MÊME STYLE PLEIN
*/
.piece {
    font-size: var(--piece);
    cursor: grab;
    transition: all var(--rapide);
    z-index: 3;
    line-height: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-weight: 400;
    /* OMBRE IDENTIQUE pour les deux couleurs */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* PIÈCES BLANCHES - Couleur pleine pure SANS contour */
.piece.piece-white {
    color: var(--blanc-piece) !important;
    text-shadow: none !important;  /* SUPPRESSION de tout contour */
}

/* PIÈCES NOIRES - Couleur pleine pure SANS contour (IDENTIQUE aux blanches) */
.piece.piece-black {
    color: var(--noir-piece) !important;
    text-shadow: none !important;  /* SUPPRESSION de tout contour */
}

.piece:hover {
    transform: scale(1.08);
    z-index: 5;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)) brightness(1.1);
}

.piece.piece-dragging {
    cursor: grabbing;
    transform: scale(1.12);
    z-index: 10;
}

/* 📦 PANNEAU CAPTURES À DROITE */
.captures-panel {
    height: fit-content;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.captures-panel::-webkit-scrollbar {
    display: none;
}

/* Sections de captures */
.captured-section {
    margin-bottom: var(--lg);
}

.captured-list {
    display: flex;
    flex-direction: column;
    gap: var(--sm);
    min-height: 60px;
    padding: var(--md);
    background: var(--fond-secondaire);
    border-radius: 8px;
    border: 1px solid var(--bordure);
}

.captured-piece {
    font-size: 24px;
    opacity: 0.9;
    display: inline-block;
    margin: 2px;
}

/* Titre des captures */
.captured-section h5 {
    color: var(--texte-principal);
    margin-bottom: var(--sm);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 🏆 Modal mode sombre */
.checkmate-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 31, 54, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
    opacity: 0;
    animation: apparition var(--lent) ease-out forwards;
}

@keyframes apparition {
    to { opacity: 1; }
}

.checkmate-modal.hidden {
    display: none !important;
}

.checkmate-content {
    background: var(--fond-carte);
    border: 4px solid var(--accent);
    border-radius: 20px;
    padding: 48px 64px;
    text-align: center;
    box-shadow: var(--ombre-lg);
    transform: scale(0.8);
    animation: popup 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    min-width: 420px;
    max-width: 640px;
}

@keyframes popup {
    to { transform: scale(1); }
}

.checkmate-title {
    font-size: 3.2rem;
    font-weight: 900;
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--texte-principal);
}

.checkmate-title.victory {
    color: var(--accent);
}

.checkmate-title.defeat {
    color: var(--rouge);
}

.checkmate-title.draw {
    color: var(--orange);
}

.checkmate-message {
    font-size: 1.4rem;
    color: var(--texte-secondaire);
    margin-bottom: 32px;
    font-weight: 600;
}

.checkmate-button {
    background: var(--accent);
    color: var(--texte-principal);
    border: none;
    padding: 18px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.checkmate-button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--ombre-md);
}

/* 🤖 IA mode sombre */
.ai-thinking {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--fond-carte);
    padding: 28px 40px;
    border-radius: 12px;
    box-shadow: var(--ombre-lg);
    border: 3px solid var(--accent);
    display: none;
    z-index: 500;
}

.ai-thinking.show {
    display: block !important;
}

.ai-thinking-text {
    font-size: 17px;
    color: var(--texte-principal);
    margin-bottom: var(--md);
    text-align: center;
    font-weight: 700;
}

.thinking-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.thinking-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent);
    animation: pulsation 1.4s ease-in-out infinite both;
}

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulsation {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 📱 Mobile */
@media (max-width: 768px) {
    .game-area {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: var(--md);
        align-items: start;
    }

    .board-container {
        order: -1;
        height: auto;
    }

    .captures-panel {
        order: 1;
    }

    :root {
        --case: 40px;
        --piece: 30px;
        --plateau: 320px;
    }

    .board-wrapper {
        grid-template-columns: 25px var(--plateau) 25px;
        grid-template-rows: var(--plateau) 25px;
        padding: var(--md);
    }

    .checkmate-content {
        padding: 24px 32px;
        min-width: 300px;
        margin: var(--md);
    }

    .checkmate-title {
        font-size: 2.2rem;
    }

    .checkmate-message {
        font-size: 1.1rem;
    }

    .rank-labels.file-left,
    .file-labels.rank-bottom {
        font-size: 11px;
    }

    .captured-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* 🎨 Animation bonus */
@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.panel {
    animation: fadeIn var(--normal) ease-out;
}

/* Améliorations focus pour accessibilité */
.btn:focus-visible,
.form-group select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}