:root {
  --bg: #0b1220;
  --bg-raised: #131c2e;
  --bg-sunken: #080e18;
  --line: #22304a;
  --line-soft: #1a2439;
  --text: #e8eefb;
  --text-dim: #97a6c2;
  --text-faint: #64748b;
  --accent: #f5b301;
  --good: #34d399;
  --bad: #f87171;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 4rem;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }

a { color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark { font-size: 1.6rem; line-height: 1; }
.brand h1 { font-size: 1.05rem; letter-spacing: -0.01em; }
.brand p { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--text-dim); }

.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.conn.ok { background: var(--good); }
.conn.err { background: var(--bad); }
.conn.busy { background: var(--accent); }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- layout ---------- */

.view { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.section-head h2 { font-size: 1rem; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 0.8rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.stack { display: grid; gap: 0.75rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ---------- podium ---------- */

.podium { display: grid; gap: 0.75rem; }

.team-row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--team-color, var(--line));
}
.team-row.leader { border-color: var(--accent); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 9%, var(--bg-raised)), var(--bg-raised)); }

.rank { font-size: 1.35rem; font-weight: 800; color: var(--text-faint); text-align: center; }
.team-row.leader .rank { color: var(--accent); }

.team-name { font-weight: 700; font-size: 1rem; }
.team-members { font-size: 0.8rem; color: var(--text-dim); }

.team-time { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; text-align: right; }
.team-gap { font-size: 0.75rem; color: var(--text-dim); text-align: right; font-family: var(--mono); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.sticky-col { position: sticky; left: 0; background: var(--bg-raised); z-index: 1; }
thead .sticky-col { z-index: 2; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.45rem; vertical-align: baseline; }

/* ---------- controls ---------- */

button, .btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--text-faint); }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1400; }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -1px; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 4rem; }

label.field { display: grid; gap: 0.25rem; font-size: 0.78rem; color: var(--text-dim); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }

/* ---------- draft grid ---------- */

.tier-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}
.tier-chip.empty { color: var(--text-faint); font-weight: 400; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.pill.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.pill.todo { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pill.off { color: var(--text-faint); }

/* ---------- event list / run sheet ---------- */

.event-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
}
.event-item:last-child { border-bottom: none; }
.event-item:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.event-item .title { font-weight: 650; }
.event-item .loc { grid-column: 1; font-size: 0.78rem; color: var(--text-dim); }
.event-item .meta { grid-row: 1 / span 2; grid-column: 2; text-align: right; }

.progress { height: 4px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; margin-top: 0.5rem; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.list-flush { padding: 0; }
.list-flush .event-item { padding-left: 1rem; padding-right: 1rem; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  z-index: 50;
  max-width: calc(100vw - 2rem);
}
.toast.err { border-color: var(--bad); color: var(--bad); }

@media (max-width: 560px) {
  .view { padding: 0.75rem; }
  .team-row { grid-template-columns: 1.75rem 1fr auto; padding: 0.75rem; gap: 0.6rem; }
  .team-time { font-size: 1.05rem; }
}

/* ---------- master grid ---------- */

table.master th.master-head { text-align: center; color: var(--text); font-size: 0.78rem; padding-bottom: 0.4rem; }
table.master td.master-cell { text-align: center; vertical-align: middle; white-space: nowrap; }
table.master .sticky-col { min-width: 8.5rem; }

.cell-result { display: block; margin-top: 0.2rem; font-size: 0.72rem; font-family: var(--mono); }
.cell-result.done { color: var(--good); }
.cell-result.bad { color: var(--bad); }
.done { color: var(--good); }
.bad { color: var(--bad); }

table.master tfoot .total-row td { border-top: 2px solid var(--line); border-bottom: none; padding-top: 0.6rem; }
table.master tfoot .total-row .mono { font-size: 0.95rem; }

/* ---------- live draft ---------- */

.clock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-left: 4px solid var(--team-color, var(--accent));
}
.clock.done-banner { border-left-color: var(--good); }
.clock-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; }
.clock-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.clock-next { text-align: right; }
.next-chip {
  display: inline-block;
  margin: 0.2rem 0 0 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--text-dim);
}

