:root {
  --night: #271a30;
  --night-soft: #3c2742;
  --cream: #fff7e9;
  --paper: #fffdf7;
  --pink: #f08ca0;
  --rose: #d94b6b;
  --gold: #f2b84b;
  --mint: #7fcbb6;
  --blue: #7ba7ff;
  --ink: #33283a;
  --muted: #775f78;
  --line: rgba(51, 40, 58, 0.16);
  --shadow: 0 28px 90px rgba(41, 25, 47, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 16%, rgba(242, 184, 75, 0.38) 0 12rem, transparent 26rem),
    radial-gradient(circle at 88% 12%, rgba(240, 140, 160, 0.36) 0 11rem, transparent 25rem),
    linear-gradient(135deg, #43294a 0%, #271a30 48%, #172d35 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.scene {
  position: relative;
  display: grid;
  min-height: 100svh;
  padding: clamp(1rem, 3vw, 2rem);
  place-items: center;
}

.scene::before,
.scene::after {
  content: "";
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.42;
  pointer-events: none;
}

.scene::before {
  left: -9rem;
  bottom: -10rem;
  background: radial-gradient(circle, rgba(127, 203, 182, 0.72), transparent 68%);
}

.scene::after {
  right: -8rem;
  top: 16%;
  background: radial-gradient(circle, rgba(123, 167, 255, 0.52), transparent 68%);
}

.gift-card {
  position: relative;
  width: min(100%, 870px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 233, 0.92)),
    radial-gradient(circle at 20% 20%, rgba(242, 184, 75, 0.26), transparent 26rem);
  box-shadow: var(--shadow);
  padding: clamp(1.35rem, 4vw, 3.5rem);
  text-align: center;
}

.gift-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(51, 40, 58, 0.08) 1.3px, transparent 1.4px),
    radial-gradient(circle, rgba(217, 75, 107, 0.08) 1.1px, transparent 1.2px);
  background-position:
    0 0,
    18px 22px;
  background-size:
    42px 42px,
    48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 78%);
  pointer-events: none;
}

.tiny-note,
.lead,
h1,
.gift-button,
.letter,
.actions {
  position: relative;
  z-index: 2;
}

.tiny-note {
  margin: 0 0 0.7rem;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  max-width: 11ch;
  margin-inline: auto;
  font-size: clamp(3.4rem, 10vw, 7.2rem);
  line-height: 0.9;
}

.lead {
  max-width: 38rem;
  margin: 1rem auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
}

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

.star,
.heart {
  position: absolute;
  display: block;
  opacity: 0.76;
  animation: float 5s ease-in-out infinite;
}

.star {
  width: 1rem;
  height: 1rem;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 65%, 50% 100%, 38% 65%, 0 50%, 38% 35%);
}

.heart {
  width: 1.05rem;
  height: 1.05rem;
  background: var(--pink);
  transform: rotate(45deg);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
}

.heart::before {
  left: -50%;
}

.heart::after {
  top: -50%;
}

.star-one {
  left: 9%;
  top: 14%;
}

.star-two {
  right: 12%;
  top: 17%;
  animation-delay: -1.6s;
}

.star-three {
  right: 19%;
  bottom: 15%;
  background: var(--mint);
  animation-delay: -2.4s;
}

.heart-one {
  left: 14%;
  bottom: 20%;
  animation-delay: -0.7s;
}

.heart-two {
  right: 8%;
  bottom: 31%;
  background: var(--rose);
  animation-delay: -1.9s;
}

.heart-three {
  left: 22%;
  top: 31%;
  background: var(--blue);
  animation-delay: -3.2s;
}

.gift-button {
  display: grid;
  width: min(100%, 23rem);
  margin: clamp(2rem, 5vw, 3.2rem) auto 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  place-items: center;
}

.gift-button:focus-visible,
.small-button:focus-visible {
  outline: 4px solid rgba(242, 184, 75, 0.7);
  outline-offset: 5px;
}

.gift-wrap {
  position: relative;
  display: grid;
  width: min(78vw, 20rem);
  height: min(58vw, 15.2rem);
  place-items: end center;
}

.gift-shadow {
  position: absolute;
  bottom: 0.25rem;
  width: 74%;
  height: 1.5rem;
  border-radius: 999px;
  background: rgba(51, 40, 58, 0.18);
  filter: blur(7px);
}

.gift-box,
.gift-lid {
  position: absolute;
  border-radius: 16px;
  box-shadow:
    inset 0 -10px 0 rgba(0, 0, 0, 0.06),
    0 16px 34px rgba(51, 40, 58, 0.2);
}

