/* ═════════════════════════════════════════════════════════════
   OLDER OR YOUNGER
   Quiet, editorial, museum-label. One accent colour, no glow.
   ═════════════════════════════════════════════════════════════ */

:root {
  --bg: #0b0b0d;
  --panel: #121215;
  --line: rgba(236, 230, 218, 0.14);
  --line-strong: rgba(236, 230, 218, 0.4);
  --cream: #ece6da;
  --muted: rgba(236, 230, 218, 0.6);
  --faint: rgba(236, 230, 218, 0.38);
  --brass: #cfb075;
  --good: #8fb996;
  --bad: #d36f66;

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.18, 1);

  --hud-h: 84px;
  --tl-h: 92px;
  --slide: 0.9s;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--sans);
  font-variation-settings: 'SOFT' 0, 'WONK' 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--sans); font-size: 0.85em; color: var(--cream); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* small uppercase label style, shared */
.kicker, .meta, .scores .k, .tl-tick span, .over-kicker, .journey h3 {
  font-family: var(--sans); font-weight: 500; text-transform: uppercase; letter-spacing: 0.2em;
}

#bg, #fx { position: fixed; inset: 0; pointer-events: none; }
#bg { z-index: 0; }
#fx { z-index: 60; }

.grain {
  position: fixed; inset: 0;
  z-index: 50; pointer-events: none;
  opacity: 0.045;
  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");
}

/* result flash: a thin edge line, opacity-animated */
.flash {
  position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 0 3px var(--flash, var(--good));
}

#app { position: fixed; inset: 0; z-index: 1; }

