:root {
  --c: #ff2ea6;          /* era color, set from JS */
  --ink: #0b0b0b;
  --display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --body: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --pad: clamp(18px, 4vw, 40px);
  --ease: cubic-bezier(.2, .9, .1, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--c);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  transition: background-color .5s var(--ease);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 50; opacity: .14; mix-blend-mode: multiply;
  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%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad) max(var(--pad), env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden; transform: translateY(24px) scale(.985);
  transition: opacity .45s var(--ease), transform .55s var(--ease), visibility 0s .5s;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; z-index: 3; }
.bar-right { display: flex; align-items: center; gap: 10px; }
.mark { font-family: var(--display); font-weight: 900; font-size: 20px; letter-spacing: -.04em; }
.mark i { font-style: normal; display: inline-block; animation: blink 2.4s infinite; }
@keyframes blink { 0%, 92% { opacity: 1; } 95% { opacity: 0; } }
.chip {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 7px 12px; border: 1.5px solid var(--ink); border-radius: 99px; white-space: nowrap;
}
.chip:empty { display: none; }
.icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--ink); transition: transform .2s var(--ease), background .2s; }
.icon:active { transform: scale(.9); }

/* ---------- home dial ---------- */
.dial {
  flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; outline: none;
  margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.dial::-webkit-scrollbar { display: none; }
.dial { container-type: size; position: relative; }
.dial .spacer { height: calc(50cqh - var(--row) / 2); }
.dial { --row: min(26vw, 21vh); }
.yr {
  height: var(--row); display: flex; align-items: center; justify-content: center; width: 100%;
  scroll-snap-align: center;
  font-family: var(--display); font-weight: 900; line-height: .8; letter-spacing: -.06em;
  font-size: min(25vw, 19vh);
  opacity: .14; transform: scale(.72); transition: opacity .35s var(--ease), transform .45s var(--ease);
  font-variant-numeric: tabular-nums;
}
.yr sup { font-size: .32em; letter-spacing: -.02em; vertical-align: top; margin-left: .04em; line-height: 1.3; }
.yr.is-on { opacity: 1; transform: none; }
.yr.is-near { opacity: .32; transform: scale(.8); }
.yr em { font-style: normal; color: transparent; -webkit-text-stroke: max(2px, .018em) var(--ink); }

.home-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; position: relative; z-index: 3; }
.era-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.era-name { font-family: var(--display); font-weight: 700; font-size: clamp(18px, 3.4vw, 26px); letter-spacing: -.03em; }
.era-best { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; opacity: .7; }

.go {
  display: inline-flex; align-items: center; gap: 14px; flex-shrink: 0;
  background: var(--ink); color: var(--c);
  font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -.02em;
  height: 62px; padding: 0 22px 0 28px; border-radius: 99px;
  transition: transform .25s var(--ease), color .5s var(--ease);
}
.go svg { transition: transform .3s var(--ease); }
.go:active { transform: scale(.94); }

