:root {
  /* day — cream (default) */
  --is-night: 0;
  --bg-rgb: 255 244 236;
  --ink-rgb: 78 52 92;
  --accent-rgb: 46 201 167;
  --violet-rgb: 138 118 255;
  --pink-rgb: 255 114 184;
  --green-rgb: 63 207 142;
  --scrim: .5;
  --vig: .55;
  --grain-opacity: .05;
  --grain-blend: multiply;
  --scan-opacity: .3;
  --boot-bg: #fff8f2;
  --title-glow: rgb(var(--pink-rgb) / .22);
  --outline-filter: url(#outline-day);

  --bg: rgb(var(--bg-rgb));
  --ink: rgb(var(--ink-rgb));
  --dim: rgb(var(--ink-rgb) / .64);
  --faint: rgb(var(--ink-rgb) / .38);
  --cyan: rgb(var(--accent-rgb));
  --violet: rgb(var(--violet-rgb));
  --pink: rgb(var(--pink-rgb));
  --green: rgb(var(--green-rgb));
  --display: "Unbounded", "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --pad: clamp(16px, 2.6vw, 38px);
  --marquee-h: 34px;
}

/* night — plum. System preference wins unless the toggle stored a choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="day"]) {
    --is-night: 1;
    --bg-rgb: 19 12 32;
    --ink-rgb: 255 241 251;
    --accent-rgb: 126 245 214;
    --violet-rgb: 183 155 255;
    --pink-rgb: 255 154 213;
    --green-rgb: 157 243 196;
    --scrim: .4;
    --vig: .72;
    --grain-opacity: .085;
    --grain-blend: screen;
    --scan-opacity: 1;
    --boot-bg: #0d0718;
    --title-glow: rgb(var(--accent-rgb) / .3);
    --outline-filter: url(#outline-night);
  }
}
:root[data-theme="night"] {
  --is-night: 1;
  --bg-rgb: 19 12 32;
  --ink-rgb: 255 241 251;
  --accent-rgb: 126 245 214;
  --violet-rgb: 183 155 255;
  --pink-rgb: 255 154 213;
  --green-rgb: 157 243 196;
  --scrim: .4;
  --vig: .72;
  --grain-opacity: .085;
  --grain-blend: screen;
  --scan-opacity: 1;
  --boot-bg: #0d0718;
  --title-glow: rgb(var(--accent-rgb) / .3);
  --outline-filter: url(#outline-night);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

body {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color .6s ease, color .6s ease;
}

::selection { background: var(--cyan); color: var(--bg); }

/* ---------- background layers ---------- */

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 2.4s ease;
}
body.is-ready #gl { opacity: 1; }

.no-webgl #gl { display: none; }
.no-webgl body {
  background:
    radial-gradient(60% 50% at 30% 40%, rgb(var(--violet-rgb) / .22), transparent 70%),
    radial-gradient(50% 50% at 72% 62%, rgb(var(--accent-rgb) / .16), transparent 70%),
    var(--bg);
}

.fx { position: fixed; inset: 0; pointer-events: none; }

.fx-vignette {
  z-index: 2;
  background:
    radial-gradient(ellipse 62% 42% at 50% 52%, rgb(var(--bg-rgb) / var(--scrim)), rgb(var(--bg-rgb) / 0) 72%),
    radial-gradient(ellipse at 50% 48%, transparent 42%, rgb(var(--bg-rgb) / var(--vig)) 100%);
}

.fx-scan {
  z-index: 3;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .028) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
  opacity: var(--scan-opacity);
}
.fx-scan::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -20vh;
  height: 20vh;
  background: linear-gradient(to bottom, transparent, rgb(var(--accent-rgb) / .05), transparent);
  animation: sweep 7s linear infinite;
}

.fx-grain {
  z-index: 4;
  inset: -120px;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain .9s steps(6) infinite;
}

.frame {
  --c: rgb(var(--accent-rgb) / .38);
  --l: 18px;
  position: fixed;
  z-index: 5;
  inset: calc(var(--pad) * .45);
  bottom: calc(var(--marquee-h) + var(--pad) * .45);
  pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1px var(--l) no-repeat;
}

