/* Celebrations — the layer src/celebrate.js drives: confetti canvas, the
   sticker banner, reveal cards, the treats fly-in and the badge stamp. It sits
   inside #stage above the results overlay, so it rotates with the phone. */
#celebrate {
  position: absolute;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  font-family: var(--menu-font);
  overflow: hidden;
}
#celebrate.hidden {
  display: none;
}
#celebrate-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* --- Sticker banner -------------------------------------------------------- */
.celebrate-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 34px 16px;
  border-radius: 22px;
  background: #fff3dc;
  color: #30263d;
  border: 4px solid #30263d;
  box-shadow:
    0 0 0 5px #ffc64b,
    0 18px 40px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%) rotate(-4deg) scale(2.6);
  opacity: 0;
  text-align: center;
  max-width: min(92%, 640px);
  white-space: nowrap;
}
.celebrate-banner[data-tone="teal"] {
  box-shadow:
    0 0 0 5px #5ad1c9,
    0 18px 40px rgba(0, 0, 0, 0.45);
}
.celebrate-banner.is-in {
  animation: celebrate-slam 0.42s cubic-bezier(0.2, 1.4, 0.3, 1) forwards;
}
.celebrate-banner.is-out {
  animation: celebrate-drop 0.42s ease-in forwards;
}
.celebrate-banner-emoji {
  font-size: 44px;
  line-height: 1;
}
.celebrate-banner-emoji:empty {
  display: none;
}
.celebrate-banner-title {
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.05;
}
.celebrate-banner-sub {
  font-size: clamp(13px, 2.4vw, 18px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6c5b93;
}
.celebrate-banner-sub.hidden {
  display: none;
}
@keyframes celebrate-slam {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-10deg) scale(2.6);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-3deg) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-4deg) scale(1);
  }
}
@keyframes celebrate-drop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-4deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 30%) rotate(6deg) scale(0.8);
  }
}

/* --- Reveal cards ------------------------------------------------------------ */
#celebrate-reveal {
  pointer-events: auto;
  z-index: 2;
  align-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(12, 10, 22, 0.55), rgba(6, 5, 12, 0.88) 80%);
}
#celebrate-reveal.hidden {
  display: none;
}
.celebrate-card {
  display: grid;
  grid-template-areas:
    "kicker"
    "stage"
    "copy";
  justify-items: center;
  gap: 10px;
  width: min(420px, 100%);
  padding: 20px 20px 18px;
  border-radius: 28px;
  background: var(--menu-surface, #2a2338);
  color: #fff3dc;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: celebrate-card-in 0.5s cubic-bezier(0.2, 1.3, 0.3, 1) both;
}
@keyframes celebrate-card-in {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.celebrate-card .flow-eyebrow,
#stage.menu-narrow .celebrate-card .flow-eyebrow {
  display: block; /* narrow menus drop their eyebrows; the card's kicker is the headline */
  grid-area: kicker;
  letter-spacing: 0.16em;
}
.celebrate-copy {
  grid-area: copy;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}
/* The stage is a square sized by the card's width; the canvas and the "?" are
   pinned to it, so neither's intrinsic size can push the card about. */
.celebrate-stage {
  grid-area: stage;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-height: min(52vh, 360px);
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(ellipse 100% 100% at 50% 125%, #30263d26 99.5%, transparent 100%),
    var(--celebrate-backdrop, #a4dedf);
}
#celebrate-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.35s ease,
    transform 0.55s cubic-bezier(0.2, 1.4, 0.3, 1);
}
.celebrate-mystery {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(90px, 30vw, 170px);
  font-weight: 900;
  color: #30263d;
  opacity: 0.85;
  animation: celebrate-wobble 1.1s ease-in-out infinite;
  transition:
    opacity 0.25s ease,
    transform 0.35s ease-in;
}
@keyframes celebrate-wobble {
  0%,
  100% {
    transform: rotate(-6deg) scale(1);
  }
  50% {
    transform: rotate(6deg) scale(1.06);
  }
}
/* A corner ribbon: the band's centre sits on the corner's diagonal (32px in on
   both axes) and it turns 45°, so the stage's edges clip both ends evenly. */
.celebrate-ribbon {
  position: absolute;
  top: 18px;
  right: -68px;
  width: 200px;
  padding: 6px 0;
  box-sizing: border-box;
  text-align: center;
  background: #ff6b6b;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2em;
  transform: rotate(45deg) translateY(-140px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.3, 1) 0.15s;
}
.celebrate-stage[data-subject="none"] .celebrate-mystery {
  animation: none;
  opacity: 1;
}
#celebrate-reveal.is-open #celebrate-portrait {
  opacity: 1;
  transform: none;
}
#celebrate-reveal.is-open .celebrate-stage[data-subject]:not([data-subject="none"]) .celebrate-mystery {
  opacity: 0;
  transform: scale(1.8);
  animation: none;
}
#celebrate-reveal.is-open .celebrate-ribbon {
  transform: rotate(45deg);
}
.celebrate-name {
  margin: 4px 0 0;
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #ffc64b;
  opacity: 0;
  transform: scale(2.2);
}
#celebrate-reveal.is-open .celebrate-name {
  animation: celebrate-stamp-in 0.4s cubic-bezier(0.2, 1.4, 0.3, 1) 0.1s forwards;
}
@keyframes celebrate-stamp-in {
  from {
    opacity: 0;
    transform: scale(2.2) rotate(-6deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.celebrate-sub {
  margin: 0;
  font-size: 14px;
  color: #d9cfeb;
  line-height: 1.45;
}
.celebrate-sub.hidden {
  display: none;
}
.celebrate-dots {
  display: flex;
  gap: 6px;
  min-height: 8px;
}
.celebrate-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 243, 220, 0.3);
}
.celebrate-dots i.is-on {
  background: #ffc64b;
}
#celebrate-continue {
  width: 100%;
  min-height: 52px;
}
/* Short stages (a phone held landscape): the square sits on the left, sized by
   the height, with the copy and the button beside it instead of beneath. */
