:root {
  --emerald-950: #000906;
  --emerald-900: #00120b;
  --emerald-800: #002b17;
  --emerald-glow: #9dffe0;
  --ivory: #fef9f3;
  --champagne: #d8c69d;
}

* {
  box-sizing: border-box;
}

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

html {
  background: var(--emerald-950);
}

body {
  margin: 0;
  color: var(--ivory);
  background: #000;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

button {
  font: inherit;
}

h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 51% 48%, rgba(157, 255, 224, 0.3), rgba(0, 18, 11, 0.12) 34%, rgba(0, 0, 0, 0.78) 82%),
    var(--emerald-950);
}

.stage.is-impact {
  animation: impactShake 680ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.scene,
.scene img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.scene {
  z-index: -5;
  transform-origin: center;
  opacity: 0;
  filter: brightness(0.5) contrast(1.2) saturate(0.94) blur(8px);
  animation:
    sceneReveal 2200ms cubic-bezier(0.16, 1, 0.3, 1) 250ms forwards,
    entranceShake 720ms cubic-bezier(0.36, 0.07, 0.19, 0.97) 1320ms both;
}

.scene img {
  object-fit: cover;
  object-position: center center;
  transform: scale(1.07);
  animation: slowPush 16s ease-out 1800ms forwards;
}

.vignette,
.mist,
.grain,
.light-sweep,
.reveal-shutter {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vignette {
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.64), rgba(0, 0, 0, 0.03) 35%, rgba(0, 0, 0, 0.68)),
    radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.78) 92%);
  opacity: 0;
  animation: fadeIn 1700ms ease 900ms forwards;
}

.mist {
  z-index: -3;
  background:
    radial-gradient(ellipse at 25% 36%, rgba(254, 249, 243, 0.22), transparent 30%),
    radial-gradient(ellipse at 70% 76%, rgba(157, 255, 224, 0.14), transparent 35%),
    linear-gradient(100deg, transparent 0%, rgba(254, 249, 243, 0.1) 46%, transparent 58%);
  mix-blend-mode: screen;
  opacity: 0;
  filter: blur(10px);
  animation: mistDrift 8200ms ease-in-out 1200ms infinite alternate, fadeIn 1800ms ease 800ms forwards;
}

.grain {
  z-index: 3;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 22% 31%, rgba(254, 249, 243, 0.11) 0 1px, transparent 1px),
    radial-gradient(circle at 78% 63%, rgba(254, 249, 243, 0.08) 0 1px, transparent 1px);
  background-size: 4px 100%, 19px 23px, 31px 29px;
  opacity: 0.38;
  mix-blend-mode: overlay;
}

.light-sweep {
  inset: 0 auto 0 0;
  z-index: 2;
  width: 36%;
  background: linear-gradient(90deg, transparent, rgba(254, 249, 243, 0.34), rgba(157, 255, 224, 0.22), transparent);
  filter: blur(18px);
  transform: translateX(-145%) skewX(-18deg);
  opacity: 0;
  animation: sweep 2600ms cubic-bezier(0.16, 1, 0.3, 1) 1550ms forwards;
}

.stage.is-impact .light-sweep {
  animation: sweep 1500ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.reveal-shutter {
  z-index: 4;
  background:
    linear-gradient(180deg, #000 0%, #000 42%, transparent 50%, #000 58%, #000 100%);
  transform: scaleY(1);
  transform-origin: center;
  animation: shutterOpen 1600ms cubic-bezier(0.8, 0, 0.2, 1) 360ms forwards;
}

.sound-toggle {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 8;
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--ivory);
  background: rgba(0, 12, 8, 0.46);
  border: 1px solid rgba(216, 198, 157, 0.44);
  border-radius: 50%;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.34),
    inset 0 0 18px rgba(157, 255, 224, 0.07);
  backdrop-filter: blur(14px);
  cursor: pointer;
  outline: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  animation: controlReveal 900ms ease 2200ms forwards;
}