/* ───────── HUD ───────── */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  height: var(--hud-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 clamp(16px, 2.6vw, 36px);
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(11, 11, 13, 0.7), rgba(11, 11, 13, 0));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.brand {
  justify-self: start;
  background: none; border: 0; padding: 8px 0;
  font-family: var(--serif); font-size: 18px; font-weight: 400;
  opacity: 0; transition: opacity 0.6s var(--ease-out);
}
.brand em { font-style: italic; font-weight: 300; color: var(--muted); }
.brand:hover { color: #fff; }
body[data-screen='game'] .brand { opacity: 1; }

.scores {
  display: grid; grid-template-columns: 72px 72px; gap: 8px;
  opacity: 0; transition: opacity 0.6s var(--ease-out) 0.1s;
}
body[data-screen='game'] .scores { opacity: 1; }
.scores > div { position: relative; text-align: center; }
.scores .k { display: block; font-size: 10px; color: var(--faint); margin-bottom: 5px; }
.scores .v {
  display: block; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1;
  font-variant-numeric: tabular-nums lining-nums;
}
.score .v { color: var(--cream); }
.best .v { color: var(--muted); }
.best.is-new .v { color: var(--brass); }
.score .v.pop { animation: scorePop 0.45s var(--ease-out); }
@keyframes scorePop { 0% { transform: scale(1); } 30% { transform: scale(1.14); } 100% { transform: scale(1); } }
/* every 5 in a row: a brief brass glow on the counter instead of a pop */
.score .v.glow { animation: scoreGlow 1.4s var(--ease-out); }
@keyframes scoreGlow {
  0% { transform: scale(1); color: var(--cream); }
  20% { transform: scale(1.12); color: var(--brass); text-shadow: 0 0 14px rgba(198, 164, 100, 0.45); }
  100% { transform: scale(1); color: var(--cream); text-shadow: none; }
}
.plus-one.is-milestone { color: var(--brass); animation-duration: 1.6s; }
.plus-one {
  position: absolute; left: 50%; top: 100%; margin-top: 2px; transform: translateX(-50%);
  font-size: 11px; font-weight: 500; letter-spacing: 0.1em; color: var(--good);
  animation: plusOne 0.9s var(--ease-out) forwards; pointer-events: none; white-space: nowrap;
}
@keyframes plusOne { from { opacity: 0; transform: translate(-50%, -4px); } 30% { opacity: 1; } to { opacity: 0; transform: translate(-50%, 8px); } }

.toggles { justify-self: end; display: flex; gap: 2px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 2px;
  display: grid; place-items: center;
  background: none; border: 0;
  color: var(--muted);
  transition: color 0.2s;
}
.icon-btn:hover { color: var(--cream); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .slash { stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset 0.3s var(--ease-out); }
.icon-btn.off .slash { stroke-dashoffset: 0; }
.icon-btn.off { color: var(--faint); }
.icon-btn.active { color: var(--brass); }

:focus-visible { outline: 1px solid var(--cream); outline-offset: 4px; }

/* ───────── Screens ───────── */
.screen { position: absolute; inset: 0; }
.title-screen {
  display: grid; place-items: center;
  transition: opacity 0.7s var(--ease-out), transform 0.9s var(--ease-out), visibility 0s;
}
/* hidden screens become visibility:hidden once faded, so their animations cost nothing */
body:not([data-screen='title']) .title-screen {
  opacity: 0; transform: scale(1.04); pointer-events: none; visibility: hidden;
  transition: opacity 0.7s var(--ease-out), transform 0.9s var(--ease-out), visibility 0s linear 0.7s;
}
.game-screen { transition: opacity 0.6s var(--ease-out), visibility 0s; }
body:not([data-screen='game']) .game-screen {
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity 0.6s var(--ease-out), visibility 0s linear 0.6s;
}

/* ───────── Title ───────── */
.astrolabe {
  position: absolute; left: 50%; top: 50%;
  width: min(112vmin, 1100px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.astrolabe svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; will-change: transform; }
.astrolabe .r1 { animation: spin 240s linear infinite; opacity: 0.08; }
.astrolabe .r2 { animation: spin 160s linear infinite reverse; opacity: 0.16; }
.astrolabe .r3 { animation: spin 90s linear infinite; opacity: 0.22; }
.astrolabe .r4 { animation: spin 300s linear infinite reverse; opacity: 0.22; }
.astrolabe circle, .astrolabe line { fill: none; stroke: var(--cream); }
.astrolabe text { fill: var(--cream); font-family: var(--sans); font-size: 12px; letter-spacing: 0.28em; }
.astrolabe text.roman { font-family: var(--serif); font-size: 26px; letter-spacing: 0; }
.astrolabe circle[fill] { stroke: none; fill: var(--brass); }
@keyframes spin { to { transform: rotate(360deg); } }

.title-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 0 20px; margin-top: -3vh;
}
.hourglass { width: 26px; margin-bottom: 26px; animation: fadeIn 1.2s var(--ease-out) both; }
.hourglass svg { width: 100%; overflow: visible; }
.hg-body { transform-origin: 32px 48px; transform-box: view-box; animation: hgFlip 7s var(--ease-io) infinite; }
.hg-glass { fill: none; stroke: var(--cream); stroke-width: 2.4; }
.hg-cap { fill: var(--cream); }
.hg-sand-top, .hg-sand-bot, .hg-stream { fill: var(--brass); }
.hg-sand-top { transform-box: fill-box; transform-origin: 50% 100%; animation: sandTop 7s linear infinite; }
.hg-sand-bot { transform-box: fill-box; transform-origin: 50% 100%; animation: sandBot 7s linear infinite; }
.hg-stream { animation: stream 7s linear infinite; }
@keyframes hgFlip { 0%, 84% { transform: rotate(0deg); } 100% { transform: rotate(180deg); } }
@keyframes sandTop { 0% { transform: scaleY(1); } 80%, 100% { transform: scaleY(0); } }
@keyframes sandBot { 0% { transform: scaleY(0); } 80%, 100% { transform: scaleY(1); } }
@keyframes stream { 0%, 79% { opacity: 1; } 81%, 100% { opacity: 0; } }

.kicker { margin: 0 0 18px; font-size: 11px; letter-spacing: 0.42em; color: var(--muted); animation: fadeIn 1.2s var(--ease-out) 0.1s both; }
.logo {
  margin: 0; line-height: 0.9;
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(3.6rem, 11.5vw, 9rem);
  letter-spacing: -0.025em;
  display: flex; flex-direction: column; align-items: center;
  color: var(--cream);
}
.logo .w { display: block; white-space: nowrap; }
.logo .ch { display: inline-block; animation: letterIn 1s var(--ease-out) both; animation-delay: calc(0.2s + var(--i) * 0.045s); }
.logo .or {
  font-style: italic; font-weight: 300; font-size: 0.3em; color: var(--muted); letter-spacing: 0;
  margin: 0.25em 0 0.2em;
  display: flex; align-items: center; gap: 0.7em;
  animation: fadeIn 1.2s var(--ease-out) 0.5s both;
}
.logo .or::before, .logo .or::after { content: ''; width: 2.4em; height: 1px; background: var(--line-strong); }
@keyframes letterIn { from { opacity: 0; transform: translateY(0.3em); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tagline {
  margin: 30px 0 40px;
  font-family: var(--serif); font-style: italic; font-weight: 350;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem); line-height: 1.55; color: var(--muted);
  animation: fadeUp 1.1s var(--ease-out) 0.8s both;
}

/* primary button: flat, rectangular; hover inverts */
.btn-play {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 17px 30px;
  border: 1px solid var(--cream); border-radius: 2px;
  background: transparent; color: var(--cream);
  font-size: 12px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase;
  transition: background 0.18s, color 0.18s;
  animation: fadeUp 1.1s var(--ease-out) 0.95s both;
}
.btn-play svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn-play:hover { background: var(--cream); color: var(--bg); }
.btn-play:active { opacity: 0.85; }
.btn-play.small { padding: 14px 24px; animation: none; background: var(--cream); color: var(--bg); }
.btn-play.small:hover { background: #fff; }

/* continue an interrupted run: sits under the main button, same width, quieter */
.title-actions { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.title-actions .btn-play { justify-content: center; }
.btn-continue {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 13px 30px; border-radius: 2px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--cream);
  font-size: 12px; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s;
  animation: fadeUp 0.8s var(--ease-out) both;
}
.btn-continue[hidden] { display: none; }
.btn-continue:hover { border-color: var(--cream); background: rgba(236, 230, 218, 0.06); }
.btn-continue:active { opacity: 0.85; }
.cont-streak { color: var(--faint); letter-spacing: 0.16em; font-weight: 500; }
.cont-streak b { color: var(--brass); font-family: var(--serif); font-weight: 400; font-size: 15px; letter-spacing: 0; margin-left: 4px; }
/* on short screens, win back the continue button's height from the title's spacing */
@media (max-height: 820px) {
  .title-inner:has(.btn-continue:not([hidden])) .hourglass { margin-bottom: 14px; }
  .title-inner:has(.btn-continue:not([hidden])) .logo { font-size: min(clamp(3.4rem, 11.5vw, 9rem), 16.5vh); }
  .title-inner:has(.btn-continue:not([hidden])) .tagline { margin: 18px 0 24px; }
  .title-inner:has(.btn-continue:not([hidden])) .title-meta { margin-top: 18px; }
}

.title-meta {
  margin-top: 28px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center;
  font-size: 12px; color: var(--faint); letter-spacing: 0.06em;
  animation: fadeIn 1.2s var(--ease-out) 1.15s both;
}
.title-meta b { color: var(--cream); font-family: var(--serif); font-weight: 400; font-size: 15px; margin-left: 6px; }
.meta-sep { opacity: 0.6; }
.meta-keys kbd { margin: 0 4px 0 8px; }

.marquee {
  position: absolute; left: 0; right: 0; bottom: 4vh; overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  animation: fadeIn 2s ease 1.3s both;
}
.marquee-track { display: flex; width: max-content; animation: marquee 160s linear infinite; }
.marquee-track span { white-space: nowrap; padding: 0 22px; font-size: 12px; letter-spacing: 0.04em; color: var(--faint); display: inline-flex; align-items: baseline; gap: 10px; }
.marquee-track b { font-family: var(--serif); font-weight: 400; color: var(--muted); font-size: 14px; }
.marquee-track i { font-style: normal; padding-left: 22px; opacity: 0.5; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ───────── Stage & cards ───────── */
.stage { position: absolute; inset: 0; overflow: hidden; transition: opacity 0.6s var(--ease-out); }
.stage.is-loading { opacity: 0; transition-duration: 0.2s; }
.stage.shake { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}
.track { position: absolute; inset: 0; }

.card {
  position: absolute; top: 0; left: 0;
  width: 50%; height: 100%;
  overflow: hidden; isolation: isolate;
  background: var(--panel);
  transform: translate3d(calc(var(--slot, 0) * 100%), 0, 0);
  transition: transform var(--slide) var(--ease-io), opacity var(--slide) var(--ease-io);
  will-change: transform;
}
html:not(.lite) .card[data-slot='-1'] { opacity: 0.3; }

/* artwork */
.art {
  position: absolute; inset: -30px; z-index: -3;
  transform: translate3d(calc(var(--px, 0) * -12px), calc(var(--py, 0) * -12px), 0);
  transition: transform 0.9s var(--ease-out);
}
/* Photos fade in at rest (no scale jump), then drift slowly.
   The drift runs as a true 3D layer (perspective + a 0.1px z-offset, both invisible).
   That keeps it on the GPU and stops the compositor snapping it to whole pixels,
   which is what made the slow zoom visibly step. Chosen by side-by-side test in Waterfox. */
.art .photo {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0;
  transform: perspective(1000px) translate3d(0, 0, 0.1px) scale(1);
  transition: opacity 0.7s ease;
  will-change: transform;
}
.art.has-photo .photo { opacity: 1; animation: kenburns 32s ease-in-out infinite alternate; }
@keyframes kenburns {
  from { transform: perspective(1000px) translate3d(0, 0, 0.1px) scale(1); }
  to { transform: perspective(1000px) translate3d(-1.2%, -0.8%, 0.1px) scale(1.08); }
}
/* no photo: a quiet monogram */
.art .glyph {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: min(72vmin, 46vw); line-height: 1;
  color: rgba(236, 230, 218, 0.05);
  transition: opacity 0.8s;
}
.art.has-photo .glyph { opacity: 0; }
.art.no-fade .photo, .art.no-fade .glyph { transition: none; }

/* scrim for legibility over photos */
.shade {
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(11, 11, 13, 0.66) 0%, rgba(11, 11, 13, 0.58) 45%, rgba(11, 11, 13, 0.85) 100%);
}
.card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 0.35s var(--ease-out);
}
.card.is-correct::after { opacity: 1; box-shadow: inset 0 0 0 2px var(--good); }
.card.is-wrong::after { opacity: 1; box-shadow: inset 0 0 0 2px var(--bad); }

/* content */
.content {
  position: absolute; inset: 0;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.45);
  padding: calc(var(--hud-h) + 10px) clamp(24px, 5vw, 80px) calc(var(--tl-h) + 18px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 16px;
  transition: padding var(--slide) var(--ease-io);
}
.card.intro .content > * { animation: rise 0.8s var(--ease-out) both; animation-delay: calc(var(--d, 0s) + var(--i) * 0.06s); }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.meta .sep { opacity: 0.5; }

.name {
  margin: 0; max-width: 16ch;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2rem, 3.4vw, 3.5rem); line-height: 1.04; letter-spacing: -0.02em;
  text-wrap: balance;
}

.stack { display: grid; place-items: center; }
.stack > * { grid-area: 1 / 1; }

.year {
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(3rem, 6vw, 5.6rem); line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--brass);
  display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap;
  transition: opacity 0.3s var(--ease-out);
  min-height: 1em;
}
.year .pre { font-style: italic; font-size: 0.4em; color: var(--muted); margin-right: 0.3em; letter-spacing: 0; }
.year .unit {
  font-family: var(--sans); font-weight: 500; font-size: max(11px, 0.17em); letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted); margin-left: 0.7em;
}
.year .unit.long { flex-basis: 100%; margin: 0.9em 0 0; }

