:root {
  --lime: #c8f31d;
  --plum: #3b0a26;
  --plum-80: rgba(59, 10, 38, 0.8);
  --plum-50: rgba(59, 10, 38, 0.5);
  --plum-20: rgba(59, 10, 38, 0.18);
  --plum-10: rgba(59, 10, 38, 0.09);
  --pad: clamp(16px, 3.6vw, 44px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--lime);
  color: var(--plum);
  font-family: 'Archivo', system-ui, sans-serif;
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
input { user-select: text; -webkit-user-select: text; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--plum); outline-offset: 3px; }

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

#stage {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  display: block;
  touch-action: none;
}

.grain {
  position: fixed; inset: -50%;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */

.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(var(--pad) * 0.75) var(--pad) 0;
  padding-top: max(calc(var(--pad) * 0.75), env(safe-area-inset-top));
  z-index: 5;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.brand { display: block; line-height: 0; }
#logo { height: clamp(34px, 4.4vw, 46px); width: auto; }

.trail {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; gap: 22px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  pointer-events: none;
}
.trail span { opacity: 0.28; transition: opacity 0.6s var(--ease); position: relative; }
.trail span.is-past { opacity: 0.55; }
.trail span.is-now { opacity: 1; }
.trail span.is-now::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 2px;
  background: var(--plum); border-radius: 2px;
  animation: grow 0.8s var(--ease) both;
}
@keyframes grow { from { transform: scaleX(0); } }
body[data-step="intro"] .trail, body[data-step="done"] .trail, body[data-step="loading"] .trail { opacity: 0; }
.trail { transition: opacity 0.6s var(--ease); }

.top-actions { display: flex; gap: 6px; }

.quiet {
  background: none; border: 0;
  padding: 10px 12px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
  border-radius: 999px;
  transition: background-color 0.3s var(--ease), opacity 0.3s;
}
.quiet:hover { background: var(--plum-10); }
body[data-step="join"] #skipBtn, body[data-step="done"] #skipBtn { opacity: 0; pointer-events: none; }

/* ---------- panels ---------- */

.panel {
  position: fixed;
  left: var(--pad);
  bottom: calc(max(var(--pad), env(safe-area-inset-bottom)) + var(--kb, 0px));
  width: min(440px, calc(100vw - var(--pad) * 2));
  z-index: 4;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.45s;
}
.panel.is-on { visibility: visible; pointer-events: auto; transition-delay: 0s; }

.panel .r {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(6px);
  transition:
    opacity 0.35s ease,
    transform 0.45s var(--ease),
    filter 0.35s ease;
}
.panel.is-on .r {
  opacity: 1; transform: none; filter: none;
  transition:
    opacity 0.7s ease calc(0.28s + var(--i, 0) * 70ms),
    transform 1.1s var(--ease) calc(0.28s + var(--i, 0) * 70ms),
    filter 0.7s ease calc(0.28s + var(--i, 0) * 70ms);
}

.panel--center {
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--plum-80);
}

.title {
  margin: 0 0 12px;
  font-size: clamp(30px, 3.6vw, 50px);
  line-height: 0.95;
  font-weight: 900;
  font-variation-settings: 'wdth' 118;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.body, .lede {
  margin: 0 0 20px;
  font-size: 16px; line-height: 1.45;
  color: var(--plum-80);
  max-width: 36ch;
  text-wrap: pretty;
}
.lede { font-size: 17px; font-weight: 500; margin-bottom: 18px; }

.note { margin: 0 0 18px; font-size: 14px; color: var(--plum-50); min-height: 1.4em; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */

.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 54px; padding: 0 26px;
  border: 0; border-radius: 999px;
  background: var(--plum); color: var(--lime);
  font-size: 15px; font-weight: 750;
  font-variation-settings: 'wdth' 110;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: transform 0.5s var(--spring), background-color 0.3s, color 0.3s, box-shadow 0.4s var(--ease);
  box-shadow: 0 10px 24px -14px rgba(59, 10, 38, 0.65);
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -14px rgba(59, 10, 38, 0.7); }
.cta:active { transform: scale(0.96); transition-duration: 0.12s; }
.cta[disabled] { opacity: 0.55; cursor: default; transform: none; }
.cta--ghost { background: transparent; color: var(--plum); box-shadow: inset 0 0 0 2px var(--plum); }
.cta--ghost:hover { box-shadow: inset 0 0 0 2px var(--plum); }
.cta--ghost.is-holding { background: var(--plum); color: var(--lime); }

.hold {
  display: inline-flex; align-items: center; gap: 12px;
  border: 0; background: none;
  padding: 12px 18px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  border-radius: 999px;
  transition: background-color 0.3s;
}
.hold:hover { background: var(--plum-10); }
.hold-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--plum);
  box-shadow: 0 0 0 0 rgba(59, 10, 38, 0.4);
  animation: pulse 1.8s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 10, 38, 0.45); }
  70%, 100% { box-shadow: 0 0 0 12px rgba(59, 10, 38, 0); }
}

/* ---------- flavours ---------- */

.flavors {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px;
  margin: 2px 0 12px;
  border-top: 2px solid var(--plum);
  padding-top: 4px;
}
.flavor {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 4px;
  width: 100%; min-height: 34px;
  padding: 5px 0;
  border: 0; border-bottom: 1px solid var(--plum-10); background: none; text-align: left;
  opacity: 0.4;
  transition: opacity 0.45s var(--ease);
}
.flavor:hover { opacity: 0.75; }
.flavor[aria-checked="true"] { opacity: 1; }
.flavor .n { font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.flavor .nm {
  font-size: clamp(15px, 1.25vw, 18px); font-weight: 820; line-height: 1.02;
  font-variation-settings: 'wdth' 108; letter-spacing: -0.005em;
}
.flavor .sw {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), inset 0 2px 3px rgba(255, 255, 255, 0.5);
  transform: scale(0.7);
  transition: transform 0.6s var(--spring);
}
.flavor[aria-checked="true"] .sw { transform: scale(1.15); }

