/* ============================================================
   WSB Solutions Chess – Corporate Identity Stylesheet
   ============================================================ */

/* ---------- CSS Custom Properties (Brand Palette) ---------- */
:root {
    /* Primary Purples */
    --color-purple-1: #6d5593;
    --color-purple-2: #877caf;
    --color-purple-3: #a59dc3;

    /* Supporting */
    --color-green-1: #16a085;
    --color-green-2: #6abba7;
    --color-orange-1: #f39c12;
    --color-orange-2: #f1bb4f;
    --color-blue-1: #2980b9;
    --color-blue-2: #70a5d0;
    --color-grey-1: #6c7785;
    --color-grey-2: #7f8c8d;
    --color-grey-3: #bdc3c7;

    /* Derived */
    --light-square: #f0ecf5;
    --dark-square: var(--color-purple-1);
    --light-square-text: var(--color-purple-2);
    --dark-square-text: #e8e0f0;
    --bg-body: #1a1525;
    --bg-panel: #241e33;
    --bg-panel-card: #2e2740;
    --text-primary: #f0ecf5;
    --text-secondary: var(--color-grey-3);
    --board-border: var(--color-purple-2);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,.45);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(109,85,147,.25) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(41,128,185,.15) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
    background: linear-gradient(135deg, var(--color-purple-1), var(--color-purple-2));
    padding: 14px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,.35);
    position: relative;
    z-index: 10;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

.logo {
    height: 42px;
    width: auto;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 4px 10px;
}

.app-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff;
    text-transform: uppercase;
}

/* ---------- Main Layout ---------- */
.game-container {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 28px auto;
    padding: 0 20px;
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

/* ---------- Board Section ---------- */
.board-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.board-frame {
    border: 3px solid var(--board-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    line-height: 0;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(72vw, 520px);
    height: min(72vw, 520px);
}

/* Squares */
.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: min(7.5vw, 54px);
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: background .15s, box-shadow .15s;
}

.square.light { background: var(--light-square); color: var(--color-purple-1); }
.square.dark  { background: var(--dark-square);  color: var(--light-square); }

/* Coordinate labels */
.square .coord-file,
.square .coord-rank {
    position: absolute;
    font-size: 0.6em;
    font-weight: 700;
    opacity: .55;
    pointer-events: none;
}
.square .coord-file { bottom: 2px; right: 5px; }
.square .coord-rank { top: 2px;    left: 5px;  }

.square.light .coord-file,
.square.light .coord-rank { color: var(--light-square-text); }

.square.dark .coord-file,
.square.dark .coord-rank { color: var(--dark-square-text); }

/* Selected piece */
.square.selected {
    box-shadow: inset 0 0 0 3px var(--color-blue-1);
    z-index: 2;
}

/* Valid move dot */
.square.valid-move::after {
    content: '';
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: var(--color-green-1);
    opacity: .55;
    pointer-events: none;
    transition: transform .15s;
}

.square.valid-move:hover::after {
    transform: scale(1.35);
    opacity: .75;
}

/* Valid capture ring */
.square.valid-capture::after {
    content: '';
    position: absolute;
    width: 88%;
    height: 88%;
    border-radius: 50%;
    border: 4px solid var(--color-green-1);
    opacity: .55;
    pointer-events: none;
    background: transparent;
}

/* Check highlight */
.square.in-check {
    animation: checkPulse 1s ease-in-out infinite;
}

@keyframes checkPulse {
    0%, 100% { box-shadow: inset 0 0 14px 4px rgba(243,156,18,.7); }
    50%      { box-shadow: inset 0 0 22px 8px rgba(243,156,18,.9); }
}

/* Last move highlight */
.square.last-move {
    background: rgba(41,128,185,.22);
}
.square.dark.last-move  { background: color-mix(in srgb, var(--dark-square), var(--color-blue-1) 22%); }
.square.light.last-move { background: color-mix(in srgb, var(--light-square), var(--color-blue-2) 22%); }

/* Hover */
.square:hover {
    filter: brightness(1.08);
}

/* ---------- Captured Pieces Bar ---------- */
.captured-bar {
    min-height: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    font-size: min(5vw, 26px);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
}

.captured-bar .cap-piece {
    opacity: .75;
    transition: opacity .2s;
}

/* ---------- Info Panel ---------- */
.info-panel {
    flex: 1;
    min-width: 220px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-card {
    background: var(--bg-panel-card);
    border: 1px solid rgba(135,124,175,.25);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.panel-card h2 {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--color-grey-2);
    margin-bottom: 10px;
}

/* Turn */
.turn-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.turn-piece {
    font-size: 2.4rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

.turn-label {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Status */
.status-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-green-2);
}

.status-text.check     { color: var(--color-orange-1); }
.status-text.checkmate { color: #e74c3c; }
.status-text.draw      { color: var(--color-blue-2); }

/* Move list */
.history-card {
    max-height: 250px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.move-list {
    flex: 1;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--text-secondary);
    padding-right: 4px;
}

.move-list::-webkit-scrollbar { width: 5px; }
.move-list::-webkit-scrollbar-thumb { background: var(--color-purple-3); border-radius: 3px; }

.move-row {
    display: flex;
    gap: 8px;
}

.move-num {
    color: var(--color-grey-2);
    min-width: 30px;
    text-align: right;
}

.move-white, .move-black {
    min-width: 55px;
    padding: 1px 4px;
    border-radius: 4px;
    cursor: default;
}

.move-white:hover, .move-black:hover {
    background: rgba(135,124,175,.18);
}

/* Reset button */
.btn-reset {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--color-purple-1), var(--color-purple-2));
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .5px;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, filter .15s;
    box-shadow: 0 4px 16px rgba(109,85,147,.4);
}

.btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(109,85,147,.55);
    filter: brightness(1.08);
}

.btn-reset:active {
    transform: translateY(0);
}

/* ---------- Promotion Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,6,18,.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: var(--bg-panel-card);
    border: 1px solid var(--color-purple-2);
    border-radius: var(--radius);
    padding: 28px 32px;
    text-align: center;
    box-shadow: 0 12px 48px rgba(0,0,0,.6);
}

.modal-dialog h3 {
    margin-bottom: 18px;
    font-size: 1.1rem;
    color: var(--color-grey-3);
}

.promo-choices {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.promo-btn {
    font-size: 2.6rem;
    width: 64px;
    height: 64px;
    border: 2px solid var(--color-purple-3);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform .12s, border-color .15s, background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.promo-btn:hover {
    transform: scale(1.12);
    border-color: var(--color-green-1);
    background: rgba(22,160,133,.12);
}

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .board {
        width: min(92vw, 520px);
        height: min(92vw, 520px);
    }

    .square {
        font-size: min(10vw, 54px);
    }

    .info-panel {
        max-width: 100%;
        width: min(92vw, 520px);
    }

    .history-card { max-height: 160px; }
}

@media (max-width: 420px) {
    .app-header { padding: 10px 14px; }
    .logo { height: 32px; }
    .app-header h1 { font-size: 1.1rem; }
    .panel-card { padding: 14px 16px; }
}
