.scene {
  position: relative;
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 48px 18px 30px;
  color: #fff8ea;
  background: url("/assets/background.png") center / cover no-repeat;
  font-family: var(--font-letter);
  isolation: isolate;
}

.light {
  position: absolute;
  z-index: -2;
  left: 50%;
  top: 55%;
  width: min(110vw, 860px);
  height: min(110vw, 860px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255,234,223,.42), rgba(255,170,188,.13) 43%, transparent 68%);
  filter: blur(14px);
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .12;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
}

.floatingPetals i {
  position: absolute;
  z-index: -1;
  width: 17px;
  height: 9px;
  border-radius: 100% 0 100% 0;
  background: rgba(255,211,75,.88);
  border: 1px solid rgba(255,244,178,.32);
  box-shadow: 0 0 18px rgba(255,207,65,.42);
  animation: petal 9s ease-in-out infinite alternate;
}
.floatingPetals i:nth-child(1) { left: 8%; top: 18%; rotate: 25deg; }
.floatingPetals i:nth-child(2) { right: 9%; top: 22%; rotate: 74deg; animation-delay: -3s; }
.floatingPetals i:nth-child(3) { left: 14%; bottom: 18%; rotate: -38deg; animation-delay: -6s; }
.floatingPetals i:nth-child(4) { right: 14%; bottom: 16%; rotate: 17deg; animation-delay: -1s; }
.floatingPetals i:nth-child(5) { left: 32%; top: 8%; rotate: 88deg; animation-delay: -5s; }

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

