:root {
    color-scheme: dark;
    --ink: #f5f2e8;
    --muted: #a8ad9f;
    --page: #10130f;
    --surface: #181c17;
    --surface-2: #20261e;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #c9f065;
    --accent-dark: #1e2a0f;
    --warm: #e4bd72;
    --board-light: #e7dcc1;
    --board-dark: #71815c;
    --danger: #ef7c6c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

body {
    min-height: 100svh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 0%, rgba(201, 240, 101, 0.08), transparent 38rem),
        var(--page);
}

button,
input {
    font: inherit;
}

button,
label,
input[type="range"] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(201, 240, 101, 0.72);
    outline-offset: 3px;
}

.app-shell {
    width: min(100%, 1180px);
    min-height: 100svh;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.brand-bar,
.player-row,
.settings-heading,
.brand,
.choice-tile,
.elo-control {
    display: flex;
    align-items: center;
}

.brand-bar {
    justify-content: space-between;
    padding: 2px 0 16px;
}

.brand {
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid rgba(201, 240, 101, 0.28);
    border-radius: 13px;
    color: var(--accent);
    background: rgba(201, 240, 101, 0.09);
    font-size: 25px;
}

.brand strong,
.brand small,
.player-copy strong,
.player-copy small,
.choice-tile strong,
.choice-tile small,
.elo-value small {
    display: block;
}

.brand strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px;
    letter-spacing: 0.01em;
}

.brand small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    background: var(--surface);
    cursor: pointer;
    font-size: 24px;
}

.game-layout {
    display: grid;
    gap: 18px;
}

.board-column {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.player-row {
    min-height: 54px;
    gap: 10px;
    padding: 7px 2px;
}

.avatar {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: #191d17;
    background: #efe9d9;
    font-size: 24px;
}

.computer-avatar {
    color: #e9eadf;
    background: #30372c;
}

.player-copy {
    min-width: 0;
}

.player-copy strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-copy small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.thinking-pill,
.turn-pill {
    margin-left: auto;
    padding: 6px 9px;
    border-radius: 999px;
    color: var(--accent);
    background: rgba(201, 240, 101, 0.09);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.thinking-pill {
    animation: pulse 1.1s ease-in-out infinite;
}

.turn-pill.is-waiting {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
}

.board-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: var(--board-dark);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

#chess-board {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
    touch-action: manipulation;
}

.game-message {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 28px;
    text-align: center;
    background: rgba(12, 15, 11, 0.88);
    backdrop-filter: blur(5px);
}

.game-message[hidden],
.thinking-pill[hidden] {
    display: none;
}

.game-message strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(28px, 8vw, 48px);
}

.game-message span {
    color: var(--muted);
    line-height: 1.5;
}

.game-message button {
    min-height: 46px;
    margin-top: 10px;
    padding: 0 22px;
    border: 0;
    border-radius: 12px;
    color: #14180f;
    background: var(--accent);
    cursor: pointer;
    font-weight: 850;
}

.status-line {
    min-height: 20px;
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.settings-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent), var(--surface);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.settings-heading {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 24px;
    font-weight: 600;
}

.core-badge {
    padding: 6px 9px;
    border: 1px solid rgba(201, 240, 101, 0.18);
    border-radius: 999px;
    color: var(--accent);
    background: rgba(201, 240, 101, 0.06);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

fieldset {
    min-width: 0;
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}

legend {
    width: 100%;
    margin-bottom: 10px;
    color: #d5d8cc;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

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

.choice-tile {
    position: relative;
    min-height: 74px;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
    cursor: pointer;
}

.choice-tile:has(input:checked) {
    border-color: rgba(201, 240, 101, 0.72);
    background: rgba(201, 240, 101, 0.08);
    box-shadow: inset 0 0 0 1px rgba(201, 240, 101, 0.18);
}

.choice-tile input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.piece-preview {
    display: grid;
    width: 34px;
    height: 42px;
    flex: 0 0 auto;
    place-items: center;
    font-size: 32px;
}

.light-piece {
    color: #f1ead9;
    text-shadow: 0 1px 3px #000;
}

.dark-piece {
    color: #0b0d0a;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.24);
}

.choice-tile strong {
    font-size: 14px;
}

.choice-tile small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.25;
}

.elo-control {
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
}

.elo-value {
    min-width: 54px;
    color: var(--accent);
    line-height: 1;
}

.elo-value strong {
    font-size: 20px;
}

.elo-value small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    color: #747b70;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.difficulty-note {
    min-height: 36px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.primary-button {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    color: #161b10;
    background: var(--accent);
    box-shadow: 0 10px 30px rgba(201, 240, 101, 0.12);
    cursor: pointer;
    font-weight: 900;
}

.primary-button:active,
.game-message button:active {
    transform: translateY(1px);
}

.how-to-play {
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

.how-to-play summary {
    padding: 8px 2px;
    color: #d5d8cc;
    cursor: pointer;
    font-weight: 750;
}

.how-to-play p {
    margin: 4px 0 0;
    line-height: 1.55;
}

@keyframes pulse {
    50% { opacity: 0.52; }
}

@media (min-width: 760px) {
    .app-shell {
        padding: 22px 28px 32px;
    }

    .brand-bar {
        padding-bottom: 24px;
    }

    .game-layout {
        grid-template-columns: minmax(0, 720px) minmax(280px, 340px);
        align-items: center;
        justify-content: center;
        gap: clamp(24px, 5vw, 64px);
    }

    .settings-card {
        position: sticky;
        top: 24px;
        padding: 24px;
    }
}

@media (max-height: 700px) and (min-width: 760px) {
    .app-shell {
        padding-top: 10px;
    }

    .brand-bar {
        padding-bottom: 4px;
    }

    .player-row {
        min-height: 44px;
    }

    .avatar {
        width: 34px;
        height: 34px;
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
