/* Last Man Standing — scoreboard and betting slip in red, white and blue.
   Fonts: Barlow + Barlow Condensed (SIL OFL, self-hosted). */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }

:root {
  /* Red, white and blue. Names kept from the original palette so nothing else has to change:
     baize = royal blue surfaces, pint = the red accent, tote = darker red for errors. */
  --baize: #1b458f;
  --baize-deep: #0f2b63;
  --baize-soft: #3b63ad;
  --board: #ffffff;
  --ink: #141a26;
  --ink-soft: #4a5368;
  --tote: #b3112a;
  --pint: #e01f36;
  --pitch: #e9edf5;
  --line: #c8d0e0;
  --ok: #1d7a4a;

  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif-condensed, sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --step-4: 3.2rem;
  --gap: 1rem;
  --tile-r: 3px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--step-0)/1.5 var(--body);
  color: var(--ink);
  background: var(--pitch);
  min-height: 100dvh;
  padding-bottom: calc(4.5rem + var(--safe-b));
}
body.no-tabs { padding-bottom: 0; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 .75rem; max-width: 65ch; }
a { color: var(--baize); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pint); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: var(--pint); color: #fff; padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: .5rem; }
.muted { color: var(--ink-soft); }
.small { font-size: var(--step--1); }
.num { font-variant-numeric: tabular-nums; }
.loading, .empty { padding: 3rem 1rem; text-align: center; color: var(--ink-soft); }
.noscript { padding: 2rem; }

main { max-width: 36rem; margin: 0 auto; padding: var(--gap); outline: none; }
main:focus, main:focus-visible { outline: none; }
.pickcell { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }

/* ---------------------------------------------------------------- masthead + pot */
.masthead { background: var(--baize); color: var(--board); padding: calc(.75rem + env(safe-area-inset-top, 0px)) 1rem 1rem; }
.masthead .inner { max-width: 36rem; margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.masthead .title { font-family: var(--cond); font-weight: 700; font-size: var(--step-1); line-height: 1.1; }
.masthead .title small { display: block; font: 400 var(--step--1)/1.3 var(--body); opacity: .8; }
.pot { text-align: right; text-decoration: none; color: inherit; }
.pot .amount { display: block; font-family: var(--cond); font-weight: 700; font-size: var(--step-4); line-height: .95; color: #fff; border-bottom: 4px solid var(--pint); padding-bottom: .1rem; font-variant-numeric: tabular-nums; }
.pot .label { font-size: var(--step--1); opacity: .85; }
.pot-calc { font-family: var(--cond); font-weight: 600; font-size: var(--step-1); color: var(--ink); font-variant-numeric: tabular-nums; margin: .25rem 0 .5rem; }
.pot-calc:empty { display: none; }

/* ---------------------------------------------------------------- tab bar */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  background: var(--baize-deep); display: flex; justify-content: center;
  padding-bottom: var(--safe-b);
}
.tabs a {
  flex: 1; max-width: 9rem; text-align: center; padding: .7rem .25rem .8rem; color: #d6e0f2; text-decoration: none;
  font-family: var(--cond); font-weight: 600; font-size: var(--step-0); letter-spacing: .02em; border-top: 3px solid transparent;
}
.tabs a[aria-current='page'] { color: var(--board); border-top-color: var(--pint); }

/* ---------------------------------------------------------------- scoreboard (the memorable bit) */
.board {
  background: var(--baize); padding: .6rem; border-radius: 6px; color: var(--board);
  box-shadow: inset 0 0 0 2px var(--baize-deep);
}
.board-head { display: flex; justify-content: space-between; align-items: baseline; padding: .1rem .25rem .5rem; font-family: var(--cond); font-weight: 600; }
.board-head h2 { margin: 0; font-size: var(--step-1); }
.board-rows { display: grid; gap: 4px; }
.board-row { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 4px; align-items: stretch; }
.tile {
  background: var(--board); color: var(--ink); border-radius: var(--tile-r);
  font-family: var(--cond); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .35rem .5rem; display: flex; align-items: center; min-height: 2.4rem;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}
.tile.pos { justify-content: center; }
.tile.name { font-size: 1.15rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 1.7rem; }
.tile.state { justify-content: center; min-width: 4.2rem; font-size: 1.05rem; }
.tile.in { color: var(--ok); }
.tile.out { color: var(--tote); }
.tile.win { background: var(--pint); color: #fff; }
.tile.wait { color: var(--ink-soft); }
.board-row.gone .tile { background: #dfe4ee; color: #6b7385; }
.board-row.gone .tile.out { color: var(--tote); }
.board-row .sub { grid-column: 2 / -1; font: 400 var(--step--1)/1.35 var(--body); color: #d6e0f2; padding: 0 .25rem .2rem; }

/* countdown tiles */
.countdown { display: flex; gap: 6px; align-items: flex-end; }
.countdown .unit { text-align: center; }
.countdown .tile { font-size: 2rem; min-width: 3.2rem; justify-content: center; min-height: 3.2rem; letter-spacing: 0; }
.countdown .cap { display: block; font: 600 .8rem/1.6 var(--cond); color: #d6e0f2; }
.countdown.closed .tile { color: var(--tote); }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--board); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; margin: 0 0 var(--gap); }
.panel.flat { background: transparent; border: 0; padding: 0; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.round-card .board { margin-bottom: .75rem; }
.facts { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: var(--step--1); color: var(--ink-soft); margin-top: .5rem; }
.facts strong { color: var(--ink); font-weight: 600; }

.banner { border-left: 6px solid var(--baize); background: #e8eef9; padding: .75rem 1rem; border-radius: 4px; margin-bottom: var(--gap); }
.banner.bad { border-color: var(--tote); background: #fbeaea; }
.banner.good { border-color: var(--ok); background: #e6f3ec; }

/* status chips */
.chip { display: inline-block; font: 600 var(--step--1)/1 var(--cond); letter-spacing: .03em; padding: .35rem .55rem; border-radius: 3px; background: #e2e7f0; color: var(--ink); white-space: nowrap; }
.chip.active { background: #e2e7f0; }
.chip.advanced, .chip.winner { background: #d7eee0; color: #0f5a33; }
.chip.eliminated { background: #f6dede; color: #8f1a20; }
.chip.awaiting { background: #fff1cc; color: #6b4d00; }
.chip.review { background: #ffe2b8; color: #7a3d00; }
.chip.prov { background: transparent; border: 1px dashed currentColor; color: var(--ink-soft); }

/* ---------------------------------------------------------------- my pick + team grid */
.mypick { display: grid; grid-template-columns: auto 1fr; gap: .75rem; align-items: center; }
.badge {
  --c: var(--baize);
  width: 3rem; height: 3rem; border-radius: 4px; display: grid; place-items: center;
  font: 700 1.1rem/1 var(--cond); letter-spacing: .03em; color: var(--fg, #fff); background: var(--c);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18);
}
.badge.sm { width: 2.2rem; height: 2.2rem; font-size: .85rem; }

.teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.team {
  --c: var(--baize);
  display: grid; grid-template-columns: .4rem 1fr; text-align: left; padding: 0; overflow: hidden;
  background: var(--board); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; min-height: 4.2rem;
}
.team::before { content: ''; background: var(--c); }
.team .t { padding: .5rem .6rem; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.team .n { font: 700 1.15rem/1.1 var(--cond); }
.team .f { font-size: .8rem; color: var(--ink-soft); line-height: 1.3; }
.team:hover:not(:disabled) { border-color: var(--baize); }
.team[aria-pressed='true'] { border: 2px solid var(--baize); background: #eef2f9; }
.team[aria-pressed='true'] .n::after { content: ' ✓'; color: var(--ok); }
.team:disabled { cursor: not-allowed; background: #eef1f6; color: #848b9a; }
.team:disabled::before { background: #c5ccd9; }
.team:disabled .n { text-decoration: line-through; text-decoration-thickness: 2px; }
@media (min-width: 30rem) { .teams { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* fixtures list */
.fixtures { list-style: none; margin: 0; padding: 0; }
.fixtures li { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; padding: .55rem 0; border-top: 1px solid var(--line); }
.fixtures li:first-child { border-top: 0; }
.fixtures .h { text-align: right; }
.fixtures .sc { font: 700 1.1rem/1 var(--cond); min-width: 4.2rem; text-align: center; background: var(--ink); color: var(--board); padding: .35rem .4rem; border-radius: 3px; font-variant-numeric: tabular-nums; }
.fixtures .sc.pending { background: #e2e7f0; color: var(--ink-soft); font-size: .85rem; }
.fixtures .meta { grid-column: 1 / -1; text-align: center; font-size: .78rem; color: var(--ink-soft); margin-top: -.2rem; }

/* history */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 3rem auto 1fr; gap: .75rem; align-items: center; padding: .7rem 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .rn { font: 700 1.4rem/1 var(--cond); color: var(--ink-soft); text-align: center; }
.timeline .rn small { display: block; font: 400 .7rem/1.4 var(--body); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }

/* round selector */
.seg { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.seg button { flex: none; border: 1px solid var(--line); background: var(--board); border-radius: 3px; padding: .35rem .7rem; font: 600 var(--step-0)/1.2 var(--cond); cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--baize); color: var(--board); border-color: var(--baize); }

/* ---------------------------------------------------------------- forms & buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.9rem; padding: .6rem 1.1rem;
  border: 0; border-radius: 4px; background: var(--baize); color: var(--board); font: 700 1.1rem/1 var(--cond); letter-spacing: .02em;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--baize-soft); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--baize); box-shadow: inset 0 0 0 2px var(--baize); }
.btn.warn { background: var(--tote); }
.btn.amber { background: var(--pint); color: #fff; }
.btn.small { min-height: 2.2rem; padding: .35rem .7rem; font-size: .95rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--baize); text-decoration: underline; cursor: pointer; }

label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-weight: 400; font-size: var(--step--1); color: var(--ink-soft); display: block; margin-top: .25rem; }
input[type=text], input[type=tel], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: .7rem .75rem; border: 1px solid #9aa3b5; border-radius: 4px; background: #fff; min-height: 2.9rem;
}
input.code { font: 700 2rem/1 var(--cond); letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
textarea { min-height: 5rem; }
.err { color: var(--tote); font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: .75rem; margin: 0 0 .9rem; }
legend { font-weight: 600; padding: 0 .25rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }

/* sign-in */
.gate { max-width: 26rem; margin: 2rem auto; }
.gate .board { margin-bottom: 1.25rem; }
.gate .board .tile.name { font-size: 1.6rem; text-align: center; line-height: 2.2rem; }

/* ---------------------------------------------------------------- the betting slip (pick confirmation) */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 30rem; background: transparent; color: var(--ink);
  max-height: 92dvh;
}
.sheet::backdrop { background: rgba(8, 20, 45, .6); }
.slip {
  background: var(--board); padding: 1.5rem 1.25rem calc(1.25rem + var(--safe-b)); position: relative;
  border-radius: 0; overflow: auto; max-height: 92dvh;
  /* perforated tear-off edge */
  -webkit-mask: radial-gradient(circle 6px at 10px 0, transparent 98%, #000) -10px 0 / 20px 100% repeat-x;
          mask: radial-gradient(circle 6px at 10px 0, transparent 98%, #000) -10px 0 / 20px 100% repeat-x;
}
.slip .stamp { font: 600 .9rem/1 var(--cond); color: var(--ink-soft); border-bottom: 2px dashed var(--line); padding-bottom: .6rem; margin-bottom: 1rem; display: flex; justify-content: space-between; }
.slip .selection { display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: center; margin-bottom: 1rem; }
.slip .selection .badge { width: 3.6rem; height: 3.6rem; font-size: 1.3rem; }
.slip .selection .what { font: 700 1.7rem/1.05 var(--cond); }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; font-size: var(--step--1); }
.slip dt { color: var(--ink-soft); }
.slip dd { margin: 0; font-weight: 600; }
.slip .terms { font-size: var(--step--1); color: var(--ink-soft); border-top: 2px dashed var(--line); padding-top: .75rem; }
.slip .actions { display: grid; gap: .5rem; margin-top: 1rem; }
.sheet[open] .slip { animation: slip-up .22s ease-out; }
@keyframes slip-up { from { transform: translateY(30%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] .slip { animation: none; } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(5.2rem + var(--safe-b)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--board); padding: .7rem 1rem; border-radius: 4px; max-width: 90vw; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.bad { background: var(--tote); }

/* ---------------------------------------------------------------- admin */
.subtabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin-bottom: var(--gap); }
@media (min-width: 40rem) { .subtabs { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.subtabs a { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: .5rem .3rem; border-radius: 3px; text-decoration: none; color: var(--ink); background: var(--board); border: 1px solid var(--line); font: 600 1rem/1.2 var(--cond); }
.subtabs a[aria-current='page'] { background: var(--baize); color: var(--board); border-color: var(--baize); box-shadow: inset 0 -3px 0 var(--pint); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
table.data th, table.data td { text-align: left; padding: .45rem .35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-family: var(--cond); font-size: .95rem; color: var(--ink-soft); }
.scroll-x { overflow-x: auto; }
.copybox { display: flex; gap: .5rem; }
.copybox input { font-size: .85rem; }
.audit-entry { border-top: 1px solid var(--line); padding: .5rem 0; font-size: var(--step--1); }
.audit-entry code { font-size: .75rem; word-break: break-all; color: var(--ink-soft); }
details summary { cursor: pointer; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* spacing utilities (CSP blocks inline style attributes) */
.center { text-align: center; }
.mt-xs { margin-top: .35rem; } .mt-s { margin-top: .5rem; } .mt { margin-top: .75rem; } .mt-m { margin-top: 1rem; } .mt-l { margin-top: 1.5rem; }
.mb { margin-bottom: 1rem; } .my { margin: .75rem 0; } .w-narrow { max-width: 16rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.msgbox { width: 100%; font: 400 var(--step--1)/1.45 var(--body); padding: .6rem; border: 1px solid var(--line); border-radius: 4px; background: var(--board); resize: vertical; }