.choices { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; transition: opacity 0.3s var(--ease-out); }
.choice {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-width: 164px; padding: 15px 22px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: rgba(11, 11, 13, 0.55);
  color: var(--cream);
  font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.25s;
}
.choice .arr { font-weight: 400; letter-spacing: 0; font-size: 15px; line-height: 1; }
.choice:hover, .choice.picked { background: var(--cream); border-color: var(--cream); color: var(--bg); }
.choice:active { opacity: 0.85; }

.card.is-pending .year { opacity: 0; pointer-events: none; }
.card.is-pending.chose-older .choice.younger,
.card.is-pending.chose-younger .choice.older { opacity: 0.25; }
.card.is-revealing .choices, .card.is-known .choices { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.25s, visibility 0s 0.3s; }
.card.is-revealing .year, .card.is-known .year { opacity: 1; }

.sub { min-height: 22px; }
.than { font-size: 13px; color: var(--faint); transition: opacity 0.3s; }
.than b { color: var(--muted); font-weight: 400; font-family: var(--serif); font-style: italic; font-size: 1.1em; }
.delta {
  font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
  opacity: 0; transition: opacity 0.4s var(--ease-out);
}
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.card.show-delta .delta { opacity: 1; }
.card.show-delta .than, .card.is-known .than { opacity: 0; }
.card[data-slot='0'] .delta, .card[data-slot='-1'] .delta { opacity: 0; }

