:root {
  --rose-50: #fff6f8;
  --rose-100: #ffe5ed;
  --rose-200: #ffc6d9;
  --rose-500: #f35b9d;
  --coral: #ff8268;
  --gold: #f4c45d;
  --ink: #312236;
  --muted: #765f76;
  --paper: rgba(255, 255, 255, 0.8);
  --paper-solid: #fffaf7;
  --shadow: 0 24px 80px rgba(97, 45, 74, 0.22);
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Avenir Next",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.82) 0 9rem, transparent 18rem),
    radial-gradient(circle at 92% 8%, rgba(255, 215, 126, 0.5) 0 8rem, transparent 17rem),
    linear-gradient(145deg, var(--rose-50), #ffe7d9 46%, #fbd3ec);
  color: var(--ink);
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  touch-action: manipulation;
}

button {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 13rem;
  height: 13rem;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(1px);
  opacity: 0.55;
  z-index: -1;
}

body::before {
  right: -6rem;
  top: 12%;
  background: repeating-conic-gradient(from 10deg, #fff 0 8deg, transparent 8deg 18deg);
}

body::after {
  left: -6rem;
  bottom: 5%;
  background: repeating-conic-gradient(from -20deg, rgba(243, 91, 157, 0.24) 0 7deg, transparent 7deg 19deg);
}

.card-shell {
  width: min(100%, 32rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.envelope {
  position: relative;
  width: 100%;
  min-height: min(42rem, calc(100svh - 2rem));
  border-radius: 2.1rem;
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
  isolation: isolate;
  touch-action: manipulation;
}

.tap-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: var(--ink);
  overflow: hidden;
  background:
    linear-gradient(135deg, transparent 49.4%, rgba(255, 255, 255, 0.36) 49.6% 50.4%, transparent 50.6%),
    linear-gradient(45deg, transparent 49.4%, rgba(255, 255, 255, 0.34) 49.6% 50.4%, transparent 50.6%),
    linear-gradient(155deg, #ffedf3, #ffd0de 53%, #ffb7d2);
  transition:
    transform 800ms cubic-bezier(0.2, 0.9, 0.12, 1),
    opacity 500ms ease,
    filter 500ms ease;
}

.tap-cover::before {
  content: "";
  position: absolute;
  inset: 1rem;
  border: 1px dashed rgba(118, 75, 102, 0.34);
  border-radius: 1.45rem;
}

.tap-cover::after {
  content: "";
  position: absolute;
  width: 9rem;
  height: 9rem;
  left: -3.5rem;
  top: -3.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.38);
}

.cover-open {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
  padding: 2rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.stamp {
  position: absolute;
  right: 1.35rem;
  top: 1.35rem;
  width: 4.4rem;
  aspect-ratio: 1;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 1.1rem;
  border: 2px solid rgba(49, 34, 54, 0.18);
  background:
    radial-gradient(circle, transparent 55%, rgba(255, 255, 255, 0.55) 56% 61%, transparent 62%),
    #fff6d8;
  font-family: Georgia, serif;
  font-size: 2rem;
  font-weight: 800;
  color: #af5b3b;
  rotate: 7deg;
  z-index: 4;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(130, 61, 85, 0.1);
  transition:
    transform 170ms ease,
    rotate 170ms ease;
}

.stamp:active {
  transform: scale(0.94);
}

.stamp.is-teasing {
  animation: stamp-shake 420ms ease;
}

.inline-age.is-teasing {
  animation: stamp-shake 420ms ease;
}

.age-note {
  position: absolute;
  right: 1.15rem;
  top: 6.15rem;
  z-index: 4;
  max-width: 7.5rem;
  min-height: 1.8rem;
  padding: 0.36rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #6f3e50;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  transform: translateY(-0.25rem) scale(0.96);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.age-note.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.cover-copy {
  position: relative;
  display: grid;
  gap: 0.7rem;
  text-align: center;
  translate: 0 0.8rem;
}

.eyebrow,
.kicker,
.joke-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

.cover-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 14vw, 4.8rem);
  line-height: 0.95;
  text-wrap: balance;
}

.tap-hint {
  justify-self: center;
  margin-top: 1.1rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 10px 30px rgba(159, 73, 112, 0.16);
  font-weight: 800;
  animation: pulse 1.6s ease-in-out infinite;
}

.inside {
  position: relative;
  width: 100%;
  min-height: min(42rem, calc(100svh - 2rem));
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1rem;
  padding: clamp(1.35rem, 6vw, 2.25rem);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 9%, rgba(244, 196, 93, 0.42), transparent 12rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), var(--paper-solid));
  opacity: 0;
}

