/* =========================================================
   Sullivan County Sheriff 2026 — Election Night Dashboard
   ========================================================= */

:root {
  /* Shared face-safe cover crop for photo pane + footer strip */
  --photo-crop-position: 50% 0%;
  --bg-0: #070b12;
  --bg-1: #0d1420;
  --bg-2: #121b2b;
  --bg-3: #182338;
  --panel: rgba(16, 24, 38, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f6fb;
  --text-dim: #9aa8bd;
  --text-mute: #6d7b90;
  --accent: #d4a24a;
  --accent-soft: rgba(212, 162, 74, 0.18);
  --accent-2: #4f8cff;
  --good: #3dcf8e;
  --good-soft: rgba(61, 207, 142, 0.18);
  --warn: #f0b35a;
  --warn-soft: rgba(240, 179, 90, 0.16);
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  /* Sized so 100% browser zoom fills the DeX / desktop viewport (no 175% zoom needed) */
  --header-h: clamp(96px, 12vh, 148px);
  --footer-photos-h: clamp(88px, 14vh, 140px);
  --ticker-h: 40px;
  --footer-h: calc(var(--footer-photos-h) + var(--ticker-h));
  --dex-h: 30px;
  --photo-split: 62%;
  --ui-scale: 1.12;
  --party-r: #c9453a;
  --party-i: #3d9b8f;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI", Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: calc(16px * var(--ui-scale, 1));
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.dimmed {
  opacity: 0.45;
}

.app {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: grid;
  /* header | optional stale banner | main (fills) | footer */
  grid-template-rows: var(--header-h) auto minmax(0, 1fr) var(--footer-h);
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(79, 140, 255, 0.12), transparent 55%),
    radial-gradient(900px 420px at 90% 0%, rgba(212, 162, 74, 0.10), transparent 50%),
    linear-gradient(180deg, #0a101a 0%, var(--bg-0) 40%, #05080e 100%);
}

/*
 * Pin each region to its grid row explicitly. The stale banner is usually
 * display:none, and a hidden element occupies no grid cell — without these
 * pins, .main auto-flows into the banner's `auto` row and the footer lands
 * in the 1fr row, leaving a dead band at the bottom of the screen.
 */
.app > .header {
  grid-row: 1;
}

.stale-banner {
  grid-row: 2;
}

.main {
  grid-row: 3;
}

.site-footer {
  grid-row: 4;
}

/* ---------- Header ---------- */
.header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 2vw, 28px);
  padding: 0 clamp(18px, 2.2vw, 36px);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.header-atmosphere {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.02), transparent),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 38px,
      rgba(255, 255, 255, 0.015) 38px,
      rgba(255, 255, 255, 0.015) 39px
    );
  pointer-events: none;
}

.header-left,
.header-right {
  position: relative;
  z-index: 1;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.6vw, 22px);
  min-width: 0;
}

.tn-map {
  flex: 0 0 auto;
  width: clamp(150px, 20vw, 280px);
  max-height: calc(var(--header-h) - 18px);
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.45));
}

.tn-map-img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(var(--header-h) - 18px);
  object-fit: contain;
  object-position: center;
  /* Blend the image's black matte into the dark header */
  mix-blend-mode: lighten;
}

.header-copy {
  min-width: 0;
}

.header-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: clamp(10px, 1.1vh, 13px);
  font-weight: 600;
}

.header-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  font-size: clamp(22px, 3.4vh, 44px);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
}

.header-race-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 0;
}

.race-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font-size: clamp(10px, 1.15vh, 13px);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.race-chip .race-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.race-chip.party-r {
  color: #f0b4ad;
  border-color: rgba(201, 69, 58, 0.4);
  background: rgba(201, 69, 58, 0.12);
}

.race-chip.party-i {
  color: #a8e0d8;
  border-color: rgba(61, 155, 143, 0.4);
  background: rgba(61, 155, 143, 0.12);
}

.race-vs {
  color: var(--text-mute);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
}

.header-meta {
  display: flex;
  gap: clamp(14px, 1.6vw, 24px);
}

.meta-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 8ch;
}

