:root {
  --gold: #f7d774;
  --ink: #f8eed6;
  --flower-w: min(86vw, calc(56vh * 0.625), 400px);
  --ease-soft: cubic-bezier(.22, .72, .32, 1);
  --ease-open: cubic-bezier(.24, .74, .34, 1.04);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: #04040a;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

.scene {
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background:
    radial-gradient(125% 65% at 50% 6%, #191340 0%, rgba(25, 19, 64, 0) 62%),
    radial-gradient(95% 50% at 50% 102%, #14113a 0%, rgba(20, 17, 58, 0) 72%),
    linear-gradient(180deg, #0b0a20 0%, #08071a 48%, #04040c 100%);
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.stars span {
  position: absolute;
  border-radius: 50%;
  background: #fff6d8;
  opacity: 0;
  animation: twinkle var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(.6); }
  50% { opacity: var(--peak); transform: scale(1); }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 85% at 50% 42%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .45) 100%);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2;
}

.flower {
  position: relative;
  width: var(--flower-w);
  height: calc(var(--flower-w) * 1.6);
  transform-origin: 50% 100%;
  margin-bottom: -1px;
}

.flower.swaying { animation: sway 13s ease-in-out infinite; }

@keyframes sway {
  0%, 100% { transform: rotate(-.55deg); }
  50% { transform: rotate(.65deg); }
}

.flower-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  overflow: visible;
}

.halo {
  position: absolute;
  left: 50%;
  top: 39.0625%;
  width: 165%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%) scale(.42);
  background: radial-gradient(closest-side, rgba(255, 214, 110, .34), rgba(255, 190, 70, .1) 46%, rgba(255, 180, 60, 0) 72%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 1800ms ease, transform 2300ms var(--ease-soft);
}

.halo.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.sparkles {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 1600ms ease;
}

.sparkles.on { opacity: 1; }

.sparkles span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  border-radius: 50%;
  background: #fff2c4;
  box-shadow: 0 0 7px rgba(255, 214, 110, .85);
  animation: floaty var(--dur) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes floaty {
  0%, 100% { opacity: 0; transform: translate3d(0, 4px, 0) scale(.5); }
  50% { opacity: .95; transform: translate3d(0, -7px, 0) scale(1); }
}

.stem {
  stroke-dasharray: var(--len, 0);
  stroke-dashoffset: var(--len, 0);
  transition: stroke-dashoffset var(--stem-dur, 4100ms) linear;
}

.stem.grown { stroke-dashoffset: 0; }

.soil {
  opacity: 0;
  transition: opacity 1400ms ease;
}

.soil.show { opacity: 1; }

.petal {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: rotate(var(--ac)) scale(var(--sc));
  transition: transform 2400ms cubic-bezier(.25, .7, .35, 1.03);
}

.petals { opacity: 0; transition: opacity 600ms ease; }

.petals.show { opacity: 1; }

.petals.open .petal { transform: rotate(var(--a)) scale(var(--so)); }

.leaf,
.cotyledon,
.sepal {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: rotate(var(--r0, 0deg)) scale(0);
  transition: transform 2000ms cubic-bezier(.2, .86, .32, 1.02), opacity 900ms ease;
}

@keyframes leafIdle {
  0%, 100% { transform: scale(var(--s)) rotate(0deg); }
  50% { transform: scale(var(--s)) rotate(1.2deg); }
}

.leaf.show,
.sepal.show { transform: rotate(0deg) scale(var(--s)); }

.cotyledon.show { transform: rotate(0deg) scale(var(--s)); opacity: 1; }

.cotyledon { opacity: 0; }

.cotyledon.gone,
.seed.gone { opacity: 0; }

.seed {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scale(0);
  transition: transform 700ms cubic-bezier(.2, .9, .3, 1.25), opacity 800ms ease 300ms;
}

.seed.show { transform: scale(1); }

.core {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  transform: scale(.55);
  opacity: 0;
  transition: opacity 1350ms ease, transform 1350ms var(--ease-soft);
}

.core.show { opacity: 1; transform: scale(1); }

.photo,
.photo-glow {
  position: absolute;
  left: 50%;
  top: 39.0625%;
  transform: translate(-50%, -50%) scale(.72);
}

.photo {
  width: 34%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  border: clamp(2px, .85vmin, 4px) solid rgba(255, 226, 150, .95);
  box-shadow:
    0 0 26px rgba(255, 197, 74, .5),
    0 0 60px rgba(255, 180, 60, .22);
  transition: opacity 1000ms ease, transform 1200ms var(--ease-soft);
}

.photo.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: inset 0 0 20px rgba(96, 46, 0, .55), inset 0 0 4px rgba(255, 235, 180, .5);
}

.photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  animation: breathe 9s ease-in-out infinite;
}

.photo.no-img {
  background: radial-gradient(circle at 50% 32%, #ffe9a8 0%, #e6a940 58%, #a9701a 100%);
}

.photo.no-img img { display: none; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.photo-glow {
  width: 58%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 228, 142, .5), rgba(255, 200, 90, .16) 55%, rgba(255, 180, 60, 0) 78%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity 1400ms ease, transform 1700ms var(--ease-soft);
}

.photo-glow.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.photo-glow.pulse { animation: glowPulse 5s ease-in-out infinite; }

@keyframes glowPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.09); }
}