.board-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.board-row:last-child { border-bottom: none; }
.board-row.row-blocked { opacity: 0.55; }
.board-event { display: grid; }
.board-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.draft-chip {
  display: grid;
  justify-items: center;
  gap: 0;
  min-width: 3.6rem;
  padding: 0.3rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  font-family: var(--mono);
  cursor: pointer;
}
.draft-chip .chip-val { font-size: 0.9rem; font-weight: 700; line-height: 1.15; }
.draft-chip .chip-owner { font-size: 0.62rem; color: var(--text-faint); line-height: 1.15; }
.draft-chip.open:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg-sunken)); }
.draft-chip.open:disabled { opacity: 0.35; cursor: not-allowed; }
.draft-chip.taken {
  border-color: var(--team-color, var(--line));
  background: color-mix(in srgb, var(--team-color, #888) 16%, var(--bg-sunken));
  cursor: default;
}
.draft-chip.taken .chip-val { color: var(--text-dim); text-decoration: line-through; }
.draft-chip.taken .chip-owner { color: var(--text); font-weight: 700; }

.pick-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; font-size: 0.85rem; }
.pick-log li { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

@media (max-width: 560px) {
  .board-row { grid-template-columns: 1fr; gap: 0.35rem; }
  .clock-name { font-size: 1.25rem; }
  .clock-next { text-align: left; }
}

/* ---------- identity ---------- */

.who { display: flex; align-items: center; gap: 0.6rem; }
.who-chip {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.who-chip:hover { border-color: var(--text-faint); color: var(--text); }
.who-chip.unset { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.who-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; }
.who-pick { text-align: left; padding: 0.7rem 0.8rem; font-size: 0.95rem; }
.who-pick.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-sunken)); }

/* ---------- sign-in gate ---------- */

.gate { max-width: 34rem; margin: 2rem auto 1rem; }
.gate-title { font-size: 1.2rem; margin-bottom: 0.35rem; }
.gate-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 1rem 0 0.85rem; }
.gate-btn { display: grid; gap: 0.15rem; padding: 1rem 0.85rem; text-align: left; }
.gate-btn-title { font-size: 1rem; font-weight: 700; }
.gate-btn-sub { font-size: 0.75rem; color: var(--text-faint); font-weight: 500; }
.gate-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg-sunken)); }

@media (max-width: 480px) {
  .gate { margin-top: 1rem; }
  .gate-choices { grid-template-columns: 1fr; }
}

/* ---------- my events ---------- */

.mine-total { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 0.5rem 0 0.25rem; }
.mine-list { display: grid; gap: 0.6rem; }

.mine-card {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
}
.mine-card.is-done { border-color: color-mix(in srgb, var(--good) 30%, var(--line-soft)); }
.mine-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.mine-name { font-weight: 700; font-size: 1rem; text-decoration: none; }
.mine-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem 1rem;
  align-items: center;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line-soft);
}
.mine-tier { display: grid; justify-items: start; gap: 0.15rem; }
.mine-entry { display: grid; gap: 0.2rem; }

/* ---------- editable scoreboard cells ---------- */

.cell-input {
  width: 4.6rem;
  margin-top: 0.25rem;
  padding: 0.28rem 0.3rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.cell-input.ok { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); color: var(--good); }
.cell-input.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.cell-check { display: flex; align-items: center; justify-content: center; gap: 0.3rem; margin-top: 0.35rem; font-size: 0.7rem; color: var(--text-dim); }

/* ---------- phone ---------- */

@media (max-width: 640px) {
  body { font-size: 16px; padding-bottom: 2rem; }

  .topbar-inner { padding: 0.6rem 0.75rem 0.4rem; }
  .brand h1 { font-size: 0.95rem; }
  .brand p { font-size: 0.68rem; }
  .brand-mark { font-size: 1.3rem; }

  /* Tabs scroll horizontally; fade the right edge so it reads as scrollable. */
  .tabs { padding: 0 0.75rem; -webkit-overflow-scrolling: touch; }
  .tabs a { padding: 0.5rem 0.6rem; font-size: 0.82rem; }

  .view { padding: 0.6rem; }
  .card { padding: 0.85rem; border-radius: 10px; }

  /* 16px inputs stop iOS from zooming the whole page on focus. */
  input, select, textarea { font-size: 16px; padding: 0.55rem 0.55rem; }
  button, .btn { padding: 0.55rem 0.8rem; }

  th, td { padding: 0.45rem 0.4rem; }
  table { font-size: 0.82rem; }

  .master-cell .cell-input { width: 3.7rem; font-size: 0.78rem; padding: 0.3rem 0.15rem; }
  table.master td.master-cell, table.master th.master-head { padding-left: 0.3rem; padding-right: 0.3rem; }
  table.master .sticky-col { min-width: 6.5rem; }
  .master-head { font-size: 0.72rem; }

  .mine-body { grid-template-columns: auto 1fr; gap: 0.5rem 0.85rem; }
  .mine-name { font-size: 1.05rem; }

  .team-row { padding: 0.7rem 0.65rem; }
  .rank { font-size: 1.1rem; }
  .team-name { font-size: 0.95rem; }
  .team-members { font-size: 0.75rem; }

  .toast { bottom: 0.75rem; font-size: 0.8rem; }
}

