/* Bowltracker — lane-monitor scoresheet look. One accent: lane-oil amber. */

@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlow-condensed-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/barlow-condensed-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('../fonts/ibm-plex-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('../fonts/ibm-plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tap: 52px;
  --pad: 16px;
  --radius: 4px;
  --fast: 140ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme='dark'] {
  --bg: #121110;
  --bg-2: #1a1816;
  --bg-3: #24211e;
  --rule: #4a443d;
  --rule-strong: #756d62;
  --ink: #f2ede4;
  --ink-2: #b9b2a6;
  --muted: #8a8378;
  --accent: #e9a23b;
  --accent-ink: #1b1204;
  --accent-soft: rgba(233, 162, 59, 0.14);
  --danger: #ff6a55;
  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #f3efe6;
  --bg-2: #fbf9f4;
  --bg-3: #e8e2d6;
  --rule: #cdc5b6;
  --rule-strong: #9d9485;
  --ink: #1b1916;
  --ink-2: #45403a;
  --muted: #6a6359;
  --accent: #935400;
  --accent-ink: #fff8ec;
  --accent-soft: rgba(147, 84, 0, 0.12);
  --danger: #b3261e;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--bg-2); padding: 8px 12px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px;
  padding: 0 calc(var(--pad) - 4px) 0 var(--pad);
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font: 700 22px/1 var(--display);
  letter-spacing: 0.06em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; background: none; color: var(--ink-2); border-radius: var(--radius);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--bg-3); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; outline: none; }

/* ---------- generic controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font-weight: 600; letter-spacing: 0.01em;
  transition: background var(--fast), border-color var(--fast), transform 80ms;
}
.btn:active { transform: scale(0.98); background: var(--bg-3); }
.btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: var(--accent); filter: brightness(0.92); }
.btn-quiet { border-color: transparent; color: var(--ink-2); }
.btn-block { width: 100%; }

.label {
  display: block;
  margin-bottom: 6px;
  font: 500 13px/1 var(--display);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.field { margin-bottom: 22px; }
.input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  background: var(--bg-2); border: 1px solid var(--rule); border-radius: var(--radius);
  font-size: 16px; /* no iOS zoom */
}
.input:focus { border-color: var(--accent); outline: none; }

.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button {
  min-height: 36px; padding: 0 14px; border: 0; background: none;
  font: 500 14px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }

/* ---------- page layout ---------- */
.page { width: 100%; max-width: 560px; margin: 0 auto; padding: 20px var(--pad) calc(32px + env(safe-area-inset-bottom)); }
.page-title { font: 700 34px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 20px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
  font: 500 14px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}

/* ---------- home ---------- */
.resume-list { list-style: none; margin: 0 0 8px; padding: 0; }
.resume-list a {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px;
  padding: 12px 0; min-height: var(--tap);
  border-bottom: 1px solid var(--rule); color: inherit; text-decoration: none;
}
.resume-list .r-title { font-weight: 600; }
.resume-list .r-meta { grid-column: 1; color: var(--muted); font-size: 13px; }
.resume-list .r-go { grid-row: 1 / 3; grid-column: 2; font: 700 15px/1 var(--display); letter-spacing: 0.12em; color: var(--accent); }

.bowler-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.bowler-list li { display: grid; grid-template-columns: 28px 1fr 44px; align-items: center; gap: 6px; }
.bowler-list .b-num { font: 700 18px/1 var(--display); color: var(--muted); text-align: center; }
.bowler-list .icon-btn { color: var(--muted); }

