:root {
  --ink: #0b0a12;
  --paper: #f3ede2;
  --dim: rgba(243, 237, 226, .55);
  --faint: rgba(243, 237, 226, .14);
  --gold: #e9c46a;
  --silver: #c9d1da;
  --lead: #e9c46a;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --c1: #e9c46a;
  --c2: #c9d1da;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--ink); color: var(--paper); -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); overflow-x: hidden; min-height: 100vh; }

.grain {
  position: fixed; inset: -50%; z-index: 50; pointer-events: none; opacity: .09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -4%); } 60% { transform: translate(-4%, -1%); }
  80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
.aura {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(80vw 60vh at 85% 8%, color-mix(in srgb, var(--c1) 30%, transparent), transparent 70%),
    radial-gradient(70vw 50vh at 0% 55%, color-mix(in srgb, var(--c2) 16%, transparent), transparent 70%);
  transition: background 1.2s ease;
}

.kicker {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim);
}

/* Hero */
.hero {
  position: relative; z-index: 1; min-height: 100vh; min-height: 100svh;
  padding: calc(env(safe-area-inset-top) + 40px) 22px 40px;
  display: flex; flex-direction: column; gap: 26px;
}
.hero h1 {
  font-family: var(--serif); font-weight: 300; font-size: clamp(54px, 16vw, 92px);
  line-height: .9; letter-spacing: -.035em; font-variation-settings: "opsz" 144;
}
.hero h1 em { font-style: italic; font-weight: 700; color: var(--gold); }
.podium { display: flex; flex-direction: column; gap: 12px; }
.place {
  position: relative; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 14px;
  padding: 16px 16px 16px 14px; border-radius: 22px;
  background: linear-gradient(140deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  border: 1px solid var(--faint); overflow: hidden;
  opacity: 0; transform: translateY(24px); animation: rise .9s cubic-bezier(.2,.8,.2,1) forwards;
}
.place.second { animation-delay: .18s; }
@keyframes rise { to { opacity: 1; transform: none; } }
.place::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent, #fff) 30%, transparent), transparent 60%);
}
.place .medal {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 800; font-size: 22px; color: var(--ink);
  background: radial-gradient(circle at 30% 30%, #fff6d6, var(--gold) 55%, #a8811f);
  box-shadow: 0 0 30px color-mix(in srgb, var(--gold) 50%, transparent);
}
.place.second .medal { background: radial-gradient(circle at 30% 30%, #fff, var(--silver) 55%, #7d8794); box-shadow: none; }
.place .who { display: flex; flex-direction: column; min-width: 0; }
.place .creator { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent, var(--dim)); font-weight: 600; }
.place .model { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.05; letter-spacing: -.01em; }
.place.second .model { font-size: 19px; }
.place .nums { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.place .score { font-family: var(--serif); font-size: 40px; font-weight: 800; line-height: .9; font-variant-numeric: tabular-nums; }
.place.second .score { font-size: 30px; }
.place .unit { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.place .cost { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 6px; white-space: nowrap; }
.lede { font-size: 16px; line-height: 1.5; color: var(--dim); max-width: 34ch; }
.scrollcue { margin-top: auto; display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.scrollcue i { display: block; width: 1px; height: 46px; background: linear-gradient(var(--gold), transparent); animation: cue 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* Journey */
.journey { position: relative; z-index: 1; height: 2200vh; }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 14px);
}
.bigyear {
  position: absolute; left: -4vw; bottom: 8svh; z-index: -1;
  font-family: var(--serif); font-weight: 900; font-size: 52vw; line-height: .8; letter-spacing: -.06em;
  color: transparent; -webkit-text-stroke: 1px rgba(243, 237, 226, .09);
  font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap;
}
.clock { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: end; column-gap: 12px; }
.clock .month { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 40px; line-height: 1; color: var(--gold); }
.clock .year { font-family: var(--serif); font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.clock .track { grid-column: 1 / -1; height: 2px; background: var(--faint); margin-top: 10px; border-radius: 2px; overflow: hidden; }
.clock .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--c2), var(--c1)); }

.race { position: relative; display: flex; flex-direction: column; gap: 8px; }
.slot {
  --accent: #fff;
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 18px; position: relative; overflow: hidden;
  background: rgba(255,255,255,.05); border: 1px solid var(--faint);
  transition: border-color .6s;
}
.slot::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .9;
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%);
  transition: background .6s;
}
.slot.s1 { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.slot .rank { font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 20px; color: var(--gold); position: relative; }
.slot.s2 .rank { color: var(--silver); font-size: 17px; }
.slot .body { position: relative; min-width: 0; }
.slot .creator { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.slot .model { font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.s2 .model { font-size: 17px; }
.slot .right { position: relative; text-align: right; }
.slot .score { font-family: var(--serif); font-weight: 800; font-size: 32px; line-height: .9; font-variant-numeric: tabular-nums; }
.slot.s2 .score { font-size: 24px; }
.slot .cost { font-family: var(--mono); font-size: 10.5px; color: var(--dim); margin-top: 4px; white-space: nowrap; }
.slot.swap { animation: swap .7s cubic-bezier(.2,.8,.2,1); }
@keyframes swap { 0% { transform: scale(.96); filter: brightness(2); } 100% { transform: none; filter: none; } }

.chartwrap { position: relative; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.cbox { position: relative; flex: 1 1 0; min-height: 110px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.legendline { display: flex; flex-wrap: nowrap; overflow: hidden; gap: 10px; font-size: 10.5px; line-height: 16px; height: 20px; color: var(--dim); padding-top: 4px; flex: none; }
.legendline span { white-space: nowrap; }
.legendline span { display: inline-flex; align-items: center; gap: 5px; transition: opacity .4s; }
.legendline i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }

.costwrap { border-top: 1px solid var(--faint); padding-top: 8px; }
.costhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.costhead b { font-weight: 600; }
.keys { white-space: nowrap; text-align: right; }
.costhead { flex-wrap: wrap; }
.keys b { margin-left: 8px; }
.keys b::before { content: ""; display: inline-block; width: 10px; height: 2px; margin-right: 4px; vertical-align: middle; background: currentColor; }
.toggle { display: inline-flex; border: 1px solid var(--faint); border-radius: 999px; padding: 2px; }
.toggle button {
  font: inherit; font-size: 10px; letter-spacing: .06em; color: var(--dim); background: none; border: 0;
  padding: 6px 10px; border-radius: 999px; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.toggle button.on { background: rgba(243,237,226,.12); color: var(--paper); }
.costhead .lead { color: var(--gold); }
.costhead .cheap { color: #7fd3c3; }
#costChart { width: 100%; height: 92px; display: block; margin-top: 4px; }


/* Best value */
.place.value .medal { background: radial-gradient(circle at 30% 30%, #e6fffa, #7fd3c3 55%, #2f8f80); box-shadow: 0 0 24px rgba(127,211,195,.35); font-family: var(--sans); font-size: 20px; }
.place.value .model { font-size: 19px; }
.place.value .score { font-size: 30px; }
.place.value .cost { color: #7fd3c3; white-space: pre-line; line-height: 1.5; }
.place .tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: #7fd3c3; margin-bottom: 2px; }
.podnote { font-size: 12px; line-height: 1.5; color: var(--dim); margin-top: -12px; }
.slot.sv { padding: 8px 13px; border-style: dashed; border-color: rgba(127,211,195,.4); }
.slot.sv::before { background: linear-gradient(100deg, rgba(127,211,195,.16), transparent 70%); }
.slot.sv .rank { color: #7fd3c3; font-family: var(--sans); font-style: normal; font-size: 17px; }
.slot.sv .model { font-size: 15px; }
.slot.sv .score { font-size: 19px; }
.slot.sv .cost { color: #7fd3c3; white-space: pre-line; line-height: 1.35; }

/* Spotlight: one line on each new arrival */
.spotlight {
  --accent: var(--gold);
  border-left: 2px solid var(--accent); padding: 2px 0 2px 11px; height: 66px; overflow: hidden;
}
.spotlight .sname { font-size: 11px; letter-spacing: .04em; color: var(--dim); }
.spotlight .sname b { font-family: var(--serif); font-size: 15px; letter-spacing: 0; color: var(--accent); font-weight: 700; margin-right: 2px; }
.spotlight .stext { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 14.5px; line-height: 1.3; margin-top: 2px; color: rgba(243,237,226,.9);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.spotlight.in { animation: spotin .6s cubic-bezier(.2,.8,.2,1); }
@keyframes spotin { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

/* Outro */
.outro { position: relative; z-index: 1; padding: 70px 22px calc(env(safe-area-inset-bottom) + 50px); background: linear-gradient(transparent, var(--ink) 120px); }
.scatterwrap { margin: 4px -6px 50px; }
#scatter { width: 100%; height: 340px; display: block; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 50px; }
.stat { padding: 16px; border-radius: 18px; border: 1px solid var(--faint); background: rgba(255,255,255,.04); }
.stat.wide { grid-column: 1 / -1; }
.stat .big { font-family: var(--serif); font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: -.02em; color: var(--gold); }
.stat .big.teal { color: #7fd3c3; }
.stat .big.sm { font-size: 30px; }
.stat .lbl { font-size: 13px; line-height: 1.4; color: var(--dim); margin-top: 8px; }
.outro h2 + .note { margin-top: 8px; }
.outro h2 { font-family: var(--serif); font-weight: 300; font-size: 40px; letter-spacing: -.02em; }
.outro .note { color: var(--dim); font-size: 14px; line-height: 1.5; margin: 8px 0 18px; }
.board { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.board li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--faint); }
.board .n { font-family: var(--serif); font-style: italic; color: var(--dim); font-size: 16px; }
.board .nm { min-width: 0; }
.board .nm b { display: block; font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.15; }
.board .nm span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.board .bar { height: 3px; border-radius: 3px; margin-top: 6px; }
.board .v { text-align: right; font-family: var(--serif); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }
.board .v small { display: block; font-family: var(--mono); font-weight: 400; font-size: 10.5px; color: var(--dim); }
footer { margin-top: 40px; font-size: 12px; line-height: 1.6; color: var(--dim); }
footer a { color: var(--paper); }

@media (min-width: 700px) {
  .hero, .outro { max-width: 560px; margin: 0 auto; }
  .stage { max-width: 560px; margin: 0 auto; }
  .bigyear { font-size: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  .grain, .scrollcue i { animation: none; }
  .place { animation: none; opacity: 1; transform: none; }
  .slot.swap, .spotlight.in { animation: none; }
}

/* Short phones (small iPhones, or Safari bars showing): tighten so the chart keeps room */
@media (max-height: 700px) {
  .stage { gap: 6px; padding-top: calc(env(safe-area-inset-top) + 8px); padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
  .clock .month, .clock .year { font-size: 30px; }
  .clock .track { margin-top: 6px; }
  .slot { padding: 7px 11px; border-radius: 14px; }
  .slot .model { font-size: 17px; }
  .slot.s2 .model, .slot.sv .model { font-size: 14px; }
  .slot .score { font-size: 25px; }
  .slot.s2 .score { font-size: 19px; }
  .slot.sv .score { font-size: 16px; }
  .slot .creator { font-size: 9.5px; }
  .slot .cost { font-size: 9.5px; margin-top: 2px; }
  .slot.sv .cost { line-height: 1.2; }
  .spotlight { height: 54px; }
  .spotlight .sname b { font-size: 13px; }
  .spotlight .stext { font-size: 13px; }
  .cbox { min-height: 90px; }
  #costChart { height: 64px; }
  .toggle button { padding: 4px 8px; }
}
@media (max-height: 580px) {
  .legendline { display: none; }
  .slot.sv .creator { display: none; }
  .slot.sv { padding: 5px 11px; }
  .clock .month, .clock .year { font-size: 26px; }
  .spotlight { height: 50px; }
}
/* Older Safari without color-mix: plain tints instead of missing ones */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .aura { background: radial-gradient(80vw 60vh at 85% 8%, rgba(233,196,106,.22), transparent 70%); }
  .slot::before, .place::before { background: linear-gradient(100deg, rgba(255,255,255,.08), transparent 70%); }
  .slot.s1 { border-color: rgba(233,196,106,.5); }
}
