:root {
  --bg-night: #03081d;
  --bg-navy: #09183a;
  --bg-purple: #2a1458;
  --text-main: #f8f3ff;
  --text-soft: rgba(240, 233, 255, 0.82);
  --accent-pink: #ff82d3;
  --accent-purple: #9c83ff;
  --accent-blue: #7da7ff;
  --shadow-main: 0 32px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  overflow: hidden;
  font-family: "Sora", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 16% 18%, rgba(156, 131, 255, 0.2), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(255, 130, 211, 0.16), transparent 28%),
    radial-gradient(circle at 80% 88%, rgba(125, 167, 255, 0.14), transparent 28%),
    linear-gradient(135deg, var(--bg-night) 0%, var(--bg-navy) 46%, var(--bg-purple) 100%);
}

#confetti-canvas,
.grain,
.background-glow,
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#confetti-canvas {
  z-index: 8;
}

.background-glow {
  z-index: 0;
  filter: blur(70px);
  opacity: 0.9;
}

.background-glow-left {
  background: radial-gradient(circle, rgba(122, 90, 255, 0.42), transparent 55%);
  transform: translate(-18%, -8%);
}

.background-glow-right {
  background: radial-gradient(circle, rgba(255, 112, 205, 0.34), transparent 55%);
  transform: translate(22%, 12%);
}

.starfield {
  z-index: 0;
  opacity: 0.42;
  background-image:
    radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 66%, rgba(255, 255, 255, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 32%, rgba(255, 255, 255, 0.58) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 74%, rgba(255, 255, 255, 0.45) 0 1px, transparent 2px);
}

.grain {
  z-index: 0;
  opacity: 0.14;
  mix-blend-mode: soft-light;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 4px 4px, 4px 4px;
}

.story-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.story-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
}

.story-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(2, 6, 22, 0.4) 0%, rgba(2, 7, 22, 0) 22%),
    linear-gradient(0deg, rgba(2, 6, 18, 0.9) 0%, rgba(2, 6, 18, 0.14) 35%, rgba(2, 6, 18, 0.12) 68%);
  pointer-events: none;
}

.scene-container {
  position: absolute;
  inset: 0;
}

.next-frame-button {
  position: absolute;
  right: 28px;
  bottom: 28px;
  z-index: 7;
  min-width: 132px;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(9, 12, 32, 0.82), rgba(39, 22, 86, 0.48));
  color: var(--text-main);
  font: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-main);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.next-frame-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.24);
  background: linear-gradient(145deg, rgba(17, 22, 52, 0.88), rgba(63, 31, 120, 0.56));
}

.scene {
  --scene-accent: #ff82d3;
  --scene-glow: rgba(156, 131, 255, 0.24);
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translate3d(18%, 0, 0) scale(0.97);
  transition:
    opacity 850ms ease,
    transform 850ms cubic-bezier(0.2, 0.72, 0.12, 1);
  pointer-events: none;
}

.scene.is-before {
  transform: translate3d(-18%, 0, 0) scale(0.97);
}

.scene.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
}

.scene-backdrop,
.scene-wash,
.scene-collage,
.scene-special-stage {
  position: absolute;
  inset: 0;
}

.scene-backdrop {
  overflow: hidden;
}

.scene-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.04) contrast(1.05) brightness(0.48);
  transform: scale(1.08);
}

.scene-wash {
  background:
    radial-gradient(circle at 70% 28%, var(--scene-glow), transparent 28%),
    radial-gradient(circle at 18% 18%, rgba(125, 167, 255, 0.14), transparent 18%),
    linear-gradient(110deg, rgba(3, 7, 24, 0.88) 10%, rgba(5, 9, 27, 0.46) 42%, rgba(15, 10, 40, 0.82) 100%);
}

.scene-collage {
  z-index: 2;
  pointer-events: none;
}

.collage-piece {
  position: absolute;
  overflow: hidden;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(145deg, rgba(141, 116, 255, 0.18), rgba(255, 130, 211, 0.1)),
    rgba(255, 255, 255, 0.04);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
}

.collage-piece::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 10, 28, 0.04), rgba(8, 10, 28, 0.24)),
    linear-gradient(140deg, rgba(255, 255, 255, 0.14), transparent 35%);
  pointer-events: none;
}

.collage-piece img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.collage-piece-main {
  right: 8vw;
  top: 10vh;
  width: min(42vw, 650px);
  height: min(74vh, 780px);
  transform: rotate(-4deg);
}

.collage-piece-main::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.collage-piece-top {
  right: 30vw;
  top: 11vh;
  width: min(18vw, 280px);
  height: min(22vh, 200px);
  transform: rotate(8deg);
}

.collage-piece-bottom {
  right: 5vw;
  bottom: 16vh;
  width: min(22vw, 320px);
  height: min(20vh, 210px);
  transform: rotate(7deg);
}

.scene-special-stage {
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 44vw);
  align-items: center;
}

