:root {
  --bg: #FAFAF7;
  --paper: #FFFFFF;
  --ink: #141414;
  --mute: #66625A;
  --line: #E4E2DC;
  --gold: #B3261E;
  --green: #2E6B45;
  --green-bg: #E3EDE3;
  --red: #9B2C22;
  --red-bg: #F3E0DC;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --stage: min(86vw, 38dvh, 420px);
  --cta-h: calc(82px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
em { font-style: italic; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand, .mute {
  background: none; border: 0; padding: 6px 0;
  font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
}
.brand { white-space: nowrap; }
.mute { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--ink); }
.mute svg { width: 20px; height: 20px; }
body[data-screen="home"] .brand { visibility: hidden; }
.hud { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.hud[hidden] { display: none; }
.hearts { display: flex; gap: 5px; }
.hearts i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); transition: background .3s; }
.hearts i.on { background: var(--ink); }
.hud-level { color: var(--mute); white-space: nowrap; }
.hud-level b { color: var(--ink); font-weight: 600; }
.hud-score { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; display: inline-block; }

/* ---------- screens ---------- */
main { padding: 0 16px calc(var(--cta-h) + 8px); max-width: 520px; margin: 0 auto; }
.screen { display: none; text-align: center; }
.screen.active { display: block; animation: screenIn .5s var(--ease); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } }

.title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(56px, 17vw, 84px); line-height: .88; letter-spacing: -.01em;
  margin: 8px 0 14px;
}
.title em { color: var(--gold); }
.title.small { font-size: clamp(40px, 11vw, 56px); line-height: 1; margin-top: 12vh; }
.subtitle { color: var(--ink); font-size: 17px; font-weight: 500; line-height: 1.4; margin: 0 0 22px; }
.banner {
  display: inline-block; margin: 4px 0 0; padding: 6px 12px; border: 1px solid var(--gold);
  color: var(--gold); border-radius: 999px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.banner[hidden] { display: none; }
.chip { margin: 4px 0 4px; color: var(--mute); font-size: 13px; color: var(--ink); letter-spacing: .02em; }
.best-line { color: var(--mute); font-size: 13px; margin: 4px 0; min-height: 1em; }
.tagline { font-family: var(--serif); font-size: 24px; line-height: 1.2; margin-top: 36px; color: var(--mute); }
.tagline em { color: var(--ink); }
.big-score {
  font-family: var(--serif); font-size: 88px; line-height: 1; margin: 24px 0 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- stage ---------- */
.stage-wrap { display: flex; justify-content: center; }
.stage {
  position: relative; width: var(--stage); aspect-ratio: 1;
  border-radius: 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 24px 48px -28px rgba(40, 30, 10, .45);
  transition: box-shadow .35s var(--ease);
  user-select: none;
}
.frame-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 24px; background: #8a8a8a; }
.stage .frame { position: absolute; display: block; max-width: none; }
.strip { position: absolute; transition: box-shadow .3s var(--ease), transform .3s var(--ease), filter .3s; }
.strip img { width: 100%; height: 100%; display: block; }

.stage[data-active="frame"] { box-shadow: 0 0 0 2px var(--gold), 0 24px 48px -28px rgba(40,30,10,.45); }
.stage[data-active="frame"] .strip { filter: brightness(.82) saturate(.8); }
.stage[data-active="eyes"] .strip[data-part="eyes"],
.stage[data-active="nose"] .strip[data-part="nose"],
.stage[data-active="mouth"] .strip[data-part="mouth"] {
  z-index: 2; transform: scale(1.04);
  box-shadow: 0 0 0 2px var(--gold), 0 10px 24px -8px rgba(0,0,0,.45);
  animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe { 50% { box-shadow: 0 0 0 4px rgba(179,38,30,.45), 0 10px 24px -8px rgba(0,0,0,.45); } }
.stage[data-active="eyes"] .strip:not([data-part="eyes"]),
.stage[data-active="nose"] .strip:not([data-part="nose"]),
.stage[data-active="mouth"] .strip:not([data-part="mouth"]) { filter: brightness(.8); }

.stage.revealing .frame-clip { filter: brightness(.72); transition: filter .4s; }
.frame-clip { transition: filter .4s; }
.stage.revealing .strip { box-shadow: 0 14px 30px -10px rgba(0,0,0,.55); z-index: 2; }

/* ---------- game ---------- */
.prompt {
  font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 8.5vw, 40px); line-height: 1.05;
  margin: 2px 0 14px;
}
.prompt em { color: var(--gold); }
.eyebrow {
  display: block; font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px;
}
.timer {
  width: var(--stage); height: 3px; margin: 14px auto 0; background: var(--line); border-radius: 2px; overflow: hidden;
}
.timer[hidden] { display: none; }
.timer span {
  display: block; height: 100%; background: var(--gold); transform-origin: left;
  transform: scaleX(var(--p, 1)); transition: background .3s;
}
.timer.danger span { background: var(--red); }
.hint-text { min-height: 20px; margin: 12px 0 8px; font-size: 14px; color: var(--mute); font-style: italic; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  font-size: 15px; font-weight: 500; text-align: left; line-height: 1.15;
  transition: transform .18s var(--ease), border-color .2s, background .2s, opacity .3s, box-shadow .2s;
}
.options.with-thumbs .opt { justify-content: flex-start; padding: 8px 10px; }
.opt-flag { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: #F1F0EC; font-size: 22px; line-height: 1; }
.opt-name { min-width: 0; }
.opt-name span { display: block; color: var(--mute); font-weight: 400; }
.opt-name, .opt-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt:active { transform: scale(.97); }
.opt.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), 0 8px 18px -12px rgba(0,0,0,.5); transform: translateY(-1px); }
.opt.out { opacity: .28; text-decoration: line-through; }
.opt.done { pointer-events: none; }
.opt.done:not(.correct):not(.wrong) { opacity: .45; }
.opt.correct { background: var(--green-bg); border-color: var(--green); box-shadow: 0 0 0 1px var(--green); color: var(--green); }
.opt.correct .opt-name span { color: var(--green); }
.opt.wrong { background: var(--red-bg); border-color: var(--red); box-shadow: 0 0 0 1px var(--red); color: var(--red); }
.options.enter .opt { animation: optIn .45s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes optIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.result { margin-top: 26px; }
.result[hidden] { display: none; }
.cast { list-style: none; padding: 0; margin: 0 auto 22px; max-width: 340px; text-align: left; }
.cast li {
  display: flex; align-items: baseline; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line);
  opacity: 0; transform: translateY(6px); transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.cast li.in { opacity: 1; transform: none; }
.cast .part { width: 54px; font-size: 10px; font-weight: 600; letter-spacing: .18em; color: var(--mute); }
.cast .who { flex: 1; font-size: 15px; font-weight: 500; }
.cast .mark { font-size: 13px; font-weight: 600; }
.cast .mark.ok { color: var(--green); }
.cast .mark.hint { color: var(--gold); }
.cast .mark.miss { color: var(--red); }
.result-body[hidden] { display: none; }
.result-kicker { font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--mute); margin: 0; }
.result-name { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 44px; line-height: 1; margin: 8px 0 10px; }
.result-line { font-family: var(--serif); font-size: 22px; line-height: 1.25; color: var(--ink); margin: 4px auto 14px; max-width: 26ch; }
.result-grid { font-size: 20px; letter-spacing: 4px; margin: 0 0 12px; }
.result-tag { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin: 0; }

/* ---------- CTA bar: one wide rounded button ---------- */
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.btn.primary {
  display: block; width: 100%; max-width: 520px; margin: 0 auto; height: 58px;
  border: 0; border-radius: 16px;
  background: var(--gold); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  box-shadow: 0 10px 22px -12px rgba(179,38,30,.7);
  transition: background .2s, color .2s, transform .15s var(--ease), box-shadow .2s;
}
.btn.primary:active:not(:disabled) { background: #8E1D17; transform: scale(.98); }
.btn.primary:disabled { background: #E4E2DC; color: #8F8B83; box-shadow: none; cursor: default; }

/* ---------- leader sheet ---------- */
.sheet-leader {
  touch-action: none; user-select: none; -webkit-user-select: none;
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(82px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; max-height: 58dvh; overflow: auto;
  padding: 10px 22px 18px; text-align: center;
  background: var(--paper); border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 40px -20px rgba(0,0,0,.35), 0 -1px 0 var(--line);
  transform: translateY(calc(100% + 100px)); visibility: hidden;
  transition: transform .55s cubic-bezier(.2,1.1,.3,1), visibility 0s .55s;
}
.sheet-leader.open { transform: none; visibility: visible; transition: transform .55s cubic-bezier(.2,1.1,.3,1); }
.sheet-leader.open.peek { transform: translateY(calc(100% - 64px)); }
.sheet-leader.open.peek .sheet-handle::after { background: var(--ink); }
.sheet-handle {
  display: block; width: 100%; height: 22px; margin: 0 0 6px; padding: 0; border: 0; background: none; position: relative;
}
.sheet-handle::after {
  content: ''; position: absolute; left: 50%; top: 8px; width: 38px; height: 4px; margin-left: -19px;
  border-radius: 2px; background: var(--line);
}
.result-msg { font-size: 15px; line-height: 1.5; color: var(--ink); margin: 0 auto 12px; max-width: 36ch; }
.sheet-leader .result-name { font-size: 38px; margin: 6px 0 12px; }
.sheet-leader .alt { margin-top: 8px; }

/* secondary actions sit inline, as quiet text buttons */
.alt-slot:empty { display: none; }
.alt {
  background: none; border: 0; padding: 10px 4px; margin: 6px 0 0;
  font-size: 14px; font-weight: 500; color: var(--ink);
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line);
}
.alt:disabled { opacity: .35; cursor: default; }
.alt[hidden] { display: none; }
.alt small {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px;
  border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 10px; vertical-align: 1px;
}
.hint-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin: 6px 0 4px; }
.hint-row .hint-text { margin: 0; text-align: left; flex: 1; }
.hint-row .alt { margin: 0; white-space: nowrap; }

/* ---------- effects ---------- */
.float-text {
  position: fixed; z-index: 40; pointer-events: none; white-space: nowrap;
  font-family: var(--serif); font-style: italic; font-size: 34px; color: var(--gold);
  text-shadow: 0 2px 0 var(--bg);
}
.float-text.combo { color: var(--ink); font-size: 30px; }
.float-text.bad { color: var(--red); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- share sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(20,20,20,0);
  display: flex; align-items: flex-end; justify-content: center; transition: background .25s;
}
.sheet-backdrop.open { background: rgba(20,20,20,.45); }
.sheet {
  width: 100%; max-width: 520px; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .3s var(--ease);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-preview { display: block; max-height: 42dvh; max-width: 100%; margin: 0 auto 16px; border-radius: 14px; box-shadow: 0 12px 30px -16px rgba(0,0,0,.5); }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sheet-grid > * {
  display: grid; place-items: center; height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500;
}
.sheet-close { width: 100%; height: 48px; margin-top: 10px; border: 0; background: none; color: var(--mute); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.result-body { scroll-margin-bottom: calc(var(--cta-h) + 12px); }
.hint-body { font-family: var(--serif); font-size: 26px; line-height: 1.2; color: var(--ink); margin: 12px auto 6px; max-width: 24ch; }
.hint-sheet { padding-bottom: 12px; }
