* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --bg: #08090d;
    --panel: rgba(15, 17, 22, 0.86);
    --panel-strong: rgba(8, 9, 12, 0.94);
    --line: rgba(230, 196, 119, 0.34);
    --text: #f6efe0;
    --muted: #b7aa91;
    --gold: #e8be5d;
    --red: #d96c4d;
    --blue: #7bbbe9;
    --green: #71d08b;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at 18% 12%, rgba(232, 190, 93, 0.16), transparent 28%),
        radial-gradient(circle at 82% 8%, rgba(123, 187, 233, 0.12), transparent 25%),
        linear-gradient(135deg, #07080b, #15181f 48%, #0b0c10);
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

body {
    padding: 16px;
    overflow-x: hidden;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    margin-bottom: 14px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    background: rgba(6, 7, 10, 0.72);
}

.game-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: stretch;
}

.board-panel,
.hud-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

.board-panel {
    position: relative;
    min-height: calc(100vh - 86px);
    overflow: hidden;
}

#scene {
    display: block;
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 86px);
    background: #07080b;
    touch-action: none;
}

.hud-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    min-height: calc(100vh - 86px);
}

.eyebrow,
.status-card span,
.capture-row span {
    margin: 0 0 6px;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 0.92;
}

h2 {
    margin: 0 0 10px;
    color: var(--gold);
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-stack {
    display: grid;
    gap: 10px;
}

.status-card,
.captures,
.moves {
    padding: 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
}

.status-card strong {
    display: block;
    min-height: 1.35em;
    color: var(--text);
    font-size: 1.08rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

button {
    min-height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(232, 190, 93, 0.26), rgba(117, 77, 26, 0.82));
    font: inherit;
    cursor: pointer;
}

button:hover {
    border-color: var(--gold);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.capture-row {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-height: 34px;
}

.capture-row p {
    min-height: 1.4em;
    margin: 0;
    color: var(--muted);
    word-spacing: 4px;
}

.moves {
    flex: 1;
    min-height: 170px;
    overflow: hidden;
}

#moveList {
    max-height: 30vh;
    margin: 0;
    padding-left: 24px;
    overflow: auto;
    color: var(--muted);
    line-height: 1.65;
}

.hint {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.9rem;
}

.overlay-card {
    position: absolute;
    inset: 50%;
    width: min(420px, calc(100% - 32px));
    height: max-content;
    transform: translate(-50%, -50%);
    z-index: 5;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-strong);
    text-align: center;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

.overlay-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.promotion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.hidden {
    display: none !important;
}

@media (max-width: 980px) {
    body {
        padding: 10px;
    }

    .game-shell {
        grid-template-columns: 1fr;
    }

    .board-panel,
    #scene {
        min-height: 66vh;
    }

    .hud-panel {
        min-height: auto;
    }

    #moveList {
        max-height: 190px;
    }
}

@media (max-width: 560px) {
    .hud-panel {
        padding: 14px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .capture-row {
        grid-template-columns: 1fr;
    }
}
