:root {
  color-scheme: dark;
  --background: #141717;
  --surface: #1b1f1f;
  --inset: #151919;
  --header: #202424;
  --line: #383e3d;
  --text: #eeeae1;
  --muted: #adafab;
  --accent: #f0bc72;
  --accent-dark: #342718;
  --good: #a2c3a0;
  --danger: #f0a796;
  --white-square: #e3cdb2;
  --black-square: #906e56;
  --mono: ui-monospace, Consolas, "Liberation Mono", monospace;
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 18rem; }
h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button, input, select, textarea { border: 1px solid var(--line); border-radius: .3rem; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-block-size: 2.3rem; padding: .36rem .72rem; background: #262c2b; font-size: .875rem; }
button:enabled, select, .button { cursor: pointer; }
button:enabled:hover, .button:hover { background: #303735; border-color: #676e68; color: var(--text); }
button:disabled { opacity: .48; }
button.primary { color: #211a12; background: var(--accent); border-color: var(--accent); font-weight: 700; }
button.primary:enabled:hover { background: #ffd098; color: #211a12; }
button.danger { color: #25100b; background: var(--danger); border-color: var(--danger); font-weight: 650; }
button.danger:enabled:hover { background: #ffd2c8; color: #25100b; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:not([type=checkbox]), textarea, select { width: 100%; min-width: 0; background: var(--inset); padding: .48rem .58rem; }
input[type=checkbox] { accent-color: var(--accent); width: 1rem; height: 1rem; }
input::placeholder { color: #9b9d99; }
select { appearance: none; padding-right: 1.7rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 1rem) 55%, calc(100% - .69rem) 55%; background-size: .32rem .32rem; background-repeat: no-repeat; }
kbd, code { font: .84rem/1.2 var(--mono); }
kbd { border: 1px solid #565e59; border-radius: .22rem; padding: .11rem .36rem; color: var(--accent); background: var(--background); }
.skip { position: absolute; z-index: 2; top: .5rem; left: .5rem; transform: translateY(-180%); padding: .6rem 1rem; background: var(--background); }
.skip:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.site-header { background: var(--header); border-bottom: 1px solid var(--line); }
.header-content, .status-content, main, footer { max-width: 78rem; margin-inline: auto; padding-inline: clamp(.8rem, 3vw, 2.2rem); }
.header-content { display: flex; align-items: stretch; gap: clamp(1rem, 3vw, 3.2rem); min-height: 4rem; }
.brand, .account-actions, nav { display: flex; align-items: center; }
.brand { flex: none; gap: .55rem; font-size: 1.28rem; font-weight: 770; letter-spacing: -.045em; }
.brand span { display: grid; place-items: center; width: 1.82rem; height: 1.82rem; color: var(--accent); background: var(--accent-dark); border: 1px solid #684c34; border-radius: .28rem; font: 1.4rem/1 Georgia, serif; }
.header-content nav { align-self: stretch; gap: .25rem; }
.header-content nav a { display: grid; place-items: center; align-self: stretch; padding: .1rem clamp(.55rem, 1.3vw, .93rem) 0; border-block-end: 2px solid transparent; color: var(--muted); font-size: .91rem; font-weight: 620; }
.header-content nav a:hover, .header-content nav a[aria-current] { color: var(--accent); }
.header-content nav a[aria-current] { border-color: var(--accent); }
.account-actions { margin-left: auto; gap: .9rem; white-space: nowrap; font-size: .9rem; }
.console-button { gap: .45rem; background: transparent; padding: .28rem .46rem; }
#account-link, #sign-in { color: var(--accent); }
.status-bar { background: #181c1c; border-bottom: 1px solid #292e2d; }
.status-content { display: flex; flex-wrap: wrap; align-items: center; min-height: 2.1rem; gap: .3rem 1.4rem; font-size: .81rem; color: var(--muted); }
.connection { display: flex; align-items: center; gap: .45rem; }
.connection > span:first-child { width: .46rem; height: .46rem; border-radius: 50%; background: var(--muted); }
.connection[data-state=online] > span:first-child { background: var(--good); }
.connection[data-state=reconnecting] > span:first-child { background: var(--accent); }
#return-game, #open-challenge-status { color: var(--accent); }

main { min-height: calc(100vh - 11rem); padding-block: clamp(1.25rem, 3vw, 2.2rem) 3rem; }
.view { display: grid; gap: 1rem; }
.page-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .15rem; }
.page-heading h1 { font-size: clamp(1.85rem, 4.5vw, 2.7rem); font-weight: 680; line-height: 1.1; letter-spacing: -.045em; }
.page-heading.compact h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.count, .surface-head > span, .seat-copy > span { font: .82rem/1.35 var(--mono); color: var(--muted); }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: .45rem; min-width: 0; }
.surface-head { min-height: 3rem; padding: .72rem .9rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem .8rem; border-bottom: 1px solid #303634; }
.surface-head h2, .dialog-head h2 { font-size: 1rem; font-weight: 680; }
.surface-head > a { color: var(--accent); font-size: .86rem; }
.panel-empty { padding: .85rem .92rem; color: var(--muted); }
.notice { margin-bottom: 1rem; padding: .62rem .82rem; color: var(--accent); background: #29241c; border: 1px solid #554431; border-radius: .3rem; }
.notice[data-error=true] { color: var(--danger); border-color: #795047; background: #342421; }

.lobby-layout, .board-layout, .activity-grid, .settings-grid { display: grid; align-items: start; gap: clamp(.9rem, 2vw, 1.4rem); }
.lobby-layout { grid-template-columns: minmax(0, 1fr) minmax(18rem, 22rem); }
.lobby-main, .lobby-side, .game-side { display: grid; gap: 1rem; min-width: 0; }
.activity-grid, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.graph-layout { padding: .95rem; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .4rem; }
.graph-y { display: flex; flex-direction: column; justify-content: space-around; align-items: end; padding-inline-end: .55rem; }
.graph-y, .graph-x { font: .78rem/1.3 var(--mono); color: var(--muted); }
.graph-x { grid-column: 2; display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; padding-top: .2rem; }
.seek-graph { position: relative; display: grid; place-items: center; min-height: clamp(12rem, 27vw, 18rem); border: 1px solid #46504d; border-radius: .26rem; color: var(--muted); background-color: #151b1a; background-image: linear-gradient(90deg, #303936 1px, transparent 1px), linear-gradient(#303936 1px, transparent 1px); background-size: 25% 33.333%, 25% 33.333%; background-position: 12.5% 16.666%; }
.seek-point { position: absolute; width: 1.24rem; min-height: 1.24rem; padding: 0; border: 2px solid #231b12; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px #fff1; transform: translate(-50%, -50%); }
.seek-point[data-kind=bot] { border-radius: .2rem; background: #a7c5c6; }
.seek-point:hover { z-index: 1; }
.seek-point:focus-visible { outline-offset: 2px; z-index: 1; }
.table-list > li { display: flex; align-items: center; justify-content: space-between; gap: .5rem .9rem; padding: .64rem .9rem; min-width: 0; border-block-start: 1px solid #2c3230; }
.table-list > li:first-child { border-block-start: 0; }
.table-list .row-title { display: block; font-weight: 630; overflow-wrap: anywhere; }
.table-list .row-detail { display: block; margin-top: .13rem; color: var(--muted); font: .83rem/1.35 var(--mono); }
.table-list .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .34rem; }
.table-list .empty { color: var(--muted); }
.stacked-form { padding: .95rem; display: grid; gap: .68rem; }
.stacked-form label { display: grid; gap: .25rem; font-size: .9rem; font-weight: 610; }
.stacked-form .check { display: flex; align-items: center; gap: .45rem; font-weight: 510; }
.two-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.secondary-form { border-top: 1px solid #303634; }
.filter-controls { display: flex; flex-wrap: wrap; gap: .45rem; }
.filter-controls select { font-size: .875rem; }
.profile-card > p { padding: .85rem .9rem; white-space: pre-line; overflow-wrap: anywhere; }
.table-list .rank-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: .55rem; }
.rank-number { color: var(--muted); font: .88rem var(--mono); text-align: right; }
.rank-score { font: 650 1rem var(--mono); }
.activity-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.activity-summary > div { display: grid; gap: .12rem; padding: .65rem .83rem; border: 1px solid var(--line); border-radius: .42rem; background: var(--surface); }
.activity-summary span { color: var(--muted); font-size: .85rem; }
.activity-summary strong { color: var(--accent); font: 700 1.35rem/1.35 var(--mono); }

.board-layout { grid-template-columns: minmax(0, min(64svh, 43rem)) minmax(17rem, 22rem); justify-content: center; }
#board-view .page-heading { width: min(100%, calc(min(64svh, 43rem) + 23.4rem)); margin-inline: auto; }
.game-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; min-width: 0; }
.seat { min-height: 3.15rem; display: flex; align-items: center; justify-content: space-between; gap: .55rem; padding: .38rem .54rem .38rem .8rem; border: 1px solid var(--line); border-radius: .38rem; background: var(--surface); }
.seat[data-turn=true] { border-color: #715739; }
.seat-copy { display: grid; gap: .06rem; min-width: 0; }
.seat-copy > a { font-weight: 670; overflow-wrap: anywhere; }
.seat-copy > span { font-size: .77rem; }
.clock { flex: none; background: var(--inset); padding: .23rem .55rem; border: 1px solid #38403d; border-radius: .25rem; min-width: 6.2ch; text-align: right; font: 700 clamp(1.08rem, 3.9vw, 1.65rem)/1.15 var(--mono); font-variant-numeric: tabular-nums; }
.seat[data-turn=true] .clock { color: var(--accent); border-color: #745636; }
.board { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); aspect-ratio: 1; border: 1px solid #6a5444; border-radius: .32rem; overflow: clip; background: var(--white-square); touch-action: manipulation; }
.square { min-block-size: 0; padding: 0; aspect-ratio: 1; position: relative; display: grid; place-items: center; border-radius: 0; border: 0; color: #38271c; background: var(--white-square); outline-offset: -3px; }
.square.dark { color: #fff1da; background: var(--black-square); }
.square:enabled:hover { background: #efd5ae; color: #38271c; }
.square.dark:enabled:hover { background: #ad8a6f; }
.square:focus-visible { outline: 3px solid #301e13; z-index: 1; }
.square.dark:focus-visible { outline-color: #fff1cd; }
.square[data-last=true], .square[data-last=true]:hover { box-shadow: inset 0 0 0 100px #ffce5655; }
.square[data-selected=true], .square[data-selected=true]:hover { box-shadow: inset 0 0 0 100px #ffaf3d8a; }
.square[data-legal=true]::after { content: ""; position: absolute; background: #25170d65; border-radius: 50%; width: 25%; height: 25%; }
.square[data-legal=true][data-occupied=true]::after { background: transparent; border: 4px solid #2a1d1775; width: 86%; height: 86%; }
.square img { display: block; width: 91%; height: 91%; pointer-events: none; user-select: none; object-fit: contain; }
.coordinate { position: absolute; z-index: 1; font: 700 clamp(.65rem, 1.5vw, .82rem)/1 var(--mono); pointer-events: none; }
.coordinate.rank { top: .21rem; left: .22rem; }
.coordinate.file { bottom: .22rem; right: .22rem; }
.game-actions, .replay-controls { display: flex; flex-wrap: wrap; gap: .42rem; padding: .7rem .8rem; }
.replay-controls { border-top: 1px solid #303634; }
.game-actions:empty { display: none; }
.score-list { display: grid; grid-template-columns: minmax(2.3rem, .48fr) minmax(0, 1fr) minmax(0, 1fr); max-height: 11rem; overflow: auto; font: .88rem/1.2 var(--mono); }
.score-list .score-empty { grid-column: 1/-1; padding: .85rem .9rem; color: var(--muted); font-family: system-ui, sans-serif; }
.score-no { padding: .52rem .75rem; color: var(--muted); background: #202625; }
.score-list > button, .score-list > .score-blank { min-block-size: 2rem; justify-content: start; border: 0; border-radius: 0; font: inherit; background: transparent; }
.score-list > [aria-current] { background: #493722; color: var(--accent); }
.chat-list { min-height: 3.5rem; max-height: 11rem; overflow: auto; }
.chat-list li { padding: .28rem .8rem; overflow-wrap: anywhere; font-size: .89rem; }
.chat-list b { color: var(--accent); margin-right: .45rem; }
.chat-control { display: inline-flex; margin-inline-start: .5rem; min-height: 1.8rem; padding: .1rem .35rem; font-size: .75rem; }
#report-game { margin: 0 .8rem .7rem; justify-self: start; }
.mod-evidence { overflow-wrap: anywhere; }
.mod-evidence blockquote { border-inline-start: 2px solid var(--accent); padding-inline-start: .8rem; margin: 0; }
.mod-evidence pre { white-space: pre-wrap; margin-block: .55rem; }
.chat-form { display: flex; gap: .4rem; padding: .65rem .8rem; border-top: 1px solid #303634; }

dialog { width: min(calc(100% - 1.4rem), 31rem); color: var(--text); background: var(--surface); border: 1px solid #59615a; border-radius: .48rem; padding: 1rem; }
dialog::backdrop { background: #080a09cc; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .72rem; }
.dialog-head > button { min-block-size: 1.95rem; }
#console-form, .confirm-actions, .promotion-choices { display: flex; gap: .55rem; }
#console-input { font-family: var(--mono); color: var(--accent); }
.console-help { margin-top: .65rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .35rem .55rem; }
#console-result:not(:empty) { margin-top: .65rem; color: var(--accent); }
.confirm-actions { justify-content: end; }
.promotion-choices > button { display: grid; width: 4.5rem; }
.promotion-choices img { display: block; width: 2.25rem; height: 2.25rem; }
footer { border-top: 1px solid #303634; padding-block: 1rem 1.5rem; display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: .8rem; }

@media (max-width: 57rem) {
  #board-view .page-heading { width: 100%; }
  .board-layout { grid-template-columns: minmax(0, 1fr) minmax(15.5rem, 18rem); }
  .lobby-layout { grid-template-columns: minmax(0, 1fr) minmax(15.5rem, 18.5rem); }
}
@media (max-width: 43rem) {
  .header-content { flex-wrap: wrap; gap: 0 .65rem; }
  .brand, .account-actions { min-height: 3rem; }
  .header-content nav { order: 3; width: 100%; min-height: 2.65rem; }
  .header-content nav a { flex: 1; }
  .console-button > span { display: none; }
  .board-layout, .lobby-layout, .activity-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .game-stage { width: min(100%, 34rem); justify-self: center; }
  .surface-head { min-height: 2.8rem; }
}
