/*
 * Bell Island Tailgate.
 *
 * Design brief: a printed sign taped to the tent pole. Big type, high contrast,
 * readable in direct sun on a phone held at arm's length. Mobile-first; the
 * layout has to survive 320px. No team marks anywhere — type only.
 */

:root {
  --maroon: #5d1725;
  --maroon-dark: #47111c;
  --maroon-ink: #5d1725;
  --surface: #f5f3f0;
  --page: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4340;
  --line: #d9d3cd;
  --accent: #a8431a;
  --accent-soft: #fdf0e9;
  --ok: #1f6b3f;
  --radius: 10px;
  --tap: 44px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --maroon: #8d2a3d;
    --maroon-dark: #6d1f2e;
    --maroon-ink: #f0b8c2;
    --surface: #241318;
    --page: #170c0f;
    --ink: #f4ece9;
    --ink-soft: #c7b5b0;
    --line: #402329;
    --accent: #ef8a55;
    --accent-soft: #35191a;
    --ok: #6fce97;
  }
}

/* The viewer's explicit toggle must win over the media query in both directions. */
:root[data-theme='dark'] {
  --maroon: #8d2a3d;
  --maroon-dark: #6d1f2e;
  --maroon-ink: #f0b8c2;
  --surface: #241318;
  --page: #170c0f;
  --ink: #f4ece9;
  --ink-soft: #c7b5b0;
  --line: #402329;
  --accent: #ef8a55;
  --accent-soft: #35191a;
  --ok: #6fce97;
}

:root[data-theme='light'] {
  --maroon: #5d1725;
  --maroon-dark: #47111c;
  --maroon-ink: #5d1725;
  --surface: #f5f3f0;
  --page: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4340;
  --line: #d9d3cd;
  --accent: #a8431a;
  --accent-soft: #fdf0e9;
  --ok: #1f6b3f;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

/* --- header --- */

.masthead {
  background: var(--maroon);
  color: #fff;
  padding: 14px 16px;
}

.masthead a { color: #fff; }

.masthead-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: uppercase;
}

.cowbell { flex: none; }

nav.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

nav.tabs a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

nav.tabs a[aria-current='page'] { background: #fff; color: var(--maroon); }

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 18px 16px 64px;
}

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 28px 0 10px; }
h3 { font-size: 1.02rem; margin: 18px 0 6px; }

.lede { color: var(--ink-soft); margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

.card h2, .card h3 { margin-top: 0; }

/* --- controls --- */

button, .btn {
  font: inherit;
  font-weight: 700;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--maroon);
  background: var(--maroon);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--maroon-ink);
  border-color: var(--maroon);
}

button.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}

button.danger { background: var(--accent); border-color: var(--accent); }

button[disabled] { opacity: 0.45; cursor: not-allowed; }

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

label { display: block; font-weight: 700; margin: 14px 0 4px; }
label .hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.9rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
}

textarea { min-height: 84px; }

.checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  font-weight: 600;
  margin: 6px 0;
}

.checkline input { width: 26px; height: 26px; min-height: 26px; flex: none; }

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

/* --- ranking list --- */

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

.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--page);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 8px;
  touch-action: none;
}

.rank-item.dragging {
  border-color: var(--maroon);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  opacity: 0.95;
}

.rank-num {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--maroon);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-body { flex: 1 1 auto; min-width: 0; }
.rank-op { font-weight: 700; }
.rank-date { color: var(--ink-soft); font-size: 0.9rem; }

.rank-buttons { display: flex; flex-direction: column; gap: 4px; flex: none; }

/* Full 44px in both directions — these are the primary reordering control on a
   phone, not a decoration. */
.rank-buttons button {
  min-height: var(--tap);
  width: var(--tap);
  padding: 0;
  font-size: 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--ink);
}

.rank-remove {
  min-height: var(--tap);
  width: var(--tap);
  padding: 0;
  flex: none;
}

.grip {
  flex: none;
  width: 30px;
  color: var(--ink-soft);
  text-align: center;
  cursor: grab;
  font-size: 1.2rem;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pool { display: flex; flex-direction: column; gap: 8px; }

.pool button {
  justify-content: flex-start;
  text-align: left;
  background: var(--page);
  color: var(--ink);
  border: 2px dashed var(--maroon);
  font-weight: 600;
}

.pool button .op { font-weight: 800; }

/* --- status + flags --- */

.flag {
  border-left: 6px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-weight: 600;
}

.flag.good { border-left-color: var(--ok); background: transparent; border: 1px solid var(--line); border-left: 6px solid var(--ok); }

.note { color: var(--ink-soft); font-size: 0.95rem; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--maroon);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill.bubble { background: var(--accent); }
.pill.quiet { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }

.winner {
  border: 3px solid var(--maroon);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
}

.winner .op { font-size: 1.5rem; font-weight: 800; line-height: 1.15; }
.winner .dt { color: var(--ink-soft); font-weight: 600; }

.stat { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--ink-soft); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- tables --- */

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

table { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface); font-weight: 800; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 45%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-out { color: var(--ink-soft); }
.cell-elected { color: var(--maroon-ink); font-weight: 800; }
.cell-gone { color: var(--accent); font-weight: 700; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }

dialog {
  border: 2px solid var(--maroon);
  border-radius: var(--radius);
  padding: 20px;
  max-width: min(30rem, 92vw);
  background: var(--page);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

.hidden { display: none !important; }

.spinner { color: var(--ink-soft); padding: 20px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--page);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 50;
  max-width: 92vw;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

footer.site {
  border-top: 1px solid var(--line);
  padding: 18px 16px 30px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-align: center;
}

@media (min-width: 640px) {
  body { font-size: 18px; }
  h1 { font-size: 2.1rem; }
}