.scene-special-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 25% 30%, rgba(125, 167, 255, 0.14), transparent 18%),
    radial-gradient(circle at 78% 26%, var(--scene-glow), transparent 24%),
    radial-gradient(circle at 72% 78%, rgba(255, 130, 211, 0.14), transparent 24%);
}

.special-visual {
  position: relative;
  justify-self: center;
  width: min(34vw, 460px);
  aspect-ratio: 1 / 1;
}

.special-orbit,
.special-spark {
  position: absolute;
  border-radius: 999px;
}

.special-orbit {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.special-orbit-one {
  inset: 2% 8% 22% 18%;
  transform: rotate(-12deg);
}

.special-orbit-two {
  inset: 22% 18% 4% 4%;
  transform: rotate(15deg);
}

.special-spark {
  width: 12px;
  height: 12px;
  background: linear-gradient(145deg, #fff7ff, #ffd3f2);
  box-shadow: 0 0 24px rgba(255, 210, 242, 0.6);
}

.special-spark-one {
  top: 14%;
  left: 10%;
}

.special-spark-two {
  right: 12%;
  top: 20%;
}

.special-spark-three {
  bottom: 12%;
  left: 20%;
}

.cake-illustration,
.ring-illustration {
  position: absolute;
  inset: 0;
}

.cake-plate {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 11%;
  height: 7%;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(215, 210, 255, 0.92));
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.22);
}

.cake-layer {
  position: absolute;
  left: 21%;
  right: 21%;
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 195, 230, 0.98), rgba(159, 137, 255, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.cake-layer-bottom {
  bottom: 17%;
  height: 22%;
}

.cake-layer-middle {
  left: 27%;
  right: 27%;
  bottom: 36%;
  height: 18%;
}

.cake-layer-top {
  left: 34%;
  right: 34%;
  bottom: 52%;
  height: 14%;
}

.cake-icing {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 57%;
  height: 9%;
  border-radius: 999px 999px 26px 26px;
  background: linear-gradient(180deg, #fff3ff 0%, #ffd3f2 100%);
}

.candle {
  position: absolute;
  width: 4.2%;
  height: 14%;
  top: 16%;
  background: linear-gradient(180deg, #fff4cd 0%, #ff93e2 100%);
  border-radius: 999px;
}

.candle-one {
  left: 39%;
}

.candle-two {
  left: 48%;
}

.candle-three {
  left: 57%;
}

.candle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -22%;
  width: 120%;
  height: 38%;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50%;
  background: radial-gradient(circle at 50% 60%, #fff2aa 0%, #ffbf5f 45%, rgba(255, 132, 38, 0.2) 100%);
  box-shadow: 0 0 18px rgba(255, 185, 95, 0.55);
}

.ring-band {
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: 18%;
  height: 38%;
  border-radius: 50%;
  border: 20px solid rgba(245, 232, 170, 0.95);
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.08),
    inset 0 0 24px rgba(255, 255, 255, 0.15);
}

.ring-diamond {
  position: absolute;
  left: 50%;
  top: 12%;
  width: 30%;
  aspect-ratio: 1 / 1;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(180, 226, 255, 0.95));
  box-shadow:
    0 0 32px rgba(210, 238, 255, 0.52),
    inset 0 0 26px rgba(255, 255, 255, 0.34);
}

.ring-diamond::before,
.ring-diamond::after {
  content: "";
  position: absolute;
  background: rgba(156, 131, 255, 0.26);
}

.ring-diamond::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
}

.ring-diamond::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-50%);
}

.scene-copy {
  position: absolute;
  z-index: 4;
  left: 5vw;
  top: 14vh;
  max-width: min(560px, 44vw);
  padding: 28px 30px 26px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top right, rgba(156, 131, 255, 0.22), transparent 34%),
    linear-gradient(145deg, rgba(6, 9, 26, 0.8), rgba(12, 16, 38, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-main);
}

.scene-copy--special {
  position: relative;
  left: auto;
  top: auto;
  margin-left: 5vw;
  max-width: min(620px, 42vw);
}

.scene-tag {
  color: var(--scene-accent);
}