.ribbonRain i {
  position: absolute;
  top: -150px;
  width: 10px;
  height: 104px;
  border-radius: 65% 18% 70% 24%;
  opacity: .64;
  background: linear-gradient(180deg, #f7a9bd, #d9507b 48%, #f8c8d3);
  box-shadow: inset 2px 0 rgba(255,255,255,.34), 0 7px 14px rgba(154,45,82,.08);
  transform-origin: 50% 0;
  animation: ribbonFall 8.4s linear infinite;
}

.ribbonRain i:nth-child(1) { left: 6%; animation-delay: -1.2s; animation-duration: 8.8s; scale: .74; }
.ribbonRain i:nth-child(2) { left: 19%; animation-delay: -5.1s; animation-duration: 10.2s; rotate: 12deg; background: linear-gradient(180deg, #f5cb79, #dca540 50%, #ffe2a1); }
.ribbonRain i:nth-child(3) { left: 34%; animation-delay: -7.3s; animation-duration: 9.4s; scale: .58; }
.ribbonRain i:nth-child(4) { left: 49%; animation-delay: -3.7s; animation-duration: 11.1s; rotate: -14deg; background: linear-gradient(180deg, #ffd9e1, #e7839e 52%, #fff0ed); }
.ribbonRain i:nth-child(5) { left: 62%; animation-delay: -8.6s; animation-duration: 9.7s; scale: .68; background: linear-gradient(180deg, #f4c36b, #d59a2d 52%, #ffe5a8); }
.ribbonRain i:nth-child(6) { left: 75%; animation-delay: -2.4s; animation-duration: 10.7s; rotate: 18deg; }
.ribbonRain i:nth-child(7) { left: 88%; animation-delay: -6.2s; animation-duration: 8.9s; scale: .52; background: linear-gradient(180deg, #ffdce5, #e07593 48%, #fff4ef); }
.ribbonRain i:nth-child(8) { left: 95%; animation-delay: -4.5s; animation-duration: 11.7s; scale: .66; background: linear-gradient(180deg, #f2c05e, #d39a2e 52%, #ffe4a0); }

.musicButton {
  position: fixed;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,221,205,.3);
  border-radius: 50%;
  color: #ffe8b0;
  background: rgba(132,18,61,.6);
  box-shadow: 0 9px 24px rgba(103,12,47,.24);
  backdrop-filter: blur(14px);
  font: 600 19px/1 var(--font-letter);
  cursor: pointer;
}

.hero {
  width: min(100%, 540px);
  display: grid;
  justify-items: center;
  text-align: center;
}

.copy {
  position: relative;
  z-index: 3;
  animation: titleReveal .9s cubic-bezier(.2,.75,.25,1) both;
}
.copy p {
  margin: 0 0 7px;
  font: 500 clamp(1.2rem, 4.4vw, 1.48rem)/1.4 var(--font-letter);
  letter-spacing: .18em;
  color: #a14f6d;
}
.copy h1 {
  margin: 0;
  font: 500 clamp(2.1rem, 8vw, 3.35rem)/1.08 var(--font-letter);
  letter-spacing: .035em;
  color: #c88f39;
  text-shadow: 0 2px 10px rgba(255,255,255,.62);
}
.copy time {
  display: block;
  margin-top: 11px;
  font: 600 12px/1.2 var(--font-letter);
  letter-spacing: .28em;
  color: #a95f76;
}

.cakeStage {
  position: relative;
  width: min(92vw, 500px);
  height: min(56vh, 500px);
  min-height: 385px;
  display: grid;
  place-items: center;
  margin: -8px 0 -22px;
}
.cakeShadow {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 58%;
  height: 52px;
  border-radius: 50%;
  transform: translateX(-50%) rotateX(72deg);
  background: rgba(100,9,44,.33);
  filter: blur(17px);
  animation: shadow 4s ease-in-out infinite;
}
.cakeFloat {
  position: relative;
  width: min(80vw, 420px);
  animation: cakeEntrance 1.05s cubic-bezier(.2,.72,.2,1) both, cakeBob 5.2s 1.05s ease-in-out infinite;
}
.cakeRig {
  position: relative;
  width: 100%;
  aspect-ratio: 1198 / 1313;
  user-select: none;
  filter: drop-shadow(0 27px 22px rgba(99,10,45,.28));
}
.cakeImage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.flagText {
  position: absolute;
  z-index: 3;
  top: 11.5%;
  left: 74.5%;
  color: #fff8ef;
  transform: rotate(7deg);
  font: 600 clamp(10px, 2.5vw, 15px)/1 var(--font-letter);
  letter-spacing: .13em;
  text-shadow: 0 1px 2px rgba(83,34,47,.4);
  pointer-events: none;
}

.sparkles i {
  position: absolute;
  z-index: 4;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff9e9;
  box-shadow: 0 0 0 5px rgba(255,249,233,.16), 0 0 20px rgba(255,245,191,.85);
  animation: sparkle 2.8s ease-in-out infinite;
}
.sparkles i:nth-child(1) { left: 18%; top: 32%; }
.sparkles i:nth-child(2) { right: 14%; top: 44%; animation-delay: -.9s; scale: .65; }
.sparkles i:nth-child(3) { right: 28%; bottom: 15%; animation-delay: -1.8s; scale: .5; }

.actionArea { position: relative; width: min(88vw, 390px); margin-top: 4px; }
.giftButton {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(255,224,155,.72);
  border-radius: 999px;
  color: #fffaf5;
  background: linear-gradient(135deg, #d94f79 0%, #9e174e 100%);
  box-shadow: 0 14px 28px rgba(105,10,47,.28), inset 0 1px rgba(255,255,255,.26);
  font: 600 16px/1.2 var(--font-letter);
  letter-spacing: .06em;
  cursor: pointer;
}

.giftButton::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -35%;
  width: 24%;
  transform: skewX(-22deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.48), transparent);
  animation: buttonShimmer 4.8s 1.4s ease-in-out infinite;
  pointer-events: none;
}

.giftButton:disabled {
  cursor: wait;
  opacity: .76;
}

.letterPage {
  position: relative;
  z-index: 3;
  width: min(100%, 520px);
  margin: auto;
  padding: 30px 28px 28px;
  border: 1px solid rgba(255, 231, 211, .82);
  border-radius: 30px;
  color: #5d2940;
  background: rgba(255, 252, 248, .9);
  box-shadow: 0 20px 60px rgba(139, 59, 88, .16), inset 0 1px rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
}

.letterPage::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(157, 42, 84, .11);
  border-radius: 22px;
  pointer-events: none;
}

.backButton {
  position: relative;
  z-index: 2;
  border: 0;
  padding: 4px 0 18px;
  color: #9c6173;
  background: transparent;
  font: 600 14px/1.2 var(--font-letter);
  cursor: pointer;
}

.letterHeading {
  position: relative;
  z-index: 2;
  text-align: center;
}

.letterHeading::before {
  content: "★";
  display: block;
  margin-bottom: 9px;
  color: #d5a247;
  font-size: 18px;
}

.letterHeading p {
  margin: 0 0 23px;
  color: #b24a70;
  font: 700 14px/1.4 var(--font-letter);
  letter-spacing: .2em;
}

.letterForm {
  position: relative;
  z-index: 2;
  display: grid;
  padding: 20px 18px 18px;
  border: 1px solid rgba(188, 116, 139, .2);
  border-radius: 10px;
  background: rgba(255, 253, 248, .72);
  box-shadow: 0 10px 24px rgba(122, 49, 75, .07);
}

.letterForm label {
  margin: 0 0 8px;
  color: #69334a;
  font: 700 15px/1.4 var(--font-letter);
}

.letterForm textarea,
.letterForm input {
  width: 100%;
  border: 0;
  outline: none;
  color: #4f2d3a;
  font: 16px/2 var(--font-letter);
  transition: border-color .16s ease, box-shadow .16s ease;
}

.letterForm textarea {
  min-height: 168px;
  padding: 0 4px;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      rgba(185, 120, 139, .22) 31px,
      rgba(185, 120, 139, .22) 32px
    );
  background-attachment: local;
  resize: vertical;
}

.letterForm input {
  width: min(72%, 270px);
  height: 52px;
  justify-self: end;
  margin-bottom: 20px;
  padding: 0 4px;
  border-bottom: 1px solid rgba(168, 91, 116, .35);
  border-radius: 0;
  background: transparent;
  text-align: right;
}

.letterForm textarea:focus,
.letterForm input:focus {
  border-color: rgba(197, 78, 119, .58);
  box-shadow: none;
}

.letterForm textarea::placeholder,
.letterForm input::placeholder { color: #b9939f; }

.letterForm label[for="birthday-name"] {
  margin-top: 4px;
  text-align: right;
}

.counter {
  margin: 7px 4px 17px;
  color: #a27d89;
  text-align: right;
  font: 13px/1.4 var(--font-letter);
}

.formMessage {
  margin: -4px 0 14px;
  padding: 10px 13px;
  border-radius: 13px;
  color: #8c2c50;
  background: rgba(238, 178, 193, .25);
  font: 14px/1.55 var(--font-letter);
}

.sendingStage {
  position: relative;
  z-index: 3;
  width: min(100%, 520px);
  min-height: 430px;
  display: grid;
  place-items: center;
  align-content: center;
  overflow: hidden;
  color: #934463;
  text-align: center;
}

.sendingStage p {
  margin: 250px 0 0;
  font: 600 17px/1.6 var(--font-letter);
  letter-spacing: .08em;
}

.flyingLetter {
  position: absolute;
  left: 8%;
  bottom: 18%;
  width: 100px;
  height: 70px;
  border: 1px solid rgba(183, 88, 120, .32);
  border-radius: 7px;
  background: #fffaf4;
  box-shadow: 0 18px 40px rgba(130, 48, 79, .18);
  transform: rotate(-8deg);
  animation: letterFlight 1.55s cubic-bezier(.34,.2,.25,1) forwards;
}

.flyingLetter::before,
.flyingLetter::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 58%, 100% 0);
}

.flyingLetter::before { background: #f7d7dd; }
.flyingLetter::after {
  clip-path: polygon(0 100%, 0 43%, 50% 79%, 100% 43%, 100% 100%);
  background: #fff1ed;
}

.flyingLetter span {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 49%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #bd4b72;
  box-shadow: inset 0 1px rgba(255,255,255,.35);
}

.flightPath i {
  position: absolute;
  left: 10%;
  bottom: 24%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(218, 161, 73, .76);
  box-shadow: 0 0 18px rgba(255, 215, 128, .78);
  animation: flightSparkle 1.4s ease-out forwards;
}

.flightPath i:nth-child(2) { left: 27%; bottom: 38%; animation-delay: .18s; }
.flightPath i:nth-child(3) { left: 49%; bottom: 52%; animation-delay: .35s; }
.flightPath i:nth-child(4) { left: 72%; bottom: 67%; animation-delay: .52s; }

.replyPage {
  position: relative;
  z-index: 3;
  width: min(100%, 540px);
  display: grid;
  gap: 18px;
  padding: 38px 30px 30px;
  border: 1px solid rgba(255, 231, 211, .88);
  border-radius: 30px;
  color: #5d2940;
  background: rgba(255, 252, 248, .92);
  box-shadow: 0 22px 64px rgba(139, 59, 88, .18), inset 0 1px rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px);
  animation: replyOpen .7s cubic-bezier(.2,.75,.25,1) both;
}

.replyPage::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(157, 42, 84, .1);
  border-radius: 22px;
  pointer-events: none;
}

.replySeal {
  position: absolute;
  z-index: 2;
  right: 30px;
  top: 27px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff8ed;
  background: #bd4b72;
  box-shadow: 0 7px 18px rgba(137, 48, 80, .22), inset 0 0 0 4px rgba(255,255,255,.15);
  font: 600 13px/1 var(--font-letter);
  letter-spacing: .06em;
  rotate: 7deg;
}

.replyEyebrow {
  position: relative;
  z-index: 2;
  margin: 0;
  padding-right: 70px;
  color: #b24a70;
  font: 700 14px/1.5 var(--font-letter);
  letter-spacing: .12em;
}

.replyLetter {
  position: relative;
  z-index: 2;
  padding: 19px 22px 17px;
  border-radius: 10px;
  background-color: rgba(255,253,248,.82);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 33px,
    rgba(185,120,139,.17) 33px,
    rgba(185,120,139,.17) 34px
  );
  background-position: 0 20px;
  box-shadow: 0 10px 24px rgba(122, 49, 75, .07);
}

.replyBody {
  margin: 0;
  color: #684052;
  font: 16px/34px var(--font-letter);
}

.replySignature {
  display: block;
  margin: 0 8px 0 0;
  color: #a34566;
  text-align: right;
  font-size: 17px;
  font-weight: 700;
}

.liveInvitation {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  padding: 20px 18px 17px;
  border: 1px solid rgba(196, 93, 129, .18);
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(145deg, rgba(255,244,244,.9), rgba(255,251,244,.9));
}

.liveInvitation p {
  margin: 0 0 4px;
  color: #a45e76;
  font: 600 13px/1.5 var(--font-letter);
  letter-spacing: .1em;
}

.liveInvitation h3 {
  margin: 0 0 12px;
  color: #8b3456;
  font: 700 20px/1.5 var(--font-letter);
}

.qrImage {
  width: min(100%, 360px);
  height: auto;
  display: block;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(115, 55, 77, .08);
}

.liveInvitation small {
  margin-top: 11px;
  color: #9f7786;
  font: 13px/1.5 var(--font-letter);
}

@keyframes shadow { 0%,100% { opacity: .68; scale: .94; } 50% { opacity: .44; scale: 1.03; } }
@keyframes petal { 0% { translate: -7px -5px; } 100% { translate: 12px 16px; } }
@keyframes sparkle { 0%,100% { opacity: .22; transform: scale(.65); } 50% { opacity: .95; transform: scale(1); } }
@keyframes ribbonFall {
  0% { translate: 0 -12vh; rotate: -18deg; }
  28% { translate: 24px 30vh; rotate: 34deg; }
  58% { translate: -18px 65vh; rotate: 112deg; }
  100% { translate: 18px 118vh; rotate: 210deg; }
}
@keyframes titleReveal {
  from { opacity: 0; transform: translateY(-17px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cakeEntrance {
  from { opacity: 0; transform: translateY(32px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cakeBob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes buttonShimmer {
  0%, 62% { left: -35%; opacity: 0; }
  68% { opacity: 1; }
  86% { left: 112%; opacity: .75; }
  100% { left: 112%; opacity: 0; }
}
@keyframes letterFlight {
  0% { left: 7%; bottom: 17%; opacity: 0; transform: rotate(-10deg) scale(.76); }
  18% { opacity: 1; }
  55% { left: 45%; bottom: 49%; transform: rotate(7deg) scale(1.03); }
  100% { left: 87%; bottom: 78%; opacity: 0; transform: rotate(18deg) scale(.58); }
}
@keyframes flightSparkle {
  0% { opacity: 0; scale: .3; }
  30% { opacity: 1; scale: 1; }
  100% { opacity: 0; translate: 8px -12px; scale: .4; }
}
@keyframes replyOpen {
  from { opacity: 0; transform: translateY(22px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 560px) {
  .scene { padding: 68px 12px 29px; align-items: center; }
  .copy p { margin-bottom: 5px; }
  .copy time { margin-top: 9px; }
  .cakeStage { width: 100vw; height: min(55vh, 470px); min-height: 360px; margin: -5px 0 -18px; }
  .cakeFloat { width: min(84vw, 420px); }
  .cakeShadow { bottom: 5%; }
  .letterPage {
    width: calc(100vw - 24px);
    padding: 24px 21px 23px;
    border-radius: 26px;
  }
  .letterPage::before { inset: 8px; border-radius: 19px; }
  .letterForm textarea { min-height: 150px; }
  .replyPage {
    width: calc(100vw - 24px);
    padding: 31px 20px 22px;
    border-radius: 26px;
  }
  .replyPage::before { inset: 8px; border-radius: 19px; }
  .replySeal { right: 21px; top: 20px; width: 48px; height: 48px; }
  .replyLetter { padding: 18px 17px 16px; }
  .replyBody { font-size: 15px; }
  .liveInvitation { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .flyingLetter,
  .flightPath i,
  .replyPage,
  .ribbonRain i,
  .copy,
  .cakeFloat,
  .giftButton::after { animation-duration: .01ms; animation-iteration-count: 1; }
}

@media (max-height: 720px) {
  .scene { padding-top: 52px; }
  .cakeStage { height: 390px; min-height: 340px; margin: -18px 0 -25px; }
  .cakeFloat { width: min(78vh, 400px); }
  .copy p { font-size: 18px; }
  .copy h1 { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .cakeShadow, .floatingPetals i, .sparkles i { animation: none; }
}