.meta-label {
  color: var(--text-mute);
  font-size: clamp(10px, 1.05vh, 12px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.meta-value {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: clamp(14px, 1.8vh, 20px);
}

.meta-status {
  min-width: 9ch;
  gap: 3px;
}

.meta-status .status-updated {
  white-space: nowrap;
}

.meta-status.dimmed .status-updated {
  color: var(--text-mute);
}

.meta-status.is-fresh .status-updated {
  color: var(--good);
}

.meta-status.is-refreshing .status-bar-fill {
  background: linear-gradient(90deg, #3b6fd4, #8eb6ff);
}

.meta-status .status-bar-track {
  width: 100%;
  height: 2px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.meta-status .status-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(212, 162, 74, 0.85), var(--accent));
  transform-origin: left center;
}

.header-controls {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ctrl-btn:hover,
.ctrl-btn:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line-strong);
  color: var(--text);
  outline: none;
}

.winner-celebrate {
  opacity: 0.4;
  /* Emoji glyphs draw larger than their nominal size — keep below button box */
  font-size: 16px;
  line-height: 1;
}

.winner-celebrate:hover,
.winner-celebrate:focus-visible {
  opacity: 1;
}

.winner-celebrate.is-active,
.winner-celebrate[aria-pressed="true"] {
  opacity: 1;
  background: rgba(61, 207, 142, 0.18);
  border-color: rgba(61, 207, 142, 0.5);
  box-shadow: 0 0 16px rgba(61, 207, 142, 0.25);
}

.demo-badge {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  border: 1px solid rgba(240, 179, 90, 0.35);
  color: var(--warn);
  font-size: 11px;
  letter-spacing: 0.2em;
  font-weight: 700;
}

/* ---------- Stale banner ---------- */
.stale-banner {
  padding: 8px 18px;
  background: var(--warn-soft);
  border-bottom: 1px solid rgba(240, 179, 90, 0.35);
  color: #ffd79a;
  font-size: clamp(12px, 1.3vh, 14px);
  text-align: center;
}

/* ---------- Main layout (≈⅔ results · ⅓ media) ---------- */
.main {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0;
}

.results-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 30%);
}

.results-content {
  height: 100%;
  overflow: auto;
  padding: clamp(14px, 1.6vw, 28px);
  padding-bottom: clamp(14px, 1.6vw, 28px);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  /* Stretch children so the districts panel fills leftover height */
  display: flex;
  flex-direction: column;
}

.results-content > .totals-block {
  flex: 0 0 auto;
}

.results-content > .districts-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.districts-wrap > .districts-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Cards hug their data; the map row absorbs leftover height instead */
.districts-panel > .district-grid {
  flex: 0 0 auto;
}

.districts-panel > .district-map-row {
  flex: 1 1 auto;
  min-height: clamp(150px, 24vh, 520px);
  max-height: min(48vh, 760px);
}

.results-empty {
  height: 100%;
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--text-dim);
  gap: 8px;
}

.empty-title {
  margin: 0;
  font-size: clamp(18px, 2.2vh, 26px);
  color: var(--text);
}

.empty-sub {
  margin: 0;
  max-width: 42ch;
  color: var(--text-mute);
}

/* Totals */
.totals-block {
  display: grid;
  gap: 12px;
  margin-bottom: clamp(18px, 2vh, 28px);
}

.totals-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.totals-heading h2 {
  margin: 0;
  font-size: clamp(14px, 1.5vh, 18px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 650;
}

.totals-heading .vote-sum {
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

.candidate-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) 2fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.25s ease, background 0.25s ease;
}

.candidate-row.is-leader {
  border-color: rgba(212, 162, 74, 0.45);
  background: linear-gradient(90deg, rgba(212, 162, 74, 0.10), rgba(16, 24, 38, 0.92) 55%);
}

.candidate-row.is-winner {
  border-color: rgba(61, 207, 142, 0.55);
  background: linear-gradient(90deg, rgba(61, 207, 142, 0.14), rgba(16, 24, 38, 0.95) 60%);
  transform: scale(1.02);
  z-index: 1;
}

