:root {
  --rose-950: #5f1738;
  --rose-800: #8f2853;
  --rose-600: #d94b80;
  --rose-300: #ffa8ca;
  --rose-100: #ffe8f2;
  --cream: #fff9fc;
  --mint: #b7eadf;
  --butter: #f8d778;
  --lavender: #d8c6ff;
  --ink: #472239;
  --shadow: 0 28px 80px rgba(143, 40, 83, 0.24);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Poppins", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 16%, rgba(248, 215, 120, 0.34), transparent 24rem),
    radial-gradient(circle at 86% 18%, rgba(183, 234, 223, 0.34), transparent 22rem),
    radial-gradient(circle at 74% 92%, rgba(216, 198, 255, 0.28), transparent 20rem),
    linear-gradient(145deg, #fff9fc 0%, #ffe8f2 46%, #ffc8dd 100%);
}

button {
  font: inherit;
}

.app {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 40px);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  transition:
    opacity 500ms ease,
    transform 500ms ease;
}

.screen.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.welcome-card {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(520px, 100%);
  padding: clamp(16px, 5vw, 40px);
  text-align: center;
}

.open-text {
  margin: 0;
  color: var(--rose-950);
  font-family: "Poppins", system-ui, sans-serif;
  font-size: clamp(2.75rem, 9vw, 5.8rem);
  font-weight: 900;
  line-height: 1.05;
  text-wrap: balance;
}

.open-arrow {
  position: relative;
  width: 4px;
  height: clamp(52px, 10vh, 86px);
  margin: 20px 0 8px;
  border-radius: 999px;
  background: var(--rose-800);
  animation: arrow-nudge 1.2s ease-in-out infinite;
}

.open-arrow::after {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 20px;
  height: 20px;
  content: "";
  border-right: 4px solid var(--rose-800);
  border-bottom: 4px solid var(--rose-800);
  transform: translateX(-50%) rotate(45deg);
}

.gift-button {
  position: relative;
  width: clamp(160px, 38vw, 250px);
  height: clamp(150px, 34vw, 224px);
  border: 0;
  cursor: pointer;
  background: transparent;
  transition: transform 180ms ease;
}

.gift-button:hover {
  transform: translateY(-4px);
}

.gift-box__lid,
.gift-box__body,
.gift-box__ribbon,
.gift-box__shine {
  position: absolute;
  display: block;
}

.gift-box__lid {
  top: 48px;
  left: 50%;
  z-index: 3;
  width: 86%;
  height: 46px;
  border: 4px solid rgba(95, 23, 56, 0.08);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffd8e8, var(--rose-300));
  box-shadow: 0 16px 24px rgba(143, 40, 83, 0.18);
  transform: translateX(-50%);
  animation: lid-shake 780ms ease-in-out infinite;
  transform-origin: center bottom;
}

.gift-box__body {
  left: 50%;
  bottom: 14px;
  width: 74%;
  height: 116px;
  border: 4px solid rgba(95, 23, 56, 0.08);
  border-radius: 14px 14px 18px 18px;
  background:
    linear-gradient(90deg, transparent 0 42%, rgba(255, 255, 255, 0.54) 42% 58%, transparent 58%),
    linear-gradient(135deg, #ffc0d9, var(--rose-600));
  box-shadow: 0 20px 38px rgba(143, 40, 83, 0.22);
  transform: translateX(-50%);
}

.gift-box__ribbon--lid {
  top: 48px;
  left: 50%;
  z-index: 4;
  width: 28px;
  height: 46px;
  border-radius: 8px;
  background: var(--butter);
  transform: translateX(-50%);
  animation: lid-shake 780ms ease-in-out infinite;
}

.gift-box__ribbon--body {
  left: 50%;
  bottom: 14px;
  z-index: 2;
  width: 30px;
  height: 116px;
  border-radius: 8px;
  background: var(--butter);
  transform: translateX(-50%);
}

.gift-box__shine {
  top: 92px;
  left: 22%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  box-shadow:
    22px 34px 0 rgba(255, 255, 255, 0.5),
    118px -8px 0 rgba(255, 255, 255, 0.45);
}

.kicker {
  margin: 0 0 12px;
  color: var(--rose-800);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
p {
  margin-top: 0;
}

.message-card__close {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.message-card__close:hover {
  transform: translateY(-3px);
}

.party-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) minmax(260px, 1fr) minmax(150px, 0.75fr);
  align-items: center;
  justify-items: center;
  gap: clamp(22px, 5vw, 64px);
  width: min(1120px, 100%);
  min-height: min(760px, calc(100vh - 42px));
  align-content: center;
}

.cake {
  position: relative;
  width: clamp(150px, 22vw, 260px);
  height: clamp(170px, 25vw, 290px);
  animation: cake-hover 2.2s ease-in-out infinite;
}

.cake__candle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 18px;
  height: 58px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    -35deg,
    #ffffff 0 8px,
    var(--rose-300) 8px 16px
  );
  transform: translateX(-50%);
  box-shadow: inset 0 -8px 0 rgba(143, 40, 83, 0.08);
}