/* Frozen first column needs a visible edge once the grid is scrolled. */
table.master .sticky-col { box-shadow: 6px 0 6px -6px rgba(0, 0, 0, 0.65); }

/* The swipe hint is only true where the grid actually overflows. */
.scroll-hint { display: none; }
@media (max-width: 900px) { .scroll-hint { display: inline; } }

/* Touch targets. Thumbs need ~36px minimum; the desktop sizes are too mean. */
@media (max-width: 640px) {
  .master-cell .cell-input { min-height: 36px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  .cell-check { min-height: 32px; }
  .mine-entry input { min-height: 42px; }
  .mine-card label.row { min-height: 40px; }
  .draft-chip { min-height: 42px; min-width: 3.9rem; }
  .who-pick { min-height: 48px; }
  .gate-btn { min-height: 62px; }
}

/* ---------- signed-out gate ---------- */

/* Before sign-in there is nothing to navigate to, so the tab bar only invites
   taps that bounce straight back to this screen. Hide it entirely. */
body.gated .tabs { display: none; }
body.gated .topbar { border-bottom: none; }
body.gated .topbar-inner { padding-bottom: 0.75rem; }
body.gated .view { padding-top: 1.5rem; }

/* Scrolling tabs get a fade so it reads as "there is more to the right". */
.tabs { position: relative; }
.topbar { -webkit-mask-image: none; }

/* ---------- explicit edit / submit ---------- */

/* Times are never saved implicitly. A stored value is text plus Edit; only
   Submit writes. Prevents a stray tap-away from overwriting a real result. */
.entry { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.entry input { flex: 1 1 5rem; min-width: 4.5rem; }
.entry-done { justify-content: flex-start; }
.entry-value { font-size: 1rem; font-weight: 700; color: var(--good); }

.btn-sm {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 7px;
  flex: none;
}

.master-cell .entry { flex-direction: column; align-items: stretch; gap: 0.25rem; }
.master-cell .entry input { width: 100%; flex: none; }
.master-cell .btn-sm { padding: 0.25rem 0.35rem; font-size: 0.68rem; }
.master-cell .entry-value { font-size: 0.85rem; }
.master-cell .entry-done { flex-direction: column; align-items: center; gap: 0.2rem; }

/* ---------- value cells (tap to open the entry sheet) ---------- */

.val {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  padding: 0.3rem 0;
  font: inherit;
  color: inherit;
  text-align: left;
}
.val-btn { cursor: pointer; width: 100%; }
.val-btn:hover .val-empty { color: var(--accent); }
.val-done { font-size: 1.05rem; font-weight: 700; color: var(--good); }
.val-part { font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.val-bad { font-weight: 700; color: var(--bad); }
.val-empty { color: var(--text-faint); }
.val-chev { margin-left: auto; color: var(--text-faint); font-size: 1.1rem; }

.master-cell .val { justify-content: center; }
.master-cell .val-done, .master-cell .val-part { font-size: 0.85rem; }
.master-cell .val-empty { font-size: 0.78rem; }

/* ---------- live beer tally ---------- */

.beer { display: grid; gap: 0.5rem; }
.pips { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.pip {
  width: 1.15rem; height: 1.15rem; border-radius: 50%;
  border: 2px solid var(--line); background: var(--bg-sunken);
}
.pip.on { background: var(--accent); border-color: var(--accent); }

.beer-row { display: flex; align-items: center; gap: 0.6rem; }
.beer-count { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; min-width: 4.2rem; }
.beer-count.done { color: var(--good); }
.beer-minus { width: 2.5rem; text-align: center; font-size: 1.1rem; padding: 0.4rem 0; }
.beer-plus { margin-left: auto; background: var(--accent); border-color: var(--accent); color: #1a1400; }

/* ---------- entry sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 7, 14, 0.72);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 460px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
}
.sheet-grip { width: 2.5rem; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 0.85rem; }
.sheet-crumb { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; margin-bottom: 0.75rem; }

.sheet-readout {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
  padding: 0.4rem 0 0.9rem;
}
.sheet-readout.muted-out { opacity: 0.35; text-decoration: line-through; }
.sheet-unit { display: block; font-family: inherit; font-size: 0.8rem; font-weight: 500; color: var(--text-dim); letter-spacing: 0; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.key {
  padding: 0.85rem 0;
  font-size: 1.35rem;
  font-weight: 600;
  font-family: var(--mono);
  background: var(--bg-sunken);
}
.key-fn { font-size: 0.9rem; font-family: inherit; color: var(--text-dim); }

.sheet-dnf { width: 100%; margin-top: 0.6rem; }
.sheet-dnf.on { border-color: var(--bad); color: var(--bad); }

.sheet-toggle-wrap { text-align: center; padding-bottom: 0.5rem; }
.sheet-big-toggle { width: 100%; padding: 1.4rem 0; font-size: 1.1rem; }
.sheet-big-toggle.on { background: var(--good); border-color: var(--good); color: #04231a; }

.sheet-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.sheet-actions button { flex: 1; padding: 0.7rem 0; }

/* A finished draft stays visible but inert -- people still want to look back
   at the board, they just cannot wander into it expecting to pick. */
.tabs a.locked { opacity: 0.38; pointer-events: none; }

/* ================= scoreboard grid ================= */

table.master { border-collapse: separate; border-spacing: 0; }

/* Header sticks so you always know whose column you are in after scrolling. */
table.master thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-raised);
  vertical-align: bottom;
  padding: 0.5rem 0.45rem 0;
  text-transform: none;
  letter-spacing: 0;
}
table.master thead th.sticky-col { left: 0; z-index: 4; }

.head-name { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text); }
.head-team { display: block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.head-rule { display: block; height: 3px; border-radius: 2px; margin-top: 0.4rem; }

/* Column definition: a faint tint on every other person, a harder rule where
   one team ends and the next starts. */
table.master .col { border-left: 1px solid var(--line-soft); }
table.master .c1 { background: color-mix(in srgb, var(--text) 3%, transparent); }
table.master .team-seam { border-left: 2px solid var(--line); }

table.master td, table.master th { border-bottom: 1px solid var(--line-soft); }
.master-cell { padding: 0.35rem; text-align: center; vertical-align: middle; }

.row-head {
  text-align: left;
  padding: 0.5rem 0.7rem 0.5rem 0;
  background: var(--bg-raised);
  min-width: 7rem;
}
.row-head a { font-weight: 700; font-size: 0.85rem; text-decoration: none; display: block; }
.row-head .small { display: block; }

/* Each cell is one tap target: drafted tier on top, result underneath. */
.tile {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  min-width: 4.4rem;
  padding: 0.4rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-sunken);
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: center;
}
.tile.ro { cursor: default; }
.tile:hover:not(.ro) { border-color: var(--text-faint); }

.t-tier {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}
.t-tbd { color: var(--text-faint); font-weight: 400; }
.t-val { font-family: var(--mono); font-size: 0.86rem; font-weight: 700; }

.tile.empty { border-style: dashed; }
.tile.empty .t-val { color: var(--text-faint); font-weight: 600; }
.tile.empty:hover:not(.ro) { border-color: var(--accent); }
.tile.empty:hover:not(.ro) .t-val { color: var(--accent); }

.tile.filled { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: color-mix(in srgb, var(--good) 9%, var(--bg-sunken)); }
.tile.filled .t-val { color: var(--good); }

.tile.part { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 9%, var(--bg-sunken)); }
.tile.part .t-val { color: var(--accent); }

.tile.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad) 9%, var(--bg-sunken)); }
.tile.bad .t-val { color: var(--bad); }

