/* One light theme only: cream page, maroon as the one accent, green for OK marks, scorebook blue for ruled lines.
   The same colours and type as the public site. Colour pairs are checked for WCAG AA by scripts/contrast.mjs. */
@font-face { font-family: "Archivo"; src: url("/assets/fonts/archivo.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/plex-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/plex-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/plex-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  color-scheme: only light; /* a phone in dark mode must not invert the page */
  --bg: #f5f0e3;
  --surface: #fffdf6;
  --sunk: #ece5d3;
  --ink: #231f1a;
  --muted: #564e42;
  --line: #d8cfb8;
  --line-strong: #857a68;
  --rule: #8fb0b8;       /* the blue of a scorebook's printed lines */
  --maroon: #6e1a2c;
  --maroon-deep: #551222;
  --maroon-ink: #ffffff;
  --maroon-bg: #f4e4e1;
  --green: #1f5a3d;
  --warn: #6b4500;
  --warn-bg: #f7e7bf;
  --display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
* { box-sizing: border-box; }
html { background: #f5f0e3; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.5; overflow-wrap: break-word; }
[hidden] { display: none !important; }
::placeholder { color: var(--muted); opacity: 1; }

h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 6.4vw, 2.6rem); font-weight: 800; font-stretch: 88%; letter-spacing: -0.02em; line-height: 1.02; }
h2 { font-size: 1.5rem; font-weight: 750; font-stretch: 92%; letter-spacing: -0.01em; line-height: 1.1; }
h3 { font-size: 1.125rem; font-weight: 700; line-height: 1.2; }
p { margin: 0; }
a { color: var(--maroon); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--maroon-deep); text-decoration-thickness: 2px; }
.small { font-size: 0.9375rem; color: var(--muted); }
.boot { padding: 48px 16px; color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 10px 14px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
main:focus { outline: none; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }

/* top bar */
.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; padding-top: 8px; padding-bottom: 6px; }
.brand { font-family: var(--display); font-stretch: 88%; font-weight: 800; font-size: 1.22rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; margin-right: auto; display: inline-flex; align-items: center; gap: 9px; min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand svg { flex: none; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; order: 3; width: 100%; }
@media (min-width: 760px) { .top nav { order: 0; width: auto; } }
.top nav a, .top nav button { color: var(--ink); text-decoration: none; font: inherit; font-size: 0.97rem; padding: 0; border: 0; border-radius: 0; background: transparent; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; cursor: pointer; }
.top nav a:hover, .top nav button:hover, .top nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--maroon); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.scans { font-size: 0.97rem; font-weight: 600; color: var(--maroon); min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }

main.wrap { display: flex; flex-direction: column; gap: 40px; padding-top: 28px; padding-bottom: 72px; }
.lead { display: flex; flex-direction: column; gap: 12px; }
.lead p { max-width: 60ch; color: var(--muted); font-size: 1.0625rem; }
.lead p.lede { color: var(--ink); font-size: 1.125rem; line-height: 1.45; }
section { display: flex; flex-direction: column; gap: 16px; }
.sec-head { display: flex; flex-direction: column; gap: 6px; }
.sec-head .hint { color: var(--muted); max-width: 64ch; }

/* the four steps on a match page: a numeral, as on the public site, not a badge */
.num { font-family: var(--display); font-weight: 800; font-stretch: 80%; color: var(--maroon); font-variant-numeric: tabular-nums; line-height: 1; }
.steps { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.steps .wrap { display: flex; gap: 4px 22px; overflow-x: auto; }
.steps a { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 7px; color: var(--ink); text-decoration: none; font-size: 0.97rem; white-space: nowrap; min-height: 44px; padding-top: 11px; }
.steps a .num { font-size: 1.15rem; }
.steps a:hover { text-decoration: underline; text-decoration-color: var(--maroon); text-decoration-thickness: 2px; text-underline-offset: 5px; }
section.step { scroll-margin-top: 60px; border-top: 2px solid var(--maroon); padding-top: 14px; }
.step-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; row-gap: 6px; align-items: baseline; }
.step-head .num { font-size: 2.2rem; }
.step-head .hint { grid-column: 1 / -1; color: var(--muted); max-width: 64ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.note { background: var(--surface); border: 1px solid var(--maroon); border-radius: 6px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.note > p, .note > div { min-width: 0; flex: 1 1 280px; }
.note > div { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.9375rem; font-weight: 500; color: var(--muted); min-width: 0; }
.row > label.field { flex: 1 1 200px; }
input[type="text"], input[type="email"], input[type="date"], textarea, select { font: inherit; font-size: 1rem; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; padding: 9px 10px; width: 100%; min-width: 0; min-height: 46px; }
textarea { resize: vertical; min-height: 96px; }
button, .btn { font: inherit; font-weight: 500; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); padding: 9px 14px; min-height: 46px; min-width: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
button:hover:not(:disabled), .btn:hover { border-color: var(--ink); color: var(--ink); }
button.primary, .btn.primary { font-family: var(--display); font-weight: 700; font-size: 1.02rem; background: var(--maroon); color: var(--maroon-ink); border: 2px solid var(--maroon); padding: 10px 18px; }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--maroon-deep); border-color: var(--maroon-deep); color: var(--maroon-ink); }
button.quiet { border-color: transparent; background: transparent; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; padding: 6px 8px; }
button.danger { color: var(--maroon); border-color: var(--maroon); }
button:disabled { color: var(--muted); background: var(--sunk); border-color: var(--line); cursor: not-allowed; }
button.primary:disabled { color: var(--muted); background: var(--sunk); border-color: var(--line); }
:focus-visible { outline: 3px solid var(--maroon); outline-offset: 2px; border-radius: 2px; }
.filebtn:focus-within { outline: 3px solid var(--maroon); outline-offset: 2px; }
details summary { cursor: pointer; color: var(--ink); font-weight: 500; padding: 10px 0; min-height: 44px; }
details[open] summary { margin-bottom: 6px; }

