:root {
  --bg: #f8f4ec;
  --card: #ffffff;
  --ink: #1b1814;
  --muted: #6e665a;
  --line: #e7dfd1;
  --soft: #efe8db;
  --a: #ff5a4e;
  --b: #2f6ff0;
  --good: #14935a;
  --btn: #1b1814;
  --btn-ink: #f8f4ec;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13110e;
    --card: #1d1a16;
    --ink: #f3eee5;
    --muted: #a39b8e;
    --line: #322d26;
    --soft: #27231d;
    --a: #f0574b;
    --b: #4a84f2;
    --good: #35c27f;
    --btn: #f3eee5;
    --btn-ink: #13110e;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  max-width: 560px; margin: 0 auto; padding: 18px 16px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font: 800 22px/1 Fraunces, Georgia, serif; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--a); position: relative; }
.brand .dot::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--a); }
.meta { color: var(--muted); font-size: 13px; font-weight: 500; text-align: right; }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 64px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

.screen { animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2 { font-family: Fraunces, Georgia, serif; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(34px, 9vw, 48px); line-height: 1.05; font-weight: 800; }
h2 { font-size: clamp(25px, 6.4vw, 32px); line-height: 1.15; font-weight: 600; }
.sub { color: var(--muted); margin: 10px 0 0; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-top: 16px; }

.steps { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: baseline; }
.steps b { font-family: Fraunces, serif; font-size: 20px; color: var(--a); min-width: 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.label { font-size: 13px; font-weight: 600; margin-top: 14px; }
.label:first-child { margin-top: 0; }
.fine { font-size: 12px; color: var(--muted); margin-top: 12px; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 16px;
  background: var(--btn); color: var(--btn-ink); font-weight: 700; font-size: 17px; margin-top: 20px;
  transition: transform .08s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-top: 10px; }
.btn:disabled { opacity: .4; }
.row { display: flex; gap: 10px; }
.row .btn { margin-top: 10px; }

.progress { display: flex; gap: 6px; margin-bottom: 20px; }
.progress span { flex: 1; height: 5px; border-radius: 9px; background: var(--line); }
.progress span.done { background: var(--ink); }
.progress span.cur { background: var(--a); }

.opts { display: grid; gap: 12px; margin-top: 26px; }
.opt {
  text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  padding: 20px 18px; font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 14px;
  transition: border-color .15s, transform .08s;
}
.opt:hover { border-color: var(--ink); }
.opt:active { transform: scale(.985); }
.opt .sw { width: 14px; height: 14px; border-radius: 50%; flex: none; }

.picked { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 600; color: #fff; font-size: 13px; }

.bignum { font: 800 clamp(72px, 24vw, 110px)/1 Fraunces, serif; text-align: center; margin: 26px 0 8px; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.bignum small { font-size: .45em; color: var(--muted); }
.slider { width: 100%; margin: 6px 0 2px; accent-color: var(--a); height: 36px; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 9px; background: linear-gradient(to right, var(--fill) 0 var(--v), var(--line) var(--v) 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; border-radius: 50%; background: var(--card); border: 3px solid var(--ink); margin-top: -11px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 9px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 9px; background: var(--fill); }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--card); border: 3px solid var(--ink); }
.scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* reveal */
.headline { font: 800 clamp(40px, 12vw, 58px)/1 Fraunces, serif; letter-spacing: -0.03em; margin-top: 6px; }
.split { position: relative; height: 44px; border-radius: 12px; overflow: visible; display: flex; margin: 34px 0 10px; }
.split .seg { height: 100%; display: flex; align-items: center; padding: 0 12px; color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.split .seg:first-child { border-radius: 12px 0 0 12px; }
.split .seg:last-child { border-radius: 0 12px 12px 0; justify-content: flex-end; }
.marker { position: absolute; top: -28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 700; transition: left .9s cubic-bezier(.2,.8,.2,1); }
.marker::after { content: ''; width: 2px; height: 58px; background: var(--ink); margin-top: 2px; border-radius: 2px; }
.legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 22px; }

.verdict { display: flex; align-items: center; gap: 14px; }
.verdict .em { font-size: 40px; line-height: 1; }
.verdict .t { font-weight: 700; font-size: 18px; }
.verdict .s { color: var(--muted); font-size: 14px; }

.insight h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.insight p { margin: 10px 0 0; }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 110px 1fr 46px; gap: 10px; align-items: center; font-size: 14px; }
.bar .track { height: 12px; background: var(--soft); border-radius: 9px; overflow: hidden; position: relative; }
.bar .fill { height: 100%; border-radius: 9px; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.bar .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar .k { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hist { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 8px; }
.hist div { flex: 1; background: var(--soft); border-radius: 4px 4px 0 0; min-height: 2px; }
.hist .line { position: absolute; top: -6px; bottom: 0; width: 2px; border-radius: 2px; }
.hist .tag { position: absolute; top: -24px; transform: translateX(-50%); font-size: 11px; font-weight: 700; white-space: nowrap; }

/* summary */
.score { font: 800 96px/1 Fraunces, serif; letter-spacing: -0.04em; }
.score small { font-size: 32px; color: var(--muted); }
.grid { font-size: 34px; letter-spacing: 6px; margin-top: 6px; }
.qrow { display: grid; grid-template-columns: 28px 1fr; column-gap: 10px; row-gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; font-size: 14px; }
.qrow:first-child { border-top: 0; padding-top: 0; }
.qrow .q { font-weight: 500; }
.qrow .n { grid-column: 2; color: var(--muted); font-variant-numeric: tabular-nums; }
.countdown { text-align: center; margin-top: 26px; color: var(--muted); font-size: 14px; }
.countdown b { display: block; font: 700 30px/1.2 Fraunces, serif; color: var(--ink); font-variant-numeric: tabular-nums; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.err { color: var(--a); text-align: center; padding: 40px 0; }

/* crowd line on guess screen */
.crowd { margin-top: 10px; font-size: 14px; color: var(--muted); }
.crowd b { color: var(--ink); }

/* ---------- reveal animation ---------- */
.ticker { font-variant-numeric: tabular-nums; display: inline-block; min-width: 1.2ch; }
.fadein { opacity: 0; transition: opacity .4s; }
.fadein.in { opacity: 1; }

.stage { position: relative; margin: 64px 0 8px; padding-bottom: 46px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tl { position: relative; height: 22px; border-radius: 12px; }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 12px 0 0 12px; }
.gap {
  position: absolute; top: -4px; bottom: -4px; width: 0; opacity: 0;
  border: 2px solid var(--ink); border-radius: 8px;
  background: repeating-linear-gradient(-45deg, rgba(255,255,255,.55) 0 4px, transparent 4px 8px);
  transition: opacity .2s;
}
.gap.show { opacity: 1; }

.pin { position: absolute; top: 0; width: 0; height: 0; }
.pin .bub {
  position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap;
  font-weight: 800; font-size: 13px; padding: 4px 9px; border-radius: 8px; font-variant-numeric: tabular-nums;
}
.pin::before { content: ''; position: absolute; left: -1.5px; width: 3px; border-radius: 3px; }
/* your guess: above the line, drops in */
.pin.you .bub { bottom: 14px; background: var(--ink); color: var(--bg); }
.pin.you::before { bottom: -26px; height: 40px; background: var(--ink); }
.pin.you { animation: drop .55s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
/* the real answer: below the line */
.pin.act { top: 22px; opacity: 0; transition: opacity .2s; }
.pin.act.show { opacity: 1; }
.pin.act .bub { top: 14px; color: #fff; font-size: 15px; }
.pin.act::before { top: -26px; height: 40px; background: var(--ink); }
.pin.act.land .bub { animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { 0% { transform: translateX(-50%) scale(1); } 40% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }
.stage.landed .tl { animation: thud .35s ease-out; }
@keyframes thud { 30% { transform: scaleY(1.25); } }

.tl-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; position: absolute; left: 0; right: 0; bottom: 0; }
.skip { position: absolute; right: 0; top: -58px; font-size: 11px; color: var(--muted); opacity: .7; }

.pending { opacity: 0; pointer-events: none; }
.verdict.stamped { animation: stamp .5s cubic-bezier(.3,1.5,.5,1) both; }
.verdict.stamped .em { animation: stampEm .6s cubic-bezier(.3,1.7,.5,1) both; }
@keyframes stamp { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes stampEm { 0% { transform: scale(3) rotate(-25deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
.later.in > * { animation: in .45s ease both; }
.later.in > *:nth-child(2) { animation-delay: .1s; }
.later.in > *:nth-child(3) { animation-delay: .2s; }
.later.in > *:nth-child(4) { animation-delay: .3s; }
.later.in > *:nth-child(5) { animation-delay: .4s; }

.stage.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

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

/* one-graphic insight: each side's guess vs truth */
.dl-title { font: 600 20px/1.25 Fraunces, Georgia, serif; letter-spacing: -0.01em; margin: 0 0 18px; }
.dl-body { position: relative; }
.dl-row + .dl-row { margin-top: 16px; }
.dl-text { font-size: 15px; margin-bottom: 8px; }
.dl-track { position: relative; height: 6px; border-radius: 6px; background: var(--soft); }
.dl-seg { position: absolute; top: 0; bottom: 0; border-radius: 6px; opacity: .45; }
.dl-dot { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 3px var(--card); }
.dl-tick { position: absolute; top: -7px; bottom: -7px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.dl-truth { position: relative; height: 18px; margin-top: 8px; }
.dl-truth span { position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; font-weight: 700; white-space: nowrap; }
.dl-cap { font-size: 12px; color: var(--muted); margin-top: 6px; }

.more { margin-top: 12px; }
.more summary { list-style: none; cursor: pointer; text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); padding: 10px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ' ▾'; }
.more[open] summary::after { content: ' ▴'; }
.more-sec { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-top: 10px; }
.more-sec h4 { margin: 0 0 12px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* compact per-question recap on the score screen */
.mini { margin-top: 14px; border-top: 1px solid var(--line); }
.mrow { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mrow span:first-child { font-size: 13px; }
.mrow .q { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .n { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
/* each recap row opens to show the full question and a bit more */
.mq > summary { list-style: none; cursor: pointer; grid-template-columns: 20px 1fr auto 14px; }
.mq > summary::-webkit-details-marker { display: none; }
.mq > summary::after { content: '▾'; color: var(--muted); font-size: 14px; line-height: 1; text-align: right; transition: transform .2s; }
.mq[open] > summary::after { transform: rotate(180deg); }
.mq > summary:hover .q { color: var(--ink); }
.mq[open] > summary .q { color: var(--ink); }
.md { padding: 10px 0 16px 28px; border-bottom: 1px solid var(--line); font-size: 14px; }
.md p { margin: 0; }
.md-q { font-weight: 600; line-height: 1.35; }
.md-sub { color: var(--muted); font-size: 13px; margin-top: 4px !important; }
.md-split { display: flex; height: 10px; border-radius: 9px; overflow: hidden; margin-top: 14px; gap: 2px; }
.md-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.md-legend span:last-child { text-align: right; }
.md-legend em { font-style: normal; color: var(--ink); font-weight: 600; }
.md-line { margin-top: 12px !important; color: var(--muted); font-size: 13px; }
.md-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.md-quip { margin-top: 6px !important; font-size: 13px; font-style: italic; color: var(--muted); }
.md .card { margin-top: 12px; }


/* percentile curve on the score screen */
.pc-head { font: 600 22px/1.2 Fraunces, Georgia, serif; }
.pc-head b { color: var(--a); font-variant-numeric: tabular-nums; }
.pc-chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 110px; margin-top: 34px; }
.pc-bar { flex: 1; height: 0; background: var(--soft); border-radius: 3px 3px 0 0; transition: height .6s cubic-bezier(.2,.8,.2,1); }
.pc-bar.below { background: color-mix(in srgb, var(--a) 40%, var(--soft)); }
.pc-bar.me { background: var(--a); }
/* players who beat you: a clear neutral so the right tail reads on dark and light */
.pc-bar.above { background: color-mix(in srgb, var(--muted) 55%, var(--card)); }
.pc-you { position: absolute; top: -28px; transform: translateX(-50%) translateY(6px); opacity: 0; transition: opacity .3s .7s, transform .4s .7s cubic-bezier(.3,1.6,.5,1); }
.pc-you span { display: block; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; }
.pc-you::after { content: ''; display: block; width: 0; height: 0; margin: 0 auto; border: 5px solid transparent; border-top-color: var(--ink); }
.pc.go .pc-you { opacity: 1; transform: translateX(-50%); }
.pc-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.pc-cap { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* personal stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; text-align: center; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 4px; }
.stats b { display: block; font: 700 20px/1.2 Fraunces, Georgia, serif; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* share image sheet */
.linkbtn { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; animation: in .2s ease both; }
.sheet { background: var(--bg); border-radius: 20px; padding: 16px; width: 100%; max-width: 440px; }
.sheet img { display: block; width: 100%; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }

/* scale + number questions */
.scale-pick { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 8px; margin-top: 26px; }
.sc { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 18px 0; font: 700 22px/1 Fraunces, Georgia, serif; transition: border-color .15s, transform .08s; }
.sc:hover { border-color: var(--ink); }
.sc:active { transform: scale(.96); }
.scale-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.scale-labels span:last-child { text-align: right; }
.scale-labels.small { font-size: 11px; margin-top: 2px; }
.hl-unit { font-size: .5em; color: var(--muted); }
.adist { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-top: 34px; }
.adist-bar { flex: 1; background: color-mix(in srgb, var(--b) 35%, var(--soft)); border-radius: 4px 4px 0 0; }
.adist-bar.mine { background: var(--b); }
.adist-line, .adist-you { position: absolute; top: -8px; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); }
.adist-line > span, .adist-you > span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; white-space: nowrap; }
.adist-you { background: var(--b); }
.adist-you > span { color: var(--b); top: auto; bottom: -18px; }

.bonus-tag { display: inline-block; background: var(--a); color: #fff; border-radius: 6px; padding: 2px 6px; margin-right: 4px; letter-spacing: .06em; }
