:root {
  --p: 0; /* credits progress 0..1, set by credits.js; drives the sunset */
  --pct: calc(var(--p) * 100%);

  /* Cloud lighting: sunlit cream and coral at first, slate and violet by nightfall. */
  --cloud-top: color-mix(in srgb, #fff1e2, #3c3668 var(--pct));
  --cloud-mid: color-mix(in srgb, #ffc2a8, #2e2858 var(--pct));
  --cloud-under: color-mix(in srgb, #f27a83, #201b48 var(--pct));

  --ink: #fff7e8;
  --muted: #f3d9c9;
  --gold: #ffe16d;
  --panel: rgba(22, 18, 62, .62);
  --line: rgba(255, 255, 255, .38);
  --button: #cf3030;
  --title: Impact, "Arial Black", "Trebuchet MS", sans-serif;
  color-scheme: dark;
  font-family: "Trebuchet MS", Verdana, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: #17163a;
  color: var(--ink);
  line-height: 1.5;
}

/* ---------- Sky ---------- */

.scene { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

.sky { position: absolute; inset: 0; }
/* Golden hour. */
.sky.day { background: linear-gradient(180deg, #4a3f88 0%, #8f66ad 32%, #ec9a8f 62%, #ffd68c 88%, #ffe7a6 100%); }
/* The sun reddens and the sky catches fire as it drops. */
.sky.sunset {
  background: linear-gradient(180deg, #34286b 0%, #7c3b7f 34%, #d9504f 64%, #ff8a3d 86%, #ffb45a 100%);
  opacity: clamp(0, calc(var(--p) * 2.2), 1);
}
/* Blue hour, then night. */
.sky.night {
  background: linear-gradient(180deg, #05051a 0%, #0f0e34 42%, #221a4e 72%, #43285c 92%, #5b2f58 100%);
  opacity: clamp(0, calc((var(--p) - .42) * 1.9), 1);
}

.stars {
  position: absolute; inset: 0 0 38% 0;
  opacity: clamp(0, calc((var(--p) - .3) * 1.6), 1);
  background-image:
    radial-gradient(2px 2px at 8% 12%, #fff8c7 50%, transparent 51%),
    radial-gradient(2px 2px at 23% 30%, #fff8c7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 31% 8%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 38% 40%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 47% 22%, #fff8c7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 45%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 69% 27%, #fff8c7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 14%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 91% 9%, #fff8c7 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 14% 44%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 4% 28%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 53% 33%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 96% 31%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 86% 38%, #fff 50%, transparent 51%);
  animation: twinkle 3.2s ease-in-out infinite;
}

/* One wish-upon-a-star moment, only once night has fallen. */
.shooting-star {
  position: absolute; top: 9%; left: 72%;
  width: 140px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 248, 199, .95), transparent);
  opacity: 0; transform: rotate(-24deg);
}
.night .shooting-star { animation: shoot 11s ease-out 1.2s infinite; }

/* ---------- Sun ---------- */

.sun-halo {
  position: absolute; left: 50%; bottom: 90px;
  width: 760px; height: 760px; margin-left: -380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 120, .55) 0%, rgba(255, 150, 90, .28) 30%, rgba(240, 90, 90, .1) 55%, transparent 70%);
  transform: translateY(calc(var(--p) * 240px)) scale(calc(1 + var(--p) * .35));
  opacity: clamp(0, calc(1 - var(--p) * 1.05), 1);
}

.sun {
  position: absolute; left: 50%; bottom: 205px;
  width: 150px; height: 150px; margin-left: -75px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #fffbe2 0%, #fff0a0 45%, #ffd36a 80%, #ffbe58 100%);
  box-shadow: 0 0 60px 20px rgba(255, 210, 110, .55);
  /* It sinks, swells a little near the horizon, and slips behind the mountains. */
  transform: translateY(calc(var(--p) * 240px)) scale(calc(1 + var(--p) * .18));
}
.sun::after {
  position: absolute; inset: 0; content: ""; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #ffcf8a 0%, #ff8a4c 50%, #ec4f3a 100%);
  box-shadow: 0 0 70px 26px rgba(255, 110, 70, .55);
  opacity: clamp(0, calc(var(--p) * 1.6), 1);
}

/* The sky keeps glowing on the horizon a little after the sun is gone. */
.afterglow {
  position: absolute; left: -10%; right: -10%; bottom: 100px; height: 300px;
  background: radial-gradient(ellipse 55% 100% at 50% 100%, rgba(255, 140, 80, .85), rgba(230, 80, 90, .35) 45%, transparent 72%);
  opacity: clamp(0, min(calc(var(--p) * 2.4), calc((1 - var(--p)) * 3.2)), 1);
}

/* ---------- Clouds ---------- */

.cloud-defs { position: absolute; }
.clouds { position: absolute; inset: 0; pointer-events: none; }
.cloud {
  position: absolute; left: 0; top: var(--top);
  width: var(--w); height: auto; aspect-ratio: 240 / 90;
  opacity: calc(var(--o) * (1 - var(--p) * .35));
  overflow: visible;
  animation: drift var(--dur) linear var(--delay) infinite;
  filter: drop-shadow(0 6px 10px rgba(60, 20, 70, .12));
}
.cloud.bank { aspect-ratio: 420 / 70; }
.cloud.streak { aspect-ratio: 520 / 40; filter: blur(1.5px); }

/* ---------- Land ---------- */

.mountains {
  position: absolute; left: -5%; width: 110%;
  clip-path: polygon(0 100%, 0 72%, 8% 38%, 14% 68%, 23% 24%, 33% 70%, 43% 33%, 52% 73%, 62% 19%, 70% 68%, 81% 30%, 90% 70%, 100% 42%, 100% 100%);
}
.mountains.far { bottom: 120px; height: 210px; background: color-mix(in srgb, #7a5590, #241e4c var(--pct)); opacity: .85; }
.mountains.near {
  bottom: 80px; height: 170px; background: color-mix(in srgb, #3f306c, #100f2c var(--pct));
  clip-path: polygon(0 100%, 0 57%, 11% 27%, 21% 66%, 32% 21%, 44% 70%, 57% 37%, 68% 73%, 80% 25%, 91% 65%, 100% 46%, 100% 100%);
}

.road {
  position: absolute; left: 0; right: 0; bottom: 0; height: 120px;
  border-top: 5px solid color-mix(in srgb, rgba(255, 221, 132, .6), rgba(120, 100, 170, .35) var(--pct));
  background: linear-gradient(180deg, #302552, #17163a);
  overflow: hidden;
}
/* A warm path of light on the road that fades with the sun. */
.road::before {
  position: absolute; inset: 0; content: "";
  background: radial-gradient(ellipse 22% 120% at 50% 0%, rgba(255, 190, 110, .45), transparent 70%);
  opacity: clamp(0, calc(1 - var(--p) * 1.2), 1);
}
.road::after {
  position: absolute; left: 0; top: 55%; width: 100%; height: 4px; content: "";
  background: repeating-linear-gradient(90deg, transparent 0 54px, #f6cf7f 54px 91px);
  opacity: calc(1 - var(--p) * .6);
  transform: perspective(180px) rotateX(44deg);
  animation: roadDash 18s linear infinite;
}

.trainer-danmaku {
  position: absolute; inset: 110px 0 230px; overflow: hidden; pointer-events: none;
  opacity: calc(1 - var(--p) * .6);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.lane { position: absolute; left: 0; right: 0; top: var(--top); overflow: hidden; }
.track { display: flex; width: max-content; animation: danmaku var(--duration) linear var(--delay) infinite; }
.sequence { display: flex; flex: none; gap: 52px; padding-right: 52px; }
.sequence span {
  max-width: 220px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 5px; background: rgba(28, 19, 70, .16); padding: 2px 5px;
  color: #fff7e8; font-size: 13px; font-weight: 900; letter-spacing: .04em; line-height: 1;
  opacity: .26; text-shadow: 0 2px 4px rgba(28, 18, 68, .72);
}
.sequence span.featured { color: var(--gold); opacity: .4; }

/* ---------- Chrome ---------- */

.topbar {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink); text-decoration: none;
  font-family: var(--title); font-size: 18px; letter-spacing: .06em; text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(29, 19, 71, .4);
}
.brand img { width: 26px; height: 26px; }

.site-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 3px solid rgba(255, 255, 255, .7); border-radius: 99px;
  background: var(--button); color: #fff; text-decoration: none;
  padding: 12px 22px;
  font-weight: 900; letter-spacing: .03em;
  box-shadow: 0 10px 26px rgba(16, 12, 54, .35), inset 0 2px rgba(255, 255, 255, .25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.site-button:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(16, 12, 54, .45), inset 0 2px rgba(255, 255, 255, .25); }
.site-button:focus-visible, .controls button:focus-visible, .credits:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.site-button.small { padding: 7px 14px; border-width: 2px; font-size: 13px; }

.controls {
  position: fixed; z-index: 5; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 6px;
  border: 2px solid var(--line); border-radius: 99px;
  background: var(--panel); padding: 5px;
  backdrop-filter: blur(6px);
}
.controls button {
  border: 0; border-radius: 99px; background: transparent; color: var(--ink);
  padding: 6px 12px; font: inherit; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; cursor: pointer;
}
.controls button:hover { background: rgba(255, 255, 255, .12); color: var(--gold); }

/* ---------- Credits roll ---------- */

.credits {
  position: fixed; z-index: 2; inset: 0;
  overflow-y: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 16%, #000 70%, transparent 86%);
  mask-image: linear-gradient(180deg, transparent 0, #000 16%, #000 70%, transparent 86%);
}
.credits::-webkit-scrollbar { display: none; }

.roll {
  width: min(640px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18vh 0 0;
  text-align: center;
  text-shadow: 0 3px 0 rgba(29, 19, 71, .3), 0 8px 22px rgba(24, 17, 64, .35);
}

.chapter { margin: 0 0 22vh; }


h1 {
  margin: 0;
  font-family: var(--title); font-size: clamp(56px, 12vw, 104px); font-weight: 900;
  letter-spacing: .02em; line-height: .9; text-transform: uppercase;
}
h1 span { color: var(--gold); }

.subtitle { margin: 14px 0 0; font-family: var(--title); font-size: clamp(20px, 4vw, 28px); letter-spacing: .12em; text-transform: uppercase; color: #ffd8c4; }

h2 {
  margin: 0 0 22px;
  color: var(--gold);
  font-family: var(--title); font-size: clamp(24px, 5vw, 34px); font-weight: 900;
  letter-spacing: .08em; line-height: 1.05; text-transform: uppercase;
}

.names { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 18px; }
.names span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 900; letter-spacing: .04em; }
.names span:nth-child(7n + 1) { color: var(--gold); }

.letter {
  padding: 28px 30px;
  border: 3px solid rgba(255, 255, 255, .6); border-radius: 22px;
  background: linear-gradient(180deg, rgba(19, 19, 69, .9), rgba(34, 20, 78, .82));
  box-shadow: 0 18px 40px rgba(24, 14, 65, .3);
  text-align: left; text-shadow: none;
  backdrop-filter: blur(8px);
}
.letter h2 { text-align: center; }
.letter p { margin: 0 0 14px; font-size: 16px; line-height: 1.65; }
.letter p:last-child { margin-bottom: 0; color: var(--gold); font-weight: 900; }

.announcement {
  margin: 28px 0 0; padding: 22px 26px;
  border: 3px solid var(--gold); border-radius: 22px;
  background: linear-gradient(180deg, rgba(19, 19, 69, .92), rgba(34, 20, 78, .86));
  box-shadow: 0 18px 40px rgba(24, 14, 65, .3);
  text-shadow: none;
}
.announcement p { margin: 0 0 12px; font-size: 16px; line-height: 1.55; }
.announcement p:first-child { color: var(--gold); font-weight: 900; }
.announcement p:last-child { margin-bottom: 0; }
.announcement a { color: var(--gold); font-weight: 900; text-underline-offset: 3px; }
.announcement a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.finale {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; margin-bottom: 0; padding-bottom: 22vh;
}
.the-end { margin: 0; font-family: var(--title); font-size: clamp(64px, 14vw, 120px); letter-spacing: .06em; line-height: 1; text-transform: uppercase; }
.or-is-it { margin: 6px 0 22px; color: var(--gold); font-family: var(--title); font-size: 24px; letter-spacing: .14em; text-transform: uppercase; }
.finale > p:not([class]) { margin: 0 0 18px; color: var(--muted); font-weight: 800; }
.snapshot { margin: 26px 0 0; color: rgba(255, 247, 232, .6); font-size: 11px; font-weight: 700; letter-spacing: .06em; }

/* ---------- Motion ---------- */

@keyframes twinkle { 50% { filter: brightness(.6); } }
@keyframes drift { from { transform: translateX(-60vw); } to { transform: translateX(160vw); } }
@keyframes roadDash { to { background-position: 91px 0; } }
@keyframes danmaku { to { transform: translateX(-50%); } }
@keyframes shoot {
  0% { opacity: 0; transform: rotate(-24deg) translateX(0); }
  2% { opacity: 1; }
  9% { opacity: 0; transform: rotate(-24deg) translateX(-420px); }
  100% { opacity: 0; transform: rotate(-24deg) translateX(-420px); }
}

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

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .brand { font-size: 15px; }
  .brand img { width: 22px; height: 22px; }
  .sun { width: 104px; height: 104px; margin-left: -52px; bottom: 165px; }
  .sun-halo { width: 520px; height: 520px; margin-left: -260px; bottom: 60px; }
  .afterglow { bottom: 80px; height: 220px; }
  .cloud { width: calc(var(--w) * .6); }
  .mountains.far { bottom: 95px; height: 140px; }
  .mountains.near { bottom: 65px; height: 115px; }
  .road { height: 95px; }
  .trainer-danmaku { inset: 90px 0 200px; }
  .sequence span { font-size: 10px; }
  .chapter:not(.finale) { margin-bottom: 18vh; }
  .names { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .names span { font-size: 13px; }
  .roll { padding-top: 14vh; }
  .announcement { margin-top: 20px; padding: 16px 16px; }
  .announcement p { font-size: 15px; line-height: 1.45; }
  .letter { padding: 22px 18px; }
  .letter p { font-size: 15px; }
  .site-button { padding: 12px 18px; font-size: 14px; }
  .controls { bottom: 10px; }
  .controls button { padding: 5px 9px; font-size: 10px; }
}
