/* Layout: one sticky full-screen stage inside a tall scroll track. Scrolling raises the
   camera from a dusk hilltop, through cloud country, into space and down onto the moon. */
:root {
  --teal: #0a7e86;        /* the old desktop wallpaper */
  --navy: #0b1050;
  --void: #04051a;
  --gold: #ffd60a;
  --magenta: #ff2ed6;
  --ink: #0e0a22;
  --display: "Titan One", "Arial Rounded MT Bold", "Arial Black", system-ui, sans-serif;
  color-scheme: dark;
}

html { background: var(--void); }
body {
  margin: 0;
  background: var(--void);
  color: #fff;
  font-family: var(--display);
  overflow-x: hidden;
}

.track { position: relative; height: 560vh; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  cursor: crosshair;
  background: var(--teal);
}

/* CRT scanlines over everything, very faint */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .09) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

.stage canvas,
.stage img,
.layer { position: absolute; left: 0; top: 0; }

.stage img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
  will-change: transform;
  max-width: none;
}

#sky { width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; }
#moon { width: 320px; height: 320px; transform-origin: 0 0; z-index: 1;
  filter: drop-shadow(0 0 18px rgba(255, 246, 200, .45)); }
#earth { z-index: 1; opacity: 0; }
.terrain { z-index: 2; transform-origin: 0 0; }
#layer-back { z-index: 3; }
#coins-back { z-index: 4; pointer-events: none; }
.title-wrap { z-index: 5; }
#computer, #ground-front { z-index: 6; }
#wizard, #flag { z-index: 7; transform-origin: 0 0; }
#layer-front { z-index: 8; }
#fx { z-index: 9; pointer-events: none; }
#hint { z-index: 10; }

.layer { width: 100%; height: 100%; pointer-events: none; }

/* ------------------------------------------------------------------ WordArt title */
.title-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 26vh;
  perspective: 900px;
}

.title {
  margin: 0;
  display: grid;
  justify-items: center;
  font-weight: 400;
  line-height: .9;
  letter-spacing: -.01em;
  text-transform: lowercase;
  transform-style: preserve-3d;
}

.word { display: block; white-space: nowrap; will-change: transform; }

.l {
  position: relative;
  display: inline-block;
  color: var(--ext);
  -webkit-text-stroke: .07em var(--ink);
  paint-order: stroke fill;
  text-shadow:
    .012em .014em 0 var(--ext), .024em .028em 0 var(--ext), .036em .042em 0 var(--ext),
    .048em .056em 0 var(--ext), .06em .07em 0 var(--ext), .072em .084em 0 var(--ext),
    .084em .098em 0 var(--ext), .096em .112em 0 var(--ink), .11em .13em 0 var(--ink),
    .16em .2em .06em rgba(4, 5, 26, .55);
}
.l::after {
  content: attr(data-ch);
  position: absolute;
  left: 0;
  top: 0;
  color: transparent;
  -webkit-text-stroke: 0;
  text-shadow: none;
  background: var(--fill);
  background-size: 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

/* magic: arched like a spell, pink-to-violet */
.w-magic {
  font-size: clamp(2.6rem, min(11.5vw, 15vh), 8.5rem);
  --ext: #3a0b6e;
  --fill: linear-gradient(180deg, #fff 8%, #ffc4f6 30%, #ff2ed6 58%, #8a3cff 100%);
  margin-bottom: -.06em;
}
.w-magic .l { transform: translateY(var(--y, 0)) rotate(var(--r, 0deg)); }
.w-magic .l:nth-child(1) { --y: .26em; --r: -18deg; }
.w-magic .l:nth-child(2) { --y: .07em; --r: -9deg; }
.w-magic .l:nth-child(3) { --y: 0em;   --r: 0deg; }
.w-magic .l:nth-child(4) { --y: .07em; --r: 9deg; }
.w-magic .l:nth-child(5) { --y: .26em; --r: 18deg; }

/* internet: chrome with a horizon line, tilted back */
.w-internet {
  font-size: clamp(3rem, min(14.5vw, 19vh), 11rem);
  --ext: #0a1f6a;
  --fill: linear-gradient(180deg, #fff 0%, #c9f6ff 30%, #4fc6ff 49%, #0d3fa8 50.5%, #9ff0ff 54%, #2de2ff 78%, #e9fdff 100%);
  transform-origin: 50% 70%;
}

/* money: gold, letters riding a wave */
.w-money {
  font-size: clamp(3.4rem, min(17vw, 22vh), 13rem);
  --ext: #6b3200;
  --fill: linear-gradient(180deg, #fffbd6 0%, #ffe24a 30%, #ffb300 52%, #ff8a00 56%, #ffe56b 72%, #c45f00 100%);
  margin-top: -.04em;
}
.w-money .l { animation: bob 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -.32s); }

@keyframes bob {
  0%, 100% { transform: translateY(-.05em) rotate(-3deg); }
  50% { transform: translateY(.06em) rotate(3deg); }
}

/* sheen that sweeps across the chrome and gold every few seconds */
.w-internet .l::after, .w-money .l::after {
  background-image: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .95) 48%, transparent 56%), var(--fill);
  background-size: 300% 100%, 100% 100%;
  background-repeat: no-repeat;
  animation: sheen 5.5s ease-in-out infinite;
  animation-delay: calc(var(--i) * .07s);
}
.w-money .l::after { animation-delay: calc(1.6s + var(--i) * .07s); }
@keyframes sheen {
  0%, 55% { background-position: 150% 0, 0 0; }
  85%, 100% { background-position: -60% 0, 0 0; }
}

/* ------------------------------------------------------------------ scroll hint */
#hint {
  left: 50%;
  top: auto;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  animation: nudge 1.1s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { translate: -50% 0; }
  50% { translate: -50% 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .w-money .l, .w-internet .l::after, .w-money .l::after, #hint { animation: none; }
  #hint { translate: -50% 0; }
}
