:root {
  --bg: #09090b;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --text: #f5f5f4;
  --muted: #8b8b94;
  --dim: #56565e;
  --accent: #ff4d2e;
  --accent-2: #ff7a55;
  --accent-soft: rgba(255, 77, 46, .12);
  --accent-glow: rgba(255, 77, 46, .45);
  --ok: #3ddc97;
  --err: #ff8b73;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --p: 0;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent); color: #fff; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ───────── Background ───────── */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
  transition: translate 1.8s var(--ease-out);
}

.b1 {
  width: 70vmax; height: 70vmax;
  left: -22vmax; top: -38vmax;
  background: radial-gradient(closest-side, rgba(255, 77, 46, .34), transparent);
  animation: drift1 24s ease-in-out infinite alternate;
  translate: calc(var(--p) * 38vw) calc(var(--p) * 12vh);
}

.b2 {
  width: 60vmax; height: 60vmax;
  right: -26vmax; bottom: -32vmax;
  background: radial-gradient(closest-side, rgba(80, 90, 255, .15), transparent);
  animation: drift2 30s ease-in-out infinite alternate;
  translate: calc(var(--p) * -22vw) 0;
}

@keyframes drift1 { to { transform: translate(8vmax, 6vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-6vmax, -8vmax) scale(1.1); } }

.spot {
  position: absolute;
  inset: 0;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 40%), rgba(255, 255, 255, .045), transparent 60%);
}

.grain {
  position: absolute;
  inset: -50%;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(4) infinite;
}

@keyframes grain {
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -1%); }
  75% { transform: translate(-1%, -3%); }
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .6));
}

/* ───────── Top bar ───────── */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(clamp(16px, 3vw, 28px), env(safe-area-inset-top)) clamp(16px, 4vw, 40px) clamp(12px, 2vw, 20px);
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sep { color: var(--dim); }

.rec {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: rec 1.6s infinite;
}

@keyframes rec {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 46, .6); opacity: 1; }
  50% { opacity: .55; }
  70% { box-shadow: 0 0 0 8px rgba(255, 77, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 46, 0); opacity: 1; }
}

body[data-phase="done"] .rec { animation: none; background: var(--muted); }

.tc { color: var(--text); font-variant-numeric: tabular-nums; }

/* ───────── Stage ───────── */

#stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 1fr;
  justify-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px clamp(16px, 6vw, 64px);
  scrollbar-width: none;
  overscroll-behavior: contain;
}

#stage::-webkit-scrollbar { display: none; }

.step {
  grid-area: 1 / 1;
  width: min(720px, 100%);
  margin-block: auto;
}

.step.is-leaving { pointer-events: none; }

/* Word-by-word reveal */
.w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: 0 .06em .1em 0;
  margin: 0 -.06em -.1em 0;
}

.w > span {
  display: inline-block;
  animation: wordUp .9s var(--ease-out) backwards;
  animation-delay: calc(var(--i) * 28ms + var(--base, 0ms));
}

@keyframes wordUp { from { transform: translateY(110%); } }

.reveal {
  animation: rise .8s var(--ease-out) backwards;
  animation-delay: var(--d, 0ms);
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ───────── Question ───────── */

.q-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font: 500 12px/1 var(--mono);
  letter-spacing: .08em;
  color: var(--accent);
}

.q-meta .q-total { color: var(--dim); }

.q-title {
  margin: 0 0 14px;
  font-weight: 500;
  font-size: clamp(26px, 4.4vw, 44px);
  line-height: 1.12;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.q-title em, .hero em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.08em;
  letter-spacing: -.01em;
  color: var(--accent-2);
}

.q-help {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 1.8vw, 17px);
}

.q-field { margin-top: clamp(24px, 4vh, 40px); }

.input-wrap {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 4px;
  border-bottom: 1px solid var(--line-2);
}

.input-wrap::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .7s var(--ease-out);
}

.input-wrap:focus-within::after { transform: scaleX(1); }

.prefix, .input {
  font: 400 clamp(22px, 3.4vw, 32px)/1.3 var(--sans);
  letter-spacing: -.01em;
}

.prefix { color: var(--dim); }

.input {
  flex: 1;
  min-width: 0;
  padding: 10px 0 12px;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  caret-color: var(--accent);
}

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

textarea.input {
  resize: none;
  overflow: hidden;
  font-size: clamp(19px, 2.6vw, 24px);
  line-height: 1.45;
}

/* Choices */
.choices {
  display: grid;
  gap: 10px;
  max-width: 600px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: rgba(255, 255, 255, .025);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .25s, background-color .25s, transform .3s var(--ease-out);
}

.choice::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.choice.flash::before { animation: flash .42s; }

@keyframes flash {
  25%, 75% { opacity: .22; }
  50% { opacity: .04; }
}

@media (hover: hover) {
  .choice:hover { border-color: var(--line-2); background-color: rgba(255, 255, 255, .05); }
}

.choice:active { transform: scale(.985); }
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.choice kbd {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font: 500 12px var(--mono);
  color: var(--muted);
  transition: background-color .25s, border-color .25s, color .25s;
}

.c-label { flex: 1; font-weight: 500; line-height: 1.3; }

.c-label small {
  display: block;
  margin-top: 3px;
  font-weight: 400;
  font-size: 13.5px;
  color: var(--muted);
}

.c-check {
  flex: none;
  width: 20px; height: 20px;
  color: var(--accent);
}

.c-check path {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset .45s var(--ease-out);
}

