.birthday-party {
  --u: min(1vw, 1.78svh, 22px);
  --ink: #a81b81;
  --pink: #ec0066;
  --paper: #fff9fd;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  color: var(--ink);
  font-family: 'Nunito Variable', 'Trebuchet MS', sans-serif;
  font-weight: 900;
  background:
    radial-gradient(ellipse 34% 55% at 50% 49%, #fff2c9 0%, #fff1d8 36%, #fff0df00 100%),
    radial-gradient(ellipse 32% 49% at 18% 34%, #ffc6e7 0%, #ffc6e700 95%),
    radial-gradient(ellipse 33% 53% at 86% 42%, #ffd3e8 0%, #ffd3e800 100%),
    radial-gradient(ellipse 40% 50% at 9% 1%, #d9d3fa 0%, #ded4fb00 100%),
    radial-gradient(ellipse 37% 53% at 94% 4%, #dcd2fb 0%, #ded4fb00 100%),
    linear-gradient(180deg, #eadcf7 0%, #fbd8f0 53%, #ffe7f0 70%, #f8d7ef 100%);
}

.party-backdrop,
.party-sprinkles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.party-backdrop {
  z-index: -1;
}

.party-backdrop::before {
  position: absolute;
  inset: 67% -8% -12%;
  background:
    radial-gradient(ellipse at 47% 51%, #ffeff644, transparent 61%),
    radial-gradient(ellipse at 50% 60%, #fff7f5 0%, #fff5f300 65%);
  content: '';
}

.party-backdrop::after {
  position: absolute;
  inset: auto -5% -6%;
  height: 24%;
  background:
    radial-gradient(ellipse 9% 72% at 4% 94%, #fff8f7 0%, #ffebf8 34%, #ffd7f7 52%, #fff0fa00 72%),
    radial-gradient(ellipse 6% 79% at 0% 72%, #fff3fa 0%, #ffe4fb 25%, #fff0fa00 76%),
    radial-gradient(ellipse 9% 72% at 96% 93%, #fff9f7 0%, #ffe8ff 35%, #e9bcea 51%, #ffebfd00 73%),
    radial-gradient(ellipse 7% 74% at 100% 72%, #fff9f6 0%, #ffd9f6 41%, #fff0fa00 70%);
  filter: blur(calc(.45 * var(--u)));
  content: '';
}

.bunting {
  position: absolute;
  top: -0.7vw;
  width: calc(20 * var(--u));
  overflow: visible;
  filter: drop-shadow(0 2px 3px #a7589b1f);
}

.bunting--left { left: -0.2%; }
.bunting--right { right: -0.2%; transform: scaleX(-1); }

.balloons {
  position: absolute;
  top: calc(8.1 * var(--u));
  width: calc(9.15 * var(--u));
}

.balloons--left { left: 0; }
.balloons--right { right: 0; top: calc(9.7 * var(--u)); }

.balloons img { position: relative; display: block; width: 100%; }

.balloons svg {
  position: absolute;
  top: 79%;
  width: 108%;
  height: 75%;
  fill: none;
  stroke: #fff5ed;
  stroke-width: 3;
  opacity: .88;
}

.balloons--right svg { right: 0; top: 55%; }

.party-header {
  position: relative;
  z-index: 2;
  flex: none;
  padding-top: calc(2.05 * var(--u));
  text-align: center;
}

.party-title {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: .18em;
  width: max-content;
  margin: 0 auto;
  color: #f9086e;
  font-family: 'Lilita One', 'Nunito Variable', sans-serif;
  font-size: calc(9.25 * var(--u));
  font-weight: 400;
  line-height: .92;
  letter-spacing: -.027em;
}

.title-word { display: inline-flex; align-items: baseline; }

.title-letter {
  position: relative;
  isolation: isolate;
  transform: translateY(var(--dip)) rotate(var(--tilt));
}

.title-letter::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  color: #fffaf7;
  -webkit-text-stroke: .089em #fffaf7;
  text-shadow: 0 .063em .035em #d0509b36;
  content: attr(data-letter);
}

.title-letter > span {
  background: linear-gradient(180deg, #ff328f 5%, #ff0a74 43%, #ed0056 82%);
  background-clip: text;
  color: transparent;
}

.title-word .title-letter:first-child { font-size: 1.11em; }

.title-rays {
  position: absolute;
  inset: -16% -8.4% auto;
  width: 116.8%;
  height: 136%;
  overflow: visible;
  fill: none;
  stroke: #ffd321;
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px #fff8cd) drop-shadow(0 0 3px #fff8cd);
}

.age-prompt {
  margin: calc(.48 * var(--u)) 0 calc(.65 * var(--u));
  font-size: calc(2.85 * var(--u));
  line-height: 1.13;
  letter-spacing: -.03em;
  text-shadow: 0 2px 0 #fff4f3;
}

.age-buttons {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: calc(.9 * var(--u));
  width: max-content;
  margin-inline: auto;
}

.age-button,
.party-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pink);
  border: max(1.5px, .17vw) solid #f6acd4;
  background: linear-gradient(180deg, #fffdfd, #fffbfe 48%, #fff4fb);
  box-shadow: 0 calc(.28 * var(--u)) 0 #d85b9f85, inset 0 1px 1px white;
  cursor: pointer;
  font-weight: 950;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.age-button {
  width: calc(5.35 * var(--u));
  height: calc(4.85 * var(--u));
  padding: 0;
  border-radius: 50%;
  font-size: calc(3.0 * var(--u));
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}

.age-button[aria-pressed='true'],
.party-button--pink {
  color: #fff9fb;
  border-color: #ff3b8e;
  background: linear-gradient(180deg, #ff2c86 0%, #ff0472 45%, #eb005c 100%);
  text-shadow: 0 1px 0 #ad00583d;
  box-shadow: 0 calc(.32 * var(--u)) 0 #db529f8a, inset 0 1px 0 #ff91bd91, inset 0 -2px 0 #b300512b;
}

.age-button[aria-pressed='true'] {
  outline: calc(.28 * var(--u)) solid #ff78b44a;
  outline-offset: 1px;
}

.age-button:focus-visible,
.party-button:focus-visible {
  outline: 3px solid #7d238a;
  outline-offset: 4px;
}

@media (hover: hover) {
  .age-button:hover,
  .party-button:not([aria-disabled='true']):hover {
    transform: translateY(-3px);
    box-shadow: 0 calc(.47 * var(--u)) 0 #d85b9f80, inset 0 1px 0 #fff9;
  }
}

.age-button:active,
.party-button:not([aria-disabled='true']):active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d85b9f85;
}

.party-scene {
  position: relative;
  flex: 1 0 0;
  width: 100%;
  container-type: size;
}

.polly,
.presents,
.cake-display { position: absolute; }

.polly,
.presents {
  isolation: isolate;
  user-select: none;
}

.polly {
  z-index: 2;
  right: calc(50% + 19.6 * var(--u));
  bottom: calc(-.65 * var(--u));
  width: min(calc(26.8 * var(--u)), 82cqh);
  height: min(calc(35.95 * var(--u)), 102.5cqh);
  transform-origin: 47% 91%;
}

.polly > img,
.presents > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.polly::before,
.presents::before,
.cake-display::before {
  position: absolute;
  z-index: -1;
  right: 5%;
  bottom: 0;
  left: 5%;
  height: 7%;
  border-radius: 50%;
  background: #9e378866;
  filter: blur(calc(.72 * var(--u)));
  content: '';
}

.polly::before { left: 15%; right: 12%; }
.polly--cheering { animation: polly-cheers 800ms ease-in-out 2; }

.polly-rays {
  position: absolute;
  top: 10%;
  right: -11.4%;
  width: 25%;
  fill: none;
  stroke: #ffbf17;
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px #fffce5);
}

.presents {
  z-index: 0;
  bottom: calc(2.45 * var(--u));
  left: calc(50% + 20.8 * var(--u));
  width: min(calc(24 * var(--u)), 78cqh);
  aspect-ratio: 385 / 317;
}

.gift-ribbon {
  position: absolute;
  right: 32%;
  bottom: -21%;
  width: 47%;
  fill: none;
  stroke: url(#gift-ribbon-color);
  stroke-width: 11;
  filter: drop-shadow(0 4px 2px #d166ab2e);
}

.cake-display {
  z-index: 1;
  isolation: isolate;
  bottom: calc(.7 * var(--u));
  left: 50%;
  width: calc(45 * var(--u));
  height: min(calc(22.76 * var(--u)), calc((100cqh - 4.62 * var(--u)) / 1.21));
  transform: translateX(-50%);
}

.cake-display::before { left: 3%; right: 3%; bottom: -1%; height: 12%; background: #a5307780; }

.cake-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.cake-aura {
  position: absolute;
  z-index: -1;
  inset: -49% 1% 48%;
  opacity: .87;
  background: radial-gradient(ellipse, #fff6b7 0%, #fff4c547 51%, #fff4c500 73%);
  transition: opacity 300ms ease;
}

.cake-display:has(.candle--out) .cake-aura { opacity: .15; }

.candle {
  position: absolute;
  top: var(--candle-y);
  left: var(--candle-x);
  width: var(--candle-width);
  height: var(--candle-height);
  transform: translate(-50%, -100%);
}

.candle-wax {
  position: absolute;
  inset: 0;
  border-radius: 42% 42% 21% 21% / 9% 9% 4% 4%;
  background:
    linear-gradient(90deg, #fff7 0%, #fff2 28%, #fff0 61%, #67234335 100%),
    repeating-linear-gradient(143deg, var(--candle-color) 0 13%, var(--candle-stripe) 13% 21%);
  box-shadow: inset 0 2px 1px #fff7, 0 2px 2px #b1655b32;
}

.candle-wick {
  position: absolute;
  bottom: 98%;
  left: 43%;
  width: 14%;
  height: 11%;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(#62506c, #90563b);
}

.candle-flame {
  position: absolute;
  bottom: 105%;
  left: -24%;
  width: 148%;
  aspect-ratio: 40 / 61;
  transform-origin: 50% 97%;
}

.flame-glow {
  position: absolute;
  inset: -33% -48% -27%;
  background: radial-gradient(ellipse, #fff074a8 0%, #ffdc5180 28%, #ffe99a00 70%);
  filter: blur(2px);
}

.flame-shape { position: relative; display: block; width: 100%; overflow: visible; }
.candle--lit .candle-flame { animation: candle-flicker var(--flicker-speed) var(--flicker-offset) infinite alternate ease-in-out; }
.candle--out .candle-flame { animation: candle-snuff 290ms var(--snuff-delay) both ease-in; }

.candle-smoke {
  position: absolute;
  bottom: 105%;
  left: -31%;
  width: 162%;
  overflow: visible;
  filter: blur(.6px);
  transform-origin: 50% 100%;
  animation: smoke-rise 1750ms calc(var(--snuff-delay) + 155ms) both ease-out;
}

.party-footer {
  position: relative;
  z-index: 3;
  flex: none;
  padding: 0 0 calc(1.73 * var(--u));
  text-align: center;
}

.wish {
  margin: 0 0 calc(.76 * var(--u));
  font-size: calc(3.65 * var(--u));
  line-height: 1.09;
  letter-spacing: -.028em;
  text-shadow: 0 2px 0 #fff6f4;
}

.party-actions { display: flex; justify-content: center; gap: calc(1.16 * var(--u)); }

.party-button {
  gap: calc(.83 * var(--u));
  min-width: calc(16 * var(--u));
  height: calc(4.76 * var(--u));
  padding-inline: calc(2.2 * var(--u));
  border-radius: 100vmax;
  font-size: calc(2.39 * var(--u));
  letter-spacing: -.035em;
  white-space: nowrap;
}

.party-button > svg { width: 1.11em; height: 1.11em; flex: none; }
.party-button--pink > svg { width: 1.3em; height: 1.3em; }
.party-button[aria-disabled='true'] { cursor: default; }

.audio-message {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  font-size: max(12px, calc(1 * var(--u)));
}

.confetti-show {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: 68%;
  left: var(--origin);
  width: var(--size);
  height: calc(var(--size) * 1.3);
  border-radius: 1px;
  background: linear-gradient(125deg, #ffffff68, transparent 66%), var(--color);
  animation: confetti-flight var(--flight) var(--launch-delay) both cubic-bezier(.17, .7, .48, 1);
}

.confetti-piece--star {
  width: calc(var(--size) * 1.35);
  height: calc(var(--size) * 1.35);
  clip-path: polygon(50% 0%, 63% 34%, 100% 38%, 73% 64%, 80% 100%, 50% 82%, 20% 100%, 27% 64%, 0 38%, 37% 34%);
}

.confetti-piece--curl { background: none; border: 3px solid var(--color); border-left: 0; border-radius: 70%; }

@keyframes candle-flicker {
  0% { transform: rotate(-5deg) scale(.92, 1.02); }
  33% { transform: rotate(2deg) scale(1.04, .94); }
  62% { transform: rotate(-2deg) scale(.94, 1.055); }
  100% { transform: rotate(6deg) scale(1.05, .97); }
}

@keyframes candle-snuff {
  0% { opacity: 1; }
  52% { transform: translate(43%, -12%) rotate(42deg) scaleX(1.34); opacity: .77; }
  100% { transform: translate(90%, -30%) rotate(68deg) scale(.1); opacity: 0; }
}

@keyframes smoke-rise {
  0% { transform: translate(0, 6%) scale(.28); opacity: 0; }
  20% { opacity: .61; }
  52% { opacity: .35; }
  100% { transform: translate(var(--smoke-drift), -115%) scale(1.65); opacity: 0; }
}

@keyframes polly-cheers {
  0%, 100% { transform: rotate(0); }
  32% { transform: translateY(-3%) rotate(-4deg); }
  64% { transform: translateY(-1%) rotate(3deg); }
}

@keyframes confetti-flight {
  0% { transform: translate(0, 0) scale(.2); opacity: 0; }
  9% { opacity: 1; }
  32% { transform: translate(var(--arc-x), var(--arc-y)) rotate(calc(var(--spin) * .33)); opacity: 1; }
  76% { opacity: 1; }
  100% { transform: translate(var(--drift-x), 44vh) rotate(var(--spin)); opacity: 0; }
}

@keyframes gentle-party {
  0%, 100% { opacity: 0; }
  17%, 67% { opacity: 1; }
}

@media (max-aspect-ratio: 1/1) {
  .birthday-party {
    --u: clamp(8px, 2.6vw, 18px);
    height: auto;
    min-height: 100svh;
  }

  .bunting { top: -1.4vw; width: 29vw; }
  .balloons { top: 39vw; width: 12.5vw; }
  .balloons--right { top: 41vw; }
  .party-header { padding: clamp(37px, 12vw, 107px) 0 0; }
  .party-title { font-size: 12vw; }
  .title-rays { stroke-width: 9; }
  .age-prompt { margin-top: 2.15vw; margin-bottom: 2.3vw; font-size: clamp(22px, 5.8vw, 45px); }
  .age-buttons { grid-template-columns: repeat(6, 1fr); gap: 2vw; }

  .age-button {
    width: clamp(36px, 10.4vw, 76px);
    height: clamp(36px, 10.4vw, 76px);
    font-size: clamp(19px, 5.6vw, 43px);
  }

  .party-scene { flex: 1 0 clamp(255px, 74vw, 630px); }
  .cake-display { width: 77%; height: auto; aspect-ratio: 1184 / 600; bottom: 18%; }
  .polly { right: auto; left: 1.5%; bottom: 3%; width: 28%; height: auto; aspect-ratio: 421 / 561; }
  .polly-rays { right: -8%; top: 10%; }
  .presents { left: auto; right: 0; bottom: 9%; width: 27%; }
  .gift-ribbon { right: 20%; bottom: -25%; }
  .party-footer { width: 100%; padding: 0 3vw clamp(22px, 6vw, 48px); }
  .wish { font-size: clamp(26px, 7.7vw, 57px); margin-bottom: 2.8vw; }
  .party-actions { gap: 1.8vw; }

  .party-button {
    gap: 1.18vw;
    min-width: 0;
    height: clamp(42px, 11vw, 72px);
    padding-inline: 2.8vw;
    font-size: clamp(12px, 3.95vw, 29px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .age-button, .party-button, .cake-aura { transition: none; }
  .age-button:hover, .party-button:not([aria-disabled='true']):hover { transform: none; }
  .candle--lit .candle-flame, .polly--cheering { animation: none; }
  .candle--out .candle-flame { animation: none; opacity: 0; }
  .candle-smoke { animation: gentle-party 1200ms both; }
  .confetti-piece { left: var(--rest-x); top: var(--rest-y); animation: gentle-party 1400ms both; }
}

@media (forced-colors: active) {
  .title-letter::before { display: none; }
  .title-letter > span { background: none; color: CanvasText; }
  .age-button[aria-pressed='true'] { outline: 3px solid Highlight; }
}
