/* ===================================================================
   Echecs - Feuille de styles
   Design responsive mobile-first, palette bois/bois sombre + néon
   =================================================================== */

#game-main {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100dvh;
    padding: 8px 10px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    overflow-x: hidden;
}

#game-main * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

#game-main #game-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}

/* ---------- En-tête ---------- */
#game-main #game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-main #game-title {
    font-size: 1.7rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 4px 0 2px;
}

/* ---------- Scores / infos ---------- */
#game-main #scores-container {
    display: flex;
    justify-content: center;
    gap: 22px;
    flex-wrap: wrap;
}

#game-main .score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-main .score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #aaa;
}

#game-main .score-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

#game-main #turn-indicator {
    margin-top: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 4px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: #b0b0ff;
    display: inline-block;
    transition: background 0.3s ease, color 0.3s ease;
}

#game-main #turn-indicator.check {
    background: rgba(255, 60, 60, 0.18);
    color: #ff7070;
    animation: pulse-check 1s ease-in-out infinite;
}

@keyframes pulse-check {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 60, 60, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(255, 60, 60, 0); }
}

/* ---------- Plateau (zone canvas) ---------- */
#game-main #board-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

#game-main #board-wrapper {
    position: relative;
    width: min(96vw, 540px);
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: #2a1810;
    box-shadow:
        0 0 0 4px #3a2410,
        0 0 0 6px #5a3a1c,
        0 12px 30px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.4);
    padding: 6px;
}

#game-main canvas {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    border-radius: 6px;
    touch-action: none;
}

/* La couche d'effets ne capture pas les clics : on clique sur les pièces */
#game-main #board-fx {
    pointer-events: none;
}

/* ---------- Sélecteur de difficulté ---------- */
#game-main #difficulty-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}

#game-main .diff-btn {
    padding: 7px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #ccc;
    border-radius: 18px;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

#game-main .diff-btn.active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(123, 47, 247, 0.4);
}

#game-main .diff-btn:active {
    transform: scale(0.95);
}

/* ---------- Boutons d'action ---------- */
#game-main #controls-container {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
    padding-bottom: 4px;
}

#game-main .game-btn {
    padding: 11px 26px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

#game-main .game-btn:active {
    transform: scale(0.95);
}

#game-main .btn-play {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

#game-main .btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}

#game-main .btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

#game-main .btn-sound {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 9px 18px;
    font-size: 0.85rem;
    min-width: 56px;
}

#game-main .game-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---------- Message d'état ---------- */
#game-main #message-container {
    width: 100%;
    text-align: center;
    min-height: 24px;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: #b0b0ff;
    transition: opacity 0.3s ease;
}

/* ---------- Modal overlay ---------- */
#game-main .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    animation: fadeIn 0.25s ease;
    overflow-y: auto;
}

#game-main .modal-overlay.hidden {
    display: none !important;
}

#game-main .modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 22px 18px;
    max-width: 460px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(28px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#game-main .modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 10px;
    transition: color 0.2s;
}

#game-main .modal-close:hover {
    color: #fff;
}

#game-main .modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

#game-main .modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

#game-main .modal-body h3 {
    font-size: 0.95rem;
    color: #b0b0ff;
    margin: 12px 0 6px;
    font-weight: 600;
}

#game-main .modal-body p,
#game-main .modal-body ul,
#game-main .modal-body ol {
    margin-bottom: 8px;
}

#game-main .modal-body ul,
#game-main .modal-body ol {
    padding-left: 22px;
}

#game-main .modal-body li {
    margin-bottom: 4px;
}

#game-main .modal-body strong {
    color: #fff;
}

/* ---------- Modal "Qui commence" ---------- */
#game-main .start-choices {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

#game-main .start-choices button {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    letter-spacing: 0.5px;
}

#game-main .start-choices button:active {
    transform: scale(0.96);
}

#game-main .start-white {
    background: linear-gradient(135deg, #f0d9b5, #d4a574);
    color: #2a1810;
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
}

#game-main .start-black {
    background: linear-gradient(135deg, #2c1810, #1a0e08);
    border: 1px solid #5a3a1c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ---------- Modal fin de partie ---------- */
#game-main .end-result {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 12px 0;
}

#game-main .end-result.win { color: #00e676; }
#game-main .end-result.lose { color: #ff5252; }
#game-main .end-result.draw { color: #ffb74d; }

#game-main .end-stats {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px;
    margin: 12px 0;
}

#game-main .end-stat {
    text-align: center;
}

#game-main .end-stat-label {
    display: block;
    font-size: 0.7rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#game-main .end-stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    margin-top: 2px;
}

#game-main .end-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- High scores ---------- */
#game-main .highscores-block {
    margin-top: 16px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

#game-main .highscores-block h4 {
    font-size: 0.95rem;
    color: #b0b0ff;
    margin-bottom: 8px;
    text-align: center;
}

#game-main .highscores-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    max-height: 160px;
    overflow-y: auto;
}

#game-main .highscores-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#game-main .highscores-list li:last-child {
    border-bottom: none;
}

#game-main .hs-rank {
    color: #7b2ff7;
    font-weight: 700;
    min-width: 28px;
}

#game-main .hs-score {
    color: #fff;
    font-weight: 600;
}

#game-main .hs-empty {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 6px;
}

/* ---------- Utilitaires ---------- */
#game-main .hidden {
    display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-height: 700px) {
    #game-main #game-title { font-size: 1.4rem; margin: 2px 0; }
    #game-main .score-value { font-size: 1.1rem; }
    #game-main #turn-indicator { font-size: 0.85rem; padding: 3px 12px; }
    #game-main .game-btn { padding: 9px 20px; font-size: 0.85rem; }
    #game-main .diff-btn { padding: 6px 10px; font-size: 0.7rem; }
    #game-main #game-container { gap: 4px; }
}

@media (min-width: 768px) {
    #game-main #game-title { font-size: 2rem; }
    #game-main .score-value { font-size: 1.6rem; }
    #game-main #board-wrapper { padding: 8px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    #game-main #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100%;
        gap: 6px;
        justify-content: center;
        align-items: center;
    }
    #game-main #game-header { width: 30%; order: 1; }
    #game-main #board-container { order: 2; flex: 0 0 auto; }
    #game-main #board-wrapper { width: min(50vh - 20px, 380px); }
    #game-main #difficulty-row { width: 35%; order: 3; flex-direction: column; align-items: center; }
    #game-main #controls-container { width: 100%; order: 4; padding: 0 0 6px; }
    #game-main #message-container { width: 100%; order: 5; }
}
