:root {
  color-scheme: dark;
  --bg: #000000;          /* pure black page */
  --bg-deep: #000000;     /* masthead, record bar */
  --surface: #111111;     /* inputs, panels */
  --surface-2: #1A1A1A;   /* pressed rows, chosen bird */
  --text: #FFFFFF;
  --muted: #A3A3A3;
  --heading: #FFFFFF;
  --line: #222222;        /* hairlines between rows */
  --line-strong: #3A3A3A; /* control outlines */
  --accent: #FFFFFF;      /* primary buttons: white with black lettering */
  --accent-text: #000000;
  --alert: #FF9C85;
  --radius: 8px;
  --font: Calibri, Carlito, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; font-weight: 700; }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Masthead ---------- */

.masthead {
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px 6px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.masthead-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }

.masthead-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--alert);
  color: #000000;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.badge.zero { background: var(--surface-2); color: var(--muted); }

.admin-settings { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }

.admin-settings h3 { margin: 0 0 8px; font-size: 1rem; }

/* Lighter pill so the guide is easy to spot. */
.help-btn {
  padding: 5px 12px;
  background: #E6E6E6;
  color: #000000;
  border: 0;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.help-btn:active { background: #FFFFFF; }

.masthead h1 { font-size: 1.3rem; line-height: 1.2; }

.season-title { margin: 2px 0 0; font-size: 1.05rem; color: var(--heading); }

.tabs {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
}

.tab {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 8px 4px 6px;
  margin-right: 14px;
  font-weight: 700;
  color: var(--muted);
}

.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.tab { border-bottom-width: 2px; }

.tab[hidden] { display: none; }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--heading);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.notice {
  padding: 8px max(16px, calc((100% - 1080px) / 2 + 16px));
  font-size: 0.92rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.notice .link-btn { padding: 0; }

/* ---------- Controls ---------- */

.controls {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}

input[type="search"], input[type="text"], input[type="email"], input[type="date"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
  min-height: 46px;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input::placeholder { color: var(--muted); opacity: 1; }

.filter-label {
  margin: 14px 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.filter {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.filter-btn {
  flex: 1;
  background: var(--surface);
  border: 0;
  border-left: 1px solid var(--line-strong);
  padding: 9px 6px;
  font-size: 0.95rem;
}

.filter-btn:first-child { border-left: 0; }

.filter-btn.is-active { background: var(--accent); color: var(--accent-text); font-weight: 700; }

.summary { margin: 10px 0 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- The sheet ---------- */

.sheet {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.group-head {
  margin: 18px 0 0;
  padding: 4px 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.col-head { display: none; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name date"
    "meta meta"
    "hist hist";
  column-gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
}

.row:active { background: var(--surface-2); }

.cell-name { grid-area: name; font-weight: 700; }

.cell-name .code { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 6px; }

.cell-date { grid-area: date; font-weight: 700; text-align: right; white-space: nowrap; }

.cell-date.waiting { font-weight: 400; color: var(--muted); }

.meta { grid-area: meta; color: var(--text); font-size: 0.95rem; }

.meta span + span::before { content: " \00B7  "; color: var(--muted); }

.hist { grid-area: hist; color: var(--muted); font-size: 0.88rem; }

.hist span + span::before { content: " \00B7  "; }

.cell-blank { display: none; }

.empty { padding: 28px 0; color: var(--muted); }

.region-list { padding-left: 20px; }

.region-list a { color: var(--text); }

/* Phone rows: one fixed-height line per bird, details slide open on tap. */

.c-row { border-bottom: 1px solid var(--line); }

.row-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
}

.row-head .cell-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-head:active { background: var(--surface); }

.chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 4px 4px 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.c-row.is-open .chev { transform: translateY(4px) rotate(-135deg); }

.row-more {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.2s ease;
}

.c-row.is-open .row-more { grid-template-rows: 1fr; }

.row-more > div { overflow: hidden; min-height: 0; }

.row-more-inner { padding: 0 0 14px; font-size: 0.95rem; }

.row-more-inner p { margin: 0 0 4px; }

.row-more-inner .dim { color: var(--muted); }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.row-actions .small-btn { padding: 7px 12px; }

@media (prefers-reduced-motion: reduce) {
  .chev, .row-more { transition: none; }
}

@media (min-width: 760px) {
  .col-head, .row {
    display: grid;
    grid-template-columns: 2fr 1fr 0.8fr 1.5fr 1.2fr 0.9fr 0.9fr;
    grid-template-areas: none;
    column-gap: 14px;
    align-items: baseline;
  }
  .mine-view .col-head, .mine-view .row { grid-template-columns: 2fr 1fr 1fr 1.6fr 1fr; }
  .col-head {
    padding: 10px 0 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--heading);
    border-bottom: 1px solid var(--line-strong);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
  }
  .row > *, .col-head > * { grid-area: auto; }
  .meta, .hist { display: contents; }
  .meta span + span::before, .hist span + span::before { content: none; }
  .hist span { color: var(--muted); }
  .cell-date { text-align: left; }
  .cell-blank { display: block; }
  .hist .label, .label-inline { display: none; }
  .group-head { margin-top: 22px; }
}

/* ---------- Record bar ---------- */

.record-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  z-index: 5;
}

.record-btn {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 54px;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 700;
}

.record-btn:active { background: var(--heading); }

.record-btn:disabled { background: var(--line); color: var(--muted); }

.secondary-btn {
  margin-top: 8px;
  padding: 9px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.secondary-btn.wide { width: 100%; }

.small-btn {
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

/* ---------- Dialogs ---------- */

dialog {
  border: 0;
  padding: 0;
  color: var(--text);
  background: var(--bg);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.75); }

.small-dialog, .sheet-dialog { border: 1px solid var(--line); }

.sheet-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px 24px;
  overflow-y: auto;
}

@media (min-width: 600px) {
  .sheet-dialog { height: auto; max-height: 92vh; margin-top: 4vh; border-radius: 4px; }
}

.small-dialog {
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 18px 18px 20px;
  border-radius: 4px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 16px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 2;
}

.small-dialog .dialog-head { padding-top: 0; position: static; }

.dialog-head h2 { font-size: 1.25rem; }

.field { margin: 0 0 16px; padding: 0; border: 0; }

.field > label, .field > legend, .small-dialog form > label {
  display: block;
  font-weight: 700;
  margin-bottom: 5px;
  padding: 0;
}

.hint { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

.choice { display: flex; gap: 8px; }

.choice label { flex: 1; }

.choice input { position: absolute; opacity: 0; }

.choice span {
  display: block;
  text-align: center;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.choice input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 700; border-color: var(--accent); }

.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.picker { position: relative; }

.picker-options {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
}

.picker-options li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.picker-options li:last-child { border-bottom: 0; }

.picker-options li[aria-selected="true"], .picker-options li:active { background: var(--surface-2); }

.picker-options .status { color: var(--muted); font-size: 0.88rem; }

.chosen {
  margin: 0;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.form-error { color: var(--alert); margin: 0 0 12px; }

.small-dialog form { margin-top: 10px; }

.small-dialog form .record-btn { margin-top: 10px; }

.or { text-align: center; color: var(--muted); margin: 14px 0 0; }

.congrats { text-align: center; }

.congrats-kicker {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--heading);
}

#congrats-text { font-size: 1.2rem; margin: 0 0 18px; }

/* ---------- Help, account ---------- */

.help h3 {
  margin: 22px 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.help p, .help li { line-height: 1.5; }

.help p { margin: 0 0 8px; }

.help ul { margin: 0 0 8px; padding-left: 20px; }

.help-lead { font-size: 1.05rem; }

.help .record-btn { margin: 12px 0 4px; }

.fine-print { color: var(--muted); font-size: 0.88rem; margin: 16px 0 0; }

.fine-print a, .footer-links a { color: inherit; }

.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.danger-zone h3 { margin: 0 0 6px; font-size: 1rem; }

.danger-zone p { color: var(--muted); font-size: 0.92rem; line-height: 1.45; margin: 0 0 10px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; font-size: 0.95rem; }

.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--alert); flex: none; }

.danger-btn {
  width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  background: none;
  color: var(--alert);
  border: 1px solid var(--alert);
  border-radius: var(--radius);
  font-weight: 700;
}

.danger-btn.solid { background: var(--alert); color: #000000; }

#delete-confirm { margin-top: 12px; }

.danger-zone .form-error { color: var(--alert); }

.confirm-row { display: grid; gap: 8px; }

.confirm-row .secondary-btn { margin-top: 0; }

/* ---------- Donate ---------- */

.donate-way { margin: 16px 0 0; }

.donate-way h3 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

a.record-btn { text-align: center; text-decoration: none; line-height: 30px; }

a.secondary-btn { display: block; text-align: center; text-decoration: none; color: var(--text); line-height: 24px; }

.bank {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 12px;
  align-items: center;
  margin: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bank dt { color: var(--muted); }

.bank dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

.example-note { color: var(--muted); font-size: 0.9rem; margin: 14px 0 0; }

/* ---------- Detail ---------- */

.detail-sci { margin: 0; font-style: italic; color: var(--muted); }

.detail-status { margin: 2px 0 14px; color: var(--muted); font-size: 0.95rem; }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0 0 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.facts dt { color: var(--muted); }

.facts dd { margin: 0; font-weight: 700; }

.detail-h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--heading); margin: 18px 0 4px; }

.records { list-style: none; margin: 0 0 16px; padding: 0; }

.records li { padding: 10px 0; border-bottom: 1px solid var(--line); }

.records .r-main { font-weight: 700; }

.records .r-sub { color: var(--muted); font-size: 0.92rem; }

.records .r-actions { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.records .is-hidden { opacity: 0.55; }

.tag { font-size: 0.8rem; padding: 1px 6px; border: 1px solid var(--alert); color: var(--alert); border-radius: 2px; }

.records a { color: var(--heading); }

/* ---------- Footer and toast ---------- */

.footnote {
  max-width: 1080px;
  margin: 20px auto 0;
  padding: 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 20;
  width: min(480px, calc(100% - 32px));
  text-align: center;
}

/* ---------- Landing page and province map ---------- */

.landing { padding-bottom: 32px; }

.landing-main { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.continue { margin: 16px 0 0; }

.choose { margin: 22px 0 8px; font-size: 1.5rem; text-align: center; }

.map-wrap { margin: 0 auto; max-width: 640px; }

.za-map { display: block; width: 100%; height: auto; }

.za-map .prov path {
  fill: #0A0A0A;
  stroke: #555555;
  stroke-width: 2;
  stroke-linejoin: round;
  transition: fill 0.15s ease;
}

.za-map .prov text {
  fill: #8A8A8A;
  font-family: var(--font);
  font-size: 30px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.za-map .prov:hover path { fill: #141414; }

.za-map .prov.is-active path { fill: #2A2A2A; stroke: #FFFFFF; stroke-width: 3; }

.za-map .prov.is-active text { fill: #FFFFFF; font-size: 36px; }

.za-map .prov.is-active:hover path { fill: #3D3D3D; }

.za-map .prov:focus { outline: none; }

.za-map .prov:focus-visible path { stroke: var(--alert); stroke-width: 4; }

.province-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.province-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
  text-align: left;
}

.province-btn span { font-size: 0.85rem; font-weight: 400; }

.province-btn.soon { background: var(--surface); color: var(--muted); border: 1px solid var(--line); font-weight: 400; }

/* ---------- Province switcher inside the app ---------- */

.province-bar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.province-chip {
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.province-chip.is-active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }

.province-bar .link-btn { font-size: 0.9rem; margin-left: 4px; }

@media (prefers-reduced-motion: reduce) {
  .za-map .prov path { transition: none; }
}

/* ---------- Leaderboard and badges ---------- */

.board-view .controls .filter-label, .board-view .controls .filter, .board-view .controls #search { display: none; }

.board { display: grid; gap: 28px; margin-top: 8px; }

@media (min-width: 760px) { .board { grid-template-columns: 1fr 1fr; } }

.board h2 { margin: 0; font-size: 1.15rem; }

.board .explain { margin: 2px 0 10px; color: var(--muted); font-size: 0.92rem; }

.board ol { list-style: none; margin: 0; padding: 0; }

.board li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.board li.is-me { background: var(--surface); border-radius: var(--radius); margin: 0 -8px; padding: 6px 8px; }

.board .pos { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.board li:nth-child(-n+3) .pos { color: var(--text); }

.board .who { min-width: 0; overflow-wrap: anywhere; }

.board .score { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.board .empty-board { color: var(--muted); padding: 10px 0; }

.board-note { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }

.board-me {
  margin: 4px 0 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

.badge-chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
}

.who .badge-chip { margin-left: 6px; font-size: 0.75rem; padding: 1px 8px; }

.profile-settings { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }

.profile-settings h3 { margin: 0 0 8px; font-size: 1rem; }

.profile-settings > label:not(.check) { display: block; font-weight: 700; margin-bottom: 5px; }

.profile-settings .check { margin-top: 10px; }

.congrats-extra { font-weight: 700; margin: -8px 0 18px; }
