:root {
  --ink: #111; --muted: #5b5b66; --line: #e7e7ee; --bg: #fff; --accent: #3A2BD8; --accent-ink: #fff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(20px, 5vw, 48px);
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 0.08em; text-underline-offset: 0.15em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1:focus, h2:focus, [tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: #111; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

.screen { min-height: 100dvh; }
/* ── Entry ───────────────────────── */
#entry { display: grid; place-items: center; padding: calc(var(--pad) + var(--safe-top)) var(--pad) var(--pad); }
.entry-inner { width: min(100%, 640px); }
.brand { display: flex; gap: 6px; margin: 0 0 28px; }
.brand span { height: 6px; flex: 1; border-radius: 3px; background: #E5202E; }
.brand span:nth-child(2) { background: #0057FF; } .brand span:nth-child(3) { background: #0A8A3A; }
.brand span:nth-child(4) { background: #D6006B; } .brand span:nth-child(5) { background: var(--line); }
h1 { font-size: clamp(64px, 19vw, 148px); line-height: 0.88; letter-spacing: -0.05em; font-weight: 900; margin: 0 0 18px; }
.lead { font-size: clamp(19px, 4.6vw, 24px); line-height: 1.3; font-weight: 600; margin: 0 0 22px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.fields { display: grid; grid-template-columns: 0.9fr 2.3fr 1.3fr; gap: 8px; }
.fields label { display: flex; flex-direction: column; font-size: 13px; font-weight: 700; color: var(--muted); gap: 4px; }
.fields input, .fields select { font-size: 22px; font-weight: 800; padding: 12px 10px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); width: 100%; min-height: 60px; appearance: none; }
.fields select { background-image: linear-gradient(45deg, transparent 50%, #111 50%), linear-gradient(135deg, #111 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 30px; }
.fields input:focus, .fields select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
[aria-invalid="true"] { border-color: #E5202E !important; }
.error { color: #B3121D; font-weight: 700; margin: 12px 0 0; }
.big-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; padding: 14px 28px; margin-top: 18px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-size: 20px; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .15s ease; }
.big-btn:hover { transform: translateY(-1px); } .big-btn:active { transform: scale(.98); }
.big-btn.ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 3px var(--ink); }
.link-btn { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; font-weight: 700; }
.privacy { color: var(--muted); font-size: 14px; margin-top: 26px; max-width: 46ch; }

/* ── Loading ─────────────────────── */
#loading { display: grid; place-content: center; text-align: center; padding: var(--pad); gap: 8px; }
#loading h2 { font-size: clamp(30px, 8vw, 56px); line-height: 1; letter-spacing: -0.03em; font-weight: 900; margin: 18px 0 0; }
.loader { display: flex; gap: 10px; justify-content: center; }
.loader span { width: 18px; height: 18px; border-radius: 50%; background: #E5202E; animation: bob 0.9s ease-in-out infinite; }
.loader span:nth-child(2) { background: #0057FF; animation-delay: .15s; } .loader span:nth-child(3) { background: #0A8A3A; animation-delay: .3s; }
@keyframes bob { 50% { transform: translateY(-14px); } }

/* ── Story ───────────────────────── */
#story { position: relative; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.progress { display: flex; gap: 4px; padding: calc(10px + var(--safe-top)) var(--pad) 0; }
.seg { flex: 1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.seg .fill { display: block; height: 100%; width: 0; background: var(--accent); }
.seg.done .fill { width: 100%; background: var(--ink); }
.seg.now .fill { width: 100%; animation: fill .5s ease-out; }
@keyframes fill { from { width: 0; } }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 8px var(--pad) 0; }
.wordmark { font-weight: 900; letter-spacing: -0.02em; font-size: 15px; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #f2f2f6; font-size: 20px; font-weight: 800; cursor: pointer; display: grid; place-items: center; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:not(:disabled):hover { background: var(--accent); color: var(--accent-ink); }
.deck { position: relative; flex: 1; min-height: 0; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.navbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px var(--pad) calc(12px + var(--safe-bottom)); }
.hint { color: var(--muted); font-size: 13px; text-align: center; }

.card { position: absolute; inset: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; padding: 14px var(--pad) 10px; }
.card-inner { flex: 1; width: min(100%, 860px); margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
.card.enter-next { animation: inR .38s cubic-bezier(.2,.8,.2,1); } .card.enter-prev { animation: inL .38s cubic-bezier(.2,.8,.2,1); }
@keyframes inR { from { opacity: 0; transform: translateX(40px); } } @keyframes inL { from { opacity: 0; transform: translateX(-40px); } }
.kicker { display: inline-block; align-self: flex-start; margin: 0 0 14px; padding: 6px 12px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
.headline { font-size: clamp(40px, min(11.5vw, 11vh), 104px); line-height: .95; letter-spacing: -0.045em; font-weight: 900; margin: 0 0 20px; overflow-wrap: anywhere; hyphens: auto; }
.headline.small-h { font-size: clamp(34px, min(10.5vw, 8vh), 68px); }
.hl, .headline .count { color: var(--accent); }
.unit { font-size: .42em; letter-spacing: -0.02em; color: var(--ink); }
.small { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.note { background: #fff4d6; padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.source { width: min(100%, 860px); margin: 14px auto 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.source a { color: var(--muted); }

.moon-row { display: flex; align-items: center; gap: 22px; }
.moon { width: clamp(120px, 34vw, 200px); height: auto; flex: none; }
.moon .lit { fill: var(--accent); }
.moon-row .lead { margin: 0; }
.rhyme { font-size: clamp(20px, 5.2vw, 30px); font-weight: 800; font-style: italic; letter-spacing: -0.01em; margin: 26px 0 0; padding-left: 14px; border-left: 6px solid var(--accent); }
.stat-grid { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr; gap: 10px; }
.stat-grid li { display: flex; flex-direction: column; border-left: 6px solid var(--accent); padding: 2px 0 2px 14px; }
.stat-grid .count, .count-text { font-size: clamp(30px, 8.5vw, 52px); font-weight: 900; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-grid li > span:last-child { color: var(--muted); font-weight: 700; font-size: 14px; }
.planets { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 4px 28px; }
@media (min-width: 560px) { .planets { grid-template-columns: 1fr 1fr; } }
.planets li { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--line); padding: 6px 0; }
.pname { font-weight: 700; } .pval { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; } .punit { font-size: 13px; font-weight: 600; color: var(--muted); }
.choices { display: grid; gap: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 14px 18px; border-radius: 18px; border: 3px solid var(--ink); background: #fff; cursor: pointer; transition: transform .12s ease, background .2s; min-height: 64px; }
.choice:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 10%, #fff); transform: translateY(-1px); }
.c-title { font-weight: 800; font-size: 19px; line-height: 1.2; } .c-artist { color: var(--muted); font-weight: 600; font-size: 15px; }
.choices.answered .choice { opacity: .45; } .choices.answered .choice.right { opacity: 1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choices.answered .choice.right .c-artist { color: inherit; } .choices.answered .choice.wrong { opacity: 1; border-style: dashed; }
.reveal { margin-top: 16px; }
.verdict { font-weight: 900; font-size: 22px; margin: 0 0 6px; color: var(--accent); }
.song { font-size: clamp(32px, 8.5vw, 64px); font-weight: 900; letter-spacing: -0.035em; line-height: 1; margin: 0; color: var(--accent); }
.artist { font-size: clamp(20px, 5vw, 30px); font-weight: 800; margin: 8px 0 0; }
.films, .people, .events, .timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.films { counter-reset: f; } .films li { counter-increment: f; display: grid; grid-template-columns: 44px 1fr; align-items: baseline; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.films li::before { content: counter(f); grid-row: span 2; font-size: 34px; font-weight: 900; color: var(--accent); line-height: 1; }
.film { font-size: clamp(21px, 5.5vw, 30px); font-weight: 900; letter-spacing: -0.02em; text-decoration: none; line-height: 1.1; }
.film:hover { text-decoration: underline; } .meta { color: var(--muted); font-size: 14px; font-weight: 600; }
.events li { display: flex; gap: 14px; align-items: flex-start; font-size: 18px; font-weight: 600; } .events p { margin: 0; }
.thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; flex: none; background: var(--line); }
.people li { display: flex; flex-direction: column; border-left: 6px solid var(--accent); padding-left: 12px; }
.people strong { font-size: clamp(19px, 5vw, 26px); font-weight: 900; letter-spacing: -0.01em; } .people a { text-decoration: none; } .people a:hover { text-decoration: underline; }
.people span { color: var(--muted); font-size: 14px; font-weight: 600; }
.timeline li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: baseline; } .timeline p { margin: 0; font-weight: 600; }
.year { font-weight: 900; font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.prices { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.prices th, .prices td { text-align: left; padding: 9px 6px; border-bottom: 2px solid var(--line); vertical-align: top; }
.prices thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.prices tbody th { font-weight: 700; } .prices td strong { font-size: 22px; font-weight: 900; color: var(--accent); }
.adj { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.albums { display: grid; gap: 18px; }
.album { border-left: 6px solid var(--accent); padding-left: 14px; }
.album .song { font-size: clamp(28px, 7.5vw, 52px); }
.more { font-weight: 800; color: var(--accent); white-space: nowrap; }
.inv { margin-top: 16px; }
.tiles { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tiles li { background: color-mix(in srgb, var(--accent) 9%, #fff); border-radius: 18px; padding: 14px 18px; display: flex; flex-direction: column; }
.t-k { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.t-v { font-size: clamp(24px, 6.5vw, 36px); font-weight: 900; letter-spacing: -0.02em; } .t-n { font-size: 14px; color: var(--muted); font-weight: 600; }
.poster-wrap { display: flex; justify-content: center; }
.poster { width: min(100%, 320px); aspect-ratio: 4 / 5; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.14); background: var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.actions .big-btn { margin-top: 14px; }

dialog { border: 0; border-radius: 22px; padding: 26px; width: min(92vw, 640px); max-height: 86vh; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10,10,20,.45); }
dialog h2 { font-size: 32px; font-weight: 900; letter-spacing: -0.03em; margin: 0 0 12px; }
dialog li { margin-bottom: 8px; font-size: 15px; }

@media (min-width: 760px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); } .stat-grid.two { grid-template-columns: repeat(3, 1fr); }
  .choices { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .card-wide-cols { columns: 2; }
  .events { grid-template-columns: repeat(3, 1fr); } .events li { flex-direction: column; } .thumb { width: 100%; height: 160px; }
  .people { grid-template-columns: 1fr 1fr; }
  .albums { grid-template-columns: 1fr 1fr; gap: 36px; }
  .share-text { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "k p" "h p" "a p" "s p"; column-gap: 48px; align-items: start; align-content: center; }
  .share-text .kicker { grid-area: k; justify-self: start; } .share-text .headline { grid-area: h; } .share-text .actions { grid-area: a; justify-content: flex-start; }
  .share-text .small { grid-area: s; } .share-text .poster-wrap { grid-area: p; align-self: center; }
  .poster { width: min(100%, 380px); }
  .c-title { font-size: 22px; } .choice { padding: 18px 22px; }
}
@media (max-height: 700px) { .headline { font-size: clamp(36px, 9vw, 80px); margin-bottom: 12px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
/* v2: show that titles with a Wikipedia article are links, without shouting */
a.film, .people a { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--line); text-underline-offset: 5px; color: inherit; }
a.film:hover, a.film:focus-visible, .people a:hover, .people a:focus-visible { text-decoration-color: var(--accent); }
.timeline.inv li { grid-template-columns: 44px 1fr; column-gap: 0; }
.timeline.inv .year { font-size: 30px; }
.share-links { text-align: center; margin: 8px 0 0; } .share-links .link-btn { margin: 0 2px; }
@media (min-width: 900px) { .share-text .share-links { text-align: left; } }

/* ---------- Birthday number ones timeline ---------- */
.bt-summary { font-size: clamp(18px, 4.6vw, 24px); font-weight: 800; margin: -6px 0 14px; letter-spacing: -0.01em; }
.bt { position: relative; margin: 0 calc(var(--pad) * -1); }
.bt-viewport { position: relative; }
.bt-viewport::before, .bt-viewport::after { content: ''; position: absolute; top: 0; bottom: 0; width: 28px; z-index: 2; pointer-events: none; }
.bt-viewport::before { left: 0; background: linear-gradient(90deg, #fff, rgba(255,255,255,0)); }
.bt-viewport::after { right: 0; background: linear-gradient(270deg, #fff, rgba(255,255,255,0)); }
.bt-track {
  list-style: none; margin: 0; padding: 4px 0 6px; display: flex; gap: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; cursor: grab;
}
.bt-track::-webkit-scrollbar { display: none; }
.bt-track.is-dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.bt-track::before, .bt-track::after { content: ''; flex: 0 0 calc(50% - min(31vw, 120px) - 11px); }
.bt-item {
  flex: 0 0 min(62vw, 240px); box-sizing: content-box; padding: 18px 11px 30px; scroll-snap-align: center; scroll-snap-stop: normal;
  content-visibility: auto; contain-intrinsic-size: auto 240px auto 300px; /* lazy-render long timelines */
}
.bt-entry {
  height: 100%; box-sizing: border-box; padding: 16px 16px 18px; border-radius: 22px; background: #fff;
  border: 2px solid var(--line); display: flex; flex-direction: column; gap: 2px;
  transform: translateY(0) scale(.94); opacity: .62; will-change: transform;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s, opacity .35s, border-color .35s;
}
.bt-item.is-centre .bt-entry { transform: translateY(-4px) scale(1); opacity: 1; border-color: var(--accent); box-shadow: 0 14px 22px -14px color-mix(in srgb, var(--accent) 60%, transparent); }
.bt-item.is-centre .bt-entry { animation: bt-float 3.2s ease-in-out .4s infinite alternate; }
.bt-entry:hover, .bt-entry:focus-visible { transform: translateY(-10px) scale(1.02); opacity: 1; border-color: var(--accent); box-shadow: 0 18px 24px -14px color-mix(in srgb, var(--accent) 65%, transparent); animation: none; }
.bt-entry:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
@keyframes bt-float { from { transform: translateY(-4px); } to { transform: translateY(-10px); } }
.bt-year { margin: 0; font-size: 44px; line-height: 1; font-weight: 900; letter-spacing: -0.04em; color: var(--accent); font-variant-numeric: tabular-nums; }
.bt-age { margin: 0 0 12px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bt-k { margin: 8px 0 0; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.bt-song { margin: 2px 0 0; font-size: 22px; line-height: 1.08; font-weight: 900; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.bt-atitle { margin: 2px 0 0; font-size: 17px; line-height: 1.12; font-weight: 800; overflow-wrap: anywhere; }
.bt-artist { margin: 2px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.bt-album { margin-top: auto; padding-top: 8px; border-top: 2px solid var(--line); }
.bt-before { margin: 10px 0 0; font-size: 22px; font-weight: 900; }
a.bt-link { color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--line); text-underline-offset: 4px; }
a.bt-link:hover, a.bt-link:focus-visible { text-decoration-color: var(--accent); }
.bt-hint { margin: -12px var(--pad) 0; min-height: 18px; font-size: 13px; font-weight: 700; color: var(--accent); opacity: 0; transition: opacity .2s; }
.bt.has-focus .bt-hint { opacity: 1; }
.bt-scrub { margin: 6px var(--pad) 0; }
.bt-rangewrap { display: flex; align-items: center; gap: 12px; }
.bt-range { flex: 1; accent-color: var(--accent); height: 28px; }
.bt-out { min-width: 3.2em; text-align: right; font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--accent); }
.bt-decades { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 8px 0 2px; }
.bt-decades::-webkit-scrollbar { display: none; }
.bt-dec { flex: 0 0 auto; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font: inherit; font-size: 13px; font-weight: 800; color: var(--ink); cursor: pointer; }
.bt-dec:hover { border-color: var(--accent); }
.bt-dec[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (min-width: 900px) {
  .bt { --btw: min(100vw - 2 * var(--pad), 1320px); width: var(--btw); margin: 0 0 0 calc(50% - var(--btw) / 2); }
  .bt-scrub, .bt-hint { width: min(100%, 860px); margin-left: auto; margin-right: auto; }
  .bt-hint { margin-top: -12px; }
  .bt-item { flex-basis: 250px; }
  .bt-track::before, .bt-track::after { flex-basis: calc(50% - 125px - 11px); }
}
/* Very narrow screens: a vertical timeline reads better than tiny cards. */
@media (max-width: 280px) {
  .bt-viewport::before, .bt-viewport::after { display: none; }
  .bt-track { flex-direction: column; overflow-x: hidden; overflow-y: auto; max-height: 52vh; scroll-snap-type: y mandatory; padding: 8px var(--pad); }
  .bt-track::before, .bt-track::after { display: none; }
  .bt-item { flex: 0 0 auto; padding: 8px 6px 14px; contain-intrinsic-size: auto 100% auto 220px; }
}
@media (prefers-reduced-motion: reduce) {
  .bt-entry, .bt-hint { transition: none; }
  .bt-item.is-centre .bt-entry, .bt-entry:hover, .bt-entry:focus-visible { animation: none; transform: none; }
  .bt-entry { transform: none; }
  .bt-track { scroll-behavior: auto; }
}
@media (max-height: 760px), (max-width: 420px) {
  .bt-year { font-size: 36px; } .bt-age { margin-bottom: 6px; } .bt-song { font-size: 20px; } .bt-entry { padding: 13px 14px 14px; }
}