.fact {
  margin: 6px 0 0; max-width: 34ch;
  font-family: var(--serif); font-style: italic; font-weight: 350;
  font-size: clamp(1rem, 1.15vw, 1.12rem); line-height: 1.55; color: rgba(236, 230, 218, 0.82);
  text-wrap: pretty;
  transition: opacity 0.6s var(--ease-out) 0.1s;
}
.fact::before { content: '“'; }
.fact::after { content: '”'; }
.card.is-pending .fact, .card.is-revealing .fact { opacity: 0; }

/* ───────── divider & medallion ───────── */
.divider {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px);
  background: var(--line);
  z-index: 4; pointer-events: none;
}
.medallion {
  position: absolute; left: 50%; top: 50%; z-index: 5;
  width: clamp(84px, 8vw, 116px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
.medallion svg { width: 100%; height: 100%; overflow: visible; }
.medallion.pulse { animation: medPulse 0.5s var(--ease-out); }
@keyframes medPulse { 0% { transform: translate(-50%, -50%) scale(1); } 35% { transform: translate(-50%, -50%) scale(1.035); } 100% { transform: translate(-50%, -50%) scale(1); } }
.m-face { fill: #101013; transition: fill 0.3s; }
.m-ring { fill: none; stroke: var(--brass); stroke-width: 2; }
.m-ring2 { fill: none; stroke: rgba(198, 164, 100, 0.3); stroke-width: 0.8; }
.m-ticks { transform-origin: 60px 60px; transform-box: view-box; animation: spin 60s linear infinite; }
.m-ticks line { stroke: rgba(198, 164, 100, 0.45); stroke-width: 1; }
.m-ticks line.major { stroke: var(--brass); stroke-width: 1.6; }
.m-vs {
  font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 28px;
  fill: var(--cream); transition: opacity 0.25s;
}
.m-hands { opacity: 0; transition: opacity 0.25s; }
.m-hand { stroke-linecap: round; transform-origin: 60px 60px; transform-box: view-box; }
.m-hour { stroke: var(--brass); stroke-width: 3.5; }
.m-min { stroke: var(--cream); stroke-width: 2; }
.m-pin { fill: var(--cream); }
.m-check, .m-cross { fill: none; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; stroke: #101013; }

.medallion.spinning .m-vs { opacity: 0; }
.medallion.spinning .m-hands { opacity: 1; }
.medallion.good .m-vs, .medallion.bad .m-vs { opacity: 0; }
.medallion.good .m-face { fill: var(--good); }
.medallion.bad .m-face { fill: var(--bad); }
.medallion.good .m-ticks line, .medallion.bad .m-ticks line { stroke: rgba(0, 0, 0, 0.25); }
.medallion.good .m-ring, .medallion.bad .m-ring { stroke: rgba(0, 0, 0, 0.25); }
.medallion.good .m-check { stroke-dashoffset: 0; transition: stroke-dashoffset 0.4s var(--ease-out) 0.05s; }
.medallion.bad .m-cross { stroke-dashoffset: 0; transition: stroke-dashoffset 0.4s var(--ease-out) 0.05s; }

/* ───────── timeline ───────── */
.timeline {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 8;
  height: var(--tl-h);
  padding: 0 clamp(24px, 5vw, 80px) env(safe-area-inset-bottom);
  background: linear-gradient(0deg, rgba(11, 11, 13, 0.85), rgba(11, 11, 13, 0));
}
.tl-inner { position: relative; height: 100%; }
.tl-axis { position: absolute; left: 0; right: 0; bottom: 38px; height: 1px; background: rgba(198, 164, 100, 0.45); }
.tl-axis::before, .tl-axis::after {
  position: absolute; top: -20px;
  font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--faint);
}
.tl-axis::after { content: 'Deep time'; left: 0; }
.tl-axis::before { content: 'Today'; right: 0; }
.tl-tick { position: absolute; bottom: 38px; transform: translateX(-50%); }
.tl-tick::before { content: ''; position: absolute; left: 50%; bottom: -4px; width: 1px; height: 8px; background: rgba(198, 164, 100, 0.45); }
.tl-tick span { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); white-space: nowrap; font-size: 9px; letter-spacing: 0.14em; color: var(--faint); }
.tl-tick.first span { left: 0; transform: none; }
.tl-tick span em { font-style: normal; }
.tl-dot {
  position: absolute; bottom: 38px; width: 9px; height: 9px; border-radius: 50%;
  transform: translate(-50%, 50%);
  background: var(--brass); box-shadow: 0 0 0 2px var(--bg);
  animation: dotIn 0.5s var(--ease-out) both;
}
.tl-dot.bad { background: var(--bad); }
.tl-dot.current::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid var(--brass); animation: ping 2.2s ease-out infinite; }
.tl-dot:hover { z-index: 3; }
.tl-dot .tip {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  padding: 7px 10px; border-radius: 2px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12px; color: var(--cream); opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.tl-dot .tip b { font-family: var(--serif); font-weight: 400; color: var(--brass); margin-right: 8px; }
.tl-dot:hover .tip { opacity: 1; }
@keyframes dotIn { from { transform: translate(-50%, 50%) scale(0); } to { transform: translate(-50%, 50%) scale(1); } }
@keyframes ping { from { transform: scale(0.7); opacity: 0.9; } to { transform: scale(1.8); opacity: 0; } }

/* ───────── game over ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 20px;
  background: rgba(8, 8, 10, 0.8);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.45s var(--ease-out);
}
.overlay[hidden] { display: none; }
.overlay.show { opacity: 1; }
.over-card {
  position: relative; width: min(540px, 100%); max-height: calc(100vh - 40px); overflow: hidden;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 40px clamp(22px, 4vw, 44px) 32px;
  border-radius: 2px;
  background: var(--panel); border: 1px solid var(--line);
  transform: translateY(14px); opacity: 0;
  transition: transform 0.6s var(--ease-out), opacity 0.45s var(--ease-out);
}
.overlay.show .over-card { transform: none; opacity: 1; }
.over-card > * { opacity: 0; transition: opacity 0.5s var(--ease-out); }
.overlay.show .over-card > * { opacity: 1; }
.overlay.show .over-card > :nth-child(3) { transition-delay: 0.1s; }
.overlay.show .over-card > :nth-child(4) { transition-delay: 0.2s; }
.overlay.show .over-card > :nth-child(5) { transition-delay: 0.35s; }
.overlay.show .over-card > :nth-child(6) { transition-delay: 0.5s; }
.overlay.show .over-card > :nth-child(7) { transition-delay: 0.6s; }

/* "New personal best" — a plain line under the score */
.over-ribbon { display: none; order: 3; margin: 2px 0 0; font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--brass); }
.over-ribbon.on { display: block; }
.over-kicker { order: 1; margin: 0; font-size: 11px; color: var(--muted); }
.over-score {
  order: 2; font-family: var(--serif); font-weight: 300; line-height: 1; margin: 10px 0 6px;
  font-size: clamp(5rem, 13vw, 7rem); letter-spacing: -0.03em; color: var(--cream);
  font-variant-numeric: tabular-nums lining-nums;
}
.over-rank { order: 4; margin: 6px 0 0; font-family: var(--serif); font-style: italic; font-weight: 350; font-size: 22px; color: var(--cream); }
.over-rank small { display: block; margin-top: 6px; font-family: var(--sans); font-style: normal; font-size: 12px; letter-spacing: 0.04em; color: var(--faint); }
.over-explain {
  order: 5; margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); width: 100%;
  font-size: 14px; line-height: 1.6; color: var(--muted);
}
.over-explain b { color: var(--cream); font-weight: 500; }
.over-explain em { color: var(--brass); font-style: normal; font-family: var(--serif); }

