:root {
  color-scheme: dark;
  --ink: #020306;
  --gold: #ffd82d;
  --warm-white: #fff8d6;
  --green: #148a3f;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
}

body {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.scene {
  position: relative;
  isolation: isolate;
  width: 100vw;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(24, 33, 46, .42), transparent 48%),
    radial-gradient(ellipse at 16% 28%, rgba(75, 37, 24, .22), transparent 29%),
    linear-gradient(180deg, #07080b 0%, #030509 58%, #010203 100%);
}

.night-sky,
.spark-layer,
.butterfly-layer,
.final-butterfly-layer,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.night-sky {
  z-index: 0;
  opacity: .75;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .78) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 220, 103, .56) 0 1px, transparent 1.5px);
  background-position: 8px 24px, 43px 67px;
  background-size: 88px 88px, 149px 149px;
  animation: star-drift 18s linear infinite;
}

@keyframes star-drift { to { translate: 0 28px; } }

.vignette {
  z-index: 50;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .22), transparent 17% 76%, rgba(0, 0, 0, .42)),
    radial-gradient(ellipse at center, transparent 46%, rgba(0, 0, 0, .55) 100%);
}

.ghost-flowers {
  position: absolute;
  z-index: 1;
  inset: 12% 0 auto;
  height: 44%;
  opacity: 0;
  filter: blur(6px);
  animation: ghosts-in 1.8s .2s ease-out forwards, ghosts-out 1.2s 3.9s ease-out forwards;
}

.ghost-flowers span {
  position: absolute;
  width: min(34vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 215, 41, .44) 0 12%, transparent 13%),
    repeating-conic-gradient(from 8deg, rgba(255, 226, 102, .26) 0 8deg, transparent 9deg 20deg);
}

.ghost-flowers span:nth-child(1) { left: 7%; top: 24%; rotate: -18deg; }
.ghost-flowers span:nth-child(2) { left: 35%; top: -5%; scale: .72; opacity: .7; }
.ghost-flowers span:nth-child(3) { right: 5%; top: 20%; scale: .86; rotate: 16deg; opacity: .55; }

@keyframes ghosts-in { to { opacity: .64; filter: blur(2px); } }
@keyframes ghosts-out { to { opacity: 0; filter: blur(11px); scale: 1.08; } }

.headline {
  position: absolute;
  z-index: 25;
  top: clamp(18px, 4vh, 42px);
  left: 50%;
  width: min(94vw, 860px);
  translate: -50% 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  filter: blur(7px);
  animation: headline-in 1.1s 1.4s ease-out forwards;
}

.headline h1 {
  margin: 0;
  color: #f7dd4e;
  font-size: clamp(2rem, 5vw, 4rem);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1.04;
  text-wrap: balance;
  text-shadow: 0 0 7px rgba(255, 226, 77, .62), 0 0 24px rgba(206, 145, 0, .26);
}

.headline p {
  margin: .42rem 0 0;
  color: var(--warm-white);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 600;
  text-shadow: 0 0 8px rgba(107, 227, 255, .95);
}

@keyframes headline-in {
  from { opacity: 0; filter: blur(7px); translate: -50% -10px; }
  to { opacity: .96; filter: blur(0); translate: -50% 0; }
}

.spark-layer { z-index: 8; }
.butterfly-layer,
.final-butterfly-layer { z-index: 35; }

.firefly,
.dust {
  position: absolute;
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
}

.firefly {
  width: var(--size);
  height: var(--size);
  background: #ffe15f;
  box-shadow: 0 0 6px 2px #ffd332, 0 0 20px 6px rgba(255, 174, 0, .66);
  animation: firefly-pulse var(--duration) var(--delay) ease-in-out infinite alternate;
}

.dust {
  width: 2px;
  height: 2px;
  background: rgba(255, 202, 45, .88);
  box-shadow: 0 0 5px #ffc72d;
  opacity: 0;
  animation: dust-rise var(--duration) var(--delay) ease-out infinite;
}

@keyframes firefly-pulse {
  0% { opacity: .12; scale: .55; translate: 0 0; }
  48% { opacity: 1; scale: 1.3; translate: 7px -10px; }
  100% { opacity: .24; scale: .7; translate: -6px 7px; }
}

@keyframes dust-rise {
  0% { opacity: 0; translate: 0 12px; }
  24% { opacity: .95; }
  100% { opacity: 0; translate: var(--drift) -34px; }
}

.butterfly {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--size);
  aspect-ratio: 1.26;
  color: var(--color);
  opacity: 0;
  transform-origin: center;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--color) 58%, transparent));
  will-change: transform, opacity;
}

