@font-face {
  font-family: "Sofia Sans Condensed";
  src: url("fonts/sofia-sans-condensed.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f3f1ee;
  --surface: #ffffff;
  --ink: #1d1a18;
  --muted: #5b554f;
  --line: #d8d1c9;
  --brick: #a8432a;
  --brick-ink: #ffffff;
  --brick-soft: #f7e6df;
  --board: #1b1816;
  --board-ink: #f4efe9;
  --led: #ffb000;
  --led-dim: #b9ada0;
  --focus: #2b4c9b;
  --warn: #8a3b00;
  --r1: 6px;
  --r2: 10px;
  --head: "Sofia Sans Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161413;
    --surface: #211e1c;
    --ink: #eee9e4;
    --muted: #b5ada5;
    --line: #3b3633;
    --brick: #e88a68;
    --brick-ink: #1d1a18;
    --brick-soft: #3a2620;
    --board: #0d0c0b;
    --board-ink: #f4efe9;
    --focus: #8fb0ff;
    --warn: #ffb27a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--body);
}
a { color: var(--ink); text-decoration-color: var(--brick); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* Header: the lane band is the site's one decorative element */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar::before {
  content: ""; display: block; height: 12px;
  background: linear-gradient(to bottom, var(--brick) 0 3px, #fff 3px 4px, var(--brick) 4px 7px, #fff 7px 8px, var(--brick) 8px 12px);
}
@media (prefers-color-scheme: dark) {
  .topbar::before { background: linear-gradient(to bottom, #a8432a 0 3px, #e9e2da 3px 4px, #a8432a 4px 7px, #e9e2da 7px 8px, #a8432a 8px 12px); }
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 1.45rem/1 var(--head); letter-spacing: .01em; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a { font: 700 1.05rem/1 var(--head); text-decoration: none; padding: 10px 10px; border-radius: var(--r1); color: var(--muted); }
.topnav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--brick); border-radius: 0; }
.topnav a:hover { color: var(--ink); }

.crumbs { font-size: .95rem; margin-top: 14px; color: var(--muted); }
.hero { padding: 18px 0 6px; max-width: 62rem; }
h1, h2, h3 { font-family: var(--head); line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2rem, 1.5rem + 2.4vw, 3rem); font-weight: 800; letter-spacing: -.005em; }
.lede { margin: 8px 0 0; font-size: 1.08rem; max-width: 60ch; }

/* ---------- the scorer ---------- */
.tool {
  margin: 18px 0 32px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "notice" "head" "meets" "setup" "board" "entry" "all" "actions" "saved";
}
@media (min-width: 960px) {
  .tool {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    grid-template-areas: "notice notice" "head head" "meets meets" "setup board" "entry board" "all board" "actions actions" "saved saved";
    align-items: start;
  }
  .board { position: sticky; top: 12px; }
}
.notice { grid-area: notice; position: relative; background: var(--brick-soft); border-left: 5px solid var(--brick); padding: 12px 48px 12px 14px; border-radius: var(--r1); }
.notice p { margin: 0; }
.notice-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px !important; }
.notice-x { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: none; color: var(--ink); font-size: 1.5rem; cursor: pointer; }
.share-url { display: block; width: 100%; margin-top: 10px; font-size: 16px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r1); background: var(--surface); color: var(--ink); }
.meet-head { grid-area: head; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.meet-id { min-width: 0; }
.meet-title { margin: 0; font: 800 1.6rem/1.1 var(--head); overflow-wrap: anywhere; }
.meet-sub { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }
.meet-sub .nw, #btn-meets { white-space: nowrap; }
.meets { grid-area: meets; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px; }
.meets-h { font-size: 1.4rem; }
.meets-h3 { font-size: 1.15rem; margin-top: 16px; }
.meet-list { list-style: none; margin: 8px 0 0; padding: 0; }
.meet-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.meet-list li.here b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brick); margin-right: 8px; vertical-align: middle; }
.meet-list span.muted { display: block; font-size: .92rem; }
.ml-btns { display: flex; gap: 6px; align-items: center; }
.clear-all { margin: 14px 0 0; }

/* buttons */
.btn {
  font: 600 1rem/1.2 var(--body); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--ink); border-radius: var(--r1); min-height: 44px; padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:hover { background: var(--brick-soft); }
