:root {
    color-scheme: light;
    --bg-top: #f8e7cf;
    --bg-bottom: #f2c177;
    --panel: rgba(255, 248, 236, 0.82);
    --panel-border: rgba(108, 63, 28, 0.16);
    --text: #402515;
    --muted: #78553c;
    --dark-square: #8b4e2c;
    --light-square: #f8e4c3;
    --red-piece: #d84d38;
    --black-piece: #262626;
    --accent: #205f4a;
    --capture: #c88911;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.55), transparent 30%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.game-shell {
    width: min(1120px, calc(100% - 24px));
    margin: 0 auto;
    padding: 24px 0 32px;
}

.panel {
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: 0 16px 34px rgba(80, 44, 13, 0.14);
}

.hero-panel {
    padding: 24px;
    margin-bottom: 18px;
}

.eyebrow,
.label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--muted);
}

h1 {
    margin: 8px 0 10px;
    font-size: clamp(2rem, 4vw, 3.6rem);
}

.subtitle {
    margin: 0;
    max-width: 620px;
    line-height: 1.5;
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

button,
.home-link {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

button {
    background: linear-gradient(90deg, #2b7f63, var(--accent));
    color: #fff9ef;
}

.home-link {
    background: rgba(64, 37, 21, 0.08);
    color: var(--text);
}

.layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sidebar,
.board-wrap {
    padding: 20px;
}

.sidebar {
    display: grid;
    gap: 16px;
}

.status-block p {
    margin: 6px 0 0;
    line-height: 1.5;
}

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

.score-card {
    padding: 16px;
    border-radius: 18px;
    color: #fff8ee;
}

.score-card strong {
    display: block;
    margin-top: 6px;
    font-size: 1.9rem;
}

.red-card {
    background: linear-gradient(160deg, #e46b59, #bc3927);
}

.black-card {
    background: linear-gradient(160deg, #535353, #1d1d1d);
}

.legend {
    display: grid;
    gap: 10px;
    color: var(--muted);
}

.legend div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-piece,
.legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex: none;
}

.red-piece {
    background: radial-gradient(circle at 30% 30%, #ffb8a9, var(--red-piece) 60%, #99291b);
}

.king-piece {
    border-radius: 6px;
    background: linear-gradient(135deg, #f8d164, #d69c1d);
}

.move-swatch {
    border-radius: 6px;
    background: rgba(32, 95, 74, 0.28);
}

.capture-swatch {
    border-radius: 6px;
    background: rgba(200, 137, 17, 0.38);
}

.board-wrap {
    display: flex;
    justify-content: center;
}

.board {
    width: min(82vw, 720px);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    border-radius: 24px;
    overflow: hidden;
    border: 8px solid rgba(84, 45, 19, 0.75);
    box-shadow: inset 0 0 0 3px rgba(255, 244, 228, 0.32);
}

.cell {
    position: relative;
    border: 0;
    padding: 0;
    display: grid;
    place-items: center;
    background: transparent;
}

.cell.light {
    background: var(--light-square);
}

.cell.dark {
    background: var(--dark-square);
}

.cell.selected {
    box-shadow: inset 0 0 0 5px rgba(255, 248, 238, 0.72);
}

.cell.valid::after,
.cell.capture::after {
    content: "";
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
}

.cell.valid::after {
    background: rgba(213, 245, 232, 0.82);
}

.cell.capture::after {
    background: rgba(255, 224, 168, 0.95);
    box-shadow: 0 0 0 5px rgba(200, 137, 17, 0.22);
}

.piece {
    width: 72%;
    height: 72%;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    font-weight: 700;
    user-select: none;
    box-shadow: inset 0 6px 10px rgba(255, 255, 255, 0.18), inset 0 -8px 14px rgba(0, 0, 0, 0.22);
}

.piece.red {
    background: radial-gradient(circle at 30% 30%, #ffbfad, var(--red-piece) 60%, #962414);
    color: #fff4ea;
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #8d8d8d, var(--black-piece) 62%, #060606);
    color: #f9f1db;
}

.piece.king::before {
    content: "K";
    display: grid;
    place-items: center;
    width: 48%;
    height: 48%;
    border-radius: 50%;
    background: rgba(255, 238, 191, 0.88);
    color: #6b4300;
}

@media (max-width: 860px) {
    .layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 520px) {
    .game-shell {
        width: min(100% - 14px, 100%);
        padding-top: 14px;
    }

    .hero-panel,
    .sidebar,
    .board-wrap {
        padding: 16px;
        border-radius: 20px;
    }

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

    .board {
        border-width: 6px;
        border-radius: 18px;
    }
}