.sunburst {
  position: absolute;
  inset: auto -7rem -8rem;
  height: 18rem;
  background: repeating-conic-gradient(from 4deg, rgba(244, 196, 93, 0.18) 0 7deg, transparent 7deg 16deg);
  mask-image: radial-gradient(circle, #000 0 42%, transparent 69%);
  animation: slow-spin 24s linear infinite;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 11ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.55rem, 13.5vw, 5.15rem);
  line-height: 0.94;
  letter-spacing: -0.06em;
}

.headline-age-wrap {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.inline-age {
  display: inline-grid;
  place-items: center;
  min-width: 1.28em;
  margin: 0 0.02em;
  padding: 0 0.05em 0.03em;
  border: 0;
  border-radius: 0.18em;
  background: linear-gradient(135deg, rgba(255, 246, 216, 0.92), rgba(255, 229, 237, 0.72));
  color: #af5b3b;
  cursor: pointer;
  font: inherit;
  font-family: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: 0.9;
  box-shadow: 0 0.08em 0.2em rgba(130, 61, 85, 0.08);
}

.inline-age:active {
  transform: scale(0.96);
}

.age-suffix {
  margin-left: 0.01em;
}

.inline-age-note {
  position: absolute;
  left: 50%;
  top: -1.2rem;
  z-index: 2;
  width: max-content;
  max-width: 8rem;
  padding: 0.28rem 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #6f3e50;
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Avenir Next",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.01em;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -0.25rem) scale(0.96);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.inline-age-note.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.message {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(1.05rem, 4.6vw, 1.28rem);
  line-height: 1.5;
  color: #533e55;
}

.signature {
  position: relative;
  z-index: 1;
  margin: 0.25rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
}

.signature span {
  display: block;
  margin-top: 0.18rem;
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Avenir Next",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fun-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.fun-button {
  flex: 1 1 5.9rem;
  max-width: 7rem;
  min-height: 3rem;
  border: 0;
  border-radius: 1rem;
  padding: 0.65rem 0.5rem;
  background: rgba(255, 229, 237, 0.88);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(159, 73, 112, 0.1);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.fun-button:active {
  transform: translateY(2px) scale(0.97);
  background: rgba(255, 214, 228, 0.95);
  box-shadow: 0 6px 14px rgba(159, 73, 112, 0.14);
}

.replay {
  position: relative;
  z-index: 1;
  align-self: center;
  margin-top: auto;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  background: var(--ink);
  color: white;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(49, 34, 54, 0.2);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.replay:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 7px 18px rgba(49, 34, 54, 0.22);
}

.effect-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.effect-token {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  font-size: var(--size, 2rem);
  transform: translate(-50%, -50%);
  animation: float-pop var(--duration, 1100ms) ease-out forwards;
  filter: drop-shadow(0 8px 12px rgba(80, 35, 55, 0.16));
}

.effect-token.puff {
  width: var(--size, 3rem);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.62), transparent 35%),
    rgba(166, 197, 126, 0.62);
  animation-name: puff-away;
}

.effect-token.puff::after {
  content: "pfft";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(72, 88, 45, 0.75);
  font-size: 0.72rem;
  font-weight: 950;
  rotate: -12deg;
}

.envelope.is-open .tap-cover {
  pointer-events: none;
  transform: translateY(-38%) rotateX(72deg) scale(0.92);
  opacity: 0;
  filter: blur(8px);
}

.envelope.is-open .inside {
  opacity: 1;
  animation: card-rise 700ms cubic-bezier(0.2, 0.9, 0.12, 1) both;
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.025);
  }
}

@keyframes slow-spin {
  to {
    rotate: 360deg;
  }
}

@keyframes card-rise {
  from {
    transform: translateY(1.2rem) scale(0.98);
  }
  to {
    transform: translateY(0) scale(1);
  }
}

@keyframes stamp-shake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  25% {
    transform: translateX(-4px) rotate(-5deg);
  }
  50% {
    transform: translateX(4px) rotate(5deg);
  }
  75% {
    transform: translateX(-2px) rotate(-3deg);
  }
}

@keyframes float-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(-8deg);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--dx, 0rem)),
        calc(-50% + var(--dy, -5rem))
      )
      scale(1.25)
      rotate(var(--rot, 12deg));
  }
}

@keyframes puff-away {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  20% {
    opacity: 0.78;
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--dx, 0rem)),
        calc(-50% + var(--dy, -3rem))
      )
      scale(1.8);
  }
}

@media (min-width: 42rem) {
  .card-shell {
    width: min(100%, 36rem);
  }

  .envelope {
    min-height: 44rem;
  }

  .tap-cover,
  .inside {
    min-height: 44rem;
  }

  .inside {
    justify-content: center;
  }
}

@media (max-width: 23rem) {
  .fun-button {
    flex-basis: 8.8rem;
    max-width: none;
  }
}

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