table.master tfoot td, table.master tfoot th {
  border-top: 2px solid var(--line);
  border-bottom: none;
  padding-top: 0.6rem;
}
.foot-big { display: block; font-size: 1rem; }
table.master tfoot .small { display: block; }

@media (max-width: 640px) {
  .tile { min-width: 4rem; padding: 0.35rem 0.2rem; }
  .t-val { font-size: 0.8rem; }
  .row-head { min-width: 6rem; }
}

/* Row headers are <th> for accessibility but must not inherit the column-header
   uppercase treatment -- they are event names, not labels. */
.row-head, .row-head a, .row-head .small {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.row-head .small { color: var(--text-faint); font-weight: 500; }
table.master tfoot th { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 0.85rem; }

/* ---------- draft: keep the clock in view ---------- */

/* The board runs past two screens, so an unpinned clock card means you scroll
   to Cornhole and lose track of whose turn it is. Pin it under the tab bar. */
.clock {
  position: sticky;
  top: calc(var(--topbar-h, 88px) - 1px);
  z-index: 10;
}

/* Condensed while pinned: the explainer text is for the first read, not the
   twentieth, and a tall sticky card eats the board. */
.clock .clock-next { display: flex; gap: 0.35rem; flex-wrap: wrap; }

@media (max-width: 640px) {
  .clock { top: calc(var(--topbar-h, 82px) - 1px); }
  .clock-name { font-size: 1.35rem; }
}

/* ---------- tabs: show that there is more to the right ---------- */

.tabs-wrap { position: relative; }
.tabs-wrap::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg));
  opacity: 0;
  transition: opacity 0.15s;
}
.tabs-wrap.scrollable::after { opacity: 1; }