.butterfly svg { width: 100%; height: 100%; overflow: visible; }
.butterfly .wing-left,
.butterfly .wing-right {
  transform-box: view-box;
  transform-origin: 60px 45px;
  animation: wing-left .22s ease-in-out infinite alternate;
}
.butterfly .wing-right { animation-name: wing-right; }

@keyframes wing-left { from { transform: perspective(90px) rotateY(-4deg); } to { transform: perspective(90px) rotateY(66deg); } }
@keyframes wing-right { from { transform: perspective(90px) rotateY(4deg); } to { transform: perspective(90px) rotateY(-66deg); } }

.final-butterfly {
  left: var(--x);
  top: var(--y);
  width: var(--size);
  animation:
    final-butterfly-in .7s var(--delay) cubic-bezier(.16, 1.16, .35, 1) forwards,
    final-butterfly-drift 4.2s calc(var(--delay) + .7s) ease-in-out infinite alternate;
}

@keyframes final-butterfly-in {
  from { opacity: 0; transform: translateY(13px) rotate(var(--rotation)) scale(.25); filter: blur(4px); }
  to { opacity: .9; transform: translateY(0) rotate(var(--rotation)) scale(var(--final-scale)); filter: blur(0); }
}

@keyframes final-butterfly-drift {
  from { transform: translateY(-3px) rotate(calc(var(--rotation) - 4deg)) scale(var(--final-scale)); }
  to { transform: translateY(5px) rotate(calc(var(--rotation) + 4deg)) scale(var(--final-scale)); }
}

.bouquet {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: clamp(8px, 1.5vh, 22px);
  width: min(640px, 100vw);
  height: min(720px, 112vw, 84vh);
  translate: -50% 0;
  transform-origin: 50% 100%;
  pointer-events: none;
  animation: bouquet-sway 5.5s 12.2s ease-in-out infinite alternate;
}

@keyframes bouquet-sway {
  from { rotate: -.7deg; }
  to { rotate: .85deg; }
}

.stems {
  position: absolute;
  z-index: 1;
  inset: 21% 15% 7%;
  opacity: 0;
  animation: simple-fade .8s 3.8s ease-out forwards;
}

.stem {
  position: absolute;
  bottom: 5%;
  left: 50%;
  width: clamp(3px, .65vw, 6px);
  height: var(--h);
  border-radius: 999px;
  transform-origin: bottom;
  rotate: var(--r);
  background: linear-gradient(90deg, #063d20, #35a951 48%, #07512a);
  animation: stem-sway var(--stem-duration) 7s ease-in-out infinite alternate;
}

.s1 { --h: 82%; --r: -18deg; --stem-duration: 4.2s; }
.s2 { --h: 73%; --r: -12deg; --stem-duration: 4.8s; }
.s3 { --h: 87%; --r: -6deg; --stem-duration: 4s; }
.s4 { --h: 91%; --r: 1deg; --stem-duration: 4.6s; }
.s5 { --h: 82%; --r: 8deg; --stem-duration: 4.3s; }
.s6 { --h: 76%; --r: 14deg; --stem-duration: 4.7s; }
.s7 { --h: 68%; --r: 21deg; --stem-duration: 4.1s; }

@keyframes stem-sway {
  from { rotate: var(--r); }
  to { rotate: calc(var(--r) + 1.65deg); }
}

.flower {
  position: absolute;
  z-index: 4;
  left: var(--left);
  bottom: var(--bottom);
  width: var(--flower-size);
  aspect-ratio: 1;
  opacity: 0;
  transform: translate(-50%, 54px) scale(.08) rotate(-24deg);
  animation:
    flower-bloom 1.15s var(--delay) cubic-bezier(.16, 1.2, .34, 1) forwards,
    flower-float 3.4s calc(var(--delay) + 1.2s) ease-in-out infinite alternate;
}

.f1 { --left: 50%; --bottom: 59%; --flower-size: 31%; --delay: 3.85s; }
.f2 { --left: 34%; --bottom: 49%; --flower-size: 29%; --delay: 5.05s; }
.f3 { --left: 67%; --bottom: 50%; --flower-size: 30%; --delay: 6.25s; }
.f4 { --left: 48%; --bottom: 38%; --flower-size: 32%; --delay: 7.45s; }
.f5 { --left: 25%; --bottom: 35%; --flower-size: 28%; --delay: 8.65s; }
.f6 { --left: 74%; --bottom: 34%; --flower-size: 29%; --delay: 9.85s; }
.f7 { --left: 57%; --bottom: 24%; --flower-size: 29%; --delay: 11.05s; }

.sunflower {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 7px 8px rgba(0, 0, 0, .46));
}

