:root {
  color-scheme: dark;
  --ink: #f8f6ff;
  --muted: #aaa5ba;
  --pink: #ff547d;
  --rose: #ff8ca7;
  --violet: #8f6cff;
  --gold: #ffd084;
  --bg: #05050c;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 120%, #321127 0, transparent 42%),
    radial-gradient(circle at 90% 10%, #191040 0, transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button { font: inherit; }

#particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  transition: opacity .9s ease, filter .9s ease;
}

#particles.is-subdued { opacity: .16; filter: blur(1px); }

.noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: .055;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.aurora {
  position: fixed;
  width: 45vw;
  height: 45vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .16;
  pointer-events: none;
  z-index: 0;
  animation: drift 12s ease-in-out infinite alternate;
}

.aurora-one { top: -18vw; left: -8vw; background: var(--violet); }
.aurora-two { right: -16vw; bottom: -19vw; background: var(--pink); animation-delay: -5s; }

.experience {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  isolation: isolate;
}

.sound-toggle {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 999px;
  padding: 9px 13px;
  color: #ded9eb;
  background: rgb(15 13 25 / 62%);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.sound-toggle:hover { border-color: rgb(255 255 255 / 26%); background: rgb(25 22 40 / 78%); }
.sound-toggle:active { transform: scale(.96); }

.sound-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #100a10;
  background: linear-gradient(145deg, var(--rose), var(--gold));
  font-weight: 900;
}

.sound-label { font-size: .82rem; font-weight: 650; }
.sound-toggle[aria-pressed="false"] .sound-icon { color: #c9c4d4; background: #282433; }

.intro {
  width: min(720px, 100%);
  text-align: center;
  transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1), filter .7s ease;
}

.intro.is-leaving { opacity: 0; transform: scale(.92) translateY(-18px); filter: blur(10px); pointer-events: none; }

.eyebrow, .final-kicker {
  margin: 0 0 18px;
  color: var(--rose);
  font-size: clamp(.75rem, 2vw, .9rem);
  font-weight: 800;
  letter-spacing: .21em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.8rem, 9vw, 6.8rem);
  line-height: .96;
  letter-spacing: -.065em;
  text-wrap: balance;
}

.intro h1 em {
  color: transparent;
  background: linear-gradient(105deg, var(--rose), var(--gold) 52%, #dbb6ff);
  -webkit-background-clip: text;
  background-clip: text;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.intro-copy {
  max-width: 510px;
  margin: 24px auto 30px;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.18rem);
}

.start-button, .replay-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #160b12;
  background: linear-gradient(110deg, #fff4f7, #ffb6c8 62%, #ffd79b);
  box-shadow: 0 18px 55px rgb(255 84 125 / 22%);
}

.start-button {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 16px 23px 16px 27px;
  font-size: 1rem;
  font-weight: 850;
  transition: transform .25s ease, box-shadow .25s ease;
}

.start-button:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 21px 65px rgb(255 84 125 / 34%); }
.start-button:active, .replay-button:active { transform: scale(.98); }
.start-button:focus-visible, .replay-button:focus-visible, .sound-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.start-spark { font-size: 1.2rem; animation: sparkle 1.6s ease-in-out infinite; }
.hint { margin: 17px 0 0; color: #968fa6; font-size: .8rem; }

.story {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.story.is-active { opacity: 1; }
.story.is-waiting { pointer-events: auto; cursor: pointer; }

.envelope-prompt {
  position: fixed;
  left: 50%;
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 56px));
  z-index: 6;
  transform: translateX(-50%);
  border: 1px solid rgb(255 182 200 / 32%);
  border-radius: 999px;
  padding: 10px 20px;
  color: #ffeaf0;
  background: rgb(22 14 32 / 72%);
  backdrop-filter: blur(12px);
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  animation: pulsePrompt 1.8s ease-in-out infinite;
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}

.envelope-prompt:hover { border-color: rgb(255 215 155 / 65%); background: rgb(36 20 48 / 85%); transform: translateX(-50%) scale(1.03); }
.envelope-prompt:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

.terminal {
  position: absolute;
  top: max(9vh, 76px);
  left: 50%;
  display: flex;
  align-items: center;
  width: min(520px, calc(100% - 44px));
  min-height: 48px;
  transform: translateX(-50%);
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 13px;
  padding: 0 17px;
  background: rgb(9 8 16 / 58%);
  backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity .5s ease, transform .5s ease;
}