.status { color: var(--muted); font-size: 1rem; }
.status:empty { display: none; }
.status.bad { color: var(--maroon); font-weight: 500; }
.status.ok { color: var(--green); font-weight: 500; }

/* a read in progress: words, a running clock and a moving rule */
.reading { display: flex; flex-direction: column; gap: 8px; }
.reading .bar { height: 4px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.reading .bar::before { content: ""; display: block; height: 100%; width: 35%; background: var(--maroon); }
@media (prefers-reduced-motion: no-preference) {
  .reading .bar::before { animation: slide 1.6s ease-in-out infinite alternate; }
  @keyframes slide { from { transform: translateX(-20%); } to { transform: translateX(205%); } }
  html { scroll-behavior: smooth; }
}

/* photos keep their own proportions */
.filebtn { position: relative; display: inline-flex; align-items: center; min-height: 46px; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 9px 14px; cursor: pointer; font-weight: 500; background: var(--surface); }
.filebtn.primary { border: 2px solid var(--maroon); background: var(--maroon); color: var(--maroon-ink); font-family: var(--display); font-weight: 700; }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); background: var(--sunk); line-height: 0; }
.thumb img { height: 132px; width: auto; max-width: 100%; display: block; }
.thumb button { position: absolute; top: 0; right: 0; min-height: 0; width: 44px; height: 44px; padding: 0; line-height: 1; font-size: 1.25rem; border-radius: 0 0 0 6px; }

.alert { background: var(--maroon-bg); border: 1px solid var(--maroon); border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.alert h3 { color: var(--maroon); }
.alert ul, .names ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.alert li, .names li { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.alert li span, .names li span { flex: 1 1 260px; min-width: 0; }
.alert button { background: var(--surface); }
.names li { border-top: 1px solid var(--rule); padding-top: 8px; }
.names .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.names q { quotes: "“" "”"; font-weight: 600; }

/* scorecard */
.innings-tabs { display: flex; gap: 0; flex-wrap: wrap; border-bottom: 2px solid var(--line); }
.innings-tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 10px 14px; margin-bottom: -2px; border-bottom: 2px solid transparent; text-align: left; font-variant-numeric: tabular-nums; }
.innings-tabs button[aria-pressed="true"] { color: var(--maroon); border-bottom-color: var(--maroon); font-weight: 600; }
.review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 960px) { .review { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } .review .side { position: sticky; top: 60px; } }
@media (max-width: 959px) { .review .side { order: -1; } }
.block { display: flex; flex-direction: column; gap: 10px; }
.block + .block { border-top: 1px solid var(--line); padding-top: 16px; }
.scroll { overflow-x: auto; min-width: 0; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 0.875rem; color: var(--muted); font-weight: 500; padding: 4px 6px 6px; white-space: nowrap; border-bottom: 2px solid var(--rule); }
td { padding: 2px 3px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
table.bat th:nth-child(n+6):nth-child(-n+9), table.bowl th:nth-child(n+3):nth-child(-n+8),
table.sheet.bat td:nth-child(n+6), table.sheet.bowl td:nth-child(n+3) { text-align: right; }
td input[type="text"], td select { padding: 6px; min-height: 44px; border-color: transparent; background: transparent; }
td input[type="text"]:hover, td select:hover { border-color: var(--line-strong); }
td input.num { width: 4.4em; text-align: right; }
td input.name { min-width: 8.5em; }
td select { min-width: 7.5em; }
input.unsure, select.unsure { background: var(--warn-bg) !important; border-color: var(--warn) !important; }
input.snapped { border-bottom: 2px dotted var(--maroon) !important; }
td.pos { color: var(--muted); width: 2em; text-align: right; padding-right: 6px; }
/* on a phone the name stays put while the figures scroll sideways */
table.keep td:nth-child(2), table.keep th:nth-child(2), table.keep1 td:first-child, table.keep1 th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; align-items: end; }
.totals input.num { text-align: right; }
.totals .gap { grid-column: 1 / -1; height: 0; }
.fow-actions { grid-column: span 2; display: flex; gap: 4px; }