/* ---------- history filters ---------- */

.log-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.log-filters select { flex: 1 1 8rem; }
.log-more { width: 100%; margin-top: 0.85rem; }

/* The clock now sits between cards rather than inside one, so sticky resolves
   against the page. Give it the card's chrome back. */
.clock {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--team-color, var(--accent));
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 20px rgba(3, 7, 14, 0.55);
}
.clock.done-banner { border-left-color: var(--good); }

/* ================= contrast + header prominence ================= */

/* The old dim/faint pair sat around 3.5:1 on this background -- fine indoors,
   poor on a phone in July sun. These clear 4.5:1 and 7:1. */
:root {
  --text-dim: #b3c0d8;
  --text-faint: #8b9ab4;
}

.brand h1 { font-size: 1.2rem; }
.brand p { font-size: 0.82rem; color: var(--text-dim); }
.brand-mark { font-size: 1.8rem; }
.tabs a { font-size: 0.95rem; padding: 0.6rem 0.8rem; }
.tabs a.active { border-bottom-width: 3px; }

@media (max-width: 640px) {
  .brand h1 { font-size: 1.15rem; }
  .brand p { font-size: 0.78rem; }
  .tabs a { font-size: 0.92rem; padding: 0.6rem 0.7rem; }
  .small { font-size: 0.84rem; }
}

/* ================= draft board: 3 x 2, no orphans ================= */

/* Six tiers in a flex row wrapped 5 + 1, orphaning one chip. A fixed 3-column
   grid always gives two even rows. */
.board-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}
.draft-chip { min-width: 0; width: 100%; }

@media (max-width: 640px) {
  /* Stack the event name above its tiers so the chips get the full width. */
  .board-row { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.85rem 0; }
  .board-event strong { font-size: 1.02rem; }
  .draft-chip { padding: 0.5rem 0.4rem; }
  .draft-chip .chip-val { font-size: 1rem; }
  .draft-chip .chip-owner { font-size: 0.68rem; }
}

/* ================= scoreboard: one team at a time ================= */