.choice[aria-pressed="true"] {
  border-color: rgba(255, 77, 46, .7);
  background-color: var(--accent-soft);
}

.choice[aria-pressed="true"] kbd {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.choice[aria-pressed="true"] .c-check path { stroke-dashoffset: 0; }

/* Actions */
.q-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: clamp(14px, 3vh, 32px);
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  transition: transform .25s var(--ease-out), box-shadow .3s, background-color .3s, border-color .3s, color .3s;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 30px -12px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .25);
}

@media (hover: hover) {
  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 40px -10px rgba(255, 77, 46, .65), inset 0 1px 0 rgba(255, 255, 255, .25);
  }
  .btn:hover svg { transform: translateX(3px); }
  .btn-ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }
}

.btn svg {
  width: 16px; height: 16px;
  transition: transform .35s var(--ease-out);
}

.btn-ghost {
  background: rgba(255, 255, 255, .02);
  border-color: var(--line-2);
  color: var(--muted);
}

.btn[disabled] { cursor: progress; }

.spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn.is-loading .spinner { display: block; }
.btn.is-loading svg { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.hint { font-size: 13px; color: var(--dim); }

kbd.k {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  font: 500 11.5px var(--mono);
  color: var(--muted);
}

@media (pointer: coarse) { .hint { display: none; } }

.q-error {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--err);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .3s, transform .3s var(--ease-out);
}

.q-error.show { opacity: 1; transform: none; }
.q-error svg { flex: none; width: 16px; height: 16px; }

/* ───────── Intro ───────── */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 7px 13px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .03);
  font: 500 11.5px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.hero {
  margin: 0 0 22px;
  font-weight: 500;
  font-size: clamp(38px, 7.4vw, 78px);
  line-height: 1.02;
  letter-spacing: -.04em;
  text-wrap: balance;
}

.lead {
  max-width: 50ch;
  margin: 0;
  font-size: clamp(16px, 2vw, 19px);
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin-top: clamp(32px, 6vh, 56px);
  padding: 0;
  list-style: none;
  font: 500 11.5px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}

.meta-row li { display: flex; align-items: center; gap: 8px; }
.meta-row svg { width: 14px; height: 14px; color: var(--muted); }

/* ───────── Done ───────── */

.done { text-align: center; }

.clap {
  display: block;
  width: 96px;
  margin: 0 auto 30px;
  color: var(--text);
  animation: thud .35s ease-out .72s;
}

.clap-arm {
  transform-box: view-box;
  transform-origin: 12px 36px;
  animation: clap .5s cubic-bezier(.6, 0, .3, 1.5) .3s backwards;
}

@keyframes clap { from { transform: rotate(-32deg); } }
@keyframes thud { 40% { transform: translateY(3px) scale(1.03); } }

.done .hero { font-size: clamp(34px, 6vw, 64px); }
.done .lead { margin-inline: auto; }
.done .lead strong { color: var(--text); font-weight: 500; }

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* ───────── Timeline ───────── */

.timeline {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 20px);
  padding: clamp(12px, 2vw, 20px) clamp(16px, 4vw, 40px) max(clamp(14px, 2.5vw, 26px), env(safe-area-inset-bottom));
  transition: opacity .5s, transform .6s var(--ease-out);
}

body:not([data-phase="q"]) .timeline {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.counter {
  min-width: 58px;
  font: 500 12px var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.counter b { font-weight: 500; color: var(--text); }

.track { position: relative; flex: 1; height: 28px; }

.track::before, .fill {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 2px;
}

.track::before { right: 0; background: var(--line); }

.fill {
  width: calc(var(--p) * 100%);
  background: linear-gradient(90deg, rgba(255, 77, 46, .25), var(--accent));
  transition: width .9s var(--ease-out);
}

.playhead {
  position: absolute;
  top: 50%;
  left: calc(var(--p) * 100%);
  width: 2px; height: 18px;
  margin: -9px 0 0 -1px;
  border-radius: 2px;
  background: var(--text);
  box-shadow: 0 0 12px rgba(255, 255, 255, .45);
  transition: left .9s var(--ease-out);
  pointer-events: none;
}

.playhead::before {
  content: '';
  position: absolute;
  top: -6px; left: 50%;
  width: 10px; height: 7px;
  margin-left: -5px;
  background: var(--text);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.tick {
  position: absolute;
  top: 50%;
  width: 20px; height: 28px;
  margin: -14px 0 0 -10px;
  padding: 0;
  background: none;
  border: 0;
}

.tick::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 8px;
  margin-top: -4px;
  background: var(--line-2);
  transition: height .2s, margin .2s, background-color .3s;
}

.tick.done::after { background: var(--accent); }
.tick:disabled { cursor: default; }
.tick:not(:disabled):hover::after { height: 14px; margin-top: -7px; background: var(--text); }

.nav { display: flex; gap: 6px; }

.nav button {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  transition: background-color .2s, opacity .2s, transform .2s var(--ease-out);
}

.nav button:active { transform: scale(.94); }
.nav button:disabled { opacity: .3; cursor: default; }
.nav svg { width: 16px; height: 16px; }

@media (hover: hover) {
  .nav button:not(:disabled):hover { background: rgba(255, 255, 255, .08); }
}

/* ───────── Responsive ───────── */

@media (max-width: 640px) {
  .sep, .brand-title { display: none; }
  #stage { padding-block: 12px 20px; }
  .choice { padding: 13px 14px; gap: 12px; }
  .q-actions .btn { padding: 14px 22px; }
  .counter { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