.journey { order: 6; width: 100%; margin-top: 22px; min-height: 0; display: flex; flex-direction: column; }
.journey h3 { margin: 0 0 12px; font-size: 10px; color: var(--faint); }
.journey ol {
  list-style: none; margin: 0; padding: 4px 6px 4px 0; text-align: left;
  max-height: min(30vh, 260px); overflow-y: auto; position: relative;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.journey li {
  position: relative; display: grid; grid-template-columns: minmax(110px, 38%) 18px 1fr; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 13.5px;
  opacity: 0; animation: fadeIn 0.4s var(--ease-out) forwards; animation-delay: calc(0.6s + var(--i) * 0.035s);
}
.journey li .jy { text-align: right; font-family: var(--serif); color: var(--brass); font-variant-numeric: tabular-nums; }
.journey li .jd { justify-self: center; width: 7px; height: 7px; border-radius: 50%; background: var(--brass); position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--panel); }
.journey li::before { content: ''; position: absolute; left: calc(38% + 17px); top: 0; bottom: 0; width: 1px; background: var(--line); }
.journey li:first-child::before { top: 50%; }
.journey li:last-child::before { bottom: 50%; }
.journey li .jn { color: var(--muted); }
.journey li.fatal .jd { background: var(--bad); }
.journey li.fatal .jn, .journey li.fatal .jy { color: var(--bad); }
.journey li.pivot .jn { color: var(--cream); }

