:root {
  --pink: #ff4fa3;
  --orange: #ff9a3c;
  --yellow: #ffe45e;
  --mint: #4dffc3;
  --cyan: #38d6ff;
  --violet: #9b5cff;
  --ink: #12002b;
  --display: "Unbounded", "Arial Black", "Avenir Next Heavy", Impact, system-ui, sans-serif;
  --body: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --rainbow: linear-gradient(90deg, var(--pink), var(--orange), var(--yellow), var(--mint), var(--cyan), var(--violet), var(--pink));
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 40%, #3a0b6e 0%, var(--ink) 55%, #05000f 100%);
  color: #fff;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  body.live, body.live button { cursor: none; }
}

/* ───────────── Intro ───────────── */
#intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(90% 70% at 50% 50%, rgba(18, 0, 43, .55) 0%, rgba(18, 0, 43, .15) 60%, transparent 100%);
  transition: opacity .9s ease, transform 1.1s cubic-bezier(.7, 0, .2, 1), filter .9s ease;
}
#intro.gone {
  opacity: 0;
  transform: scale(1.6);
  filter: blur(18px);
  pointer-events: none;
}
.intro-inner { max-width: 1100px; }

.eyebrow {
  font-size: clamp(11px, 1.4vw, 15px);
  letter-spacing: .6em;
  text-transform: uppercase;
  opacity: .85;
  margin-bottom: 1.2em;
  padding-left: .6em;
}

.title {
  font-family: var(--display);
  font-weight: 900;
  line-height: .92;
  font-size: clamp(44px, 12.5vw, 190px);
  letter-spacing: -.02em;
  filter: drop-shadow(0 0 40px rgba(255, 79, 163, .55)) drop-shadow(0 12px 0 rgba(10, 0, 30, .35));
}
.title .word { display: block; white-space: nowrap; }
.title .ch {
  display: inline-block;
  background: var(--rainbow);
  background-size: 600% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: bob 2.4s ease-in-out infinite, slide 9s linear infinite;
  animation-delay: calc(var(--i) * -.14s), calc(var(--i) * -.55s);
  will-change: transform;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0) scale(1); }
  50% { transform: translateY(-.07em) rotate(calc(var(--r) * 1deg)) scale(1.04); }
}
@keyframes slide { to { background-position: 600% 0; } }

.tagline {
  margin-top: 1.6em;
  font-size: clamp(14px, 1.7vw, 20px);
  opacity: .92;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .6);
}

#enter {
  position: relative;
  margin-top: 2.2em;
  font: 900 clamp(15px, 1.6vw, 20px) var(--display);
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 1.25em 3em 1.25em 3.28em;
  background: var(--rainbow);
  background-size: 300% 100%;
  animation: slide 5s linear infinite, breathe 1.15s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .22), 0 14px 50px rgba(255, 79, 163, .65), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 4px 0 rgba(255, 255, 255, .5);
  cursor: pointer;
  transition: transform .2s cubic-bezier(.3, 1.8, .5, 1);
}
#enter:hover { transform: scale(1.1) rotate(-2deg); }
#enter:active { transform: scale(.94); }
#enter:focus-visible { outline: 3px solid #fff; outline-offset: 6px; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 255, 255, .22), 0 14px 50px rgba(255, 79, 163, .65), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 4px 0 rgba(255, 255, 255, .5); }
  50% { box-shadow: 0 0 0 12px rgba(255, 255, 255, .08), 0 14px 80px rgba(155, 92, 255, .9), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 4px 0 rgba(255, 255, 255, .5); }
}

.fineprint {
  margin-top: 2.2em;
  font-size: 12px;
  letter-spacing: .12em;
  opacity: .6;
}

/* ───────────── HUD ───────────── */
#hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity 1.2s ease .5s;
}
body.live #hud { opacity: 1; }
#hud button, #hud nav { pointer-events: auto; }

.hud-top, .hud-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 16px;
}
.hud-bottom { align-items: end; }

.brand {
  font: 900 14px var(--display);
  letter-spacing: .18em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
.brand b {
  margin-left: .35em;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: slide 6s linear infinite;
}

.meter-wrap { width: min(340px, 44vw); text-align: center; }
.meter-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  margin-bottom: 7px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .7);
}
#score {
  font: 900 17px var(--display);
  letter-spacing: .04em;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}
#score.bump { animation: bump .28s cubic-bezier(.3, 2.4, .5, 1); }
@keyframes bump { 0% { transform: scale(1.5); color: var(--yellow); } 100% { transform: scale(1); } }

.meter {
  height: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), 0 4px 22px rgba(0, 0, 0, .35);
  overflow: hidden;
  backdrop-filter: blur(6px);
}
#meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  border-radius: 99px;
  background: var(--rainbow);
  background-size: 300% 100%;
  animation: slide 3s linear infinite;
  box-shadow: 0 0 18px var(--pink);
}
body.euphoria .meter { box-shadow: inset 0 0 0 1px #fff, 0 0 30px var(--yellow), 0 0 60px var(--pink); }

#combo {
  height: 22px;
  margin-top: 6px;
  font: 900 15px var(--display);
  letter-spacing: .1em;
  color: var(--yellow);
  text-shadow: 0 0 16px var(--orange);
  opacity: 0;
  transition: opacity .3s;
}
#combo.on { opacity: 1; }
#combo.hit { animation: bump .25s cubic-bezier(.3, 2.4, .5, 1); }

