:root {
    color-scheme: dark;
    --night: #000000;
    --panel: #1f1f1f;
    --panel-raised: #292929;
    --line: rgba(255, 255, 255, 0.12);
    --text: #f2f2ef;
    --muted: #a6a6a6;
    --gold: #bcfe00;
    --gold-bright: #bcfe00;
    --green: #5c8052;
    --light-square: #f0ead9;
    --dark-square: #5c8052;
    font-family: Inter, Montserrat, Arial, sans-serif;
    background: var(--night);
    color: var(--text);
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; background: var(--night); color: var(--text); }
button, select { font: inherit; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }
.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.site-header { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand img { width: 48px; height: 48px; object-fit: cover; border: 1px solid rgba(240, 215, 122, .55); border-radius: 50%; }
.brand span, .player-copy { display: grid; gap: 3px; }
.brand strong { font-family: Georgia, 'Times New Roman', serif; font-size: 1rem; letter-spacing: .015em; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .07em; }
.back-link { color: #d5d9d3; font-size: .84rem; text-decoration: none; }
.back-link:hover, .site-footer a:hover { color: var(--gold-bright); }
.back-link span { margin-right: .35rem; color: var(--gold); font-size: 1.1rem; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 37px 0 25px; }
.eyebrow, .section-kicker { margin: 0; color: var(--gold); font-size: .68rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.eyebrow { align-self: start; display: flex; align-items: center; gap: 9px; padding-top: 10px; }
.eyebrow-mark { color: var(--gold-bright); font-size: 1.25rem; }
.intro-copy { flex: 1; max-width: 760px; }
.intro-copy h1 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.06; }
.intro-copy p { margin: 9px 0 0; color: #b5bfba; font-size: .95rem; }
.viewer { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 16px 42px rgba(0, 0, 0, .3); }
.viewer-topline { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 21px 25px 18px; border-bottom: 1px solid var(--line); }
.viewer-topline > div { display: grid; grid-template-columns: auto minmax(220px, 1fr); align-items: center; gap: 8px 17px; }
.viewer-topline .section-kicker { grid-column: 1 / -1; }
.select-label { color: #b9c1bb; font-size: .76rem; font-weight: 700; }
.game-select { width: min(480px, 58vw); min-height: 42px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 7px; padding: 0 38px 0 12px; background: #151515; color: var(--text); font-size: .85rem; }
.game-select:disabled { opacity: .7; }
.demo-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0 2px 5px 0; color: #e8d99e; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.demo-badge span { color: var(--gold-bright); font-size: .55rem; }
.game-meta { display: grid; grid-template-columns: minmax(0, 1fr) 150px minmax(0, 1fr); align-items: stretch; gap: 12px; padding: 18px 24px; }
.player-card { min-width: 0; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px 15px; background: #171717; }
.player-white { border-left: 3px solid #ded6bf; }
.player-black { border-left: 3px solid #454545; }
.player-piece { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 9px; background: rgba(240, 235, 220, .1); color: #f2ecdc; font-size: 1.65rem; }
.player-copy { min-width: 0; flex: 1; }
.player-copy small { color: var(--muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .1em; }
.player-copy strong { overflow: hidden; color: var(--text); font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.player-score { color: var(--gold-bright); font-size: .8rem; font-weight: 800; }
.match-center { display: grid; align-content: center; justify-items: center; gap: 3px; text-align: center; }
.match-event { color: #d4e9a4; font-size: .69rem; font-weight: 700; }
.match-result { font-family: Georgia, 'Times New Roman', serif; font-size: 1.55rem; font-weight: 500; }
.match-date { color: var(--muted); font-size: .68rem; }
.play-area { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, .9fr); gap: clamp(22px, 3vw, 38px); padding: 3px 25px 23px; }
.board-column { min-width: 0; }
.board-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.board-file-label { color: #c9cec8; font-family: Georgia, 'Times New Roman', serif; font-size: .83rem; }
.position-label { color: var(--gold-bright); font-size: .72rem; font-weight: 700; text-align: right; }
.board-frame { width: 100%; max-width: 552px; margin: 0 auto; padding: 3px; border: 1px solid #333; border-radius: 3px; background: #111; }
.chessboard { display: grid; width: 100%; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; overflow: hidden; border-radius: 2px; }
.square { position: relative; display: grid; min-width: 0; min-height: 0; place-items: center; appearance: none; border: 0; padding: 0; cursor: pointer; }
.square.light { background: var(--light-square); }
.square.dark { background: var(--dark-square); }
.square:hover { filter: brightness(1.09); }
.square.selected { box-shadow: inset 0 0 0 3px var(--gold); z-index: 1; }
.square.target::after { position: absolute; width: 25%; height: 25%; border: 2px solid rgba(0, 0, 0, .55); border-radius: 50%; background: rgba(188, 254, 0, .72); content: ''; }
.square.target-occupied::after { width: 88%; height: 88%; border: 4px solid rgba(188, 254, 0, .88); background: transparent; }
.square.last-move { background-image: linear-gradient(rgba(188, 254, 0, .2), rgba(188, 254, 0, .2)); }
.piece { position: relative; z-index: 1; display: block; width: 82%; height: 82%; overflow: visible; pointer-events: none; user-select: none; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .28)); }
.piece use { width: 100%; height: 100%; }
.coordinate { position: absolute; z-index: 2; left: 4px; top: 3px; color: #29372e; font-size: clamp(.58rem, 1.3vw, .72rem); font-weight: 800; line-height: 1; pointer-events: none; text-shadow: 0 0 1px rgba(255,255,255,.4); }
.square.dark .coordinate { color: #f8f3e4; text-shadow: 0 1px 1px rgba(0,0,0,.34); }
.board-hint { min-height: 18px; margin: 8px 0 10px; color: var(--muted); font-size: .67rem; text-align: center; }
.transport { display: flex; align-items: center; justify-content: center; gap: 9px; }
.transport-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(230, 220, 191, .22); border-radius: 9px; background: #111a1c; color: #eee9db; font-size: .85rem; cursor: pointer; transition: background .16s, border-color .16s, transform .16s; }
.transport-button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--gold); background: #26332f; }
.transport-button.transport-next { border-color: rgba(240, 215, 122, .56); color: var(--gold-bright); }
.transport-button:disabled { opacity: .38; cursor: not-allowed; }
.transport-button.transport-edge { font-size: .72rem; }
.transport-count { min-width: 75px; color: #cbd0ca; font-size: .75rem; font-variant-numeric: tabular-nums; text-align: center; }
.game-status { min-height: 18px; margin-top: 9px; color: #c5ceca; font-size: .71rem; text-align: center; }
.game-status.error { color: #ffb5a8; }
.moves-panel { min-width: 0; align-self: stretch; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #191919; }
.moves-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px 13px; border-bottom: 1px solid var(--line); }
.moves-heading h2 { margin: 4px 0 0; font-family: Georgia, 'Times New Roman', serif; font-size: 1.24rem; font-weight: 500; }
.moves-total { color: var(--muted); font-size: .72rem; }
.moves-list { display: grid; grid-auto-rows: minmax(40px, auto); align-content: start; max-height: 555px; overflow: auto; padding: 7px; scrollbar-color: #595959 #1f1f1f; scrollbar-width: thin; }
.move-row { display: grid; grid-template-columns: 39px 1fr 1fr; align-items: stretch; gap: 4px; border-radius: 6px; }
.move-row:nth-child(even) { background: rgba(255,255,255,.025); }
.move-number { display: grid; place-items: center; color: #87928c; font-size: .7rem; font-variant-numeric: tabular-nums; }
.move-cell { min-width: 0; display: flex; align-items: center; }
.move-cell:empty::after { content: '·'; color: #53605a; }
.move-button { width: 100%; min-height: 34px; border: 0; border-radius: 5px; padding: 4px 8px; background: transparent; color: #dce0d9; font-size: .78rem; text-align: left; cursor: pointer; }
.move-button:hover { background: rgba(188, 254, 0, .09); color: var(--gold-bright); }
.move-button.current { background: var(--gold); color: #10120b; font-weight: 800; }
.moves-empty { margin: 18px 12px; color: var(--muted); font-size: .82rem; text-align: center; }
.viewer-footer { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 13px 24px; color: #aeb8b1; font-size: .68rem; }
.viewer-footer span { color: var(--gold); }
.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 20px 0 25px; color: #a6a6a6; font-size: .72rem; }
.site-footer a { color: #c9b765; text-decoration: none; }
.error-panel { grid-column: 1 / -1; border: 1px solid rgba(255, 181, 168, .3); border-radius: 9px; padding: 18px; color: #ffc3b8; background: rgba(90, 38, 31, .16); font-size: .85rem; }

@media (max-width: 780px) {
    .page-shell { width: min(100% - 32px, 600px); }
    .site-header { min-height: 76px; }
    .brand img { width: 42px; height: 42px; }
    .brand strong { font-size: .9rem; }
    .brand small { font-size: .65rem; }
    .page-intro { display: block; padding: 27px 0 20px; }
    .eyebrow { padding: 0 0 10px; }
    .intro-copy h1 { font-size: clamp(2rem, 8vw, 2.8rem); }
    .intro-copy p { font-size: .85rem; }
    .viewer-topline { align-items: start; padding: 17px 16px 15px; }
    .viewer-topline > div { grid-template-columns: 1fr; gap: 7px; }
    .viewer-topline .section-kicker { grid-column: auto; }
    .game-select { width: min(56vw, 350px); min-width: 190px; font-size: .76rem; }
    .demo-badge { align-self: end; margin-bottom: 10px; font-size: .64rem; }
    .game-meta { grid-template-columns: minmax(0, 1fr) minmax(70px, .38fr) minmax(0, 1fr); gap: 7px; padding: 12px 13px 17px; }
    .player-card { gap: 7px; padding: 9px 8px; }
    .player-piece { width: 30px; height: 32px; font-size: 1.35rem; }
    .player-copy small { font-size: .58rem; }
    .player-copy strong { font-size: .72rem; }
    .player-score { font-size: .68rem; }
    .match-event { max-width: 100%; font-size: .58rem; }
    .match-result { font-size: 1.3rem; }
    .match-date { font-size: .58rem; }
    .play-area { grid-template-columns: 1fr; gap: 17px; padding: 0 13px 17px; }
    .board-frame { max-width: 552px; padding: 4px; }
    .piece { font-size: clamp(1.35rem, 9vw, 3.6rem); }
    .moves-list { max-height: 340px; }
    .viewer-footer { align-items: start; padding: 12px 15px; line-height: 1.5; }
}

@media (max-width: 420px) {
    .page-shell { width: calc(100% - 22px); }
    .site-header { min-height: 69px; }
    .brand { gap: 8px; }
    .brand img { width: 36px; height: 36px; }
    .brand strong { font-size: .79rem; }
    .brand small { font-size: .59rem; }
    .back-link { font-size: .73rem; }
    .viewer { border-radius: 13px; }
    .viewer-topline { gap: 8px; padding-inline: 11px; }
    .game-select { min-width: 165px; width: 55vw; max-width: 235px; }
    .demo-badge { gap: 5px; font-size: .56rem; }
    .game-meta { grid-template-columns: minmax(0, 1fr) 53px minmax(0, 1fr); gap: 5px; padding-inline: 8px; }
    .player-card { gap: 5px; padding: 8px 6px; }
    .player-piece { width: 25px; height: 28px; font-size: 1.15rem; }
    .player-copy strong { font-size: .64rem; }
    .player-score { font-size: .62rem; }
    .match-event { max-width: 53px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .board-file-label { font-size: .73rem; }
    .position-label { font-size: .64rem; }
    .board-hint { font-size: .63rem; }
    .transport { gap: 6px; }
    .transport-button { width: 35px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
