:root {
  color-scheme: dark;
  font-family:
    "WinkyRough",
    "Microsoft JhengHei",
    "PingFang TC",
    system-ui,
    sans-serif;
  background: #101412;
  color: #f4f0e9;
  font-weight: 300;
}

@font-face {
  font-family: "Julee";
  src: url("assets/Julee-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "WinkyRough";
  src: url("assets/WinkyRough-VariableFont_wght.ttf") format("truetype");
  font-display: swap;
  font-weight: 300 900;
}

@font-face {
  font-family: "Inter";
  src: url("assets/Inter-Regular.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(74, 140, 105, 0.22), transparent 30%),
    linear-gradient(135deg, #121917 0%, #20241d 42%, #101412 100%);
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-rows: minmax(420px, 1fr);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 2px;
}

.toolbar h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 500;
}

.toolbar p {
  max-width: 720px;
  margin: 0;
  color: #c9d3c1;
  line-height: 1.6;
}

.distance-meter {
  flex: 0 0 auto;
  min-width: 132px;
  padding-left: 18px;
  border-left: 1px solid rgba(244, 240, 233, 0.18);
  color: #c9d3c1;
}

.distance-meter span,
.distance-meter output {
  display: block;
}

.distance-meter span {
  margin-bottom: 3px;
  font-size: 0.78rem;
}

.distance-meter output {
  color: rgba(184, 231, 133, 0.92);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #0d110f;
  isolation: isolate;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #b9c3b0;
  pointer-events: none;
  z-index: 0;
}

.empty-state span {
  border: 1px solid rgba(244, 240, 233, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(16, 20, 18, 0.74);
}

.stage.has-image .empty-state {
  display: none;
}

.scene-layer,
#sparkLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-background {
  display: none;
  object-fit: cover;
  object-position: center bottom;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 1;
}

.stage.has-image .scene-background {
  display: block;
}

.entrance-overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 8, 0.2);
  opacity: 1;
  pointer-events: auto;
  transition:
    opacity 900ms ease,
    visibility 900ms ease;
}

.preload-panel {
  display: grid;
  width: min(360px, calc(100vw - 48px));
  justify-items: center;
  gap: 18px;
}

.preload-status {
  min-height: 24px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 300;
  letter-spacing: 0;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.36);
}

.preload-track {
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.preload-track span {
  display: block;
  width: var(--preload-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.22));
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.52);
  transition: width 220ms ease;
}

.entrance-button {
  min-width: 112px;
  min-height: 46px;
  padding: 0 26px;
  border: 1px solid rgba(214, 242, 222, 0.5);
  border-radius: 999px;
  background: rgba(14, 26, 21, 0.46);
  color: #ffffff;
  cursor: pointer;
  font-family: "Julee", cursive;
  font-size: clamp(1.15rem, 2.3vw, 1.65rem);
  line-height: 1;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.4);
  box-shadow:
    0 0 18px rgba(197, 233, 206, 0.24),
    inset 0 0 22px rgba(255, 255, 255, 0.08);
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.entrance-button[hidden] {
  display: none;
}

.entrance-button:hover,
.entrance-button:focus-visible {
  background: rgba(27, 48, 36, 0.62);
  color: #c8ef9a;
  box-shadow:
    0 0 28px rgba(157, 212, 104, 0.48),
    inset 0 0 22px rgba(255, 255, 255, 0.12);
  transform: translateY(-1px) scale(1.03);
}

.entrance-button:focus-visible {
  outline: 2px solid rgba(184, 231, 133, 0.84);
  outline-offset: 4px;
}

body.experience-started .entrance-overlay {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

#sparkLayer {
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.completion-reveal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.82);
  transition:
    opacity 600ms ease,
    transform 600ms ease;
}

.completion-reveal.is-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.completion-button {
  position: relative;
  top: 96px;
  display: grid;
  width: 58px;
  height: 56px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition:
    opacity 260ms ease,
    background-color 180ms ease,
    transform 180ms ease;
}