.start-sound {
  position: fixed;
  left: 50%;
  bottom: clamp(28px, 7vh, 72px);
  z-index: 9;
  display: inline-grid;
  min-width: 142px;
  height: 44px;
  place-items: center;
  padding: 0 28px;
  color: var(--ivory);
  background: rgba(0, 12, 8, 0.54);
  border: 1px solid rgba(216, 198, 157, 0.52);
  border-radius: 999px;
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.42),
    0 0 28px rgba(157, 255, 224, 0.14),
    inset 0 0 18px rgba(157, 255, 224, 0.08);
  backdrop-filter: blur(14px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 320ms ease, transform 320ms ease, border-color 180ms ease, background 180ms ease;
}

.start-sound span {
  font-family: Didot, "Bodoni 72", Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.18em;
  transform: translateX(0.09em);
}

.start-sound:hover,
.start-sound:focus-visible {
  background: rgba(0, 43, 23, 0.68);
  border-color: rgba(254, 249, 243, 0.9);
  outline: none;
}

.stage.audio-blocked .start-sound {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  border-color: rgba(254, 249, 243, 0.88);
  background: rgba(0, 43, 23, 0.58);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.36),
    0 0 28px rgba(157, 255, 224, 0.18),
    inset 0 0 18px rgba(157, 255, 224, 0.12);
  transform: translateY(-1px);
}

.sound-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sound-icon-on {
  display: none;
}

.sound-toggle.is-playing .sound-icon-on {
  display: block;
}

.sound-toggle.is-playing .sound-icon-off {
  display: none;
}

@keyframes sceneReveal {
  0% {
    opacity: 0;
    filter: brightness(0.24) contrast(1.35) saturate(0.68) blur(12px);
    transform: scale(1.055);
  }

  55% {
    opacity: 1;
    filter: brightness(1.08) contrast(1.12) saturate(1.02) blur(0);
  }

  100% {
    opacity: 1;
    filter: brightness(0.94) contrast(1.08) saturate(0.98) blur(0);
    transform: scale(1);
  }
}

@keyframes slowPush {
  to {
    transform: scale(1.015);
  }
}

@keyframes entranceShake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0) scale(1.003);
  }

  20%,
  80% {
    transform: translate3d(2px, 1px, 0) scale(1.004);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, -1px, 0) scale(1.004);
  }

  40%,
  60% {
    transform: translate3d(4px, 1px, 0) scale(1.004);
  }
}

@keyframes impactShake {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }

  12%,
  48%,
  82% {
    transform: translate3d(-5px, 2px, 0) scale(1.006);
  }

  28%,
  66% {
    transform: translate3d(5px, -2px, 0) scale(1.006);
  }
}

@keyframes playingGlow {
  0% {
    filter: brightness(0.94) contrast(1.08) saturate(0.98);
  }

  36% {
    filter: brightness(1.14) contrast(1.12) saturate(1.08);
  }

  100% {
    filter: brightness(0.94) contrast(1.08) saturate(0.98);
  }
}

@keyframes shutterOpen {
  0% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }

  72% {
    clip-path: inset(48% 0 48% 0);
    opacity: 1;
  }

  100% {
    clip-path: inset(50% 0 50% 0);
    opacity: 0;
  }
}

@keyframes sweep {
  0% {
    opacity: 0;
    transform: translateX(-145%) skewX(-18deg);
  }

  18%,
  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(330%) skewX(-18deg);
  }
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

@keyframes mistDrift {
  from {
    transform: translate3d(-1.5%, 0, 0) scale(1.02);
  }

  to {
    transform: translate3d(1.5%, -1%, 0) scale(1.06);
  }
}

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

@media (max-width: 760px) {
  .scene img {
    object-position: 50% 46%;
  }

  .vignette {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0.08) 34%, rgba(0, 0, 0, 0.72)),
      radial-gradient(ellipse at center, transparent 36%, rgba(0, 0, 0, 0.74) 90%);
  }

  .sound-toggle {
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
  }

  .start-sound {
    bottom: 26px;
    min-width: 128px;
    height: 42px;
    padding: 0 22px;
  }
}

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