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

html, body { height: 100%; overflow: hidden; background: #fbd3e3; }
body {
  font-family: 'Quicksand', system-ui, sans-serif;
  color: #6b2c4a;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
#petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* ---------- Scenes ---------- */
.scene {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2vh;
  padding: max(4vh, env(safe-area-inset-top)) 4vw calc(11vh + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden;
  transform: scale(1.06); filter: blur(6px);
  transition: opacity 1.2s ease, transform 1.4s ease, filter 1.2s ease, visibility 0s linear 1.4s;
  overflow: hidden;
}
.scene.active {
  opacity: 1; visibility: visible; transform: none; filter: none;
  transition: opacity 1.2s ease, transform 1.4s ease, filter 1.2s ease, visibility 0s;
}

.s1 { background: radial-gradient(120% 90% at 50% 40%, #fff7fa 0%, #fcd9e7 45%, #e7c9f2 100%); }
.s2 { background: linear-gradient(180deg, #fdebe4 0%, #f7cdd8 100%); }
.s3 { background: radial-gradient(130% 90% at 50% 0%, #5b3a8e 0%, #231552 55%, #0d0a26 100%); color: #fdeaf3; }
.s4 { background: linear-gradient(180deg, #fff5ea 0%, #ffdbe6 55%, #f6c3da 100%); }

.art {
  position: relative; z-index: 1;
  width: min(94vw, 600px);
  flex: 1 1 0; min-height: 0; max-height: 620px;
}
.art > svg { width: 100%; height: 100%; display: block; overflow: visible; }
.s2 .art > svg { filter: drop-shadow(0 14px 30px rgba(190, 80, 120, .25)); }

/* ---------- Text card ---------- */
.card {
  position: relative; z-index: 2;
  max-width: min(92vw, 560px);
  text-align: center;
  padding: 1rem 1.4rem 1.1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, .58);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 10px 40px rgba(200, 80, 130, .18);
}
.card.dark {
  background: rgba(30, 18, 70, .45);
  border-color: rgba(255, 255, 255, .15);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
h2 {
  font-family: 'Great Vibes', cursive; font-weight: 400;
  font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1.1;
  color: #d23f7c; margin-bottom: .35rem;
}
.dark h2 { color: #ffc1dc; text-shadow: 0 0 18px rgba(255, 140, 200, .5); }
.card p { font-size: clamp(.98rem, 3.7vw, 1.15rem); line-height: 1.6; font-weight: 500; }
.card p + p { margin-top: .5rem; }
.card p.big { font-weight: 700; color: #ffd6e8; }
.card em { font-style: italic; color: #ff9ccc; }
.countdown { font-weight: 700 !important; color: #d23f7c; }
.countdown:empty { display: none; }
.sign { font-family: 'Great Vibes', cursive; font-size: clamp(1.7rem, 6vw, 2.2rem) !important; color: #c2185b; line-height: 1.2 !important; }
.replay {
  margin-top: .7rem;
  font: 600 .95rem 'Quicksand', sans-serif;
  color: #fff; background: linear-gradient(135deg, #ff7aa8, #d23f7c);
  border: 0; border-radius: 999px; padding: .55rem 1.3rem; cursor: pointer;
  box-shadow: 0 6px 18px rgba(210, 63, 124, .35);
}

/* ---------- Scene 1 ---------- */
.wreath {
  position: relative; z-index: 1;
  width: min(86vw, 56vh, 540px); aspect-ratio: 1;
  container-type: inline-size;
}
#wreath { width: 100%; height: 100%; display: block; overflow: visible; animation: spin 140s linear infinite; }
.title {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: 'Great Vibes', cursive; font-weight: 400;
  font-size: 19cqw; line-height: 1.3; white-space: nowrap;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 0 22px rgba(255, 255, 255, .95));
}
.shimmer {
  background: linear-gradient(100deg, #c2185b 20%, #ff9cc4 40%, #c2185b 60%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 4s linear infinite;
  display: inline-block; padding: .12em .18em .3em;
}
.tagline { font-family: 'Great Vibes', cursive; font-size: clamp(1.8rem, 7vw, 2.4rem) !important; color: #d23f7c; line-height: 1.2 !important; }
.corner { position: absolute; width: min(40vw, 320px); height: auto; pointer-events: none; overflow: visible; }
.corner.bl { left: -2vw; bottom: -2vw; }
.corner.tr { right: -2vw; top: -2vw; transform: rotate(180deg); }

/* ---------- Scene 3 ---------- */
.sky { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute; border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, .8);
  animation: twinkleCss var(--t, 3s) ease-in-out infinite; animation-delay: var(--d, 0s);
}
.shoot {
  position: absolute; top: 8%; left: 5%; width: 130px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
  transform-origin: left center; opacity: 0;
  animation: shoot 7s linear infinite 1.5s;
}
.shoot.late { top: 22%; left: 30%; animation-delay: 4.8s; animation-duration: 9s; }
#constellation {
  fill: none; stroke: rgba(255, 196, 228, .75); stroke-width: 1.6;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.scene.active #constellation, .scene.leaving #constellation { animation: draw 3.2s ease .5s forwards; }

/* ---------- Floating hearts (scene 2) ---------- */
.floaties { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.floaties span {
  position: absolute; bottom: 30%; left: var(--x);
  font-size: var(--s); color: var(--c, #ff6f9f); opacity: 0;
  animation: floatUp var(--t) ease-in infinite; animation-delay: var(--d);
}

/* ---------- SVG animation helpers ---------- */
.bloom, .sway, .twinkle, .bob, .breathe, .bell, .floatHeart, .grow { transform-box: fill-box; transform-origin: center; }
.bloom { opacity: 0; }
.scene.active .bloom, .scene.leaving .bloom { animation: bloom 1.3s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, 0s); }
.grow { opacity: 0; transform-origin: 50% 100%; }
.scene.active .grow, .scene.leaving .grow { animation: grow 1s ease-out both; animation-delay: var(--d, 0s); }
.reveal { opacity: 0; }
.scene.active .reveal, .scene.leaving .reveal { animation: rise 1s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0s); }
.sway { animation: sway 4s ease-in-out infinite; }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.bob { animation: bob 4s ease-in-out infinite; }
.breathe { transform-origin: 50% 100%; animation: breathe 3.6s ease-in-out infinite; }
.bell { transform-origin: 50% 0; animation: swing 2.4s ease-in-out infinite; }
.bell.late { animation-delay: -1.2s; }
.floatHeart { animation: heartBeat 1.6s ease-in-out infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes bloom { from { opacity: 0; transform: scale(0) rotate(-50deg); } to { opacity: 1; transform: none; } }
@keyframes grow { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: none; } }
@keyframes sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes twinkleCss { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-3px) scaleY(1.012); } }
@keyframes swing { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
@keyframes heartBeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1); } 45% { transform: scale(1.18); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shoot {
  0% { opacity: 0; transform: rotate(18deg) translateX(0); }
  3% { opacity: 1; }
  14% { opacity: 0; transform: rotate(18deg) translateX(75vw); }
  100% { opacity: 0; transform: rotate(18deg) translateX(75vw); }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(0, 0) scale(.5); }
  15% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--dx), -260px) scale(1.15); }
}

/* ---------- UI ---------- */
.ui-btn {
  position: fixed; top: max(14px, env(safe-area-inset-top)); z-index: 10;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #d23f7c; font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  transition: opacity .4s;
}
.ui-btn[hidden] { display: none; }
.ui-btn.back { left: 14px; }
.ui-btn.music { right: 14px; font-size: 1.1rem; }
.ui-btn.music:not(.on) { opacity: .55; text-decoration: line-through; }
body.first .ui-btn.back { opacity: 0; pointer-events: none; }

.hint {
  position: fixed; left: 0; right: 0; z-index: 10;
  bottom: calc(5.2vh + 16px + env(safe-area-inset-bottom));
  text-align: center; font-size: .9rem; font-weight: 600; letter-spacing: .04em;
  color: #c2457c; pointer-events: none;
  animation: pulse 2.2s ease-in-out infinite;
  transition: opacity .6s;
}
body.last .hint { opacity: 0; animation: none; }
.dots {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 10;
  bottom: calc(3.2vh + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.dot {
  width: 9px; height: 9px; border-radius: 9px; border: 0; padding: 0; cursor: pointer;
  background: rgba(210, 63, 124, .3); transition: width .4s, background .4s;
}
.dot.on { width: 26px; background: #d23f7c; }
body.dark .hint { color: #ffc1dc; }
body.dark .dot { background: rgba(255, 193, 220, .3); }
body.dark .dot.on { background: #ffc1dc; }
body.dark .ui-btn { background: rgba(40, 24, 90, .5); border-color: rgba(255, 255, 255, .2); color: #ffc1dc; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.pop {
  position: fixed; z-index: 20; pointer-events: none;
  color: #ff5c93; font-size: 24px;
  animation: pop .9s ease-out forwards;
}
@keyframes pop {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.4); }
  to { opacity: 0; transform: translate(-50%, -170%) scale(1.5); }
}
.burst {
  position: fixed; left: 50%; top: 42%; z-index: 15; pointer-events: none;
  font-size: var(--s); color: var(--c);
  animation: burst var(--t) cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes burst {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.3); }
  70% { opacity: 1; }
  to { opacity: 0; transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--r)) scale(1); }
}

/* ---------- Layout tweaks ---------- */
@media (orientation: landscape) and (max-height: 620px) {
  .scene { flex-direction: row; gap: 3vw; padding: 5vh 5vw 13vh; }
  .art { flex: 1 1 0; height: 100%; max-height: none; min-width: 0; }
  .card { flex: 0 1 46%; }
  .wreath { width: min(44vw, 78vh); }
  .card p { font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .3s !important; }
  .floaties, .shoot { display: none; }
}