.candidate-row.is-winner .cand-name,
.candidate-row.is-winner .cand-votes,
.candidate-row.is-winner .cand-pct {
  font-size: 1.22em;
  font-weight: 800;
}

.candidate-row.is-dimmed {
  opacity: 0.42;
  filter: saturate(0.7);
}

.cand-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-weight: 700;
  font-size: clamp(16px, 2vh, 24px);
}

.cand-name-text {
  min-width: 0;
}

.cand-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.party-badge,
.incumbent-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

.party-badge.party-r {
  color: #fff4f2;
  background: var(--party-r);
}

.party-badge.party-i {
  color: #e8fffb;
  background: var(--party-i);
}

.incumbent-badge {
  color: #f4dfb0;
  background: rgba(212, 162, 74, 0.18);
  border: 1px solid rgba(212, 162, 74, 0.4);
}

.candidate-row.party-r.is-leader {
  border-color: rgba(201, 69, 58, 0.45);
  background: linear-gradient(90deg, rgba(201, 69, 58, 0.12), rgba(16, 24, 38, 0.92) 55%);
}

.candidate-row.party-i.is-leader {
  border-color: rgba(61, 155, 143, 0.45);
  background: linear-gradient(90deg, rgba(61, 155, 143, 0.12), rgba(16, 24, 38, 0.92) 55%);
}

.cand-check {
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--good);
  color: #042417;
  font-weight: 900;
  font-size: 14px;
  place-items: center;
}

.candidate-row.is-winner .cand-check {
  display: grid;
}

.bar-wrap {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3b6fd4, #6ea0ff);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.candidate-row.is-leader .bar-fill {
  background: linear-gradient(90deg, #b8862f, var(--accent));
}

.candidate-row.is-winner .bar-fill {
  background: linear-gradient(90deg, #1f9d66, var(--good));
}

.cand-stats {
  text-align: right;
  min-width: 9ch;
}

.cand-votes {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  font-size: clamp(18px, 2.4vh, 30px);
  line-height: 1.1;
}

.cand-votes.flash {
  animation: voteFlash 0.8s ease;
}

.cand-pct {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: clamp(12px, 1.4vh, 15px);
}

@keyframes voteFlash {
  0% { color: var(--accent); text-shadow: 0 0 18px rgba(212, 162, 74, 0.6); }
  100% { color: var(--text); text-shadow: none; }
}

/* Districts section (map + cards) */
.districts-wrap {
  margin-bottom: clamp(10px, 1.4vh, 18px);
}

.districts-panel {
  padding: 12px 14px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.districts-panel-heading {
  margin-bottom: 10px;
}

.districts-panel-heading h3 {
  margin: 0;
  font-size: clamp(13px, 1.4vh, 16px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 650;
}

/* Map + winner call side-by-side when declared */
.district-map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0fr;
  gap: 0;
  align-items: stretch;
  margin-bottom: 12px;
  transition: grid-template-columns 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    gap 0.45s ease;
}

.district-map-row.has-winner {
  grid-template-columns: minmax(0, 1.15fr) minmax(200px, 0.85fr);
  gap: 12px;
  position: relative;
  z-index: 10; /* keep map + winner above fireworks */
}

.district-map-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  /* Fill whatever height the flex-grown map row provides */
  max-height: 100%;
  transition: background 0.45s ease;
}

.district-map-row.has-winner .district-map-stage {
  /* Let fireworks read through the map area */
  background: transparent;
}

.district-map-img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: lighten;
  opacity: 1;
  transition: opacity 0.55s ease;
}

.district-map-row.has-winner .district-map-img {
  opacity: 0.5;
}

.ctrl-btn.edit-pencil {
  opacity: 0.4;
  font-size: 16px;
  line-height: 1;
}

.ctrl-btn.edit-pencil:hover,
.ctrl-btn.edit-pencil:focus-visible {
  opacity: 1;
  color: var(--accent);
  border-color: rgba(212, 162, 74, 0.45);
}

.ctrl-btn.edit-pencil.is-active {
  opacity: 1;
  color: #042417;
  background: var(--good);
  border-color: rgba(61, 207, 142, 0.55);
}

.district-row .dist-vote-input {
  width: 7.5ch;
  margin: 0;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(212, 162, 74, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: inherit;
  text-align: right;
}

.district-row .dist-vote-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 162, 74, 0.2);
}

