@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    /* Un fond moderne en dégradé radial sombre */
    background: radial-gradient(circle at top, #2b323c, #11151a);
    color: #f1f5f9;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow-x: hidden;
}

.game-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    width: 100%;
    max-width: 1200px;
    box-sizing: border-box;
    flex-wrap: wrap;
}

/* --- LE PLATEAU DE JEU --- */
#board {
    width: 90vmin;
    height: 90vmin;
    max-width: 680px;
    max-height: 680px;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    background-image: url('assets/board.png');
    background-size: cover;
    /* Bordure épaisse et moderne */
    border: 10px solid #1e242b;
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 0 15px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    position: relative;
    user-select: none;
    background-size: 85%;
    background-repeat: no-repeat;
    background-position: center;
}
.square:hover { cursor: pointer; }

/* --- PIÈCES --- */
/* Effet d'ombre sur les pièces pour le relief */
.wp, .wn, .wb, .wr, .wq, .wk,
.bp, .bn, .bb, .br, .bq, .bk {
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}

/* Images des pièces */
.wp { background-image: url('assets/wp.png'); } .wn { background-image: url('assets/wn.png'); } .wb { background-image: url('assets/wb.png'); } .wr { background-image: url('assets/wr.png'); } .wq { background-image: url('assets/wq.png'); } .wk { background-image: url('assets/wk.png'); }
.bp { background-image: url('assets/bp.png'); } .bn { background-image: url('assets/bn.png'); } .bb { background-image: url('assets/bb.png'); } .br { background-image: url('assets/br.png'); } .bq { background-image: url('assets/bq.png'); } .bk { background-image: url('assets/bk.png'); }

/* --- MISE EN ÉVIDENCE (HIGHLIGHTS) CORRIGÉE DÉFINITIVEMENT --- */
/* On utilise des couleurs de fond directes pour éviter que les pièces disparaissent */

.square.highlight-selected { 
    background-color: rgba(234, 179, 8, 0.4) !important;
    box-shadow: inset 0 0 0 4px rgba(234, 179, 8, 0.9) !important;
}
.highlight-selected::after { display: none !important; }

.square.highlight-last { 
    background-color: rgba(59, 130, 246, 0.3) !important; 
}

.square.highlight-check { 
    background-color: rgba(239, 68, 68, 0.6) !important; 
    box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.8) !important;
}
.highlight-check::after { display: none !important; }

/* L'indicateur de coup possible (petit rond) */
.highlight-valid::after { 
    content: ''; 
    position: absolute; 
    top: 50%; left: 50%; 
    width: 25%; height: 25%; 
    min-width: 12px; min-height: 12px; 
    background-color: rgba(0, 0, 0, 0.3); 
    border-radius: 50%; 
    transform: translate(-50%, -50%); 
    border: 2px solid rgba(255, 255, 255, 0.5); 
    pointer-events: none;
    z-index: 1;
}

/* --- PANNEAUX LATERAUX (Glassmorphism) --- */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 280px;
    flex-shrink: 0;
}

#info-panel, #controls-panel {
    width: 100%;
    padding: 20px;
    /* Effet verre dépoli */
    background: rgba(30, 35, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    box-sizing: border-box;
}

#info-panel {
    font-size: 1.1em;
    line-height: 1.6;
    min-height: 100px;
}

#controls-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#controls-panel h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #e2e8f0;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

#controls-panel label {
    font-size: 0.95em;
    color: #cbd5e1;
}

#depth-selector {
    width: 60px;
    padding: 8px;
    background-color: rgba(15, 20, 25, 0.8);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 1em;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}
#depth-selector:focus { border-color: #3b82f6; }

/* --- BOUTON MODERNE --- */
#start-game-btn {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
#start-game-btn:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.6);
}
#start-game-btn:active {
    transform: translateY(1px);
}

/* --- MODALE DE PROMOTION --- */
#promotion-choice { 
    position: absolute; 
    background: rgba(15, 23, 42, 0.95); 
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15); 
    padding: 10px; 
    z-index: 100; 
    display: none; 
    gap: 10px; 
    border-radius: 12px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.8); 
}
.promotion-button { 
    width: 65px; height: 65px; 
    cursor: pointer; 
    border: 1px solid rgba(255,255,255,0.1); 
    background-color: rgba(255,255,255,0.05); 
    background-size: 85%; 
    background-repeat: no-repeat; 
    background-position: center; 
    border-radius: 8px; 
    transition: all 0.2s ease; 
}
.promotion-button:hover { 
    background-color: rgba(255,255,255,0.15); 
    border-color: #3b82f6; 
    transform: scale(1.05);
}

/* --- RESPONSIVE DESIGN (Mobiles & Tablettes) --- */
@media (max-width: 1000px) {
    body, html { display: block; padding: 20px 0; min-height: auto; }
    .game-container { flex-direction: column; gap: 30px; padding: 15px; }
    .side-panel { width: 90vmin; max-width: 680px; flex-direction: row; flex-wrap: wrap; }
    #info-panel, #controls-panel { flex: 1; min-width: 280px; }
}

@media (max-width: 600px) {
    .side-panel { flex-direction: column; }
    .promotion-button { width: 50px; height: 50px; }
}