.scene-title {
  margin: 12px 0 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(3.4rem, 7vw, 6.4rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
}

.scene-subtitle {
  margin: 0;
  color: rgba(250, 244, 255, 0.94);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  line-height: 1.45;
}

.scene-body {
  margin: 18px 0 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.88;
}

.scene-proposal-line {
  margin-top: 18px;
  color: #ffd3f2;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.scene.is-active .animate {
  animation: revealUp 900ms cubic-bezier(0.2, 0.7, 0.14, 1) both;
}

.scene.is-active .delay-1 {
  animation-delay: 100ms;
}

.scene.is-active .delay-2 {
  animation-delay: 180ms;
}

.scene.is-active .delay-3 {
  animation-delay: 300ms;
}

.scene.is-active .delay-4 {
  animation-delay: 420ms;
}

.scene.is-active .collage-piece-main {
  animation: floatCard 11s ease-in-out both;
}

.scene.is-active .collage-piece-top {
  animation: floatCardSmallA 10s ease-in-out both;
}

.scene.is-active .collage-piece-bottom {
  animation: floatCardSmallB 10.8s ease-in-out both;
}

.scene.is-active .scene-backdrop img {
  animation: driftBackground 11s ease-in-out both;
}

.scene.is-active .special-visual {
  animation: specialFloat 9s ease-in-out both;
}

.scene.is-active .special-spark {
  animation: sparklePulse 2.8s ease-in-out infinite;
}

.scene.is-missing .scene-backdrop img,
.scene.is-missing .collage-piece img {
  opacity: 0;
}

.scene.is-missing .scene-backdrop {
  background:
    radial-gradient(circle at 20% 20%, rgba(125, 167, 255, 0.2), transparent 20%),
    linear-gradient(145deg, rgba(24, 19, 67, 0.88), rgba(73, 28, 95, 0.72));
}

.scene.is-missing .collage-piece {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(145deg, rgba(125, 167, 255, 0.22), rgba(255, 130, 211, 0.16)),
    rgba(255, 255, 255, 0.04);
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

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

@keyframes driftBackground {
  from {
    transform: scale(1.08) translate3d(0, 0, 0);
  }

  50% {
    transform: scale(1.13) translate3d(-1.5%, -1%, 0);
  }

  to {
    transform: scale(1.1) translate3d(1.2%, -0.6%, 0);
  }
}

@keyframes floatCard {
  from {
    transform: rotate(-5deg) translate3d(0, 24px, 0) scale(0.96);
  }

  45% {
    transform: rotate(-2deg) translate3d(-10px, -12px, 0) scale(1.02);
  }

  to {
    transform: rotate(-4deg) translate3d(8px, 6px, 0) scale(1);
  }
}

@keyframes floatCardSmallA {
  from {
    transform: rotate(11deg) translate3d(0, 18px, 0) scale(0.95);
  }

  50% {
    transform: rotate(6deg) translate3d(-8px, -8px, 0) scale(1.03);
  }

  to {
    transform: rotate(8deg) translate3d(5px, 8px, 0) scale(1);
  }
}

@keyframes floatCardSmallB {
  from {
    transform: rotate(9deg) translate3d(0, 18px, 0) scale(0.95);
  }

  50% {
    transform: rotate(4deg) translate3d(6px, -10px, 0) scale(1.02);
  }

  to {
    transform: rotate(7deg) translate3d(-6px, 8px, 0) scale(1);
  }
}

@keyframes specialFloat {
  from {
    transform: translateY(18px) scale(0.97);
  }

  50% {
    transform: translateY(-10px) scale(1.02);
  }

  to {
    transform: translateY(6px) scale(1);
  }
}

@keyframes sparklePulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.92);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@media (max-width: 1080px) {
  .scene-copy {
    max-width: min(620px, calc(100% - 44px));
    top: 12vh;
  }

  .scene-copy--special {
    max-width: min(620px, calc(100% - 44px));
    margin-top: 12vh;
  }

  .collage-piece-main {
    right: 4vw;
    top: 17vh;
    width: min(46vw, 520px);
    height: min(56vh, 580px);
  }

  .collage-piece-top {
    right: 32vw;
    top: 14vh;
    width: min(24vw, 250px);
    height: min(20vh, 180px);
  }

  .collage-piece-bottom {
    right: 8vw;
    bottom: 18vh;
    width: min(28vw, 250px);
    height: min(18vh, 160px);
  }

  .scene-special-stage {
    grid-template-columns: 1fr;
    justify-items: start;
    padding-top: 4vh;
  }

  .special-visual {
    position: absolute;
    right: 4vw;
    top: 12vh;
    width: min(40vw, 360px);
  }
}

@media (max-width: 780px) {
  .next-frame-button {
    left: 50%;
    right: auto;
    bottom: 14px;
    transform: translateX(-50%);
    min-width: 116px;
    padding: 12px 18px;
  }

  .scene-copy {
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 70px;
    max-width: none;
    max-height: min(38vh, 400px);
    padding: 18px 16px 16px;
    overflow: auto;
  }

  .scene-copy--special {
    margin: auto 14px 24px;
  }

  .scene-title {
    font-size: clamp(2.5rem, 10.5vw, 3.7rem);
  }

  .scene-subtitle {
    font-size: 0.96rem;
  }

  .scene-body {
    font-size: 0.88rem;
    line-height: 1.68;
  }

  .collage-piece-main {
    inset: 12vh 6vw 34vh 6vw;
    width: auto;
    height: auto;
    transform: rotate(-2deg);
  }

  .collage-piece-top {
    left: 10vw;
    right: auto;
    top: 8vh;
    width: 32vw;
    height: 13vh;
    transform: rotate(-8deg);
  }

  .collage-piece-bottom {
    right: 10vw;
    bottom: 42vh;
    width: 34vw;
    height: 13vh;
    transform: rotate(9deg);
  }

  .special-visual {
    position: absolute;
    left: 50%;
    right: auto;
    top: 8vh;
    width: min(68vw, 320px);
    transform: translateX(-50%);
  }

  .ring-band {
    border-width: 16px;
  }
}

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