:root {
  --bg: #0c0a12;
  --ink: #fff8f0;
  --muted: rgba(255, 248, 240, 0.68);
  --accent: #ffd23f;
  --ig1: #feda75;
  --ig2: #fa7e1e;
  --ig3: #d62976;
  --ig4: #962fbf;
  --ig5: #4f5bd5;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* Landing */
.landing {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(214, 41, 118, 0.35), transparent 70%),
    radial-gradient(50% 50% at 90% 90%, rgba(79, 91, 213, 0.35), transparent 70%),
    var(--bg);
}
.landing-inner { max-width: 560px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--muted); margin: 0 0 12px; }
h1 { font-family: var(--display); font-size: clamp(40px, 8vw, 64px); line-height: 1; margin: 0 0 16px; font-weight: 800; letter-spacing: -0.02em; }
.grad { background: linear-gradient(90deg, var(--ig1), var(--ig2), var(--ig3), var(--ig4)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: 17px; line-height: 1.5; margin: 0 0 28px; }
.year-pick { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.year-pick select { background: rgba(255,255,255,.08); color: var(--ink); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 8px 12px; font: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; padding: 14px 22px;
  font: 600 15px var(--body); cursor: pointer; text-decoration: none; color: var(--ink);
  transition: transform .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(90deg, var(--ig2), var(--ig3), var(--ig4)); }
.btn.ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); }
.btn.small { padding: 10px 16px; font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.note { color: var(--muted); font-size: 13px; margin-top: 16px; line-height: 1.5; }
.note code { background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 6px; }
.error { color: #ff8a8a; font-size: 14px; }

/* Loading */
.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--ig3); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Story viewer */
.story { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; }
.stage {
  position: relative;
  width: min(420px, 100%, calc((100vh - 110px) * 9 / 16));
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.progress { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 5; }
.progress span { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
.progress span.done { background: rgba(255,255,255,.95); }
.progress span.active { background: rgba(255,255,255,.95); }
.nav { position: absolute; top: 0; bottom: 0; width: 35%; background: none; border: 0; cursor: pointer; z-index: 4; }
.nav.prev { left: 0; }
.nav.next { right: 0; width: 65%; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.card-wrap { position: absolute; inset: 0; }

/* Cards: sized in container units so they scale with the stage. */
.card {
  position: absolute; inset: 0;
  container-type: inline-size;
  padding: 14% 8% 16%;
  display: flex; flex-direction: column; justify-content: center;
  color: var(--ink);
  animation: cardIn .45s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.card .kicker { font: 600 3.4cqw var(--body); text-transform: uppercase; letter-spacing: .14em; opacity: .8; margin: 0 0 3cqw; }
.card h2 { font: 800 10cqw/0.98 var(--display); margin: 0 0 4cqw; letter-spacing: -0.02em; }
.card h3 { font: 700 6cqw/1.05 var(--display); margin: 0 0 2cqw; }
.card p { font-size: 4cqw; line-height: 1.45; margin: 0 0 3cqw; opacity: .92; }
.card .big { font: 800 24cqw/0.9 var(--display); letter-spacing: -0.04em; margin: 2cqw 0; }
.card .foot { position: absolute; left: 8%; right: 8%; bottom: 6%; font: 600 3cqw var(--body); opacity: .75; display: flex; justify-content: space-between; align-items: baseline; gap: 3cqw; }
.card .foot .mark { font-size: 2.6cqw; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* On phones the share sheet is the main action; saving becomes secondary. */
#share:not([hidden]) + #download { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); }
.reveal > * { animation: rise .5s both cubic-bezier(.2,.8,.2,1); }
.reveal > *:nth-child(2) { animation-delay: .08s; }
.reveal > *:nth-child(3) { animation-delay: .16s; }
.reveal > *:nth-child(4) { animation-delay: .24s; }
.reveal > *:nth-child(5) { animation-delay: .32s; }
.reveal > *:nth-child(6) { animation-delay: .40s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.bg-sunset { background: linear-gradient(160deg, #fa7e1e 0%, #d62976 55%, #962fbf 100%); }
.bg-night { background: linear-gradient(170deg, #1a1036 0%, #4f5bd5 100%); }
.bg-lime { background: linear-gradient(160deg, #0f3d2e 0%, #1dd1a1 100%); }
.bg-gold { background: linear-gradient(160deg, #ffd23f 0%, #fa7e1e 100%); color: #1b0f05; }
.bg-gold .card, .bg-gold { --ink: #1b0f05; }
.bg-pink { background: linear-gradient(160deg, #ff9ff3 0%, #d62976 100%); }
.bg-ink { background: radial-gradient(80% 60% at 50% 0%, #3a1d5c 0%, #0c0a12 70%); }
.bg-blue { background: linear-gradient(160deg, #48dbfb 0%, #4f5bd5 100%); }

.avatar { width: 30cqw; height: 30cqw; border-radius: 50%; object-fit: cover; border: 1.4cqw solid rgba(255,255,255,.9); margin-bottom: 6cqw; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3cqw; margin-top: 2cqw; }
.stat { background: rgba(255,255,255,.14); border-radius: 4cqw; padding: 4cqw; }
.stat b { display: block; font: 800 9cqw/1 var(--display); letter-spacing: -0.02em; }
.stat span { font-size: 3.4cqw; opacity: .85; }
.stat.wide { grid-column: span 2; }

.bars { display: flex; flex-direction: column; gap: 3cqw; margin-top: 2cqw; }
.bar-row { display: grid; grid-template-columns: 22cqw 1fr 14cqw; align-items: center; gap: 3cqw; font-size: 3.8cqw; }
.bar-track { height: 5cqw; background: rgba(255,255,255,.15); border-radius: 3cqw; overflow: hidden; }
.bar-fill { height: 100%; background: rgba(255,255,255,.92); border-radius: 3cqw; transform-origin: left; animation: grow .8s .2s both cubic-bezier(.2,.8,.2,1); }
@keyframes grow { from { transform: scaleX(0); } }
.bar-row .val { text-align: right; font-weight: 600; }

.months { display: flex; align-items: flex-end; gap: 1.2cqw; height: 36cqw; margin: 4cqw 0 2cqw; }
.months div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1cqw; height: 100%; justify-content: flex-end; }
.months i { display: block; width: 100%; background: rgba(255,255,255,.35); border-radius: 1.4cqw 1.4cqw .4cqw .4cqw; transform-origin: bottom; animation: growY .7s both cubic-bezier(.2,.8,.2,1); }
.months i.hot { background: var(--accent); }
.months span { font-size: 2.6cqw; opacity: .8; }
@keyframes growY { from { transform: scaleY(0); } }

.hero-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5cqw; margin: 2cqw 0 4cqw; box-shadow: 0 4cqw 10cqw rgba(0,0,0,.35); }
.metrics { display: flex; flex-wrap: wrap; gap: 2cqw 4cqw; font-size: 3.8cqw; font-weight: 600; }
.caption { font-size: 3.4cqw !important; opacity: .8 !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.list { list-style: none; padding: 0; margin: 2cqw 0 0; display: flex; flex-direction: column; gap: 2.6cqw; }
.list li > * { min-width: 0; }
.list li { display: grid; grid-template-columns: 9cqw 14cqw minmax(0, 1fr) auto; gap: 3cqw; align-items: center; background: rgba(255,255,255,.12); border-radius: 4cqw; padding: 2.4cqw 3cqw; font-size: 3.8cqw; }
.list li.no-thumb { grid-template-columns: 9cqw minmax(0, 1fr) auto; }
.list .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .rank { font: 800 6cqw var(--display); }
.list img { width: 14cqw; height: 14cqw; border-radius: 2.4cqw; object-fit: cover; }
.list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: 3cqw; opacity: .75; }
.list .num { font-weight: 700; }

.tags { display: flex; flex-wrap: wrap; gap: 2.4cqw; margin-top: 3cqw; }
.tags span { background: rgba(255,255,255,.16); border-radius: 999px; padding: 2cqw 4cqw; font: 700 4.6cqw var(--display); }
.tags span:first-child { background: var(--accent); color: #1b0f05; font-size: 6cqw; }

.persona-badge { font: 800 14cqw/0.9 var(--display); letter-spacing: -0.03em; margin: 4cqw 0 6cqw; background: linear-gradient(90deg, var(--ig1), var(--ig2), var(--ig3)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.recap { display: grid; grid-template-columns: 1fr 1fr; gap: 2.4cqw; margin-top: 2cqw; }
.recap .stat b { font-size: 7cqw; }
.recap-head { display: flex; align-items: center; gap: 3cqw; margin-bottom: 4cqw; }
.recap-head img { width: 14cqw; height: 14cqw; border-radius: 50%; object-fit: cover; border: .8cqw solid #fff; }
.recap-head b { font: 800 5.4cqw var(--display); display: block; }
.recap-head span { font-size: 3.2cqw; opacity: .8; }

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