:root {
    color-scheme: light dark;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 24px 16px 48px;
    background: #f3f3f3;
    color: #202020;
}

main {
    width: min(1100px, 100%);
    margin: 0 auto;
}

header {
    margin-bottom: 24px;
}

h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 5vw, 48px);
}

.subtitle {
    margin: 0;
    color: #666;
}

.layout {
    display: grid;
    grid-template-columns:
        minmax(280px, 600px)
        minmax(260px, 1fr);
    gap: 28px;
    align-items: start;
}

.board-wrap {
    width: 100%;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #333;
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    font-family:
        "Segoe UI Symbol",
        "Noto Sans Symbols 2",
        serif;
    font-size: clamp(28px, 6vw, 64px);
    line-height: 1;
    user-select: none;
}

.square.light {
    background: #e7d7b5;
}

.square.dark {
    background: #8c6f54;
}

.square.last-move {
    outline: 4px solid rgba(255, 215, 0, 0.75);
    outline-offset: -4px;
}

.file-label,
.rank-label {
    position: absolute;
    font-family: system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    opacity: 0.65;
}

.file-label {
    right: 3px;
    bottom: 2px;
}

.rank-label {
    left: 3px;
    top: 2px;
}

.panel {
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 20px;
}

.status-line {
    margin-bottom: 20px;
}

.game-number {
    font-size: 13px;
    color: #666;
}

.status {
    margin-top: 4px;
    font-size: 24px;
    font-weight: 700;
}

.countdown-box {
    padding: 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    background: #f5f5f5;
}

.countdown-label {
    font-size: 13px;
    color: #666;
}

.countdown {
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    font-size: 34px;
    font-weight: 700;
}

.last-move-text {
    margin-bottom: 20px;
}

.moves-title {
    margin: 0 0 10px;
    font-size: 18px;
}

.moves {
    max-height: 360px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    font-family: ui-monospace, monospace;
    line-height: 1.8;
}

.move-row {
    display: grid;
    grid-template-columns: 42px 1fr 1fr;
    gap: 8px;
}

.move-number {
    color: #777;
}

.result {
    margin-bottom: 20px;
    padding: 14px;
    border-radius: 8px;
    background: #f5f5f5;
}

.hidden {
    display: none;
}

.error {
    padding: 14px;
    margin-bottom: 16px;
    color: #8b0000;
    background: #ffeaea;
    border-radius: 8px;
}

.about {
    margin-top: 28px;
    line-height: 1.7;
    color: #555;
}

@media (max-width: 760px) {
    body {
        padding: 16px 10px 40px;
    }

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

    .panel {
        padding: 16px;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background: #181818;
        color: #eee;
    }

    .panel {
        background: #242424;
        border-color: #444;
    }

    .subtitle,
    .game-number,
    .countdown-label,
    .about {
        color: #aaa;
    }

    .countdown-box,
    .result {
        background: #303030;
    }

    .moves {
        background: #202020;
        border-color: #444;
    }
}

.site-nav {
    margin-top: 14px;
}

.site-nav a {
    color: inherit;
}