/* Edit-mode district management (remove ✕ on cards + Add district card) */
.dist-remove-btn {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid rgba(201, 69, 58, 0.4);
  background: rgba(201, 69, 58, 0.12);
  color: #f2a49b;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dist-remove-btn:hover,
.dist-remove-btn:focus-visible {
  background: var(--party-r);
  border-color: var(--party-r);
  color: #fff;
  outline: none;
}

.add-district-card {
  border-style: dashed;
  border-left-width: 1px;
  background: rgba(212, 162, 74, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.add-district-card h4 {
  color: var(--accent);
  margin-bottom: 0;
}

.add-district-row {
  display: flex;
  gap: 8px;
}

.add-district-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(212, 162, 74, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: inherit;
}

.add-district-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 162, 74, 0.2);
}

.add-district-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid rgba(212, 162, 74, 0.5);
  background: rgba(212, 162, 74, 0.18);
  color: #f4dfb0;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-district-btn:hover,
.add-district-btn:focus-visible {
  background: rgba(212, 162, 74, 0.35);
  outline: none;
}

.add-district-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-mute);
}

/* Per-district percent reported */
.dist-pct {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(212, 162, 74, 0.3);
  background: rgba(212, 162, 74, 0.1);
  color: var(--accent);
  font-size: 0.78em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.district-pct-row {
  color: var(--text-mute);
  font-size: 0.9em;
}

.district-row .dist-pct-input {
  width: 7.5ch;
  margin: 0;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px dashed rgba(212, 162, 74, 0.35);
  background: rgba(0, 0, 0, 0.3);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: inherit;
  text-align: right;
}

.district-row .dist-pct-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212, 162, 74, 0.2);
}

.county-pct {
  color: var(--accent);
  font-weight: 700;
}

.meta-status.is-static .status-bar-track {
  display: none;
}

.district-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.district-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 14px;
  border-left: 3px solid rgba(255, 255, 255, 0.12);
}

.district-card.won-r {
  border-left-color: var(--party-r);
  background: linear-gradient(90deg, rgba(201, 69, 58, 0.08), rgba(255, 255, 255, 0.02) 40%);
}

.district-card.won-i {
  border-left-color: var(--party-i);
  background: linear-gradient(90deg, rgba(61, 155, 143, 0.08), rgba(255, 255, 255, 0.02) 40%);
}

.district-card.is-early-vote {
  border-color: rgba(212, 162, 74, 0.28);
  border-left-color: var(--accent);
  background:
    linear-gradient(90deg, rgba(212, 162, 74, 0.12), rgba(255, 255, 255, 0.02) 45%),
    rgba(255, 255, 255, 0.02);
}

.district-card.is-early-vote h4 {
  color: #f4dfb0;
}

.early-vote-note {
  margin: -4px 0 8px;
  color: var(--text-mute);
  font-size: clamp(11px, 1.2vh, 12px);
  letter-spacing: 0.02em;
}

.district-card h4 {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(13px, 1.4vh, 15px);
  color: var(--text-dim);
  font-weight: 650;
}

.district-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 4px 0;
  font-size: clamp(12px, 1.35vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.district-row:first-of-type {
  border-top: 0;
}

.district-row strong {
  font-variant-numeric: tabular-nums;
}

.district-row.is-dist-leader {
  font-weight: 700;
}

.district-row.is-winner-cand {
  color: var(--good);
  font-weight: 700;
}

.party-inline {
  color: var(--text-mute);
  font-weight: 500;
  font-size: 0.92em;
}

/* Fireworks — over dashboard; map/winner row stacks above for readability */
.fireworks-canvas {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

/* Winner call — sits to the right of the county map inside Districts */
.winner-banner {
  position: relative;
  z-index: 1;
  pointer-events: none;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 14, 22, 0.92), rgba(8, 14, 22, 0.72));
  border: 1px solid transparent;
  box-shadow: none;
  opacity: 0;
  backdrop-filter: blur(2px);
}

.winner-banner.hidden {
  display: none;
}