.completion-reveal.is-visible .completion-button {
  animation:
    completionButtonEntrance 1800ms cubic-bezier(0.16, 0.8, 0.24, 1.16) both,
    completionButtonFlicker 1.7s 1800ms ease-in-out infinite alternate;
}

.completion-button.is-dismissed {
  animation: dismissCompletionButton 420ms ease forwards;
  opacity: 0;
  transform: scale(0.72);
  pointer-events: none;
}

.completion-reveal.is-visible .completion-button.is-dismissed {
  animation: dismissCompletionButton 420ms ease forwards;
}

.completion-button:hover,
.completion-button:focus-visible {
  filter: drop-shadow(0 0 18px rgba(184, 231, 133, 0.58));
  transform: scale(1.06);
  animation-play-state: paused;
}

.completion-button:focus-visible {
  outline: 2px solid rgba(184, 231, 133, 0.84);
  outline-offset: 4px;
}

.completion-button img {
  width: 50px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.5));
  animation: rotateCounterclockwise 9s linear infinite;
}

.completion-button:hover img,
.completion-button:focus-visible img {
  animation-play-state: paused;
}

.completion-copy {
  position: absolute;
  width: min(520px, calc(100% - 40px));
  text-align: center;
  pointer-events: none;
}

.completion-copy.is-visible {
  pointer-events: auto;
}

.completion-copy h2 {
  margin: 0 0 12px;
  color: #ffffff;
  font-family: "Julee", cursive;
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 400;
  line-height: 1;
}

.completion-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  font-weight: 300;
  line-height: 1.65;
}

.completion-copy p span {
  display: block;
}

.completion-copy .reveal-line {
  opacity: 0;
  transform: translateY(18px);
}

.completion-copy.is-visible .reveal-line {
  animation: revealTextLine 700ms ease forwards;
}

.completion-copy.is-visible .reveal-line:nth-child(1) {
  animation-delay: 200ms;
}

.completion-copy.is-visible p .reveal-line:nth-child(1) {
  animation-delay: 850ms;
}

.completion-copy.is-visible p .reveal-line:nth-child(2) {
  animation-delay: 1300ms;
}

.completion-copy.is-visible p .reveal-line:nth-child(3) {
  animation-delay: 1750ms;
}

.email-signup {
  visibility: hidden;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.completion-copy.is-visible .email-signup {
  animation: revealEmailSignup 700ms 2300ms ease forwards;
  pointer-events: auto;
}

.stage-footer {
  position: absolute;
  right: 22px;
  bottom: 18px;
  left: 22px;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none;
}

.stage-wordmark {
  grid-column: 2;
  width: min(175px, 27vw);
  height: auto;
  opacity: 0.9;
}

.music-player {
  position: relative;
  grid-column: 3;
  justify-self: end;
  width: 227px;
  height: 25px;
  opacity: 0.78;
  pointer-events: auto;
  transition: opacity 180ms ease;
}

.music-player:hover,
.music-player:focus-within,
.music-player.is-playing {
  opacity: 1;
}

.music-player > img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.music-equalizer {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: 101px;
  height: 25px;
  align-items: end;
  justify-content: space-between;
  padding: 1px;
  background: transparent;
  pointer-events: none;
}

.music-equalizer span {
  width: 2px;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.35);
  transform-origin: bottom;
  transition: height 70ms linear;
}