/* ---------- play ---------- */
.pips { flex: 1; display: flex; gap: 5px; max-width: 420px; }
.pips i { flex: 1; height: 6px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 16%, transparent); transition: background .3s, transform .3s var(--ease); }
.pips i.now { background: color-mix(in srgb, var(--ink) 45%, transparent); transform: scaleY(1.5); }
.pips i.ok { background: var(--ink); }
.pips i.no { background: repeating-linear-gradient(45deg, var(--ink) 0 2px, transparent 2px 5px); }
.score { font-family: var(--display); font-weight: 900; font-size: 22px; letter-spacing: -.04em; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

.timer { height: 3px; margin: 18px calc(var(--pad) * -1) 0; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.timer i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; }
.timer.low i { animation: pulse .5s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }

.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 760px; width: 100%; margin: 0 auto; gap: clamp(22px, 4vh, 40px); }
.q-meta { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.combo { font-family: var(--display); font-weight: 900; font-size: 13px; letter-spacing: 0; background: var(--ink); color: var(--c); padding: 5px 10px; border-radius: 99px; transform: scale(0); transition: transform .35s cubic-bezier(.3, 1.8, .5, 1); }
.combo.on { transform: scale(1); }
.combo.bump { animation: bump .4s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 40% { transform: scale(1.45) rotate(-6deg); } }

.question {
  font-family: var(--body); font-weight: 600; letter-spacing: -.035em; line-height: 1.08;
  font-size: clamp(26px, 5.2vw, 48px); text-wrap: balance;
}
.question .w { display: inline-block; opacity: 0; transform: translateY(.4em); animation: rise .5s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

.answers { display: grid; gap: 10px; }
@media (min-width: 720px) { .answers { grid-template-columns: 1fr 1fr; } }
.ans {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: 64px; padding: 14px 18px; border-radius: 18px;
  border: 2px solid var(--ink); font-weight: 600; font-size: clamp(16px, 2.2vw, 19px); letter-spacing: -.015em; line-height: 1.2;
  opacity: 0; transform: translateY(14px);
  animation: rise .45s var(--ease) forwards;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.ans kbd { font-family: var(--mono); font-size: 11px; font-weight: 600; width: 24px; height: 24px; flex-shrink: 0; display: grid; place-items: center; border-radius: 7px; border: 1.5px solid currentColor; opacity: .55; }
.ans:active:not(:disabled) { transform: scale(.97); }
.ans:disabled { cursor: default; }
.ans.right { background: var(--ink); color: var(--c); }
.ans.right kbd { opacity: 1; }
.ans.wrong { animation: shake .45s var(--ease) both; text-decoration: line-through; text-decoration-thickness: 2px; opacity: 1; }
.ans.dim { opacity: .3 !important; transition: opacity .3s; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

.pop {
  position: fixed; left: 50%; top: 44%; z-index: 20; pointer-events: none;
  font-family: var(--display); font-weight: 900; font-size: clamp(56px, 13vw, 130px); letter-spacing: -.06em;
  transform: translate(-50%, -50%) scale(.4); opacity: 0;
  -webkit-text-stroke: 0; white-space: nowrap;
}
.pop.go-up { animation: popup .95s var(--ease) forwards; }
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5) rotate(-8deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.05) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(.9) rotate(0); }
}

body.flash-ok::after, body.flash-no::after { content: ""; position: fixed; inset: 0; z-index: 10; pointer-events: none; animation: flash .5s ease-out forwards; }
body.flash-ok::after { background: #fff; }
body.flash-no::after { background: var(--ink); }
@keyframes flash { from { opacity: .35; } to { opacity: 0; } }

/* ---------- result ---------- */
.res { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.res-label { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; padding: 8px 14px; background: var(--ink); color: var(--c); border-radius: 99px; }
.res-score { font-family: var(--display); font-weight: 900; letter-spacing: -.07em; line-height: .85; font-size: min(30vw, 26vh); font-variant-numeric: tabular-nums; }
.res-sub { font-weight: 600; font-size: 18px; letter-spacing: -.02em; }
.res-grid { display: flex; gap: 6px; margin-top: 6px; }
.res-grid i { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--ink); opacity: 0; transform: scale(.3); animation: pip .4s cubic-bezier(.3, 1.8, .5, 1) forwards; }
.res-grid i.ok { background: var(--ink); }
@keyframes pip { to { opacity: 1; transform: none; } }
.res-best { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; min-height: 1em; }
.res-best.new { opacity: 1; animation: bump .6s cubic-bezier(.3, 1.8, .5, 1) 1.2s both; }

.res-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.res-actions .go { width: min(100%, 360px); justify-content: center; }
.res-row { display: flex; gap: 10px; width: min(100%, 360px); }
.ghost { flex: 1; height: 52px; border-radius: 99px; border: 2px solid var(--ink); font-weight: 600; font-size: 15px; transition: background .2s, color .2s, transform .2s var(--ease); }
.ghost:active { transform: scale(.95); }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 140%);
  background: var(--ink); color: var(--c); font-family: var(--mono); font-size: 13px; padding: 12px 18px; border-radius: 99px;
  opacity: 0; transition: transform .4s var(--ease), opacity .3s;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }

/* confetti shards */
.shard { position: fixed; z-index: 30; pointer-events: none; width: 10px; height: 16px; background: var(--ink); border-radius: 2px; }

/* Hover only where a real pointer exists — on touch screens :hover sticks to whatever lands under the last tap. */
@media (hover: hover) and (pointer: fine) {
  .icon:hover { background: var(--ink); color: var(--c); }
  .go:hover svg { transform: translateX(4px); }
  .ans:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 9%, transparent); }
  .ghost:hover { background: var(--ink); color: var(--c); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .grain { animation: none; }
}