/* ---------- cursor ---------- */

#cursor-dot, #cursor-ring {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 90;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  will-change: transform;
}
#cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  transition: opacity .3s;
}
#cursor-ring {
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 1px solid rgb(var(--accent-rgb) / .55);
  transition: opacity .3s, width .3s, height .3s, margin .3s, border-color .3s, background-color .3s;
}
body.has-cursor #cursor-dot, body.has-cursor #cursor-ring { opacity: 1; }
body.cursor-hover #cursor-ring {
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-color: var(--pink);
  background-color: rgb(var(--pink-rgb) / .07);
}
body.cursor-down #cursor-ring {
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-color: var(--ink);
}
@media (pointer: fine) {
  body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: var(--pad);
  color: var(--dim);
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease .6s;
}
body.is-ready .hud { opacity: 1; }
.hud a { pointer-events: auto; }
.hud-top { top: 0; padding-top: max(var(--pad), env(safe-area-inset-top)); }
.hud-bottom { bottom: var(--marquee-h); align-items: flex-end; }

.hud-block { display: grid; gap: 6px; font-size: 11px; }
.hud-right { text-align: right; }
.hud-block span:not(.k) { color: var(--ink); font-variant-numeric: tabular-nums; }
.k { color: var(--faint); margin-right: .7em; }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: .7em;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .2em;
}
.brand svg { width: 34px; height: 34px; color: var(--ink); transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.brand:hover svg { transform: rotate(-180deg); }
.brand b { color: var(--cyan); font-weight: 400; padding: 0 .2em; }

.hud-tools { display: flex; align-items: center; gap: 14px; }
.hud button { pointer-events: auto; }
.theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(var(--accent-rgb) / .5);
  border-radius: 50%;
  background: rgb(var(--bg-rgb) / .3);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), border-color .3s, background-color .3s, color .3s;
}
.theme-toggle:hover { transform: rotate(-25deg) scale(1.12); border-color: var(--pink); color: var(--pink); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }

.hint {
  align-self: flex-end;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: .32em;
  animation: breathe 3.2s ease-in-out infinite;
}

/* ---------- stage ---------- */

.stage {
  position: fixed;
  inset: 0;
  bottom: var(--marquee-h);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 var(--pad);
  text-align: center;
  pointer-events: none;
  will-change: transform;
}

.kicker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6em 2.6em;
  margin-bottom: clamp(14px, 3.2vh, 36px);
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .35em;
}

.title {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: min(12vw, 24vh);
  line-height: .9;
  letter-spacing: -.01em;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
}
.line { display: block; white-space: nowrap; perspective: 800px; }
.line.sub { margin-top: .28em; font-size: .4em; letter-spacing: .03em; }

.dot.dot-warn { background: var(--pink); box-shadow: 0 0 10px var(--pink); }

.title { --ab: 1.5; }

.char {
  display: inline-block;
  position: relative;
  text-align: center;
  transform-origin: 50% 80%;
  transition: transform .55s cubic-bezier(.2, .8, .2, 1), opacity .55s ease, color .3s, text-shadow .3s, -webkit-text-stroke-color .3s;
}
.solid .char {
  color: var(--ink);
  text-shadow:
    calc(var(--ab) * -1px) 0 rgb(var(--pink-rgb) / .8),
    calc(var(--ab) * 1px) 0 rgb(var(--accent-rgb) / .8),
    0 0 42px var(--title-glow);
}
/* Hollow letters via an SVG dilate filter: text-stroke draws the variable font's
   overlapping contours, the filter only sees the merged glyph silhouette. */
.defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.outline .char {
  color: var(--cyan);
  filter: var(--outline-filter);
}
.outline .char.lit {
  filter: none;
  text-shadow: 0 0 24px rgb(var(--accent-rgb) / .9), 0 0 90px rgb(var(--accent-rgb) / .55);
}
.char:hover, .char.glitch { transform: translateY(-.07em) skewX(-9deg); }
.solid .char:hover { color: var(--pink); }
.outline .char:hover {
  color: var(--pink);
  filter: none;
  text-shadow: 0 0 30px rgb(var(--pink-rgb) / .8);
}