.ground {
  position: relative;
  flex: 0 0 auto;
  height: 9vh;
  height: 9dvh;
  min-height: 58px;
  z-index: 2;
  background:
    radial-gradient(72% 130% at 50% 0%, rgba(255, 196, 88, .17) 0%, rgba(255, 196, 88, 0) 64%),
    linear-gradient(180deg, #0a0918 0%, #06060f 68%, #040409 100%);
}

.ground::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 214, 120, 0) 0%, rgba(255, 214, 120, .34) 50%, rgba(255, 214, 120, 0) 100%);
}

.intro {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
  padding-bottom: 10dvh;
  pointer-events: none;
  transition: opacity 1100ms ease, transform 1100ms var(--ease-soft);
}

.intro.hide {
  opacity: 0;
  transform: scale(.95);
}

.intro-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffdc86;
  box-shadow: 0 0 22px rgba(255, 205, 90, .85), 0 0 48px rgba(255, 190, 70, .35);
  animation: introPulse 3s ease-in-out infinite;
}

@keyframes introPulse {
  0%, 100% { transform: scale(.8); opacity: .6; }
  50% { transform: scale(1.45); opacity: 1; }
}

.intro-text {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif", serif;
  font-size: clamp(.85rem, 3.6vw, 1.05rem);
  letter-spacing: .16em;
  color: rgba(255, 233, 180, .8);
  text-shadow: 0 0 24px rgba(255, 197, 74, .3);
  animation: introFade 3.6s ease-in-out infinite;
}

@keyframes introFade {
  0%, 100% { opacity: .5; }
  50% { opacity: 1; }
}

.caption {
  position: relative;
  flex: 0 0 auto;
  z-index: 3;
  padding: .2rem 6vw max(1.5rem, env(safe-area-inset-bottom));
  text-align: center;
}

.caption::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: 0 -20vw;
  background: radial-gradient(60% 100% at 50% 30%, rgba(255, 190, 80, .09), rgba(255, 190, 80, 0) 70%);
  pointer-events: none;
}

.line {
  position: relative;
  margin: 0 auto;
  max-width: 34ch;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1300ms ease, transform 1300ms var(--ease-soft);
}

.line.show { opacity: 1; transform: none; }

.line-1 {
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif", serif;
  font-size: clamp(1.02rem, 4.5vw, 1.6rem);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: .01em;
  color: #ffeec4;
  text-shadow: 0 0 26px rgba(255, 197, 74, .38);
}

.line-2 {
  margin-top: .5em;
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif", serif;
  font-size: clamp(.82rem, 3.4vw, 1.05rem);
  color: #ffd8a4;
  opacity: 0;
  text-shadow: 0 0 20px rgba(255, 170, 90, .3);
}

.line-2.show { opacity: .92; }

.replay {
  display: inline-block;
  margin-top: 1.15rem;
  padding: .6rem 1.2rem;
  font: inherit;
  font-size: clamp(.76rem, 3.1vw, .92rem);
  letter-spacing: .05em;
  color: #ffe8b4;
  background: rgba(255, 214, 120, .07);
  border: 1px solid rgba(255, 214, 120, .32);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 900ms ease, transform 900ms var(--ease-soft), background 250ms ease, border-color 250ms ease;
}

.replay.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.replay:active {
  background: rgba(255, 214, 120, .16);
  border-color: rgba(255, 214, 120, .6);
}

.sound {
  position: absolute;
  top: max(.85rem, env(safe-area-inset-top));
  right: max(.85rem, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 150, .2);
  background: rgba(255, 225, 160, .06);
  color: rgba(255, 232, 178, .68);
  cursor: pointer;
  z-index: 12;
  transition: background 300ms ease, border-color 300ms ease, color 300ms ease, opacity 700ms ease, transform 200ms ease;
}

.sound:active { transform: scale(.93); }

.sound.on {
  color: #ffdf9a;
  border-color: rgba(255, 214, 120, .48);
  background: rgba(255, 214, 120, .12);
}

.sound .slash { opacity: 0; transition: opacity 200ms ease; }

.sound.off .slash { opacity: .9; }

.sound.hidden { opacity: 0; pointer-events: none; }

.bursts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.bursts .heart {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  will-change: transform, opacity;
}

.bursts .ripple {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 218, 120, .55);
  will-change: transform, opacity;
}

.no-anim,
.no-anim * {
  transition: none !important;
  animation: none !important;
}

@media (max-height: 620px) {
  .ground { height: 7vh; min-height: 42px; }
  .caption { padding-bottom: max(.9rem, env(safe-area-inset-bottom)); }
  .line-1 { font-size: clamp(.95rem, 4vw, 1.2rem); }
  .replay { margin-top: .7rem; padding: .45rem 1rem; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .caption { padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
  .ground { display: none; }
}