.stepper { display: inline-grid; grid-template-columns: var(--tap) 64px var(--tap); align-items: center; border: 1px solid var(--rule); border-radius: var(--radius); }
.stepper button { height: var(--tap); border: 0; background: none; font-size: 22px; color: var(--ink-2); }
.stepper output { text-align: center; font: 700 26px/1 var(--display); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* mode picker */
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--rule-strong); border-radius: var(--radius); }
.mode-pick button {
  display: grid; gap: 4px; align-content: center; text-align: left;
  min-height: 72px; padding: 10px 14px; border: 0; background: none;
}
.mode-pick button + button { border-left: 1px solid var(--rule-strong); }
.mode-pick .mode-name { font: 700 19px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.mode-pick .mode-hint { font-size: 12.5px; line-height: 1.3; color: var(--muted); }
.mode-pick button[aria-pressed='true'] { background: var(--bg-2); box-shadow: inset 0 -3px 0 var(--accent); }
.mode-pick button[aria-pressed='true'] .mode-name { color: var(--ink); }

/* score-only entry */
.score-grid { display: grid; align-items: start; column-gap: 10px; border-top: 1px solid var(--rule-strong); margin-top: 4px; }
.score-grid > * { padding: 10px 0; border-bottom: 1px solid var(--rule); min-width: 0; }
.col-name { font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: end; }
.row-label { align-self: stretch; display: flex; align-items: center; height: 80px; font: 700 22px/1 var(--display); letter-spacing: 0.06em; color: var(--muted); }
.score-cell { display: grid; gap: 4px; }
.score-input {
  width: 100%; height: 60px; padding: 0;
  background: var(--bg-2); border: 1px solid var(--rule); border-radius: var(--radius);
  text-align: center; font: 700 36px/1 var(--display); font-variant-numeric: tabular-nums;
}
.score-input::placeholder { color: var(--rule-strong); }
.score-input:focus { border-color: var(--accent); outline: none; box-shadow: inset 0 -3px 0 var(--accent); }
.score-input[aria-invalid='true'] { border-color: var(--danger); color: var(--danger); }
.cell-error { font-size: 12.5px; color: var(--danger); text-align: center; }
.note-btn { min-height: 32px; border: 0; background: none; color: var(--muted); font-size: 13px; }
.note-input { width: 100%; min-height: 36px; padding: 0 10px; font-size: 16px; background: none; border: 0; border-bottom: 1px solid var(--rule); }
.note-input:focus { outline: none; border-bottom-color: var(--accent); }
.total-label { height: auto; color: var(--ink-2); border-bottom: 0 !important; }
.score-total { display: grid; justify-items: center; gap: 2px; border-bottom: 0 !important; }
.score-total .big { font-size: 40px; font-weight: 700; line-height: 1; }
.score-total .avg { font: 500 14px/1 var(--display); letter-spacing: 0.08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.score-actions { display: flex; justify-content: space-between; margin: 8px 0 20px; }

/* ---------- game screen ---------- */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.series-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--pad); border-bottom: 1px solid var(--rule);
  font-size: 13px; color: var(--muted);
}
.series-bar .meta { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-tabs { display: flex; gap: 2px; }
.game-tabs a {
  display: grid; place-items: center; min-width: 40px; height: 32px; padding: 0 6px;
  font: 600 15px/1 var(--display); letter-spacing: 0.08em; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.game-tabs a[aria-current='page'] { color: var(--ink); border-bottom-color: var(--accent); }

.sheets { flex: 1; overflow-y: auto; padding: 4px 0 8px; }

/* scoresheet */
.sheet { padding: 10px var(--pad) 12px; position: relative; }
.sheet + .sheet { border-top: 1px solid var(--rule); }
.sheet.is-active::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 12px; width: 3px; background: var(--accent); }
.sheet-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet-name {
  min-height: 40px; padding: 0; border: 0; background: none; text-align: left;
  font-weight: 600; font-size: 16px; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.sheet.is-active .sheet-name { color: var(--ink); }
.sheet-name .turn { font: 500 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.sheet-total { display: flex; align-items: baseline; gap: 10px; }
.sheet-total .total { font: 700 38px/0.9 var(--display); font-variant-numeric: tabular-nums; }
.sheet-total .max { font: 500 14px/1 var(--display); letter-spacing: 0.06em; color: var(--muted); font-variant-numeric: tabular-nums; }

.frames {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)) minmax(0, 1.5fr);
  border: 1px solid var(--rule-strong);
  background: var(--bg-2);
}
.frame {
  display: grid; grid-template-rows: 18px 24px 30px;
  border-left: 1px solid var(--rule-strong);
  padding: 0; margin: 0; background: none; border-top: 0; border-right: 0; border-bottom: 0;
  text-align: center; color: inherit; min-width: 0;
}
.frame:first-child { border-left: 0; }
.frame:disabled { cursor: default; }
.fnum {
  display: grid; place-items: center;
  font: 500 12px/1 var(--display); color: var(--muted); font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--rule);
}
.fnum span { display: grid; place-items: center; width: 16px; height: 16px; }
.frame.is-split .fnum span { border: 1.5px solid var(--accent); border-radius: 50%; color: var(--accent); font-weight: 700; }
.marks { display: grid; grid-template-columns: 1fr 1fr; }
.frame-10 .marks { grid-template-columns: 1fr 1fr 1fr; }
.mark {
  display: grid; place-items: center;
  font: 700 17px/1 var(--display); font-variant-numeric: tabular-nums;
}
.marks .mark:nth-child(2), .frame-10 .marks .mark { border-left: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.frame-10 .marks .mark:first-child { border-left: 0; }
.mark.is-x, .mark.is-spare { color: var(--accent); }
.mark.is-foul { color: var(--danger); }
.mark.is-cursor { box-shadow: inset 0 -3px 0 var(--accent); background: var(--accent-soft); }
.mark.is-edit { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.cum { display: grid; place-items: center; font: 700 19px/1 var(--display); font-variant-numeric: tabular-nums; }
.frame.is-current { background: var(--bg-3); }

@keyframes stamp { from { transform: scale(1.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(5px); opacity: 0; } to { transform: none; opacity: 1; } }
.mark.is-fresh { animation: stamp 180ms var(--ease) both; }
.cum.is-fresh { animation: rise 200ms var(--ease) both; }

/* entry panel */
.panel {
  border-top: 1px solid var(--rule-strong);
  background: var(--bg);
  padding: 10px var(--pad) calc(12px + env(safe-area-inset-bottom));
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; margin-bottom: 4px; }
.panel-who { min-width: 0; }
.panel-who strong { font-weight: 600; }
.panel-who .where { display: block; font: 500 14px/1.1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.panel-who .where b { color: var(--accent); font-weight: 700; }
.edit-balls { display: flex; gap: 6px; margin: 2px 0 6px; }
.edit-balls button {
  min-height: 36px; min-width: 64px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: none; font: 600 15px/1 var(--display); letter-spacing: 0.06em;
}
.edit-balls button[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); }

/* pin deck */
.deck {
  position: relative;
  width: min(100%, 340px, 44dvh);
  aspect-ratio: 8 / 6.2;
  margin: 0 auto 6px;
}
.deck-lines { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--rule); pointer-events: none; }
.pin {
  position: absolute;
  width: 19%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  padding: 0; border: 0; background: none; border-radius: 50%;
  color: var(--ink);
}
.pin svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pin .body { fill: transparent; stroke: var(--rule-strong); stroke-width: 1.5; stroke-dasharray: 3 3; transition: fill var(--fast), stroke var(--fast); }
.pin .neck { fill: none; stroke: transparent; stroke-width: 1.5; transition: stroke var(--fast); }
.pin .n { font: 700 15px/1 var(--display); fill: var(--muted); text-anchor: middle; dominant-baseline: central; transition: fill var(--fast); }
.pin[aria-pressed='true'] .body { fill: var(--ink); stroke: var(--ink); stroke-dasharray: none; }
.pin[aria-pressed='true'] .neck { stroke: var(--bg-3); }
.pin[aria-pressed='true'] .n { fill: var(--bg); }
.pin[aria-pressed='true'] svg { animation: pinup 140ms var(--ease); }
.pin:disabled { cursor: default; }
.pin:disabled .body { stroke: none; fill: var(--rule); r: 3; }
.pin:disabled .n { display: none; }
.pin:focus-visible { outline-offset: -2px; }
@keyframes pinup { from { transform: scale(0.82); } to { transform: none; } }
.deck.is-split-leave .pin[aria-pressed='true'] .body { stroke: var(--accent); stroke-width: 3; }
.deck-note { min-height: 20px; text-align: center; font: 500 14px/1.4 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.deck-note b { color: var(--accent); }

/* keypad */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: min(100%, 360px); margin: 4px auto 8px; }
.key {
  min-height: 56px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg-2);
  font: 700 26px/1 var(--display);
}
.key:active { background: var(--bg-3); }
.key:disabled { opacity: 0.25; }
.key.is-mark { color: var(--accent); }

.actions { display: grid; grid-template-columns: var(--tap) var(--tap) var(--tap) 1fr; gap: 6px; }
.actions .btn { padding: 0; font: 700 22px/1 var(--display); }
.actions .btn-primary { font-size: 22px; letter-spacing: 0.06em; text-transform: uppercase; }
.actions svg { width: 22px; height: 22px; }

/* game over */
.summary { padding: 4px 0 2px; }
.summary h2 { font: 700 26px/1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.summary table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.summary th { text-align: right; font: 500 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0 0 6px; }
.summary th:first-child, .summary td:first-child { text-align: left; }
.summary td { padding: 8px 0; border-top: 1px solid var(--rule); text-align: right; font: 700 24px/1 var(--display); font-variant-numeric: tabular-nums; }
.summary td:first-child { font: 600 15px/1.2 var(--ui); }
.summary .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary .btns .btn-primary:only-child { grid-column: 1 / -1; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: calc(100% - 32px); padding: 12px 16px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: transform 160ms var(--ease), opacity 160ms;
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.toast.is-error { background: var(--danger); color: #fff; }

.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.noscript { padding: 24px; }

/* ---------- offline + update ---------- */
.net-badge {
  padding: 4px 7px 3px; border: 1px solid var(--accent); border-radius: 2px;
  font: 600 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.net-badge[hidden] { display: none; }
a.net-badge { text-decoration: none; }
.update-bar {
  position: fixed; z-index: 15; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 24px);
  padding: 4px 4px 4px 14px; background: var(--ink); color: var(--bg); border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
}
.update-bar .btn { min-height: 40px; color: var(--bg); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- account ---------- */
.account { display: flex; align-items: center; }
.account:empty { display: none; }
.account-who { display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 4px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--bg-3); object-fit: cover; }
.avatar-initial { display: grid; place-items: center; font: 700 15px/1 var(--display); color: var(--ink-2); }
.account-name { max-width: min(22vw, 140px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.account .icon-btn { width: 40px; }

/* ---------- login + auth pages ---------- */
.login { padding-top: 12vh; }
.login .page-title { font-size: 44px; line-height: 0.95; }
.login .lede { margin: 0 0 24px; font-size: 16px; }
.login-note { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg-2); font-size: 14px; }
.login-note.is-warn { border-left-color: var(--danger); }
.btn-discord { background: var(--ink); border-color: var(--ink); color: var(--bg); font-size: 16px; text-decoration: none; }
.btn-discord svg { width: 22px; height: 22px; }
.btn-discord[aria-disabled='true'] { opacity: 0.4; pointer-events: none; }
.login-facts { margin: 20px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13.5px; }
.login-facts li { padding: 8px 0; border-top: 1px solid var(--rule); }
.auth-page { padding-top: 10vh; }
.auth-page .lede { margin: 0 0 16px; }
.id-box { display: grid; gap: 6px; margin: 18px 0 24px; padding: 14px 16px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--bg-2); }
.id-box .label { margin: 0; }
.id-box code { font: 700 30px/1.1 var(--display); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; user-select: all; -webkit-user-select: all; word-break: break-all; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.auth-actions .btn { text-decoration: none; }

/* ---------- dialog ---------- */
.dialog { width: min(92vw, 420px); padding: 20px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--bg-2); color: var(--ink); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h2 { font: 700 26px/1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }
.dialog p { margin: 0 0 18px; color: var(--ink-2); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- tab bar ---------- */
.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
body[data-route='play'] .tabbar, body[data-route='login'] .tabbar { display: none; }
.tabbar a {
  display: grid; justify-items: center; align-content: center; gap: 3px;
  min-height: 56px; color: var(--muted); text-decoration: none;
  font: 500 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase;
  position: relative;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg .fill { fill: currentColor; stroke: none; }
.tabbar a[aria-current='page'] { color: var(--ink); }
.tabbar a[aria-current='page']::before { content: ''; position: absolute; top: -1px; left: 30%; right: 30%; height: 2px; background: var(--accent); }

.tag {
  display: inline-block; padding: 3px 6px 2px; border: 1px solid var(--rule-strong); border-radius: 2px;
  font: 500 11px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  vertical-align: middle;
}
.tag-live { border-color: var(--accent); color: var(--accent); }
.lede { color: var(--ink-2); margin: -8px 0 4px; }
.muted-note { color: var(--muted); font-size: 14px; }

/* ---------- history ---------- */
.filters { margin: -6px 0 6px; }
.filters-head { display: flex; justify-content: space-between; }
.filters-toggle { padding: 0; min-height: 44px; }
.filter-fields { padding: 10px 0 0; }
.filter-fields .field { margin-bottom: 12px; }
select.input { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 18px center, right 13px center; background-size: 5px 5px; background-repeat: no-repeat; }
.summary-line { display: grid; grid-template-columns: repeat(3, 1fr); margin: 8px 0 8px; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
.summary-line div { padding: 10px 0; }
.summary-line div + div { border-left: 1px solid var(--rule); padding-left: 12px; }
.summary-line dt { font: 500 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.summary-line dd { margin: 0; font-size: 28px; font-weight: 700; line-height: 1; }
.hist { padding: 14px 0 12px; border-bottom: 1px solid var(--rule); }
.hist-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hist-title { flex: 1; min-width: 0; color: inherit; text-decoration: none; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.hist-title > span:first-child { font-weight: 600; }
.hist-loc { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-del { width: 40px; height: 40px; color: var(--muted); margin-right: -10px; }
.hist-table { display: grid; align-items: baseline; color: inherit; text-decoration: none; row-gap: 2px; }
.ht-h { font: 500 11px/1 var(--display); letter-spacing: 0.14em; color: var(--muted); text-align: right; padding-bottom: 2px; }
.ht-name { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ht-score { text-align: right; font: 700 21px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.ht-score sup { color: var(--accent); font-size: 12px; margin-left: 1px; }
.ht-score.is-empty { color: var(--rule-strong); }
.ht-score.is-partial { color: var(--muted); font-weight: 500; }
.ht-ser { color: var(--accent); }

/* ---------- stats ---------- */
.stats-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.stats-controls .field { margin: 0; flex: 1; min-width: 140px; }
.stats-who { margin: 0; font-weight: 600; font-size: 17px; }
.hero-stat { display: grid; grid-template-columns: 1fr auto; align-items: end; padding: 14px 0 10px; border-bottom: 1px solid var(--rule-strong); }
.hero-stat .label { grid-column: 1 / -1; margin: 0; }
.hero-num { font-size: 84px; font-weight: 700; line-height: 0.9; letter-spacing: -0.01em; }
.hero-sub { font: 500 16px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.stat { padding: 12px 0 10px; border-bottom: 1px solid var(--rule); }
.stat:nth-child(odd) { padding-right: 12px; }
.stat:nth-child(even) { border-left: 1px solid var(--rule); padding-left: 14px; }
.stat dt { font: 500 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stat dd { margin: 0; display: flex; align-items: baseline; gap: 8px; }
.stat dd .num { font-size: 34px; font-weight: 700; line-height: 1; }
.stat small { font-size: 12.5px; color: var(--muted); }

.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.c-grid { stroke: var(--rule); stroke-width: 1; }
.c-tick { fill: var(--muted); font: 500 11px var(--display); font-variant-numeric: tabular-nums; }
.c-line { fill: none; stroke: var(--rule-strong); stroke-width: 1; }
.c-dot { fill: var(--ink-2); }
.c-avg { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-key { display: flex; gap: 18px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.k-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); }
.k-line { width: 16px; height: 2.5px; background: var(--accent); }

.leaves { list-style: none; margin: 0; padding: 0; }
.leaves li { display: grid; grid-template-columns: 44px 1fr 48px 52px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.mini-leave { width: 40px; height: 31px; }
.mini-leave .down { fill: var(--rule-strong); }
.mini-leave .up { fill: var(--ink); }
.mini-leave.is-split .up { fill: var(--accent); }
.leave-name { font: 700 20px/1 var(--display); letter-spacing: 0.04em; display: flex; gap: 8px; align-items: center; }
.leave-count { color: var(--muted); font-size: 18px; text-align: right; }
.leave-made { font-size: 18px; font-weight: 700; text-align: right; }

/* ---------- data ---------- */
.sync-state { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sync-state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-state[data-state='idle']::before { background: var(--accent); }
.sync-state[data-state='syncing']::before { background: var(--accent); animation: blink 900ms ease-in-out infinite; }
.sync-state[data-state='error']::before, .sync-state[data-state='signed-out']::before { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.25; } }
.data-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.data-row p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.data-row .btn { min-width: 96px; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (min-width: 720px) {
  .game { max-width: 760px; width: 100%; margin: 0 auto; }
  .frame { grid-template-rows: 20px 30px 36px; }
  .mark { font-size: 20px; }
  .cum { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