.story.is-active .terminal { opacity: 1; transform: translateX(-50%) translateY(0); }
.story.is-active .terminal.is-gone { opacity: 0; transform: translateX(-50%) translateY(-14px); }
.terminal-dot { width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
.dot-pink { background: #ff668b; }
.dot-gold { background: #ffd070; }
.dot-green { background: #64dcaf; }
.terminal-line { margin: 0 0 0 8px; color: #bdb7cb; font: 600 .78rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; overflow: hidden; }
.terminal-line::after { content: "_"; color: var(--rose); animation: blink .8s steps(1) infinite; }

.final-message {
  width: min(1040px, 100%);
  text-align: center;
  opacity: 0;
  transform: translateY(20px) scale(.96);
  filter: blur(8px);
  transition: opacity 1s ease, transform 1s cubic-bezier(.2,.8,.2,1), filter 1s ease;
}

.final-message.is-visible { opacity: 1; transform: none; filter: none; pointer-events: auto; }
.final-message h2 { margin: 0; font-size: clamp(2.6rem, 11vw, 7.8rem); line-height: .88; letter-spacing: -.06em; text-transform: uppercase; }
.final-message h2 span:first-child { display: block; color: #fff; }
.final-message h2 span:last-child {
  display: block;
  padding-inline: .12em;
  color: transparent;
  background: linear-gradient(100deg, var(--pink), var(--gold) 54%, #c8a7ff);
  -webkit-background-clip: text;
  background-clip: text;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 500;
}

.final-copy { max-width: 590px; margin: 28px auto 0; color: #bbb5c7; font-size: clamp(1rem, 2.4vw, 1.18rem); text-wrap: balance; }
.replay-button { margin-top: 26px; padding: 11px 18px; font-size: .86rem; font-weight: 800; opacity: .9; transition: transform .25s ease, opacity .25s ease, box-shadow .25s ease; }
.replay-button:hover { opacity: 1; transform: translateY(-2px); box-shadow: 0 21px 65px rgb(255 84 125 / 34%); }

.progress {
  position: fixed;
  left: 50%;
  bottom: max(38px, calc(env(safe-area-inset-bottom) + 24px));
  width: min(260px, 54vw);
  height: 2px;
  overflow: hidden;
  transform: translateX(-50%);
  border-radius: 99px;
  background: rgb(255 255 255 / 9%);
  opacity: 0;
}

.progress.is-visible { opacity: 1; }
.music { position: fixed; z-index: -1; right: 0; bottom: 0; width: 200px; height: 200px; overflow: hidden; opacity: .01; pointer-events: none; }
.music iframe { display: block; width: 200px; height: 200px; border: 0; }
.progress span { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--gold)); }

.signature { position: fixed; left: max(20px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); margin: 0; color: #5d5868; font-size: .68rem; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }

noscript { position: fixed; inset: auto 20px 20px; z-index: 20; border-radius: 10px; padding: 14px; color: #fff; background: #9f2242; }

@keyframes drift { to { transform: translate3d(9vw, 7vh, 0) scale(1.15); } }
@keyframes sparkle { 50% { transform: rotate(18deg) scale(1.35); opacity: .62; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulsePrompt { 0%, 100% { opacity: .82; box-shadow: 0 0 22px rgb(255 84 125 / 18%); } 50% { opacity: 1; box-shadow: 0 0 32px rgb(255 84 125 / 42%); } }

@media (max-width: 600px) {
  .sound-label { display: none; }
  .sound-toggle { padding: 7px; }
  .experience { padding-inline: 18px; }
  .intro h1 { font-size: clamp(2.75rem, 15vw, 4.8rem); }
  .terminal { top: max(12vh, 80px); }
  .terminal-line { font-size: .68rem; }
  .final-message h2 { font-size: clamp(1.85rem, 9.5vw, 3.4rem); }
  .final-copy { max-width: 310px; margin-top: 24px; line-height: 1.45; }
  .signature { display: none; }
}

@media (max-height: 560px) {
  .intro h1 { font-size: clamp(2.1rem, 7vw, 3.6rem); }
  .intro-copy { margin: 14px auto 18px; }
  .terminal { top: 16px; }
  .final-message h2 { font-size: clamp(2.8rem, 11vw, 5.2rem); }
  .final-copy { margin-top: 14px; }
  .replay-button { margin-top: 16px; }
  .signature { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .aurora { display: none; }
}