.other { margin: -4px 0 12px; }
.other input {
  width: 100%; height: 46px; padding: 0 18px;
  border: 2px solid var(--plum); border-radius: 999px;
  background: rgba(255, 255, 255, 0.25); color: var(--plum);
  font: inherit; font-size: 15px; font-weight: 600;
  outline: none;
  transition: box-shadow 0.4s var(--ease);
}
.other input::placeholder { color: var(--plum-50); font-weight: 500; }
.other input:focus { box-shadow: 0 0 0 5px var(--plum-20); }

/* ---------- scale readout ---------- */

.readout {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 4px 0 20px;
  border-top: 2px solid var(--plum);
}
.readout > div { padding: 10px 0 0; }
.readout > div + div { padding-left: 12px; border-left: 1px solid var(--plum-20); }
.readout dt { font-size: 11px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--plum-50); margin-bottom: 6px; }
.readout dd { margin: 0; display: flex; align-items: baseline; gap: 3px; }
.readout b {
  font-size: clamp(24px, 2.4vw, 30px); font-weight: 850; line-height: 1;
  font-variation-settings: 'wdth' 112;
  font-variant-numeric: tabular-nums;
}
.readout small { font-size: 13px; font-weight: 600; color: var(--plum-50); }
.readout b.bump { animation: bump 0.45s var(--spring); }
@keyframes bump { 40% { transform: translateY(-3px); } }

/* ---------- join form ---------- */

.join { margin: 0; }
.field { position: relative; display: flex; }
.field input {
  flex: 1; min-width: 0;
  height: 62px;
  padding: 0 170px 0 24px;
  border: 2px solid var(--plum); border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: var(--plum);
  font: inherit; font-size: 17px; font-weight: 550;
  outline: none;
  transition: box-shadow 0.4s var(--ease), background-color 0.3s;
}
.field input::placeholder { color: var(--plum-50); }
.field input:focus { box-shadow: 0 0 0 5px var(--plum-20); background: rgba(255, 255, 255, 0.4); }
.field .cta { position: absolute; right: 5px; top: 5px; height: 52px; padding: 0 22px; }
.field.is-shake { animation: shake 0.5s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.fine a { color: var(--plum); font-weight: 600; text-underline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fine { margin: 12px 0 0 24px; font-size: 12.5px; color: var(--plum-50); }
.err { margin: 6px 0 0 24px; min-height: 1.3em; font-size: 13.5px; font-weight: 600; color: #8b0020; }

/* ---------- done ---------- */

.votes { display: grid; gap: 9px; margin: 2px 0 22px; }
.vote { display: grid; grid-template-columns: 112px 1fr 44px; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.vote .bar { height: 8px; border-radius: 8px; background: var(--plum-10); overflow: hidden; }
.vote .bar i {
  display: block; height: 100%; border-radius: 8px;
  background: var(--c);
  transform-origin: left; transform: scaleX(0);
  transition: transform 1.4s var(--ease);
}
.vote .pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--plum-80); }
.vote.is-mine .nm::after { content: ' · yours'; font-weight: 500; color: var(--plum-50); }

/* ---------- hold ring cursor ---------- */

.ring {
  position: fixed; left: 0; top: 0;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  will-change: transform;
}
.ring.is-on { opacity: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 3; }
.ring-track { stroke: var(--plum-20); }
.ring-fill { stroke: var(--plum); stroke-linecap: round; stroke-dasharray: 169.65; stroke-dashoffset: 169.65; }
.ring span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
}
@media (hover: none) { .ring { display: none; } }

/* ---------- loader ---------- */

.loader {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: var(--lime);
  transition: opacity 0.8s var(--ease), visibility 0s linear 0.8s;
}
.loader span {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--plum-20); border-top-color: var(--plum);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
body:not([data-step="loading"]) .loader { opacity: 0; visibility: hidden; }

.noscript { position: fixed; inset: auto 16px 16px; z-index: 20; font-weight: 600; }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .trail { display: none; }
  .quiet { padding: 8px 10px; font-size: 12.5px; }
  .title { font-size: 30px; }
  .body { font-size: 15px; margin-bottom: 14px; }
  .eyebrow { margin-bottom: 8px; }
  .flavors { gap: 0 12px; }
  .flavor { grid-template-columns: 20px 1fr auto; min-height: 30px; padding: 3px 0; }
  .flavor .nm { font-size: 14.5px; }
  .other input { height: 42px; }
  .note { display: none; }
  .readout { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
  .readout > div + div { padding-left: 8px; }
  .readout dt { font-size: 9.5px; letter-spacing: 0.08em; }
  .readout b { font-size: 22px; }
  .field input { flex: none; width: 100%; height: 56px; padding-right: 24px; }
  .field { flex-direction: column; gap: 8px; }
  .field .cta { position: static; height: 54px; width: 100%; }
  .fine, .err { margin-left: 4px; }
  .cta { width: 100%; }
  .row .quiet { width: 100%; }
  .vote { grid-template-columns: 96px 1fr 40px; }
}

@media (max-width: 720px) and (max-height: 700px) {
  .body { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel .r, .panel.is-on .r { transition-duration: 0.01s !important; transition-delay: 0s !important; filter: none; transform: none; }
  .hold-dot { animation: none; }
}