.district-map-row.has-winner .winner-banner:not(.hidden) {
  display: flex;
  padding: clamp(12px, 1.8vh, 22px) clamp(14px, 2vw, 28px);
  border-color: rgba(61, 207, 142, 0.4);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(61, 207, 142, 0.14),
    0 0 48px rgba(255, 255, 255, 0.05);
}

.winner-banner.show {
  animation: winnerIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.winner-banner.hide {
  animation: winnerOut 0.35s ease forwards;
}

.winner-banner-label {
  display: block;
  font-family: var(--display);
  font-size: clamp(28px, 4.2vh, 56px);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
  background: linear-gradient(180deg, #fff 10%, #b8f0d2 55%, var(--good) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 14px rgba(61, 207, 142, 0.35));
}

.winner-banner-name {
  display: block;
  margin-top: 8px;
  font-size: clamp(14px, 1.8vh, 22px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e8fff3;
  font-weight: 650;
  line-height: 1.25;
  max-width: 18ch;
}

@keyframes winnerIn {
  0% { opacity: 0; transform: translateX(18px) scale(0.92); }
  60% { opacity: 1; transform: translateX(0) scale(1.03); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes winnerOut {
  to { opacity: 0; transform: translateX(10px) scale(0.96); }
}

/* (status chip lives in header-meta) */

/* ---------- Right column ---------- */
.right-col {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, var(--photo-split)) var(--dex-h) minmax(0, 1fr);
  background: #05080f;
}

.photo-pane {
  position: relative;
  overflow: hidden;
  background: transparent;
  /* Soften all four edges (~15%) into the page background */
  --photo-edge-fade: 15%;
  -webkit-mask-image:
    linear-gradient(
      to right,
      transparent 0%,
      #000 var(--photo-edge-fade),
      #000 calc(100% - var(--photo-edge-fade)),
      transparent 100%
    ),
    linear-gradient(
      to bottom,
      transparent 0%,
      #000 var(--photo-edge-fade),
      #000 calc(100% - var(--photo-edge-fade)),
      transparent 100%
    );
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(
      to right,
      transparent 0%,
      #000 var(--photo-edge-fade),
      #000 calc(100% - var(--photo-edge-fade)),
      transparent 100%
    ),
    linear-gradient(
      to bottom,
      transparent 0%,
      #000 var(--photo-edge-fade),
      #000 calc(100% - var(--photo-edge-fade)),
      transparent 100%
    );
  mask-composite: intersect;
}

.photo-pane .slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Prefer faces: when cropping, pin to the top of the source photo */
  object-position: var(--photo-crop-position, 50% 0%);
  opacity: 0;
  transition: opacity 0.85s ease;
  background: transparent;
}

.photo-pane .slide.active {
  opacity: 1;
}

.photo-overlay {
  position: absolute;
  inset: auto 0 0 0;
  height: 22%;
  background: linear-gradient(transparent, rgba(7, 11, 18, 0.35));
  pointer-events: none;
}

.dex-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #101722, #0b111a);
  user-select: none;
}

.dex-splitter {
  position: absolute;
  left: 0;
  right: 0;
  top: -6px;
  height: calc(100% + 12px);
  cursor: ns-resize;
  z-index: 2;
}

.dex-logo,
.dex-text {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.dex-logo {
  opacity: 0.9;
  filter: drop-shadow(0 0 6px rgba(79, 140, 255, 0.25));
}

.dex-text {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}

.video-pane {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.video-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.video-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(79, 140, 255, 0.16), transparent 45%),
    linear-gradient(160deg, #0c1422, #070b12 70%);
}

.video-fallback-inner {
  max-width: 28ch;
  text-align: center;
}

.video-fallback-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}

.video-fallback-title {
  margin: 0 0 8px;
  font-size: clamp(16px, 2vh, 22px);
  font-weight: 750;
}

.video-fallback-copy {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Fixed footer (photo strip + ticker) ---------- */
.site-footer {
  height: var(--footer-h);
  min-height: var(--footer-h);
  max-height: var(--footer-h);
  display: grid;
  grid-template-rows: var(--footer-photos-h) var(--ticker-h);
  overflow: hidden;
  z-index: 6;
  border-top: 1px solid var(--line);
  background: #070b12;
}

.footer-photos {
  /* Near-square tiles: less vertical crop on portrait people photos */
  --footer-photo-w: calc(var(--footer-photos-h) * 1.15);
  --footer-photo-overlap: calc(var(--footer-photo-w) * 0.1);
  --photo-crop-position: 50% 0%;
  height: var(--footer-photos-h);
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border-bottom: 1px solid var(--line);
  /* Soften left/right ends (~15%) and fade the top 5% into the page background */
  -webkit-mask-image:
    linear-gradient(
      90deg,
      transparent 0%,
      #000 15%,
      #000 85%,
      transparent 100%
    ),
    linear-gradient(
      to bottom,
      transparent 0%,
      #000 5%,
      #000 100%
    );
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(
      90deg,
      transparent 0%,
      #000 15%,
      #000 85%,
      transparent 100%
    ),
    linear-gradient(
      to bottom,
      transparent 0%,
      #000 5%,
      #000 100%
    );
  mask-composite: intersect;
}

.footer-photos-track {
  display: flex;
  align-items: stretch;
  width: max-content;
  height: 100%;
  gap: 0;
  padding: 0;
  animation: footerPhotosScroll 120s linear infinite;
  will-change: transform;
}

.footer-photos:hover .footer-photos-track {
  animation-play-state: paused;
}

.footer-photo {
  position: relative;
  flex: 0 0 auto;
  width: var(--footer-photo-w);
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  /* Overlap neighbors ~10% and blend edges so the strip reads as one image */
  margin-left: calc(var(--footer-photo-overlap) * -1);
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 14%,
    #000 86%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0%,
    #000 14%,
    #000 86%,
    transparent 100%
  );
}

.footer-photo:first-child {
  margin-left: 0;
}

/* Same crop box model as .photo-pane .slide — absolute fill + top-pinned cover */
.footer-photo img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: var(--photo-crop-position, 50% 0%);
  image-orientation: from-image;
  transition: filter 0.6s ease;
}

/* Dim the photo strip during the victory treatment so fireworks pop */
body.winner-declared .footer-photo img {
  filter: brightness(0.5) saturate(0.85);
}

.footer-photos-empty {
  display: flex;
  align-items: center;
  padding: 0 18px;
  color: var(--text-mute);
  font-size: 12px;
  white-space: nowrap;
}

@keyframes footerPhotosScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker {
  height: var(--ticker-h);
  min-height: var(--ticker-h);
  max-height: var(--ticker-h);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: stretch;
  background: linear-gradient(180deg, #101826, #0a111c);
  overflow: hidden;
}

.ticker-chip {
  display: grid;
  place-items: center;
  padding: 0 10px;
  background: linear-gradient(180deg, rgba(212, 162, 74, 0.22), rgba(212, 162, 74, 0.08));
  border-right: 1px solid rgba(212, 162, 74, 0.28);
  color: #f4dfb0;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.ticker-track-wrap {
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}

.ticker-track {
  display: flex;
  width: max-content;
  align-items: center;
  height: 100%;
  gap: 0;
  animation: tickerScroll 60s linear infinite;
}

.ticker:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  white-space: nowrap;
  color: var(--text);
  font-size: 16px;
  font-weight: 550;
  line-height: 1;
}

.ticker-item::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
  box-shadow: 0 0 8px rgba(212, 162, 74, 0.4);
}