.over-actions { order: 7; display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; justify-content: center; }
.btn-ghost {
  padding: 14px 22px; border-radius: 2px;
  background: transparent; border: 1px solid var(--line-strong);
  font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s;
}
.btn-ghost:hover { border-color: var(--cream); background: rgba(236, 230, 218, 0.06); }

.toast {
  position: fixed; left: 50%; bottom: 40px; z-index: 70;
  transform: translate(-50%, 10px); opacity: 0;
  padding: 12px 18px; border-radius: 2px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────── Performance ───────── */
body.is-over .stage *, body.is-over .tl-dot::after { animation-play-state: paused !important; }

/* Performance mode (auto-detected, ⚡ toggle, or ?lite): nothing animates
   unless the player just did something, and nothing animates full-screen. */
html.lite { --slide: 0s; }
html.lite .stage { transition: none; }
html.lite .grain, html.lite #bg, html.lite #fx { display: none; }
html.lite .card, html.lite .astrolabe svg { will-change: auto; }
html.lite .art.has-photo .photo, html.lite .astrolabe svg, html.lite .m-ticks,
html.lite .hourglass, html.lite .hourglass *, html.lite .kicker, html.lite .logo .ch, html.lite .logo .or,
html.lite .tagline, html.lite .btn-play, html.lite .btn-continue, html.lite .title-meta, html.lite .marquee, html.lite .marquee-track,
html.lite .tl-dot.current::after, html.lite .journey li, html.lite .stage.shake, html.lite .medallion.pulse,
html.lite .card.intro .content > *, html.lite .card.intro .art { animation: none !important; }
html.lite .hg-sand-top { transform: scaleY(0.55); }
html.lite .hg-sand-bot { transform: scaleY(0.45); }
html.lite .journey li { opacity: 1; }
html.lite .art { transition: none; transform: none; }
html.lite .art .photo, html.lite .art.has-photo .photo { transition: none; transform: none; will-change: auto; }
html.lite .art .glyph { transition: none; }
html.lite .art.has-photo .glyph { display: none; }
html.lite .title-screen, html.lite .game-screen,
html.lite body:not([data-screen='title']) .title-screen,
html.lite body:not([data-screen='game']) .game-screen { transition: none !important; }
html.lite body:not([data-screen='title']) .title-screen { transform: none; }
html.lite .card::after, html.lite .brand, html.lite .scores, html.lite .overlay,
html.lite .over-card, html.lite .over-card > *, html.lite .medallion { transition: none !important; }
html.lite .overlay { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(8, 8, 10, 0.92); }

/* ───────── Responsive: stacked cards ───────── */
@media (max-aspect-ratio: 4/5), (max-width: 620px) {
  :root { --hud-h: 66px; --tl-h: 64px; }
  .brand { display: none; }
  .hud { grid-template-columns: 1fr auto; }
  .scores { justify-self: start; grid-template-columns: 60px 60px; }
  .scores .v { font-size: 24px; }

  .card { width: 100%; height: 50%; transform: translate3d(0, calc(var(--slot, 0) * 100%), 0); }
  .card[data-slot='0'] .content, .card[data-slot='-1'] .content { padding: calc(var(--hud-h) + 4px) 20px 50px; }
  .card[data-slot='1'] .content, .card[data-slot='2'] .content { padding: 50px 20px calc(var(--tl-h) + 6px); }
  .content { gap: 10px; }
  .name { font-size: clamp(1.4rem, 6.4vw, 2.2rem); max-width: 20ch; }
  .year { font-size: clamp(2.2rem, 11vw, 3.4rem); }
  .meta { font-size: 9.5px; }
  .fact { font-size: 0.9rem; max-width: 40ch; }
  .choice { min-width: 130px; padding: 13px 16px; font-size: 11px; }
  .divider { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px; transform: translateY(-0.5px); }
  .medallion { width: 74px; }
  .tl-axis, .tl-tick, .tl-dot { bottom: 30px; }
  .tl-tick.minor, .tl-tick span em, .tl-axis::before, .tl-axis::after { display: none; }
  .marquee { bottom: 2vh; }
  .logo { font-size: clamp(3.4rem, 19vw, 6rem); }
  .title-meta .meta-keys, .title-meta .meta-sep { display: none; }
}
@media (max-aspect-ratio: 4/5) and (max-height: 760px), (max-width: 620px) and (max-height: 760px) {
  .fact { display: none; }
}
@media (max-height: 640px) and (min-aspect-ratio: 4/5) {
  .fact { display: none; }
  .tagline { margin: 18px 0 24px; }
}

/* ───────── Reduced motion ───────── */
@media (prefers-reduced-motion: reduce) {
  :root { --slide: 0.3s; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.2s !important; }
}
