@font-face {
  font-family: "Barlow Condensed";
  src: url("/assets/barlow-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("/assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --rock: #101621;
  --panel: #1a2331;
  --recess: #252f3f;
  --line: #3b4657;
  --paper: #fffaf0;
  --muted: #c1cad8;
  --lamp: #ffd089;
  --lamp-ink: #22190e;
  --rise: cubic-bezier(.22, 1, .36, 1);
  --heading: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--paper);
  font-family: var(--body);
  background: radial-gradient(ellipse at 15% 0%, #26354c 0, var(--rock) 57%) fixed;
}
body[data-view="stage"] {
  background: radial-gradient(ellipse at 20% 5%, #2a374b 0, transparent 55%),
    radial-gradient(ellipse at 85% 130%, #322b2c 0, transparent 48%), var(--rock);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--lamp);
  outline-offset: 4px;
}
img { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--heading); font-weight: 700; text-wrap: balance; }
h1 { line-height: .99; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.initial-status { padding: 40px 24px; color: var(--muted); }
.tone-1 { --option: #ffd089; }
.tone-2 { --option: #9dcbff; }
.tone-3 { --option: #f6a690; }

.masthead {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.brand img { width: 32px; border-radius: 7px; }
.brand b { color: var(--paper); }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.status-badge span { display: inline-block; width: 8px; height: 8px; background: currentColor; border-radius: 50%; }
.status-badge.is-live { color: var(--lamp); }
.status-badge.is-live span { box-shadow: 0 0 14px #ffd08966; }
.art { width: 100%; height: auto; background: var(--recess); }
.connection {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 3;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--paper);
  background: var(--panel);
}
.primary, .secondary {
  min-height: 51px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: background 160ms ease, transform 160ms var(--rise);
}
.primary { color: var(--lamp-ink); background: var(--lamp); }
.primary:hover:not(:disabled) { background: #ffe1b1; }
.primary:active:not(:disabled) { transform: scale(.985); }
.primary:disabled { color: var(--muted); background: var(--recess); border-color: var(--line); }
.secondary { color: var(--paper); border-color: var(--line); background: var(--recess); }
.notice { color: #ffc7af; font-size: 14px; line-height: 1.4; }
.text-button, .fullscreen, .motion-toggle {
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}
.text-button:hover, .fullscreen:hover, .motion-toggle:hover { border-color: var(--line); color: var(--paper); }
.motion-toggle { font-size: 13px; padding-inline: 0; text-decoration: underline; text-underline-offset: 3px; }
:fullscreen .fullscreen { visibility: hidden; }

.stage-shell {
  position: relative;
  margin-inline: auto;
  max-width: 2000px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(20px, 2.6vw, 52px) clamp(24px, 4vw, 76px);
}
.stage-shell .brand { font-size: clamp(15px, 1.25vw, 23px); }
.stage-shell .status-badge { font-size: clamp(14px, 1.2vw, 22px); }
.stage-layout { display: grid; align-items: center; margin-block: auto; padding-block: 26px; }
.stage-wait { grid-template-columns: minmax(0, 1fr) minmax(260px, 31%); gap: clamp(24px, 5vw, 96px); }
.stage-wait h1 { font-size: clamp(53px, min(6vw, 10.6vh), 112px); letter-spacing: -.014em; margin: 14px 0 28px; }
.stage-wait .motif-strip { max-width: 960px; }
.motif-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.motif {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  border-bottom: 3px solid var(--option);
}
.motif .art { height: 100%; object-fit: cover; }
.stage-wait .motif { aspect-ratio: 16 / 9; }
.motion-frame { position: relative; isolation: isolate; }
.motion-frame video {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 200ms ease;
}
.motion-frame video.playing { opacity: 1; }
.qr-panel {
  display: grid;
  justify-items: center;
  min-width: 0;
  gap: 8px;
  padding: 0 0 18px;
  border-radius: clamp(12px, 1.7vw, 30px);
  overflow: hidden;
  background: #fff;
  color: #131720;
  text-align: center;
}
.qr-panel img { width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.qr-panel strong { font-size: clamp(17px, 1.75vw, 32px); line-height: 1.15; }
.qr-panel a { font-size: clamp(13px, 1.3vw, 25px); text-decoration: none; }
.qr-panel a:hover { text-decoration: underline; }
.stage-open { grid-template-columns: minmax(0, 1fr) minmax(175px, 23%); gap: clamp(28px, 4vw, 72px); }
.stage-open h1 { font-size: clamp(38px, 4.05vw, 76px); margin: 10px 0 23px; }
.live-lanes { display: grid; gap: clamp(8px, 1.1vh, 18px); }
.live-lane {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(84px, 19%) minmax(0, 1fr);
  gap: clamp(12px, 1.7vw, 30px);
  padding: 6px clamp(12px, 2vw, 36px) 6px 6px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.live-lane .art { aspect-ratio: 3 / 2; height: auto; border-radius: 5px; }
.lane-detail h2 { font-size: clamp(26px, 2.9vw, 55px); line-height: 1; margin-bottom: .29em; text-wrap: wrap; }
.track {
  height: clamp(12px, 2vh, 24px);
  overflow: hidden;
  border-radius: 3px;
  background: var(--recess);
}
.fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--option), var(--panel) 38%), var(--option));
  transform: scaleX(var(--portion, 0));
  transform-origin: left center;
  transition: transform 620ms var(--rise);
}
.stage-open .qr-panel strong { font-size: clamp(14px, 1.4vw, 26px); }
.stage-open .qr-panel a { font-size: clamp(12px, 1.2vw, 22px); }

.stage-result { margin-block: auto; padding-block: clamp(12px, 1.45vh, 20px); }
.result-heading { text-align: center; margin-bottom: clamp(21px, 3vh, 46px); }
.stage-result h1 { font-size: clamp(60px, min(6.3vw, 10.2vh), 125px); margin-top: 8px; }
.result-cards { display: grid; gap: 12px; }
.stage-result .result-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 34px); }
.result-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.result-card.leader { border-color: var(--option); box-shadow: inset 0 0 0 1px var(--option); }
.result-art { position: relative; overflow: hidden; }
.result-art .art { aspect-ratio: 3 / 2; height: 100%; object-fit: contain; }
.result-data { padding: 12px; }
.result-data h2 { line-height: 1.02; text-wrap: wrap; }
.result-numbers { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.result-count, .result-percent { color: var(--muted); font-variant-numeric: tabular-nums; }
.result-count strong { font-family: var(--heading); color: var(--paper); line-height: .9; }
.result-percent { margin-left: auto; font-weight: 700; }
.result-marker { color: var(--option); font-size: 13px; font-weight: 700; margin-top: 6px; }
.result-total { color: var(--muted); text-align: center; margin-top: 18px; font-size: 14px; }
.stage-result .result-data { padding: clamp(12px, 1.6vw, 30px); min-height: clamp(120px, 17vh, 198px); }
.stage-result .result-data h2 { font-size: clamp(24px, 2.42vw, 47px); }
.stage-result .result-numbers { margin-top: 10px; }
.stage-result .result-count { font-size: clamp(14px, 1.5vw, 26px); }
.stage-result .result-count strong { font-size: clamp(44px, 6vw, 124px); }
.stage-result .result-percent { font-size: clamp(18px, 2.1vw, 38px); }
.stage-result .result-marker, .stage-result .result-total { font-size: clamp(14px, 1.25vw, 22px); }
.reveal .result-card { animation: poster-in 720ms var(--rise) both; }
.reveal .result-card:nth-child(2) { animation-delay: 100ms; }
.reveal .result-card:nth-child(3) { animation-delay: 200ms; }
.reveal .result-numbers, .reveal .result-marker { animation: number-in 590ms 680ms var(--rise) both; }
.stage-result.reveal .result-card::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(108deg, transparent 30%, #fff5d966 48%, transparent 63%);
  animation: light-sweep 1280ms 150ms var(--rise) both;
}
@keyframes poster-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes number-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes light-sweep {
  from { transform: translateX(-90%); opacity: 0; }
  25% { opacity: 1; }
  to { transform: translateX(105%); opacity: 0; }
}

.mobile-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  margin-inline: auto;
}
.mobile-shell h1 { font-size: clamp(36px, 9.5vw, 51px); letter-spacing: .002em; margin: 8px 0 16px; }
.mobile-wait, .mobile-thanks { padding-top: clamp(28px, 8vh, 80px); }
.mobile-wait .motif-strip { margin-top: 20px; }
.mobile-wait .motif { aspect-ratio: 3 / 2; }
.mobile-hint { color: var(--muted); margin-top: 15px; line-height: 1.5; font-size: 15px; max-width: 34ch; }
.mobile-poll, .mobile-result { padding-top: 16px; }
.mobile-poll h1 { text-wrap: wrap; }
.ballot { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.poll-option {
  position: relative;
  display: grid;
  grid-template-columns: 37% minmax(0, 1fr) 22px;
  gap: clamp(6px, 2.3vw, 14px);
  align-items: center;
  padding: 5px 10px 5px 5px;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: transform 140ms var(--rise), background 140ms ease, border-color 140ms ease;
}
.poll-option:active { transform: scale(.985); }
.poll-option:has(input:focus-visible) { outline: 3px solid var(--lamp); outline-offset: 3px; }
.poll-option:has(input:checked) { border-color: var(--option); background: color-mix(in srgb, var(--option) 12%, var(--panel)); }
.poll-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.poll-option .art { aspect-ratio: 3 / 2; border-radius: 5px; }
.option-title { font-family: var(--heading); font-size: clamp(22px, 5.9vw, 32px); line-height: .99; font-weight: 700; }
.selection-mark { width: 20px; height: 20px; border: 1px solid #9caabe; border-radius: 50%; }
.poll-option:has(input:checked) .selection-mark {
  background: radial-gradient(circle, var(--option) 0 45%, transparent 46%);
  border-color: var(--option);
}
.vote-actions {
  position: sticky;
  bottom: 0;
  padding: 10px 0 max(6px, env(safe-area-inset-bottom));
  background: var(--rock);
  box-shadow: 0 -10px 22px var(--rock);
  margin-top: 9px;
}
.vote-actions .primary { width: 100%; min-height: 52px; }
.vote-actions .notice { margin-bottom: 8px; }
.receipt-art { aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; border: 2px solid var(--option); animation: receipt 750ms var(--rise); }
.receipt-art .art { width: 100%; height: 100%; object-fit: cover; object-position: center 62%; }
.receipt-choice { font: 700 28px/1.05 var(--heading); margin-top: 14px; }
@keyframes receipt {
  from { box-shadow: 0 0 0 0 var(--option); }
  to { box-shadow: 0 0 0 14px transparent; }
}
.mobile-result .result-card { display: grid; grid-template-columns: 37% minmax(0, 1fr); gap: 2px; min-height: 102px; }
.mobile-result .result-art { display: flex; align-items: center; }
.mobile-result .result-art .art { height: auto; }
.mobile-result .result-data h2 { font-size: clamp(21px, 5.9vw, 29px); }
.mobile-result .result-count { font-size: 13px; }
.mobile-result .result-count strong { font-size: 34px; }
.mobile-result .result-percent { font-size: 15px; }

.control-shell { width: min(calc(100% - 32px), 720px); margin-inline: auto; padding-block: 16px 36px; }
.control-panel { margin-top: 36px; padding: clamp(20px, 5vw, 44px); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.control-panel h1 { margin: 0 0 16px; font-size: clamp(46px, 10vw, 70px); }
.control-panel .status-badge { margin-bottom: 8px; }
.control-panel form { display: grid; gap: 10px; max-width: 440px; }
.control-panel label { font-weight: 700; }
.control-panel input {
  min-height: 49px;
  padding: 9px 12px;
  color: var(--paper);
  background: var(--rock);
  border: 1px solid #637187;
  border-radius: 7px;
}
.control-question { color: var(--muted); line-height: 1.45; max-width: 46ch; }
.control-count { color: var(--muted); margin: 12px 0 20px; }
.control-count strong { color: var(--paper); font: 700 54px/1 var(--heading); font-variant-numeric: tabular-nums; }
.control-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; color: var(--lamp); }
.control-panel .notice { margin-top: 8px; }
dialog {
  width: min(calc(100% - 32px), 500px);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--paper);
  background: var(--panel);
}
dialog::backdrop { background: #070b14bb; }
dialog h2 { font-size: 37px; margin-bottom: 8px; }
dialog p { color: var(--muted); line-height: 1.45; }
dialog form { display: flex; flex-wrap: wrap; margin-top: 20px; gap: 8px; }

@media (max-width: 900px) {
  .stage-wait h1 { font-size: clamp(44px, 7.4vw, 70px); }
  .stage-open h1 { font-size: clamp(38px, 5vw, 62px); }
}
@media (max-width: 620px) {
  .stage-shell { padding: 16px; }
  .stage-layout { gap: 22px; grid-template-columns: 1fr; }
  .stage-wait h1 { font-size: clamp(39px, 9.25vw, 57px); }
  .qr-panel { width: min(100%, 270px); justify-self: center; }
  .stage-open .qr-panel { width: min(100%, 195px); }
  .stage-result .result-cards { grid-template-columns: 1fr; }
  .stage-result .result-card { display: grid; grid-template-columns: 39% 1fr; align-items: center; }
  .stage-result .result-data { min-height: 0; }
  .stage-result h1 { font-size: clamp(42px, 11vw, 60px); }
}
@media (max-height: 800px) and (min-width: 901px) {
  .stage-shell { padding-block: 20px; }
  .stage-layout { padding-block: 16px; }
  .stage-wait h1 { font-size: clamp(50px, min(6vw, 10.6vh), 81px); margin-bottom: 20px; }
  .stage-open h1 { font-size: clamp(42px, 6.2vh, 65px); margin-bottom: 13px; }
  .live-lane { grid-template-columns: minmax(84px, min(19%, 21vh)) minmax(0, 1fr); }
  .stage-result { padding-block: 18px; }
  .stage-result h1 { font-size: clamp(58px, 10.2vh, 92px); }
  .stage-result .result-card .art { max-height: 35vh; background: var(--panel); }
  .stage-result .result-count strong { font-size: clamp(52px, 9.2vh, 76px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