.controls { display: flex; gap: 10px; justify-content: flex-end; }
.controls button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(20, 0, 50, .35);
  backdrop-filter: blur(8px);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), background .2s;
}
.controls button:hover { transform: scale(1.15); background: rgba(255, 79, 163, .55); }
.controls button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.controls .spk { fill: currentColor; stroke: none; }
.controls .mute { display: none; }
body.muted .controls .mute { display: block; }
body.muted .controls .wave { display: none; }

.world { text-shadow: 0 2px 22px rgba(0, 0, 0, .65); }
.world-index { font-size: 11px; letter-spacing: .4em; opacity: .75; margin-bottom: 6px; }
.world-name {
  font: 900 clamp(22px, 3.6vw, 50px) var(--display);
  line-height: 1;
  letter-spacing: -.01em;
}
.world-sub { margin-top: 8px; font-size: 13px; opacity: .8; letter-spacing: .04em; }
.world.swap .world-name, .world.swap .world-sub, .world.swap .world-index { animation: rise .8s cubic-bezier(.2, .9, .2, 1) both; }
.world.swap .world-sub { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(26px) skewY(4deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

.dots { display: flex; gap: 12px; padding-bottom: 6px; }
.dots button {
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .8);
  background: transparent;
  transition: transform .25s cubic-bezier(.3, 1.8, .5, 1), background .25s, box-shadow .25s;
  position: relative;
}
.dots button::after { content: ""; position: absolute; inset: -10px; }
.dots button:hover { transform: scale(1.4); }
.dots button.on { background: #fff; transform: scale(1.35); box-shadow: 0 0 18px #fff, 0 0 40px var(--pink); }
.dots button:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.hint {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  flex-wrap: wrap;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .8;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .8);
}
.hint span { white-space: nowrap; }
kbd {
  font: inherit;
  padding: 3px 8px;
  margin-right: 5px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(20, 0, 50, .35);
}

/* ───────────── Pops, banner, cursor ───────────── */
#pops { position: fixed; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute;
  left: 0;
  top: 0;
  font: 900 clamp(20px, 3.2vw, 44px) var(--display);
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 18px var(--c, var(--pink)), 0 0 44px var(--c, var(--pink)), 0 4px 0 rgba(10, 0, 30, .4);
  animation: pop 1s cubic-bezier(.15, .85, .3, 1) forwards;
  will-change: transform, opacity;
}
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(var(--rot)); opacity: 0; }
  18% { transform: translate(-50%, -90%) scale(1.25) rotate(var(--rot)); opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(.9) rotate(calc(var(--rot) * -1)); opacity: 0; }
}

#banner {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
}
#banner span {
  font: 900 clamp(40px, 13vw, 210px) var(--display);
  letter-spacing: -.02em;
  background: var(--rainbow);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, .7);
  filter: drop-shadow(0 0 50px rgba(255, 228, 94, .8));
  animation: slide 1.6s linear infinite;
}
#banner.show { animation: banner 2.6s cubic-bezier(.2, .9, .2, 1) forwards; }
@keyframes banner {
  0% { opacity: 0; transform: scale(.3) rotate(-8deg); filter: blur(0); }
  14% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  24% { transform: scale(1) rotate(0); }
  75% { opacity: 1; transform: scale(1.04); filter: blur(0); }
  100% { opacity: 0; transform: scale(1.7); filter: blur(14px); }
}

#cursor { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; display: none; mix-blend-mode: screen; }
@media (hover: hover) and (pointer: fine) { body.live #cursor { display: block; } }
#cursor i, #cursor b { position: absolute; left: 0; top: 0; border-radius: 50%; will-change: transform; }
#cursor i {
  width: 10px; height: 10px; margin: -5px;
  background: #fff;
  box-shadow: 0 0 14px #fff, 0 0 30px var(--pink);
}
#cursor b {
  width: 44px; height: 44px; margin: -22px;
  border: 2px solid rgba(255, 255, 255, .8);
  box-shadow: 0 0 20px rgba(255, 79, 163, .7), inset 0 0 14px rgba(56, 214, 255, .5);
  transition: width .25s, height .25s, margin .25s, border-color .25s;
}
#cursor.down b { width: 76px; height: 76px; margin: -38px; border-color: var(--yellow); }

.noscript, .fatal {
  position: fixed; inset: 0; z-index: 99; display: grid; place-items: center; padding: 30px;
  text-align: center; font-size: 18px; background: var(--ink);
}

@media (max-width: 720px) {
  .hud-top { grid-template-columns: 1fr auto; }
  .brand { display: none; }
  .meter-wrap { width: min(260px, 58vw); text-align: left; }
  .hud-bottom { grid-template-columns: 1fr auto; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .title .ch, #enter { animation: slide 20s linear infinite; }
}