body.is-booting .char,
.title.intro .char { opacity: 0; transform: translateY(.45em) rotateX(-85deg); }
.title.intro.go .char {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--i, 0) * 55ms);
}

.tagline {
  margin-top: clamp(18px, 4.2vh, 46px);
  color: var(--dim);
  font-size: clamp(11px, 1.05vw, 14px);
  letter-spacing: .45em;
  white-space: nowrap;
}
.tagline .tilde { color: var(--cyan); }
#tagline { display: inline-block; min-width: 23ch; }

.return {
  display: inline-flex;
  align-items: center;
  gap: .9em;
  margin-top: clamp(22px, 4.5vh, 44px);
  padding: 14px 24px;
  border: 1px solid rgb(var(--accent-rgb) / .4);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .35em;
  text-decoration: none;
  pointer-events: auto;
  transition: background-color .3s, border-color .3s, color .3s;
}
.return:hover { background-color: var(--cyan); border-color: var(--cyan); color: var(--bg); }

/* ---------- marquee ---------- */

.marquee {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--marquee-h);
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 1px solid rgb(var(--accent-rgb) / .14);
  background: rgb(var(--bg-rgb) / .55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.marquee-track {
  display: flex;
  white-space: nowrap;
  animation: marquee 60s linear infinite;
  will-change: transform;
}
.marquee-track span { color: var(--dim); font-size: 11px; letter-spacing: .3em; }
.marquee-track em { padding: 0 .9em; color: var(--cyan); font-style: normal; }

/* ---------- boot ---------- */

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) * 1.6);
  background: var(--boot-bg);
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.1s cubic-bezier(.77, 0, .18, 1);
  animation: boot-fallback .01s linear 7s forwards;
}
#boot.done { clip-path: inset(0 0 100% 0); }

.boot-inner { width: min(580px, 100%); color: var(--dim); font-size: 12px; }
.boot-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--ink);
  letter-spacing: .25em;
}
#boot-pct { font-variant-numeric: tabular-nums; }
#boot-log {
  height: 12.8em;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  line-height: 1.55;
  white-space: pre;
}
#boot-log .ok { color: var(--green); }
#boot-log .c { color: var(--cyan); }
.boot-bar { margin-top: 14px; height: 2px; overflow: hidden; background: rgb(var(--accent-rgb) / .12); }
.boot-bar i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 12px var(--cyan);
}

/* ---------- keyframes ---------- */

@keyframes sweep { to { transform: translateY(140vh); } }
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-40px, 30px); }
  40% { transform: translate(30px, -50px); }
  60% { transform: translate(-60px, -20px); }
  80% { transform: translate(50px, 40px); }
  100% { transform: translate(-20px, 60px); }
}
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
@keyframes breathe { 50% { opacity: .35; } }
@keyframes marquee { to { transform: translate3d(-50%, 0, 0); } }
@keyframes boot-fallback { to { opacity: 0; visibility: hidden; } }

/* ---------- responsive / a11y ---------- */

@media (max-width: 720px) {
  .hint { display: none; }
  .brand span { font-size: 10px; letter-spacing: .14em; }
  .brand svg { width: 28px; height: 28px; }
  .hud-block { gap: 4px; font-size: 10px; }
  .kicker { gap: .5em 1.4em; font-size: 9px; letter-spacing: .24em; }
  .kicker span:last-child { display: none; }
  .title { font-size: min(12.5vw, 22vh); }
  .tagline { letter-spacing: .24em; font-size: 10px; }
  #tagline { min-width: 21ch; }
}

@media (max-height: 460px) {
  .kicker, .hud-bottom .hud-block div:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-grain, .fx-scan::after, .dot, .hint { animation: none; }
  .marquee-track { animation-duration: 240s; }
}
