/* NCCA Roll Call. Phone first: one column for reps and hosts on phones, two-pane console on wide screens. */
:root {
  /* NCCA colours, shared with ask.nccacricket.org: navy, crest red, cool grey page */
  --navy: #1b2a6b;
  --red: #c41e3a;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --sunk: #eef1f8;
  --fg: #1a1a1a;
  --muted: #5d6272;
  --line: #e3e6ef;
  --accent: var(--navy);
  --accent-strong: #14205a;
  --accent-fg: #ffffff;
  --accent-soft: #e4e9f8;
  --hero-a: var(--navy);
  --hero-b: var(--navy);
  --hero-line: var(--red);
  --hero-fg: #ffffff;
  --hero-muted: #cdd4f0;
  --yes: #1e7b45;
  --no: #c41e3a;
  --abstain: #a15c00;
  --warn-bg: #fdf0d8;
  --warn-fg: #7a4500;
  --ok-bg: #dcf1e3;
  --ok-fg: #14532d;
  --bad-bg: #fbe0e4;
  --bad-fg: #8f1429;
  --shadow: 0 1px 2px rgb(27 42 107 / .06), 0 6px 20px rgb(27 42 107 / .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 16px;
  --r-sm: 12px;
  --tap: 46px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1020; --surface: #171b30; --sunk: #20253f; --fg: #e8eaf4; --muted: #a0a6bd; --line: #2c3252;
    --accent: #93a5f5; --accent-strong: #b3c0fa; --accent-fg: #0c1230; --accent-soft: #232b55;
    --hero-a: #141d4d; --hero-b: #141d4d; --hero-line: #d5354f; --hero-fg: #f2f4fc; --hero-muted: #b4bde6;
    --yes: #5fc88d; --no: #f4808f; --abstain: #e0b25a;
    --warn-bg: #3a2c10; --warn-fg: #f4d792; --ok-bg: #163824; --ok-fg: #a9e7c0; --bad-bg: #421922; --bad-fg: #f8b6bf;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 12px; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  overflow-wrap: break-word;
}
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 800; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.eyebrow { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }

/* Page frame */
.wrap, .wide {
  margin: 0 auto; display: grid; gap: 14px; min-width: 0;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.wrap { max-width: 592px; }
.wide { max-width: 1312px; }
main.wrap, main.wide { padding-top: 16px; }

/* Brand band across the top of every page */
.hero {
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: var(--hero-fg);
  padding-top: calc(14px + env(safe-area-inset-top, 0px)); padding-bottom: 18px;
  border-bottom: 4px solid var(--hero-line);
}
.hero > .wrap, .hero > .wide { gap: 10px; }
.hero .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hero .brand img { flex: none; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgb(255 255 255 / .35); }
.hero .brand > div { min-width: 0; display: grid; gap: 2px; }
.hero h1 { font-size: 1.3rem; }
.hero .eyebrow, .hero .muted, .hero .conn { color: var(--hero-muted); }
.hero a { color: var(--hero-fg); }
.hero .heroline { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .875rem; }
.hero .heroline > .grow { flex: 1 1 auto; }
.hero button.quiet, .hero a.herobtn {
  background: rgb(255 255 255 / .14); color: var(--hero-fg); border: 1px solid rgb(255 255 255 / .28);
  border-radius: 999px; padding: 6px 14px; min-height: 36px; font-size: .85rem; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center;
}
.hero.center > .wrap { justify-items: center; text-align: center; }
.hero.center h1 { font-size: 1.45rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow);
}
.card .card { box-shadow: none; background: var(--sunk); border-color: transparent; }
.card .card .codebox, .card .card .pill.plain { background: var(--surface); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: 8px; min-width: 0; }

/* Forms: 16px text stops iPhones zooming in on focus; 46px controls are easy to hit */
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--fg); background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; width: 100%; min-width: 0; min-height: var(--tap);
}
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
input[type="file"] { padding: 8px; }
input::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: .95rem; }
label.check input { margin-top: 1px; }
label.check.small { font-size: .875rem; }
textarea { font-family: var(--mono); font-size: 14px; min-height: 160px; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button {
  font: inherit; font-weight: 700; border-radius: var(--r-sm); padding: 10px 18px; cursor: pointer; min-height: var(--tap);
  border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  touch-action: manipulation; transition: transform .08s, background-color .15s, opacity .15s;
}
button:active:not(:disabled) { transform: scale(.97); }
button.ghost { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
button.quiet { background: var(--surface); color: var(--fg); border-color: var(--line); font-weight: 600; }
button.sm { padding: 6px 12px; font-size: .85rem; min-height: 36px; border-radius: 10px; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: var(--accent); }
summary { cursor: pointer; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.plain { background: var(--sunk); color: var(--muted); }
.league { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--sunk); color: var(--muted); vertical-align: middle; }

.notice { padding: 12px 14px; border-radius: var(--r-sm); font-size: .92rem; }
.notice.small { font-size: .875rem; padding: 10px 12px; }
.notice.err { background: var(--bad-bg); color: var(--bad-fg); }
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }

.conn { font-size: .8rem; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f2a39a; }
.conn.live::before { background: #6fe0a0; box-shadow: 0 0 0 3px rgb(111 224 160 / .25); }

/* Quorum meters */
.quorum { display: grid; gap: 12px; }
.qhead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.qstate { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.qstate.ok { color: var(--yes); }
.qstate.bad { color: var(--no); }
.meter { display: grid; gap: 6px; }
.meter .bar { position: relative; height: 12px; border-radius: 6px; background: var(--sunk); overflow: hidden; }
.meter .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 6px; transition: width .3s; }
.meter .mark { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--hero-line); box-shadow: 0 0 0 1px var(--surface); }

/* Vote buttons (rep) */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice { padding: 18px 4px; font-size: 1.1rem; font-weight: 800; border-width: 2px; background: var(--surface); min-height: 68px; border-radius: 14px; }
.choice.yes { color: var(--yes); border-color: var(--yes); }
.choice.no { color: var(--no); border-color: var(--no); }
.choice.abstain { color: var(--abstain); border-color: var(--abstain); }
.choice.sel { box-shadow: 0 4px 14px rgb(0 0 0 / .18); }
.choice.sel.yes { background: var(--yes); color: var(--surface); }
.choice.sel.no { background: var(--no); color: var(--surface); }
.choice.sel.abstain { background: var(--abstain); color: var(--surface); }

/* Secret ballot: each option is a full-width tap target that lights up when chosen */
fieldset.race { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 8px; }
fieldset.race legend { font-weight: 800; font-size: 1.02rem; padding: 0; margin-bottom: 2px; }
fieldset.race label.check {
  align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); min-height: 52px; cursor: pointer; font-weight: 600;
}
fieldset.race label.check input { margin: 0; }
fieldset.race label.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
fieldset.race label.check:has(input:disabled) { opacity: .5; cursor: not-allowed; }
fieldset.race + fieldset.race { margin-top: 10px; }

