:root {
  color-scheme: light dark;
  --paper: #f7f5f0;
  --surface: #fff;
  --ink: #111;
  --muted: #77736d;
  --line: #d8d4cc;
  --soft: #eeebe5;
  --dark: #111;
  --dark-ink: #fafafa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .5; }
.shell { width: min(100% - 28px, 560px); margin: 0 auto; padding: 22px 0 48px; }
.brand { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 42px; font: 700 12px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .13em; }
.brand > span { min-width: 0; }
.brand strong { font-size: 16px; letter-spacing: -.04em; }
.active-player-control { position: relative; display: flex; justify-content: flex-end; min-width: 0; width: 100%; max-width: 100%; margin-left: 0; text-align: right; }
.active-player-control[hidden] { display: none; }
#player-name { width: 100%; min-width: 0; max-width: 100%; margin: 0; overflow: hidden; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); padding: 8px 10px; text-align: right; text-overflow: ellipsis; white-space: nowrap; font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1.1; letter-spacing: 0; }
.active-player-select { width: 100%; max-width: 100%; min-height: 40px; margin: 0; border: 1px solid var(--ink); border-radius: 0; appearance: none; -webkit-appearance: none; background: var(--ink); color: var(--paper); padding: 7px 32px 7px 9px; text-align: right; font-family: inherit; font-size: 11px; font-weight: 800; line-height: 1.1; }
.active-player-control.has-dropdown::after { content: '⌄'; position: absolute; top: 50%; right: 10px; color: var(--paper); transform: translateY(-50%); pointer-events: none; }
.active-player-select:focus, #player-name:focus { outline: 2px solid currentColor; outline-offset: 2px; }
.panel, .match-card { border: 1.5px solid var(--line); background: var(--surface); padding: 20px; }
.panel { margin-bottom: 14px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font: 700 10px/1.2 "SFMono-Regular", Consolas, monospace; letter-spacing: .14em; }
h1 { margin: 0 0 22px; font-size: clamp(30px, 8vw, 44px); line-height: .98; letter-spacing: -.055em; }
label { display: block; margin: 16px 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.input-row { display: flex; gap: 8px; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--ink); padding: 10px 12px; }
.player-picker { position: relative; }
.picker-panel { padding: 10px; border: 1px solid var(--ink); background: var(--surface); }
.player-options { max-height: 260px; margin-top: 8px; overflow-y: auto; }
.player-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; border-top: 1px solid var(--soft); background: var(--surface); color: var(--ink); padding: 9px 8px; text-align: left; font-size: 13px; font-weight: 700; cursor: pointer; }
.player-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.player-option:hover, .player-option.selected { background: var(--ink); color: var(--paper); }
.player-option.selected input { accent-color: var(--paper); }

button { min-height: 46px; border: 1px solid var(--ink); border-radius: 0; background: var(--ink); color: var(--paper); padding: 10px 15px; font-weight: 800; }
#open-dashboard { width: 100%; margin-top: 16px; }
.status { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.status.error { color: #a12c22; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; gap: 6px; }
.quiet { min-height: 34px; padding: 6px 9px; border-color: var(--line); background: transparent; color: var(--ink); font-size: 11px; }
.match-card { margin-bottom: 14px; padding: 22px; }
.match-card.white-mode { background: #fff; border-color: #111; color: #111; }
.match-card.black-mode { background: #111; border-color: #111; color: #fff; }
.match-card.black-mode .muted, .match-card.black-mode .eyebrow { color: #b8b8b8; }
.match-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.match-label { font: 800 11px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .13em; }
.match-colour { font: 800 11px/1.2 "SFMono-Regular", Consolas, monospace; text-align: right; }
.match-card h2, .opponent-button { margin: 34px 0 6px; font-size: clamp(26px, 8vw, 42px); line-height: .95; letter-spacing: -.06em; }
.opponent-button { display: flex; align-items: center; gap: 9px; min-height: 0; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; font-weight: 800; }
.opponent-name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.opponent-button:hover .opponent-name { text-decoration-thickness: 2px; }
.history-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.opponent-modal { width: min(calc(100% - 28px), 560px); max-height: 82vh; border: 1.5px solid var(--ink); border-radius: 0; background: var(--surface); color: var(--ink); padding: 20px; }
.opponent-modal::backdrop { background: rgb(17 17 17 / 45%); }
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-heading h2 { margin: 0 0 5px; font-size: clamp(25px, 7vw, 36px); line-height: .98; letter-spacing: -.055em; }
.match-detail { margin: 0; font-size: 14px; }
.match-time { margin: 25px 0 0; font: 700 12px/1.3 "SFMono-Regular", Consolas, monospace; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--line); margin-bottom: 14px; background: var(--surface); }
.stat { min-width: 0; padding: 16px 12px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-interactive { cursor: pointer; }
.stat-button { display: block; min-height: 0; border: 0; background: transparent; color: inherit; padding: 0; text-align: left; }
.stat-interactive:hover .stat-value { text-decoration: underline; text-underline-offset: 5px; }
.standing-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--soft); }
.standing-row:first-child { border-top: 0; }
.standing-row.is-you { margin: 0 -8px; padding-right: 8px; padding-left: 8px; background: var(--ink); color: white; }
.standing-rank, .standing-points { font: 700 13px "SFMono-Regular", Consolas, monospace; }
.standing-name { min-width: 0; font-weight: 700; }
.standing-name strong { font: 700 10px "SFMono-Regular", Consolas, monospace; letter-spacing: .08em; }
.standing-points { text-align: right; }
.standing-gap { padding: 7px 0; color: var(--muted); text-align: center; }
.stat-label { display: block; color: var(--muted); font: 700 10px/1.2 "SFMono-Regular", Consolas, monospace; letter-spacing: .08em; }
.stat-value { display: block; margin-top: 8px; font: 800 clamp(22px, 7vw, 32px)/1 "SFMono-Regular", Consolas, monospace; letter-spacing: -.06em; }
.stat-note { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.rounds-panel { padding-bottom: 8px; }
.round { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 13px 0; border-top: 1px solid var(--soft); }
.round:first-child { border-top: 0; }
.round-number { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; font: 700 11px "SFMono-Regular", Consolas, monospace; }
.round.win .round-number { background: var(--ink); color: var(--paper); }
.round-opponent { min-width: 0; font-weight: 700; }
.round-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.round-score { text-align: right; font: 700 13px "SFMono-Regular", Consolas, monospace; }
.empty { padding: 22px 0; color: var(--muted); font-size: 14px; }
.site-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 0 8px; text-align: center; }
.site-footer img { display: block; width: min(150px, 42vw); height: auto; }
.site-footer a { color: var(--ink); font: 700 11px/1.2 "SFMono-Regular", Consolas, monospace; letter-spacing: .04em; text-underline-offset: 4px; }
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a0a0a;
    --surface: #141414;
    --ink: #f5f5f5;
    --muted: #8a8a8a;
    --line: #262626;
    --soft: #262626;
  }
  .site-footer img { filter: invert(1); }
  .match-card.white-mode { background: #f5f5f5; border-color: #f5f5f5; color: #0a0a0a; }
  .match-card.black-mode { background: #0a0a0a; border-color: #f5f5f5; color: #f5f5f5; }
  .standing-row.is-you { background: #f5f5f5; color: #0a0a0a; }
}
@media (max-width: 420px) { .input-row { display: block; } .input-row button { width: 100%; margin-top: 8px; } .dashboard-heading { display: block; } .heading-actions { margin-top: 12px; } }