#stage.menu-compact .celebrate-card {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "stage kicker"
    "stage copy";
  align-items: center;
  column-gap: 18px;
  width: min(680px, 100%);
  padding: 16px 20px;
}
#stage.menu-compact .celebrate-stage {
  width: auto;
  height: min(calc(var(--stage-vh) * 100 - 92px), 300px);
  max-height: none;
}
#stage.menu-compact .celebrate-card .flow-eyebrow {
  align-self: end;
}
#stage.menu-compact .celebrate-copy {
  align-self: start;
}
#stage.menu-compact .celebrate-name {
  font-size: clamp(22px, 4.5vw, 30px);
}
#stage.menu-compact .celebrate-mystery {
  font-size: clamp(70px, 24vh, 130px);
}

/* The standings over the podium: the ceremony is a busy backdrop, so the card
   goes near-opaque there instead of letting the karts show through the rows. */
#results.over-podium .menu-card.results-main {
  background: rgba(27, 21, 41, 0.94);
}

/* --- Treats fly-in ------------------------------------------------------------ */
.celebrate-fish {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
  z-index: 3;
  animation: celebrate-fly 0.75s cubic-bezier(0.3, 0, 0.7, 1) both;
}
/* Two keyframes can't bend a path on their own: the arc is the lift halfway. */
@keyframes celebrate-fly {
  0% {
    transform: translate(var(--x0), var(--y0)) translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  50% {
    transform: translate(calc((var(--x0) + var(--x1)) / 2), calc((var(--y0) + var(--y1)) / 2 + var(--lift)))
      translate(-50%, -50%) scale(1.15);
  }
  100% {
    transform: translate(var(--x1), var(--y1)) translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
}
.celebrate-bump {
  display: inline-block; /* transforms need a box; the amount spans are inline */
  animation: celebrate-bump 0.32s cubic-bezier(0.2, 1.4, 0.3, 1);
}
@keyframes celebrate-bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.22);
  }
  100% {
    transform: scale(1);
  }
}

/* --- Badge stamp --------------------------------------------------------------- */
.celebrate-stamp {
  animation: celebrate-stamp 0.45s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}
@keyframes celebrate-stamp {
  0% {
    opacity: 0;
    transform: scale(1.6) rotate(-4deg);
  }
  60% {
    opacity: 1;
    transform: scale(0.96);
  }
  100% {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .celebrate-banner.is-in,
  .celebrate-banner.is-out,
  .celebrate-card,
  .celebrate-mystery,
  #celebrate-reveal.is-open .celebrate-name,
  .celebrate-fish,
  .celebrate-bump,
  .celebrate-stamp {
    animation: none;
  }
  .celebrate-banner.is-in {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  .celebrate-name,
  #celebrate-portrait,
  .celebrate-ribbon {
    transition: none;
  }
  #celebrate-reveal.is-open .celebrate-name {
    opacity: 1;
    transform: none;
  }
}

/* --- Premium award cats ------------------------------------------------------ */
/* Onyx, Rosetta and Leo arrive on a gold card: a gold ring and glow, a gold
   ribbon, slow rays turning behind the model and a sweep of light across it.
   (The regalia are the only shiny things in the game; so is this card.) */
.celebrate-card.is-premium {
  box-shadow:
    0 0 0 2px #f2c54b,
    0 0 44px rgba(255, 205, 80, 0.35),
    0 24px 60px rgba(0, 0, 0, 0.5);
}
.celebrate-card.is-premium .flow-eyebrow {
  color: #f2c54b;
}
.celebrate-card.is-premium .celebrate-ribbon {
  background: linear-gradient(90deg, #b9832a, #ffe08a 50%, #b9832a);
  color: #3a2a08;
}
.celebrate-card.is-premium .celebrate-stage::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: repeating-conic-gradient(rgba(255, 214, 102, 0.3) 0 9deg, rgba(255, 214, 102, 0) 9deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 68%);
  mask: radial-gradient(circle, #000 25%, transparent 68%);
  animation: celebrate-award-turn 18s linear infinite;
  pointer-events: none;
}
.celebrate-card.is-premium .celebrate-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 250, 230, 0.4) 48%, transparent 58%) no-repeat;
  background-size: 260% 100%;
  animation: celebrate-award-sweep 3.4s ease-in-out 0.8s infinite;
  pointer-events: none;
}
@keyframes celebrate-award-turn {
  to {
    transform: rotate(360deg);
  }
}
@keyframes celebrate-award-sweep {
  0% {
    background-position: 130% 0;
  }
  45%,
  100% {
    background-position: -30% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .celebrate-card.is-premium .celebrate-stage::before,
  .celebrate-card.is-premium .celebrate-stage::after {
    animation: none;
  }
}