.flower-center { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .55)); }

@keyframes flower-bloom {
  0% { opacity: 0; transform: translate(-50%, 54px) scale(.08) rotate(-24deg); filter: blur(6px); }
  62% { opacity: 1; transform: translate(-50%, -4px) scale(1.06) rotate(3deg); filter: blur(0); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1) rotate(0); filter: blur(0); }
}

@keyframes flower-float { from { margin-bottom: -2px; } to { margin-bottom: 5px; } }

.leaf {
  position: absolute;
  z-index: 2;
  width: 14%;
  aspect-ratio: 2;
  border-radius: 100% 0 100% 0;
  background:
    linear-gradient(15deg, transparent 47%, rgba(218, 255, 190, .38) 49% 51%, transparent 53%),
    linear-gradient(135deg, #38b655, #087033);
  opacity: 0;
  animation:
    leaf-in .75s var(--delay) ease-out forwards,
    leaf-sway 3.8s calc(var(--delay) + .75s) ease-in-out infinite alternate;
}

.leaf-a { left: 22%; bottom: 43%; rotate: 24deg; --delay: 7.3s; }
.leaf-b { right: 21%; bottom: 43%; rotate: 154deg; --delay: 8.5s; }
.leaf-c { left: 33%; bottom: 31%; rotate: 6deg; scale: .85; --delay: 9.7s; }
.leaf-d { right: 31%; bottom: 30%; rotate: 171deg; scale: .82; --delay: 10.3s; }
.leaf-e { left: 16%; bottom: 27%; rotate: 36deg; scale: .76; --delay: 11s; }
.leaf-f { right: 15%; bottom: 27%; rotate: 145deg; scale: .76; --delay: 11.3s; }

@keyframes leaf-in {
  from { opacity: 0; scale: .2; }
  to { opacity: 1; }
}

@keyframes leaf-sway {
  from { translate: -2px 0; }
  to { translate: 2px -3px; }
}

.wrapper {
  position: absolute;
  z-index: 6;
  inset: 0;
  opacity: 0;
  filter: blur(7px);
  transform: translateY(36px) scale(.94);
  animation: wrapper-in 1.1s 10.5s cubic-bezier(.18, 1, .28, 1) forwards;
}

.paper,
.paper-fold,
.band,
.ribbon { position: absolute; }

.paper-left {
  z-index: 1;
  left: 17%;
  bottom: 4%;
  width: 44%;
  height: 44%;
  clip-path: polygon(0 5%, 100% 34%, 78% 100%, 40% 100%);
  background: linear-gradient(145deg, rgba(255, 206, 228, .92), rgba(224, 109, 161, .76));
}

.paper-right {
  z-index: 1;
  right: 17%;
  bottom: 4%;
  width: 44%;
  height: 44%;
  clip-path: polygon(0 34%, 100% 5%, 60% 100%, 22% 100%);
  background: linear-gradient(215deg, rgba(255, 215, 233, .94), rgba(224, 111, 164, .74));
}

.paper-front {
  z-index: 4;
  left: 50%;
  bottom: 3.5%;
  width: 47%;
  height: 34%;
  translate: -50% 0;
  clip-path: polygon(2% 0, 98% 0, 73% 100%, 27% 100%);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .2), transparent 22% 72%, rgba(255, 255, 255, .17)),
    linear-gradient(180deg, rgba(236, 154, 190, .88), rgba(187, 73, 124, .92));
}

.paper-fold {
  z-index: 5;
  bottom: 23%;
  width: 19%;
  height: 12%;
  background: linear-gradient(150deg, rgba(255, 234, 240, .68), rgba(226, 139, 174, .5));
}

.fold-left { left: 28%; clip-path: polygon(0 12%, 100% 0, 72% 100%, 14% 78%); }
.fold-right { right: 28%; clip-path: polygon(0 0, 100% 12%, 86% 78%, 28% 100%); }