.gift-box {
  bottom: 1.4rem;
  width: 74%;
  height: 48%;
  overflow: hidden;
  background:
    linear-gradient(135deg, #ff8fa6 0%, #e9567a 58%, #c73d62 100%);
  transform-origin: center bottom;
  transition: transform 480ms ease;
}

.gift-lid {
  bottom: calc(48% + 0.6rem);
  width: 82%;
  height: 22%;
  background:
    linear-gradient(135deg, #ffb0bf 0%, #ed6d8b 60%, #d94b6b 100%);
  transform-origin: 18% 100%;
  transition:
    transform 850ms cubic-bezier(0.2, 0.92, 0.28, 1.16),
    translate 850ms cubic-bezier(0.2, 0.92, 0.28, 1.16);
}

.lid-top {
  position: absolute;
  left: 50%;
  top: -3.2rem;
  width: 7rem;
  height: 5rem;
  border: 14px solid var(--gold);
  border-radius: 999px 999px 16px 16px;
  transform: translateX(-50%);
}

.lid-top::before,
.lid-top::after {
  content: "";
  position: absolute;
  top: 1rem;
  width: 4rem;
  height: 3.2rem;
  border: 12px solid var(--gold);
  border-radius: 999px;
}

.lid-top::before {
  right: 3.1rem;
  transform: rotate(-28deg);
}

.lid-top::after {
  left: 3.1rem;
  transform: rotate(28deg);
}

.lid-ribbon,
.box-ribbon-vertical,
.box-ribbon-horizontal {
  position: absolute;
  background: var(--gold);
}

.lid-ribbon,
.box-ribbon-vertical {
  left: 50%;
  top: 0;
  width: 16%;
  height: 100%;
  transform: translateX(-50%);
}

.box-ribbon-horizontal {
  left: 0;
  top: 44%;
  width: 100%;
  height: 18%;
}

.box-sparkle {
  position: absolute;
  width: 0.8rem;
  height: 0.8rem;
  background: rgba(255, 255, 255, 0.92);
  clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
}

.sparkle-a {
  left: 16%;
  top: 22%;
}

.sparkle-b {
  right: 18%;
  bottom: 17%;
}

.gift-tag {
  position: absolute;
  right: 10%;
  bottom: 33%;
  display: grid;
  width: 3.4rem;
  height: 2.2rem;
  border: 2px solid rgba(51, 40, 58, 0.12);
  border-radius: 7px;
  background: var(--paper);
  color: var(--rose);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  font-weight: 700;
  place-items: center;
  rotate: -9deg;
  box-shadow: 0 9px 18px rgba(51, 40, 58, 0.14);
}

.button-text {
  margin-top: 0.9rem;
  border: 1px solid rgba(51, 40, 58, 0.12);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(51, 40, 58, 0.12);
  padding: 0.82rem 1.1rem;
  font-weight: 900;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.gift-button:hover .button-text {
  background: var(--gold);
  transform: translateY(-2px);
}

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

.gift-card.is-open .gift-lid {
  translate: -4.2rem -5.7rem;
  transform: rotate(-30deg);
}

.gift-card.is-open .gift-box {
  transform: translateY(5px) scaleX(1.04);
}

.gift-card.is-open .gift-tag {
  animation: tag-wiggle 720ms ease;
}

.gift-card.is-open .button-text {
  background: var(--mint);
}

.letter {
  max-height: 0;
  max-width: 650px;
  margin: 0 auto;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  transition:
    max-height 900ms ease,
    margin-top 600ms ease,
    opacity 700ms ease 160ms,
    transform 700ms ease 160ms;
}

.gift-card.is-open .letter {
  max-height: 56rem;
  margin-top: clamp(1.2rem, 4vw, 2rem);
  opacity: 1;
  transform: translateY(0) scale(1);
}

.letter {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 253, 247, 0.98)),
    repeating-linear-gradient(0deg, transparent 0 2.35rem, rgba(51, 40, 58, 0.055) 2.38rem);
  box-shadow: 0 20px 50px rgba(51, 40, 58, 0.12);
  padding: clamp(1.2rem, 4vw, 2.15rem);
  text-align: left;
}

.letter-label {
  margin: 0 0 0.55rem;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.letter h2 {
  max-width: 12ch;
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 0.95;
}

.letter p {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.1rem);
}

.letter .signature {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 4vw, 2.4rem);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height 500ms ease,
    margin-top 500ms ease,
    opacity 500ms ease;
}

.gift-card.is-open .actions {
  max-height: 5rem;
  margin-top: 1rem;
  opacity: 1;
}

.small-button {
  min-height: 2.7rem;
  border: 1px solid rgba(51, 40, 58, 0.14);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0.72rem 1rem;
  font-weight: 900;
}

.small-button:hover {
  background: var(--gold);
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-15px) rotate(8deg);
  }
}

@keyframes tag-wiggle {
  0%,
  100% {
    rotate: -9deg;
  }

  35% {
    rotate: 13deg;
  }

  70% {
    rotate: -16deg;
  }
}

@media (max-width: 640px) {
  .scene {
    align-items: start;
    padding: 0.8rem;
  }

  .gift-card {
    min-height: calc(100svh - 1.6rem);
    border-radius: 22px;
    padding-top: clamp(1.5rem, 8vw, 2.5rem);
  }

  h1 {
    max-width: 10ch;
  }

  .lead {
    max-width: 19rem;
  }

  .gift-wrap {
    width: min(86vw, 18.5rem);
    height: min(63vw, 14rem);
  }

  .letter {
    border-radius: 16px;
  }

  .star-three,
  .heart-three {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