@keyframes tickerScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- Buttons / modal / settings ---------- */
.btn-primary,
.btn-ghost {
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #5a93ff, #3b6fd4);
  border-color: rgba(140, 180, 255, 0.35);
  color: white;
  font-weight: 650;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
  color: var(--text-dim);
}

.btn-ghost:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  border-radius: 16px;
  background: #121b2b;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.modal-title {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-body {
  margin: 0 0 18px;
  color: var(--text-dim);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settings-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100%;
  background: #0e1624;
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  margin: 0;
  font-size: 18px;
}

.settings-form {
  padding: 16px 18px 28px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  outline: none;
  border-color: rgba(79, 140, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.fieldset legend {
  padding: 0 6px;
  color: var(--text-mute);
  font-size: 12px;
}

/* Slideshow photo manager (Settings drawer) */
.photo-manager-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-mute);
}

.photo-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-upload-row input[type="file"] {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
}

.photo-upload-row .btn-primary {
  flex: 0 0 auto;
}

.photo-upload-status {
  margin: 0;
  font-size: 12px;
  color: var(--good);
}

.photo-upload-status.is-error {
  color: #f2a49b;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-tile {
  position: relative;
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  aspect-ratio: 1 / 1;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  display: block;
}

.photo-tile.is-hidden img {
  opacity: 0.25;
  filter: grayscale(0.8);
}