.team-pager {
  display: grid;
  grid-auto-flow: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.team-pager button {
  padding: 0.55rem 0.4rem;
  font-size: 0.85rem;
  border-left: 3px solid var(--pager-color, var(--line));
}
.team-pager button.on {
  background: color-mix(in srgb, var(--pager-color) 18%, var(--bg-sunken));
  border-color: var(--pager-color);
  color: var(--text);
}
.pager-sub { display: block; font-size: 0.68rem; color: var(--text-faint); font-weight: 500; }

/* With two people on screen instead of six, the cells can breathe. */
.board-two .tile { min-width: 0; padding: 0.6rem 0.4rem; }
.board-two .t-val { font-size: 1.05rem; }
.board-two .t-tier { font-size: 0.8rem; }
.board-two .master-head { padding-bottom: 0.2rem; }
.board-two .head-name { font-size: 1rem; }
.board-two .row-head { min-width: 7.5rem; }
.board-two table.master { table-layout: fixed; }
.board-two .master-cell { width: 34%; }

/* Beers are edited in place on the scoreboard, same as on My Events -- a tally
   you nudge all day should never need a dialog. */
.beer-tile { gap: 0.3rem; }
.beer-mini { display: grid; grid-auto-flow: column; gap: 0.3rem; }
.beer-mini button {
  padding: 0.3rem 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  background: var(--bg-raised);
}
.beer-mini button:last-child { background: var(--accent); border-color: var(--accent); color: #1a1400; }
.beer-mini button:disabled { opacity: 0.3; }

/* ================= scoreboard sub-tabs ================= */

.subtabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  margin: 0 -0.25rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.subtab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.25rem;
  display: grid;
  gap: 0.1rem;
  cursor: pointer;
  min-width: 0;
}
.subtab:hover { border-color: transparent; background: color-mix(in srgb, var(--text) 4%, transparent); }
.subtab-name { font-size: 0.92rem; font-weight: 700; color: var(--text-dim); }
.subtab-sub {
  font-size: 0.66rem;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subtab.on { border-bottom-color: var(--pager-color, var(--accent)); }
.subtab.on .subtab-name { color: var(--text); }

/* Showing one team means the grid fits, so the horizontal scroll container is
   not just unnecessary -- it was intercepting vertical swipes and making the
   page feel stuck. Drop it, and let the header stick to the viewport instead. */
.board-two .table-wrap { overflow: visible; }
.board-two table.master thead th { top: var(--topbar-h, 88px); }

/* The alternating column tint uses a transparent mix, which beats the sticky
   header's opaque background and lets rows show through as they pass under it.
   Header cells need the tint pre-composited against the card, not alpha. */
table.master thead th,
table.master thead th.col,
table.master thead th.c1 {
  background: var(--bg-raised);
}
table.master thead th.c1 {
  background: color-mix(in srgb, var(--text) 3%, var(--bg-raised));
}
/* Same for the pinned event column, which scrolls past cells horizontally. */
table.master .row-head,
table.master tbody th.sticky-col {
  background: var(--bg-raised);
}

/* ================= draft: select, then confirm ================= */

.draft-chip.picking {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-sunken));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.draft-chip.picking .chip-val { color: var(--accent); }

/* Pinned to the bottom of the screen: the tier you tapped may be far up the
   board, and the commit should be reachable without scrolling back. */
.confirm-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(3, 7, 14, 0.7);
}
.confirm-bar.stale { border-color: var(--bad); }
.confirm-what { display: grid; gap: 0.1rem; min-width: 0; }
.confirm-what strong { font-size: 1.02rem; }
.confirm-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.confirm-actions button { padding: 0.55rem 0.9rem; }

@media (max-width: 480px) {
  .confirm-actions { width: 100%; }
  .confirm-actions button { flex: 1; }
}

/* ---------- disc golf: time plus stroke penalty ---------- */

.stroke-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.85rem;
  padding: 0.7rem 0.8rem;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.stroke-val { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; }
.stroke-btns { display: grid; grid-auto-flow: column; gap: 0.45rem; }
.stroke-btns button { width: 3rem; padding: 0.6rem 0; font-size: 1.25rem; font-weight: 700; line-height: 1; }
.stroke-btns button:last-child { background: var(--accent); border-color: var(--accent); color: #1a1400; }
.stroke-btns button:disabled { opacity: 0.3; }
.sheet-total { margin: 0.7rem 0 0; text-align: center; }
.sheet-total strong { color: var(--good); font-family: var(--mono); }

.val-sub { font-size: 0.75rem; color: var(--text-faint); margin-left: 0.35rem; }
.t-sub { font-size: 0.7rem; color: var(--text-faint); font-weight: 600; }

/* ---------- organiser draft controls ---------- */

.organiser-panel { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-soft)); }
.ctl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.ctl-row:last-of-type { border-bottom: none; }
.ctl-row > div { min-width: 0; }
.ctl-row button { flex: none; }

@media (max-width: 480px) {
  .ctl-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .ctl-row button { width: 100%; }
}