/* checks: a word in colour, never a coloured lozenge */
.verdict { font-family: var(--display); font-stretch: 92%; font-weight: 700; font-size: 1.125rem; line-height: 1.25; }
.checks { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 4.4em minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--rule); font-size: 0.9375rem; }
.tag { font-weight: 600; white-space: nowrap; }
.ok .tag, .tag.ok { color: var(--green); }
.warn .tag, .tag.warn { color: var(--warn); }
.bad .tag, .tag.bad { color: var(--maroon); }

.why { display: flex; flex-direction: column; gap: 12px; }
.why-note { display: flex; flex-direction: column; gap: 6px; font-size: 0.9375rem; border-top: 1px solid var(--rule); padding-top: 10px; }
.why .opts { display: flex; flex-wrap: wrap; gap: 4px; }

/* typing sheet */
.sheet-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.sheet-head .verdict:empty { display: none; }
.sheet-head button { margin-left: auto; }
.innings-sheet { display: flex; flex-direction: column; gap: 12px; }
.innings-sheet + .innings-sheet { border-top: 1px solid var(--line); padding-top: 18px; }
.sheet td { padding: 10px 6px; white-space: nowrap; }
.sheet tr.done td { color: var(--muted); text-decoration: line-through; }
.sheet td.tick { width: 44px; padding: 0; text-decoration: none; }
.sheet td.tick label { display: grid; place-items: center; width: 44px; height: 44px; }
.sheet input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--green); }
.scoreline { font-family: var(--display); font-stretch: 92%; font-weight: 700; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 18px; font-variant-numeric: tabular-nums; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 8px 2px; }
.kv b { font-weight: 600; }
pre.chat { white-space: pre-wrap; font-family: var(--body); font-size: 1rem; margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; max-width: 76ch; }
textarea.report { min-height: 220px; max-width: 76ch; }
textarea.social { min-height: 120px; max-width: 76ch; }
.end { display: flex; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--line); padding-top: 20px; }

label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.check input { width: 24px; height: 24px; accent-color: var(--green); flex: 0 0 auto; }
#sharePanel a { overflow-wrap: anywhere; }
.shared table td:nth-child(n+3), .shared table th:nth-child(n+3) { text-align: right; }
table.stats td, .shared table td, .grid2 table td { padding: 9px 6px; }
table.stats td:nth-child(n+2), table.stats th:nth-child(n+2) { text-align: right; white-space: nowrap; }

/* lists: matches, players, people */
.list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.list li { border-bottom: 1px solid var(--rule); }
.list a.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 4px; color: var(--ink); text-decoration: none; min-height: 44px; }
.list a.item:hover { background: var(--surface); }
.list .title { font-weight: 600; }
.list .meta { grid-column: 1; color: var(--muted); font-size: 0.9375rem; }
.list .tag { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 0.9375rem; }
.list li.line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; padding: 4px; }
.list li.line .grow { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.list li.line.off .grow { color: var(--muted); text-decoration: line-through; }

/* prices: ruled like a page of the book, one line for each thing you can buy */
.ledger { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.ledger li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; padding: 14px 2px; border-bottom: 1px solid var(--rule); }
.ledger h3 { grid-column: 1; }
.ledger .price { grid-column: 2; grid-row: 1; font-family: var(--display); font-stretch: 88%; font-weight: 800; font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums; text-align: right; }
.ledger p { grid-column: 1 / -1; max-width: 60ch; color: var(--muted); }
.ledger .buy { grid-column: 1 / -1; margin-top: 6px; justify-self: start; }
.ledger li.main .price { color: var(--maroon); font-size: 2.1rem; }
.ledger li.main p { color: var(--ink); }
.left-now { display: flex; flex-direction: column; gap: 4px; }
.left-now .verdict { font-size: 1.5rem; font-weight: 800; font-stretch: 88%; }
.plain { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; color: var(--muted); }

/* how it goes: three numbered lines under a maroon rule, as on the public site */
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; counter-reset: how; }
.how li { counter-increment: how; display: grid; grid-template-columns: 1.6em minmax(0, 1fr); column-gap: 8px; align-items: baseline; }
.how li::before { content: counter(how); font-family: var(--display); font-weight: 800; font-stretch: 80%; font-size: 1.7rem; line-height: 1; color: var(--maroon); }
@media (min-width: 760px) { .how { grid-template-columns: repeat(3, 1fr); gap: 32px; } }
.points { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; max-width: 62ch; }
.points li::marker { color: var(--maroon); }
.signin { max-width: 480px; border-color: var(--line-strong); }
.landing { display: grid; gap: 32px; align-items: start; }
@media (min-width: 900px) { .landing { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 56px; } }
footer.wrap { color: var(--muted); font-size: 0.9375rem; padding-top: 20px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); }
footer p { max-width: 70ch; }
@media print {
  .top, .steps, #photos, #check, #report-step, .end, footer, .sheet-head button, .skip { display: none !important; }
  body, html { background: #fff; }
}