.music-toggle {
  position: absolute;
  top: 0;
  left: 124px;
  width: 31px;
  height: 25px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.music-toggle:focus-visible,
.music-volume:focus-visible {
  border-radius: 4px;
  outline: 2px solid rgba(184, 231, 133, 0.84);
  outline-offset: 3px;
}

.music-volume {
  position: absolute;
  top: 4px;
  right: 0;
  width: 69px;
  height: 18px;
  margin: 0;
  opacity: 0.001;
  cursor: pointer;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.music-volume-track {
  position: absolute;
  top: 0;
  right: 0;
  width: 69px;
  height: 25px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
}

.music-volume-track::before {
  position: absolute;
  top: 11px;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: #ffffff;
  content: "";
}

.music-volume-indicator {
  position: absolute;
  top: 7px;
  left: calc(var(--music-volume, 0.52) * 59px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.4);
}

.music-player.is-off {
  opacity: 0.42;
}

.email-form {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.email-form input {
  min-width: 0;
  min-height: 46px;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(20, 25, 22, 0.64);
  color: #ffffff;
  padding: 0 17px;
  font: inherit;
  font-weight: 300;
}

.email-form input::placeholder {
  color: rgba(225, 232, 226, 0.68);
}

.email-form input:focus {
  border-color: rgba(184, 231, 133, 0.72);
  outline: 2px solid rgba(184, 231, 133, 0.2);
  outline-offset: 2px;
}

.email-form button {
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid rgba(222, 255, 229, 0.38);
  border-radius: 999px;
  background:
    linear-gradient(115deg, rgba(160, 220, 85, 0.96) 0%, rgba(38, 169, 143, 0.95) 58%, rgba(18, 116, 108, 0.96) 100%);
  background-size: 160% 100%;
  color: #ffffff;
  cursor: pointer;
  font-family: "Inter", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  font-weight: 400;
  box-shadow:
    0 10px 24px rgba(22, 105, 84, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  white-space: nowrap;
  transition:
    background-position 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.email-form button:hover {
  background-position: 100% 0;
  box-shadow:
    0 13px 30px rgba(37, 139, 106, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.email-form button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.form-status {
  min-height: 21px;
  margin: 9px 0 0;
  color: #dce8d7;
  font-size: 0.85rem;
  line-height: 1.4;
}

.form-status.error {
  color: #ffd3ca;
}

.toolbar,
.completion-reveal,
.stage-footer {
  transition:
    opacity 700ms ease,
    visibility 700ms ease;
}

body.early-access-complete .toolbar,
body.early-access-complete .completion-reveal {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.coming-soon-message {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(88vw, 760px);
  color: #ffffff;
  text-align: center;
  text-shadow:
    0 0 18px rgba(255, 245, 188, 0.65),
    0 0 54px rgba(255, 196, 72, 0.38);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.coming-soon-message h2 {
  margin: 0 0 14px;
  color: #ffffff;
  font-family: "Julee", cursive;
  font-size: clamp(2.4rem, 7vw, 6.2rem);
  font-weight: 400;
  line-height: 0.95;
}

.coming-soon-message p {
  margin: 0 auto;
  max-width: 620px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 2.1vw, 1.35rem);
  font-weight: 300;
  line-height: 1.65;
}

.coming-soon-message .reveal-line {
  opacity: 0;
  transform: translateY(18px);
}

.coming-soon-message.is-visible .reveal-line {
  animation: revealTextLine 700ms ease forwards;
}

.coming-soon-message.is-visible .reveal-line:nth-child(1) {
  animation-delay: 200ms;
}

.coming-soon-message.is-visible .reveal-line:nth-child(2) {
  animation-delay: 850ms;
}

.coming-soon-message.is-visible .copy-body .reveal-line:nth-child(1) {
  animation-delay: 850ms;
}

.coming-soon-message.is-visible .copy-body .reveal-line:nth-child(2) {
  animation-delay: 1300ms;
}

.coming-soon-message.is-visible .copy-body .reveal-line:nth-child(3) {
  animation-delay: 1750ms;
}

.spark {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(
    circle,
    #ffffff 0 18%,
    hsl(52 100% 82%) 36%,
    hsl(42 100% 56% / 0.78) 62%,
    transparent 76%
  );
  transform: translate(-50%, -50%);
  will-change: opacity, transform;
  opacity: 0.5;
  filter: blur(0.65px);
}

.spark-star {
  overflow: visible;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 22%, hsl(52 100% 80%) 42%, transparent 72%);
  filter: blur(0.35px);
  box-shadow:
    0 0 7px 2px hsl(52 100% 76% / 0.82),
    0 0 18px 6px hsl(42 100% 54% / 0.42);
}

.spark-star::before,
.spark-star::after {
  position: absolute;
  top: 50%;
  left: 50%;
  background: linear-gradient(90deg, transparent, #ffffff, transparent);
  content: "";
  filter: blur(0.45px);
  transform: translate(-50%, -50%);
}

.spark-star::before {
  width: 38px;
  height: 1px;
}

.spark-star::after {
  width: 1px;
  height: 38px;
  background: linear-gradient(transparent, #ffffff, transparent);
}

.spark-dust {
  filter: blur(0.2px);
}

.explosion-flash {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  background: radial-gradient(
    circle,
    #ffffff 0 10%,
    hsl(52 100% 80% / 0.92) 28%,
    hsl(42 100% 56% / 0.55) 52%,
    transparent 72%
  );
  transform: translate(-50%, -50%);
  will-change: opacity, transform;
  filter: blur(1px);
}

/* Sprite mode: pre-baked PNG sparks survive Samsung Internet's forced dark
   mode untouched (it rewrites gradients/box-shadows but only slightly dims
   bitmaps). Glow is baked into the sprite; JS grows the element to hold it.
   !important beats the inline box-shadow set for CSS mode. */
.sprite-sparks .spark {
  background: url("assets/spark-glow.png?v=2") center / 100% 100% no-repeat;
  box-shadow: none !important;
  filter: none;
}

.sprite-sparks .spark-star {
  background: url("assets/spark-star.png?v=2") center / 100% 100% no-repeat;
}

.sprite-sparks .spark-star::before,
.sprite-sparks .spark-star::after {
  display: none;
}

.sprite-sparks .explosion-flash {
  background: url("assets/explosion-flash.png?v=2") center / 100% 100% no-repeat;
  filter: none;
}

@keyframes revealTextLine {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes completionButtonFlicker {
  from {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.22));
  }
  to {
    filter: drop-shadow(0 0 22px rgba(184, 231, 133, 0.52));
  }
}

@keyframes dismissCompletionButton {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1);
  }

  100% {
    opacity: 0;
    transform: scale(0.42);
    filter: brightness(1.6) blur(6px);
  }
}

@keyframes completionButtonEntrance {
  0% {
    opacity: 0;
    transform: scale(0.18);
  }
  48% {
    opacity: 1;
    filter:
      drop-shadow(0 0 18px rgba(255, 255, 255, 0.72))
      drop-shadow(0 0 42px rgba(184, 231, 133, 0.38));
    transform: scale(2.2);
  }
  76% {
    filter: drop-shadow(0 0 8px rgba(184, 231, 133, 0.34));
    transform: scale(0.72);
  }
  100% {
    opacity: 1;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.28));
    transform: scale(1);
  }
}

@keyframes revealEmailSignup {
  from {
    visibility: visible;
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes soundBarPulse {
  from {
    filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
    transform: scaleY(0.94);
  }
  to {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.42));
    transform: scaleY(1.04);
  }
}

@keyframes rotateCounterclockwise {
  to {
    transform: rotate(-360deg);
  }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    height: 100svh;
    overflow: hidden;
  }

  .app-shell {
    width: 100%;
    height: 100svh;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    grid-template-rows: 100svh;
  }

  .stage {
    height: 100svh;
    min-height: 0;
  }

  .scene-background {
    object-position: center center;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .distance-meter {
    min-width: 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(244, 240, 233, 0.18);
    border-left: 0;
  }

  .completion-copy {
    width: min(calc(100% - 24px), 520px);
  }

  .completion-reveal {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(24px, 7vh, 54px);
    padding: 72px 18px 126px;
  }

  .completion-copy {
    position: relative;
    order: 1;
  }

  .completion-button {
    top: auto;
    order: 2;
  }

  .email-form {
    flex-direction: column;
  }

  .email-form button {
    width: 100%;
  }

  .stage-footer {
    right: 14px;
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px));
    left: 14px;
    grid-template-columns: 1fr;
    gap: 12px;
    justify-items: center;
  }

  .stage-wordmark,
  .music-player {
    grid-column: 1;
    justify-self: center;
  }

  .stage-wordmark {
    order: 2;
    width: min(175px, 45vw);
  }

  .music-player {
    order: 1;
    width: min(227px, 80vw);
  }

}