.cake__candle span {
  position: absolute;
  top: -24px;
  left: 50%;
  width: 24px;
  height: 30px;
  border-radius: 50% 50% 48% 48%;
  background: linear-gradient(#fff2a6, #ff9d4f 70%);
  transform: translateX(-50%);
  animation: flame 700ms ease-in-out infinite alternate;
}

.cake__top,
.cake__middle,
.cake__bottom {
  position: absolute;
  left: 50%;
  border: 4px solid rgba(95, 23, 56, 0.08);
  transform: translateX(-50%);
  box-shadow: 0 16px 28px rgba(143, 40, 83, 0.12);
}

.cake__top {
  top: 56px;
  width: 62%;
  height: 58px;
  border-radius: 22px 22px 12px 12px;
  background:
    radial-gradient(circle at 24% 35%, #fff 0 7px, transparent 8px),
    radial-gradient(circle at 74% 44%, #fff 0 7px, transparent 8px),
    linear-gradient(#ffeef5 0 42%, var(--rose-300) 43%);
}

.cake__middle {
  top: 104px;
  width: 82%;
  height: 72px;
  border-radius: 24px 24px 14px 14px;
  background:
    radial-gradient(circle at 22% 44%, var(--butter) 0 8px, transparent 9px),
    radial-gradient(circle at 50% 42%, #fff 0 8px, transparent 9px),
    radial-gradient(circle at 76% 44%, var(--mint) 0 8px, transparent 9px),
    linear-gradient(#ffd6e6 0 45%, #f782ad 46%);
}

.cake__bottom {
  top: 166px;
  width: 100%;
  height: 78px;
  border-radius: 26px 26px 18px 18px;
  background:
    radial-gradient(circle at 18% 44%, #fff 0 8px, transparent 9px),
    radial-gradient(circle at 40% 48%, var(--butter) 0 8px, transparent 9px),
    radial-gradient(circle at 64% 44%, #fff 0 8px, transparent 9px),
    radial-gradient(circle at 84% 48%, var(--lavender) 0 8px, transparent 9px),
    linear-gradient(#ffc2dc 0 45%, var(--rose-600) 46%);
}

.cake__plate {
  position: absolute;
  bottom: 15px;
  left: 50%;
  width: 112%;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  transform: translateX(-50%);
  box-shadow: 0 18px 28px rgba(143, 40, 83, 0.14);
}

.greeting-wrap {
  text-align: center;
}

.greeting {
  min-height: 1.18em;
  margin: 0;
  color: var(--rose-950);
  font-family: "Poppins", system-ui, sans-serif;
  font-size: clamp(2.65rem, 8vw, 5.9rem);
  font-weight: 900;
  line-height: 1.08;
  text-wrap: balance;
  transition:
    opacity 450ms ease,
    transform 450ms ease;
}

.greeting.is-changing {
  opacity: 0;
  transform: translateY(8px);
}

.envelope {
  position: relative;
  width: clamp(150px, 36vw, 230px);
  height: clamp(104px, 25vw, 158px);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  filter: drop-shadow(0 18px 28px rgba(143, 40, 83, 0.2));
  animation: envelope-shake 1.4s ease-in-out infinite;
  transition: transform 180ms ease;
}

.envelope__body,
.envelope__flap {
  position: absolute;
  inset: 0;
  border-radius: 8px;
}

.envelope__body {
  background:
    linear-gradient(145deg, transparent 49%, #ffb5d1 50%),
    linear-gradient(215deg, transparent 49%, #ff9ec3 50%),
    linear-gradient(#ffdcea, #ffc0d8);
  border: 3px solid rgba(143, 40, 83, 0.1);
}

.envelope__flap {
  z-index: 2;
  clip-path: polygon(0 0, 100% 0, 50% 58%);
  background: #ffe8f2;
  transform-origin: top;
  transition: transform 360ms ease;
}

.envelope__seal {
  position: absolute;
  z-index: 3;
  top: 43%;
  left: 50%;
  width: clamp(28px, 8vw, 42px);
  height: clamp(28px, 8vw, 42px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--butter) 0 28%, transparent 30%),
    conic-gradient(var(--mint), var(--rose-300), var(--lavender), var(--butter), var(--mint));
  transform: translate(-50%, -50%);
}

.envelope__label {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 58%;
  color: var(--rose-950);
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
}

.envelope.is-open .envelope__flap {
  transform: rotateX(150deg);
}

.message-card {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: min(560px, calc(100% - 32px));
  padding: clamp(28px, 6vw, 46px);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: rgba(255, 249, 252, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -46%) scale(0.95);
  transition:
    opacity 300ms ease,
    transform 300ms ease;
}

.message-card.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.card-title {
  margin: 0 0 18px;
  color: var(--rose-800);
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  font-weight: 900;
}

.message-card p:not(.card-title) {
  margin-bottom: 26px;
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  font-weight: 800;
  line-height: 1.55;
}

.message-card footer {
  color: var(--rose-800);
  font-size: 1.2rem;
  font-weight: 900;
  text-align: right;
}

.message-card__close {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 38px;
  padding: 0 14px;
  color: var(--rose-950);
  background: var(--rose-100);
}

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

.confetti span {
  position: absolute;
  top: -12vh;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 1.8);
  border-radius: 3px;
  background: var(--color);
  animation: confetti-fall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes cake-hover {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-18px);
  }
}


@keyframes envelope-shake {
  0%,
  100% {
    transform: rotate(0deg);
  }

  20% {
    transform: rotate(-3deg);
  }

  40% {
    transform: rotate(3deg);
  }

  60% {
    transform: rotate(-2deg);
  }

  80% {
    transform: rotate(2deg);
  }
}

@keyframes flame {
  from {
    transform: translateX(-50%) scale(0.9) rotate(-5deg);
  }

  to {
    transform: translateX(-50%) scale(1.08) rotate(6deg);
  }
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 115vh, 0) rotate(720deg);
  }
}

@keyframes arrow-nudge {
  0%,
  100% {
    transform: translateY(0);
  }

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

@keyframes lid-shake {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }

  25% {
    transform: translateX(-52%) rotate(-4deg);
  }

  50% {
    transform: translateX(-50%) rotate(3deg);
  }

  75% {
    transform: translateX(-48%) rotate(-2deg);
  }
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .screen {
    padding: 14px;
  }

  .open-text {
    font-size: clamp(2.4rem, 13vw, 3.8rem);
  }

  .open-arrow {
    height: 58px;
    margin: 16px 0 2px;
  }

  .gift-button {
    width: 188px;
    height: 212px;
  }

  .gift-box__lid {
    top: 50px;
    height: 44px;
  }

  .gift-box__ribbon--lid {
    top: 50px;
    height: 44px;
  }

  .gift-box__body {
    bottom: 18px;
    height: 112px;
  }

  .gift-box__ribbon--body {
    bottom: 18px;
    height: 112px;
  }

  .gift-box__shine {
    top: 112px;
  }

  .party-stage {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: calc(100vh - 28px);
    align-content: center;
    gap: 8px;
  }

  .cake {
    width: 150px;
    height: 164px;
    margin-bottom: 2px;
    transform-origin: center top;
    animation: cake-hover-mobile 2.2s ease-in-out infinite;
  }

  .greeting {
    max-width: 9ch;
    font-size: clamp(2.15rem, 11vw, 3.25rem);
    line-height: 1.04;
  }

  .envelope {
    width: 156px;
    height: 108px;
    margin-top: 6px;
  }

  .envelope__label {
    font-size: 0.95rem;
  }

  .message-card {
    max-height: calc(100vh - 36px);
    overflow: auto;
  }
}

@keyframes cake-hover-mobile {
  0%,
  100% {
    transform: scale(0.58) translateY(0);
  }

  50% {
    transform: scale(0.58) translateY(-18px);
  }
}

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