.photo-tile.is-upload {
  border-color: rgba(212, 162, 74, 0.45);
}

.photo-tile-btn {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  padding: 4px 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.photo-tile-btn:hover,
.photo-tile-btn:focus-visible {
  background: var(--accent);
  color: #1a1206;
  outline: none;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  grid-template-columns: none !important;
}

.checkbox-row input {
  width: auto;
}

.hint {
  color: var(--text-mute);
  font-weight: 400;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.import-area {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.wake-video {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  bottom: 0;
  right: 0;
}

/* Responsive / DeX */
@media (max-width: 1100px) {
  .main {
    grid-template-columns: 1.7fr 1fr;
  }

  .candidate-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .cand-stats {
    text-align: left;
  }

  .header-race-line {
    gap: 6px;
  }
}

@media (max-width: 820px) {
  .district-map-row.has-winner {
    grid-template-columns: 1fr;
  }

  .winner-banner-name {
    max-width: none;
  }

  .app {
    grid-template-rows: auto auto minmax(0, 1fr) var(--footer-h);
    overflow: hidden;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
    height: auto;
  }

  .header-brand {
    width: 100%;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(50vh, auto) minmax(40vh, auto);
  }

  .results-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* ---------- Large displays (4K / DeX TV at 100% zoom) ----------
   The base clamps cap out at laptop sizes; raise the ceilings so a
   3840×2160 viewport reads like the old 175% browser zoom. */
@media (min-width: 2200px) and (min-height: 1300px) {
  :root {
    --ui-scale: 1.5;
    --header-h: clamp(130px, 12vh, 220px);
    --footer-photos-h: clamp(120px, 14vh, 220px);
    --ticker-h: 64px;
    --dex-h: 44px;
  }

  .header-title {
    font-size: clamp(40px, 3.6vh, 80px);
  }

  .header-eyebrow,
  .race-chip,
  .meta-label {
    font-size: clamp(15px, 1.2vh, 24px);
  }

  .meta-value {
    font-size: clamp(22px, 1.9vh, 40px);
  }

  .ctrl-btn {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    font-size: 26px;
  }

  .winner-celebrate {
    font-size: 24px;
  }

  .header-controls {
    gap: 12px;
  }

  .totals-heading h2,
  .districts-panel-heading h3 {
    font-size: clamp(20px, 1.5vh, 30px);
  }

  .cand-name {
    font-size: clamp(26px, 2.1vh, 44px);
  }

  .cand-votes {
    font-size: clamp(30px, 2.5vh, 54px);
  }

  .cand-pct {
    font-size: clamp(18px, 1.4vh, 28px);
  }

  .party-badge,
  .incumbent-badge {
    min-width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .bar-wrap {
    height: 22px;
  }

  .district-card h4 {
    font-size: clamp(20px, 1.5vh, 30px);
  }

  .district-row,
  .early-vote-note {
    font-size: clamp(18px, 1.4vh, 26px);
  }

  .districts-panel > .district-map-row {
    min-height: clamp(300px, 26vh, 900px);
    max-height: min(50vh, 1100px);
  }

  .district-grid {
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 20px;
  }

  .ticker-chip {
    font-size: 20px;
  }

  .ticker-item {
    font-size: 27px;
  }

  .winner-banner-label {
    font-size: clamp(48px, 4.6vh, 110px);
  }

  .winner-banner-name {
    font-size: clamp(24px, 2vh, 42px);
  }
}