.band {
  z-index: 8;
  left: 50%;
  bottom: 25%;
  width: 18%;
  height: 6%;
  translate: -50% 0;
  border-radius: 7px;
  background: linear-gradient(90deg, #dba52e, #ffe56a 48%, #d69c26);
  box-shadow: 0 3px 8px rgba(48, 18, 0, .32);
}

.ribbon {
  z-index: 7;
  bottom: 25%;
  width: 18%;
  height: 5%;
  border-radius: 65% 15% 60% 18%;
  background: linear-gradient(145deg, #ffe268, #dda323);
}

.ribbon-left { left: 27%; rotate: -14deg; }
.ribbon-right { right: 27%; rotate: 14deg; scale: -1 1; }

@keyframes wrapper-in {
  to { opacity: 1; filter: blur(0); transform: translateY(0) scale(1); }
}

@keyframes simple-fade { to { opacity: 1; } }

.dedication {
  position: absolute;
  z-index: 27;
  top: clamp(26px, 5vh, 52px);
  left: 50%;
  width: min(90vw, 560px);
  translate: -50% 0;
  color: #fff0a1;
  text-align: center;
  opacity: 0;
  filter: blur(5px);
  animation: dedication-in 1.1s 14.15s ease-out forwards;
}

.dedication p {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.35rem);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1.15;
  text-wrap: balance;
  text-shadow: 0 0 8px rgba(255, 221, 64, .7), 0 0 24px rgba(255, 193, 28, .28);
}

@keyframes dedication-in {
  from { opacity: 0; filter: blur(5px); translate: -50% -8px; }
  to { opacity: 1; filter: blur(0); translate: -50% 0; }
}

@keyframes headline-soften {
  to { opacity: 0; filter: blur(4px); translate: -50% -8px; }
}

.headline { animation: headline-in 1.1s 1.4s ease-out forwards, headline-soften .8s 13.55s ease-out forwards; }

.grass {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 24vh;
  opacity: 0;
  background:
    repeating-linear-gradient(79deg, transparent 0 17px, rgba(31, 130, 57, .43) 18px 20px, transparent 21px 45px),
    linear-gradient(to top, rgba(0, 18, 7, .98), transparent 82%);
  clip-path: polygon(0 100%, 0 75%, 2% 89%, 4% 50%, 5% 88%, 7% 39%, 8% 84%, 10% 54%, 12% 89%, 14% 42%, 16% 85%, 19% 47%, 21% 88%, 24% 52%, 26% 87%, 28% 37%, 30% 83%, 34% 49%, 36% 89%, 38% 40%, 40% 84%, 43% 51%, 46% 89%, 48% 38%, 50% 85%, 54% 51%, 57% 88%, 60% 41%, 63% 84%, 66% 50%, 69% 89%, 73% 43%, 75% 84%, 79% 51%, 81% 88%, 85% 40%, 88% 84%, 92% 51%, 95% 87%, 98% 46%, 100% 80%, 100% 100%);
  animation: simple-fade 1.2s 11.8s ease-out forwards;
}

.replay,
.music-toggle {
  position: absolute;
  z-index: 60;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 13px;
  border: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, .76);
  background: rgba(8, 9, 12, .5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: .58;
  transition-property: opacity, transform;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.replay { right: 14px; }
.music-toggle { left: 14px; }

.replay svg,
.music-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.replay:hover,
.music-toggle:hover { opacity: 1; transform: translateY(-1px); }
.replay:active,
.music-toggle:active { transform: scale(.96); }
.replay:focus-visible,
.music-toggle:focus-visible { outline: 2px solid #ffe166; outline-offset: 3px; }

.music-toggle[aria-pressed="true"] {
  color: #fff5b6;
  background: rgba(99, 72, 9, .46);
  opacity: .92;
}

.scene.restart *,
.scene.restart *::before,
.scene.restart *::after { animation: none !important; }

@media (max-width: 720px) {
  .headline { top: 20px; }
  .headline h1 { font-size: clamp(1.65rem, 8.2vw, 2.55rem); }
  .headline p { font-size: 1rem; }
  .bouquet { top: 0; bottom: auto; width: 100vw; height: min(175vw, 80vh); }
  .f1 { --bottom: 67%; }
  .f2 { --bottom: 56%; }
  .f3 { --bottom: 57%; }
  .f4 { --bottom: 45%; }
  .f5 { --bottom: 41%; }
  .f6 { --bottom: 40%; }
  .f7 { --bottom: 30%; }
  .dedication { top: 26px; width: min(88vw, 360px); }
  .dedication p { font-size: clamp(1.22rem, 6.4vw, 1.7rem); }
  .replay span,
  .music-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .replay,
  .music-toggle { min-width: 42px; justify-content: center; padding: 9px; }
}

@media (max-height: 640px) and (min-width: 721px) {
  .bouquet { height: 82vh; width: min(560px, 82vw); }
  .headline h1 { font-size: 2.25rem; }
  .headline p { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .night-sky,
  .firefly,
  .dust,
  .butterfly .wing-left,
  .butterfly .wing-right,
  .flower,
  .dedication { animation-duration: .01ms; animation-delay: 0s; }

  .ghost-flowers { display: none; }
  .headline,
  .stems,
  .flower,
  .leaf,
  .wrapper,
  .message,
  .grass { animation-delay: 0s; animation-duration: .01ms; }

  .butterfly { display: none; }
}
