@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

/* Monochrome UI: the only colour on the page is each player's own. */
:root {
  --bg: #f6f5f2;
  --text: #16171a;
  --muted: #6d6f75;
  --faint: #a4a5a9;
  --line: #e2e0db;
  --line-strong: #c9c7c1;
  --hover: #eeece7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131416;
    --text: #ecebe7;
    --muted: #94969c;
    --faint: #5d5f65;
    --line: #26282b;
    --line-strong: #393b40;
    --hover: #1b1c1f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131416;
  --text: #ecebe7;
  --muted: #94969c;
  --faint: #5d5f65;
  --line: #26282b;
  --line-strong: #393b40;
  --hover: #1b1c1f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 720px;
  font: 16px/1.4 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
table { border-collapse: collapse; width: 100%; }
/* Tabular figures only where numbers line up. */
td, .tip b, .chart .axis text { font-variant-numeric: tabular-nums; }
th { font-weight: inherit; text-align: left; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 2px; }

.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* nav */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: stretch; gap: 22px;
  padding-top: env(safe-area-inset-top); margin-bottom: 20px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.tabs a {
  padding: 16px 0 13px; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
.theme {
  margin-left: auto; align-self: center; display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px;
}
.theme:hover { color: var(--text); background: var(--hover); }

.status, .note { color: var(--muted); }
.note { font-size: 0.9rem; margin: 0 0 12px; }

/* leaderboard */
.latest { margin-top: 40px; }
.latest h2, .day h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1rem; font-weight: 700; }
.latest h2 a { text-decoration: none; }
.latest h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }

.board th { padding: 0 0 10px; border-bottom: 1px solid var(--line-strong); }
.board th, .stats thead th { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.board td { padding: 22px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.board .c-rank { width: 32px; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.board .c-num { text-align: right; width: 64px; }
.board .c-form { width: 112px; }
.board .name { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; }
.board td.c-num { font-weight: 600; color: var(--muted); }
.board td.ties { font-size: 1.15rem; font-weight: 600; color: var(--muted); line-height: 1; }
.board td.wins { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); line-height: 1; }
.form { display: flex; gap: 5px; }
.form i { width: 10px; height: 10px; border-radius: 2px; border: 1.5px solid var(--line-strong); }
.form i.w { background: var(--c); border-color: var(--c); }
.form i.t { border-color: var(--c); background: linear-gradient(135deg, var(--c) 50%, transparent 50%); }
.form i.x { border: 0; background: none; position: relative; }
.form i.x::after { content: ""; position: absolute; left: 3px; top: 4px; width: 4px; height: 2px; border-radius: 1px; background: var(--faint); }
@media (max-width: 420px) {
  .board .c-form { width: 96px; }
  .form { gap: 4px; }
  .board .c-num { width: 56px; }
}

/* history */
.day-list { list-style: none; margin: 0; padding: 0; }

/* date scrubber: a rail on the right, with a wider invisible touch area. Dragging it
   slides a magnified run of dates through a highlight beside the finger. */
.scrubber {
  position: fixed; z-index: 6; width: 52px;
  top: calc(64px + env(safe-area-inset-top)); bottom: calc(20px + env(safe-area-inset-bottom));
  right: max(env(safe-area-inset-right), calc((100vw - 720px) / 2 - 52px), 0px);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: ns-resize;
}
.scrubber .rail { position: absolute; top: 0; bottom: 0; right: 0; width: 30px; }
.scrubber .track { position: absolute; inset: 8px 0; }
.scrubber .track i {
  position: absolute; right: 9px; width: 5px; height: 1.5px; border-radius: 1px;
  background: var(--line-strong); transform: translateY(-50%);
}
.scrubber .track i.m { width: 11px; background: var(--muted); }
.scrubber .here {
  position: absolute; right: 6px; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%;
  background: var(--text); border: 2px solid var(--bg);
}
.scrubber .here.glide { transition: top 160ms ease-out; }
.scrubber .lens { position: absolute; top: 0; bottom: 0; right: 34px; width: 0; pointer-events: none; visibility: hidden; }
.scrubber.scrubbing .lens { visibility: visible; }
.scrubber .lens .band, .scrubber .lens .d { position: absolute; top: 0; right: 0; }
.scrubber .lens .band {
  width: 128px; height: 40px; border-radius: 10px; background: var(--text);
  box-shadow: 0 6px 20px rgb(0 0 0 / 18%);
}
.scrubber .lens .d {
  display: flex; align-items: baseline; gap: 6px; padding: 0 14px; transform-origin: right center;
  white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; will-change: transform, opacity;
}
.scrubber .lens .d b { font-size: 1.05rem; font-weight: 700; }
.scrubber .lens .d small { font-size: 0.78rem; font-weight: 500; opacity: 0.8; }
.scrubber .lens .d.on { color: var(--bg); }
.scrubber .lens .d.on b { font-weight: 800; }
.scrubber.scrubbing::before {
  content: ""; position: fixed; top: calc(54px + env(safe-area-inset-top)); bottom: 0; right: 0; width: min(280px, 75vw); pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg) 50%);
}
@media (max-width: 820px) { #view-history:has(.scrubber:not([hidden])) .day-list { margin-right: 22px; } }

.day { padding: 18px 0 22px; border-bottom: 1px solid var(--line); scroll-margin-top: 64px; }
.day.focus h2 span:first-child { box-shadow: inset 0 -2px 0 var(--text); }
.detail { padding: 0; }
.detail table { font-size: 0.95rem; }
.detail th, .detail td { padding: 7px 0; }
.detail thead th { padding: 0 0 4px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-align: center; }
.detail thead th:first-child { text-align: left; }
.detail thead th:last-child { text-align: right; }
.detail thead small { color: var(--faint); font-weight: 500; }
.detail tbody tr + tr td, .detail tbody tr + tr th { border-top: 1px solid var(--line); }
.detail .p { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.detail .note-under { display: block; margin: 2px 0 0 16px; font-size: 0.75rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.detail .note-under b { font-weight: 700; color: var(--text); margin-left: 2px; }
.detail td.r { text-align: center; width: 2.75rem; color: var(--muted); }
.detail td.r em { display: block; font-style: normal; font-size: 0.85rem; line-height: 1.2; margin-top: 3px; }
.detail td.r span { display: inline-block; min-width: 2.3em; padding: 1px 0; border: 1.5px solid transparent; border-radius: 4px; }
.detail td.r.bull span { border-color: var(--text); color: var(--text); font-weight: 700; }
.detail td.r.goose span { border: 1.5px dashed var(--muted); color: var(--text); font-weight: 700; }
.detail td.t { text-align: right; width: 3.5rem; font-weight: 600; }
.detail tr.won td.t, .detail tr.won .p { font-weight: 800; }
.detail .absent { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.tag { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 4px; }

/* stats: chart */
.chart { position: relative; margin: 0 0 28px; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .series path { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series circle { fill: var(--c); stroke: var(--bg); stroke-width: 2; }
.chart .end text { font-size: 12px; font-weight: 600; fill: var(--text); }
.chart .cross { stroke: var(--line-strong); }
.tip {
  position: absolute; top: 34px; pointer-events: none; z-index: 2; min-width: 120px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px;
  font-size: 0.82rem; box-shadow: 0 4px 16px rgb(0 0 0 / 8%);
}
.tip .d { color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.tip div.r { display: flex; align-items: center; gap: 8px; }
.tip div.r b { margin-left: auto; padding-left: 12px; }
.tip div.r small { color: var(--muted); font-size: 0.75rem; }

/* stats: table */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.stats { font-size: 0.95rem; }
.stats thead th { padding: 0 0 8px 10px; text-align: right; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.stats thead th span.n { display: inline-flex; align-items: center; gap: 5px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 0.9rem; font-weight: 700; }
.stats tbody th { color: var(--muted); padding: 8px 8px 8px 0; font-weight: 500; }
.stats td { text-align: right; padding: 8px 0 8px 10px; font-weight: 500; white-space: nowrap; }
.stats td small { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.stats td.lead { font-weight: 800; }
.stats tbody tr { border-bottom: 1px solid var(--line); }
.stats tr.group th { padding: 22px 0 6px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.stats tr.group { border-bottom: 1px solid var(--line-strong); }