.btn.primary { background: var(--brick); color: var(--brick-ink); border-color: var(--brick); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: var(--line); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: .95rem; }
.btn.icon { min-width: 44px; padding: 0; font-size: 1.2rem; border-color: var(--line); }
.btn:disabled { opacity: .45; cursor: default; background: var(--surface); }
.btn.primary:disabled { background: var(--brick); }

/* setup */
.setup { grid-area: setup; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); }
.setup > summary, .more > summary {
  list-style: none; cursor: pointer; padding: 12px 16px; min-height: 48px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.setup > summary { font: 800 1.25rem/1.2 var(--head); }
.setup > summary::-webkit-details-marker, .more > summary::-webkit-details-marker { display: none; }
.setup > summary::before, .more > summary::before { content: "\25B8"; color: var(--brick); font-size: .9em; transition: transform .15s; }
.setup[open] > summary::before, .more[open] > summary::before { transform: rotate(90deg); }
.setup-sum { font: 400 .95rem/1.3 var(--body); color: var(--muted); }
.setup-body { padding: 0 16px 16px; display: grid; gap: 14px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, label, .sub-h { font-weight: 650; font-size: .98rem; }
.sub-h { font: 800 1.15rem/1.2 var(--head); margin-top: 6px; }
.field { display: grid; gap: 4px; min-width: 0; }
input[type="text"], input[type="date"], select {
  font: 16px/1.3 var(--body); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r1); min-height: 44px; padding: 8px 10px; min-width: 0; max-width: 100%;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus { border-color: var(--ink); }
.hint { margin: 0; color: var(--muted); font-size: .95rem; }
.hint a { color: var(--muted); }
.warn-text { color: var(--warn); font-weight: 600; }
.err { margin: 0; color: var(--warn); font-weight: 600; min-height: 0; }
.err:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--brick); }
.check.small { min-height: 44px; font-size: .95rem; gap: 6px; white-space: nowrap; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.team-list { list-style: none; margin: 6px 0 8px; padding: 0; display: grid; gap: 8px; }
.team-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) 4.8em; gap: 8px; align-items: center; }
.team-list li.has-del { grid-template-columns: 10px minmax(0, 1fr) 4.8em 44px; }
.swatch { width: 10px; align-self: stretch; border-radius: 3px; background: var(--tc); }
.tcode { text-transform: uppercase; text-align: center; }
.custom { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.custom .err { grid-column: 1 / -1; }
.more { border-top: 1px solid var(--line); margin: 0 -16px; padding: 0 16px; }
.more > summary { padding-left: 0; font-weight: 650; }
.more[open] { display: grid; gap: 12px; padding-bottom: 4px; }
.event-edit { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.event-edit li { display: grid; grid-template-columns: 6.2em minmax(0, 1fr); gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.event-edit .check, .event-edit .ev-btns { grid-column: auto; }
.ev-btns { display: flex; gap: 4px; justify-content: flex-end; }
@media (min-width: 640px) {
  .event-edit li { grid-template-columns: 6.2em minmax(0, 1fr) auto auto; border-bottom: 0; padding: 0; }
}

/* the timing board: the one result card */
.board { grid-area: board; background: var(--board); color: var(--board-ink); border-radius: var(--r2); padding: 14px 16px 10px; }
.board-t { width: 100%; border-collapse: collapse; }
.board-t th, .board-t td { padding: 6px 4px; text-align: right; vertical-align: baseline; }
.board-t thead th { font: 700 .95rem/1.2 var(--head); color: var(--led-dim); border-bottom: 1px solid #3d3833; }
.board-t th:first-child { text-align: left; }
.board-t tbody th { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.board-t tbody tr + tr > * { border-top: 1px solid #2e2a27; }
.board .num { font: 800 1.9rem/1 var(--head); color: var(--led); font-variant-numeric: tabular-nums; }
.board .rk { display: block; font-size: .8rem; color: var(--led-dim); }
.pair { padding: 8px 0; border-bottom: 1px solid #2e2a27; }
.pair-name { margin: 0 0 4px; font-weight: 600; overflow-wrap: anywhere; }
.pair-name .v { color: var(--led-dim); font-weight: 400; margin: 0 4px; }
.pair-name .dot + .dot, .pair-name .v + .dot { margin-left: 2px; }
.pair-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 4px 12px; }
.pair-cells p { margin: 0; white-space: nowrap; }
.pair-cells .lbl { display: block; font: 700 .85rem/1.2 var(--head); color: var(--led-dim); }
.pairs-b .num { font-size: 1.5rem; color: var(--led-dim); }
.pairs-b .num.lead { color: var(--led); }
.board .dash { color: var(--led-dim); padding: 0 3px; font-size: 1.2rem; }
.board .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--tc); margin: 0 7px 0 0; }
.board-foot { margin: 8px 0 0; font-size: .9rem; color: var(--led-dim); }

/* event entry */
.entry { grid-area: entry; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px 16px; scroll-margin-top: 8px; }
.ev-nav { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 8px; }
.ev-nav select { width: 100%; }
.btn.nav { font-size: 1.6rem; padding: 0; border-color: var(--line); }
.ev-title { font-size: 1.8rem; font-weight: 800; margin: 14px 0 2px; }
.ev-title:focus { outline: none; }
.ev-title:focus-visible { outline: 3px solid var(--focus); }
.pad { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.tb {
  position: relative; min-height: 56px; text-align: left; padding: 8px 34px 8px 14px; cursor: pointer;
  font: 700 1.15rem/1.15 var(--head); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-left: 8px solid var(--tc); border-radius: var(--r1);
}
.tb:hover { background: var(--brick-soft); }
.tb:active { transform: translateY(1px); }
.tb-name { overflow-wrap: anywhere; }
.tb kbd { position: absolute; right: 8px; top: 8px; font: 600 .75rem/1 var(--body); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; }
@media (hover: none) { .tb kbd { display: none; } .tb { padding-right: 14px; } }
.places { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.places li {
  display: grid; grid-template-columns: 4.4rem minmax(0, 1fr) auto; gap: 6px 8px; align-items: center;
  padding: 8px 0 8px 10px; border-left: 6px solid var(--tc); border-bottom: 1px solid var(--line);
}
.places li.off { opacity: .75; }
.places .pl { font: 800 1.25rem/1 var(--head); }
.tie-mark { display: block; font: 600 .75rem/1.2 var(--body); color: var(--brick); text-transform: none; }
.places select { width: 100%; }
.places .pts { font: 800 1.3rem/1 var(--head); min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.places .why { font-size: .85rem; color: var(--muted); text-align: right; }
.row-btns { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
.btn.tog { border-color: var(--line); font-size: .92rem; padding: 6px 10px; }
.btn.tog[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.places .rn { grid-column: 1 / -1; width: 100%; }
@media (min-width: 620px) {
  .places li { grid-template-columns: 4.4rem minmax(0, 1fr) auto auto; }
  .row-btns { grid-column: auto; }
}
.ev-sum { margin: 12px 0 0; font-weight: 600; }
.ev-score { margin: 6px 0 0; font-size: .95rem; padding: 6px 10px; background: var(--board); color: var(--led); border-radius: var(--r1); font-variant-numeric: tabular-nums; }
.ev-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.ev-foot .primary { min-width: 10rem; margin-left: auto; }

/* all events */
.all { grid-area: all; }
.all h2 { font-size: 1.5rem; }
.all h3 { font-size: 1.15rem; margin: 14px 0 4px; color: var(--muted); }
.all-ev { list-style: none; margin: 0; padding: 0; }
.all-ev li { border-bottom: 1px solid var(--line); }
.all-ev li.here { box-shadow: inset 4px 0 0 var(--brick); }
.ev-link {
  display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: 2px 12px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--ink); font: inherit; padding: 8px 6px 8px 10px; min-height: 44px; cursor: pointer;
}
.ev-link:hover { background: var(--surface); }
.ev-n { font-weight: 650; }
.ev-o { font-size: .95rem; overflow-wrap: anywhere; }
.ev-p { grid-column: 2; font-size: .92rem; color: var(--muted); }
@media (max-width: 480px) {
  .ev-link { grid-template-columns: minmax(0, 1fr); }
  .ev-p { grid-column: 1; }
}

.actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 8px; }
.saved { grid-area: saved; margin: 0; color: var(--muted); font-size: .92rem; }
.saved.warn { color: var(--warn); font-weight: 600; }
.undo-bar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; width: max-content; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: var(--r2);
  background: var(--board); color: var(--board-ink); box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}
.undo-bar .btn { background: var(--led); color: #1d1a18; border-color: var(--led); }

/* ---------- content ---------- */
.content { max-width: 46rem; padding-bottom: 24px; }
.content section { margin-top: 30px; }
.content h2 { font-size: 1.75rem; font-weight: 800; margin-bottom: 8px; }
.content p, .content li { max-width: 68ch; }
.table-wrap { overflow-x: auto; }
.pts-table { border-collapse: collapse; margin: 10px 0; min-width: 18rem; }
.pts-table caption { text-align: left; font-weight: 650; padding-bottom: 6px; }
.pts-table th, .pts-table td { text-align: left; padding: 7px 14px 7px 0; border-bottom: 1px solid var(--line); }
.pts-table thead th { font-family: var(--head); font-size: 1.05rem; border-bottom: 2px solid var(--ink); }
.pts-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pts-table tbody th { font-weight: 600; }
.steps { padding-left: 1.4em; }
.steps li { margin: 6px 0; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 650; min-height: 44px; }
.faq details p { margin: 0 0 14px; }
.sources { font-size: .92rem; color: var(--muted); margin-top: 30px; }
.sources a { color: var(--muted); }

footer { border-top: 1px solid var(--line); background: var(--surface); padding: 18px 0 28px; font-size: .92rem; color: var(--muted); }
footer a { color: var(--muted); }
.sb-footer p { margin: 6px 0; }

.print-sheet { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- printed score sheet ---------- */
@page { margin: 12mm; }
@media print {
  body { background: #fff; color: #000; font: 10pt/1.3 var(--body); }
  body > *:not(main), main .wrap > *:not(.print-sheet), .undo-bar, .skip { display: none !important; }
  main .wrap { padding: 0; max-width: none; }
  .print-sheet { display: block !important; color: #000; }
  .ps-head h2 { font: 800 18pt/1.1 var(--head); margin: 0 0 4px; }
  .ps-head p { margin: 2px 0; }
  .ps-teams { display: flex; flex-wrap: wrap; gap: 2px 14px; }
  .ps-teams span { white-space: nowrap; }
  .ps-teams { gap: 6pt 18pt !important; }
  .wl { display: inline-block; width: 42mm; height: 1.1em; border-bottom: .6pt solid #000; vertical-align: bottom; }
  .wl.short { width: 14mm; margin-right: 6pt; }
  .ps-tot th .wl { width: 48mm; }
  .ps-warn { font-weight: 700; }
  .print-sheet table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; }
  .print-sheet th, .print-sheet td { border: .5pt solid #555; padding: 2.5pt 3.5pt; text-align: left; vertical-align: top; }
  .print-sheet thead th { background: none; font-weight: 700; }
  .ps-tot { width: auto !important; min-width: 60%; }
  .ps-tot td { min-width: 22mm; height: 7mm; }
  .ps-g { margin-top: 10pt; }
  .ps-g h3 { font: 800 13pt/1.1 var(--head); margin: 0; break-after: avoid; }
  .ps-ev { table-layout: fixed; }
  .ps-ev col.c-ev { width: 30mm; }
  .ps-ev col.c-pt { width: 11mm; }
  .ps-ev.pairs col.c-pt { width: 16mm; }
  .ps-ev.pairs td:not(.ord) { white-space: nowrap; font-size: 9pt; padding-left: 2pt; padding-right: 2pt; }
  .ps-g + .ps-g { break-before: page; }
  .ps-ev.wide col.c-ev { width: 34mm; }
  .ps-ev tbody { break-inside: avoid; }
  .ps-ev tbody.long, .ps-ev tbody.long tr { break-inside: auto; }
  .ps-ev tbody th { font-weight: 600; }
  .ps-ev td, .ps-ev th { overflow-wrap: anywhere; }
  .ps-ev td:not(.ord) { text-align: center; font-variant-numeric: tabular-nums; }
  .ps-ev td.run { font-weight: 700; }
  .ps-ev tr.sub th { font-weight: 400; font-size: 8pt; text-align: center; }
  .ps-ev tbody tr { height: 7mm; }
  .ps-ev td.ord { font-size: 9pt; }
  .print-sheet.blank .ps-ev tbody tr { height: 10mm; }
  .ps-ev thead th { overflow-wrap: normal; word-break: keep-all; font-size: 8.5pt; }
  .ps-pl { white-space: nowrap; margin-right: 5pt; }
  .ps-note { margin-right: 5pt; }
  .print-sheet .muted { color: #555; }
  .ps-foot { margin-top: 8pt; font-size: 8pt; color: #333; }
  a { text-decoration: none; color: #000; }
}
@media (max-width: 480px) {
  .pts-table { font-size: .88rem; min-width: 0; }
  .pts-table th, .pts-table td { padding-right: 8px; }
  .pts-table td { white-space: normal; }
  .pts-table tbody th { font-size: .85rem; }
}