/* Tally bars */
.tally { display: grid; gap: 8px; }
.trow { display: grid; grid-template-columns: 64px minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.trow .bar { height: 24px; background: var(--sunk); border-radius: 7px; overflow: hidden; position: relative; }
.trow .fill { position: absolute; inset: 0 auto 0 0; transition: width .3s; border-radius: 7px; }
.trow.yes .fill { background: var(--yes); }
.trow.no .fill { background: var(--no); }
.trow.abstain .fill { background: var(--abstain); }
.trow .lbl { font-weight: 700; font-size: .92rem; }
.trow .n { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.threshold { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); }

/* Host console */
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; text-decoration: none; color: var(--muted);
  font-weight: 700; font-size: .92rem; border-radius: 999px; white-space: nowrap;
}
.tabs a svg { width: 20px; height: 20px; flex: none; }
.tabs a.on { color: var(--accent-strong); background: var(--accent-soft); }
.grid2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; padding: 4px 9px; border-radius: 8px; background: var(--sunk); border: 1px solid var(--line); }
.chip.yes { border-color: var(--yes); color: var(--yes); }
.chip.no { border-color: var(--no); color: var(--no); }
.chip.abstain { border-color: var(--abstain); color: var(--abstain); }
.chip.pending { border-style: dashed; color: var(--muted); }
.list { display: grid; max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .who { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.item > .row { flex: 0 1 auto; justify-content: flex-end; gap: 6px; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
.codebox { font-family: var(--mono); font-size: .95rem; padding: 8px 12px; background: var(--sunk); border-radius: 10px; overflow-wrap: anywhere; user-select: all; min-width: 0; }
a.codebox { text-decoration: none; }
pre.codebox { margin: 0; }

/* Messages float over the page so they are seen wherever you have scrolled to */
#msg { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 20; box-shadow: 0 6px 20px rgb(0 0 0 / .18); font-weight: 600; }

a.btnlink {
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; border-radius: var(--r-sm);
  padding: 10px 18px; min-height: var(--tap); background: var(--accent); color: var(--accent-fg); text-decoration: none;
}

/* Rep page: the action in each card spans the phone's width */
.rep .card > button, .rep .card > .row > button:only-child, .rep .card > a.btnlink { width: 100%; }
.rep .card > .row:has(> #ballotSubmit) > button { flex: 1 1 140px; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
  .list { max-height: none; overflow: visible; }
  .hero h1 { font-size: 1.18rem; }

  /* Host console sections move to a thumb-reach bar at the bottom of the screen */
  body.hasnav { padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0; margin: 0;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgb(0 0 0 / .08);
  }
  .tabs a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .72rem; border-radius: 12px; min-height: 52px; justify-content: center; }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs .tabx { display: none; }

  /* Attendance: team on top, status and actions underneath, buttons easy to hit */
  .item > .row { flex: 1 1 100%; justify-content: flex-start; }
  .item > .row button.sm, .card .row > button.sm { min-height: 40px; }

  /* Roster table becomes one card per team */
  table.cards thead { display: none; }
  table.cards, table.cards tbody { display: grid; gap: 10px; }
  table.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
  table.cards td { border: 0; padding: 0; min-width: 0; overflow-wrap: anywhere; }
  table.cards td:empty { display: none; }
  table.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .78rem; font-weight: 600; }
  table.cards td.full { grid-column: 1 / -1; }
  table.cards td.head { font-weight: 700; font-size: 1rem; }
}
@media (min-width: 761px) {
  .tabs { padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; box-shadow: var(--shadow); flex-wrap: wrap; }
  .tabs a svg { display: none; }
  main.wrap, main.wide { padding-top: 20px; }
  .hero { padding-bottom: 22px; }
  .hero h1 { font-size: 1.5rem; }
}

/* Presentation mode for Zoom screen share */
body.present .hostonly { display: none !important; }
body.present { font-size: 18px; padding-bottom: 40px; }
body.present .grid2 { grid-template-columns: minmax(0, 1fr); }
body.present .qstate { font-size: 2.2rem; }
body.present .trow { grid-template-columns: 110px minmax(0, 1fr) 60px; }
body.present .trow .bar { height: 34px; }
body.present .chip { font-size: .95rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } button:active { transform: none !important; } }
@media print { .hero { background: none; color: #000; } .hero .eyebrow, .hero .muted { color: #333; } .tabs { display: none; } body { padding: 0; } .card { box-shadow: none; } }
