/* ==========================================================================
   THE SURPRISE — stylesheet
   Act 0  : a deliberately boring file-share portal (the disguise)
   Act 1-4: the celebration it detonates into
   ========================================================================== */

/* ---------------------------------------------------------------- reset */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: #fff;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

/* ---------------------------------------------------- party theme tokens */

:root {
  --bg-deep: #07030f;
  --accent-a: #ff2a85;
  --accent-b: #ffbe0b;
  --accent-c: #00f5d4;
  --accent-d: #9d4edd;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-edge: rgba(255, 255, 255, 0.13);
  --ink-soft: rgba(255, 255, 255, 0.66);
  --ink-faint: rgba(255, 255, 255, 0.42);
}

[data-theme="synthwave"] {
  --bg-deep: #04040f;
  --accent-a: #ff007f;
  --accent-b: #4cc9f0;
  --accent-c: #7b2cbf;
  --accent-d: #f72585;
}

[data-theme="fairy"] {
  --bg-deep: #120415;
  --accent-a: #ff70a6;
  --accent-b: #ffd6e0;
  --accent-c: #c77dff;
  --accent-d: #b5e2fa;
}

[data-theme="rosegold"] {
  --bg-deep: #150708;
  --accent-a: #ff8f7a;
  --accent-b: #ffd9a0;
  --accent-c: #f4a261;
  --accent-d: #fcd5ce;
}

/* ============================================================== ACT 0
   THE DISGUISE — a blank page and a cursor. Nothing more.
   ================================================================== */

.gate-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: #fdfdfc;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: #1c1c1a;
  overflow-y: auto;
}

.doc-label {
  position: absolute;
  top: clamp(1.1rem, 3vh, 1.9rem);
  left: clamp(1.25rem, 4vw, 2.5rem);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #b6b6b0;
  transition: color 0.3s;
}

.doc-label.is-bad {
  color: #d1332b;
}

.doc-shell {
  width: min(560px, 100%);
}

.doc-content,
.doc-line {
  font-size: clamp(1rem, 2.1vw, 1.16rem);
  line-height: 2.05;
  letter-spacing: -0.005em;
}

.doc-line {
  margin-bottom: 1.15rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-line:last-child {
  margin-bottom: 0;
}

/* the cursor rides whichever line is being written */
.doc-line.is-typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.17em;
  background: #1c1c1a;
  animation: caretBlink 1.06s steps(1) infinite;
}

@keyframes caretBlink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.doc-line.is-garbled {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.95rem;
  color: #d1332b;
}

/* their answer, dressed as ordinary typed text */

.name-line {
  display: flex;
}

.doc-name-input {
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  font-weight: 500;
  color: #1a6fd4;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
}

.doc-name-input::placeholder {
  color: #c9c9c3;
  font-weight: 400;
}

/* a finger needs more room than a cursor does */
@media (pointer: coarse), (max-width: 600px) {
  .doc-name-input {
    min-height: 44px;
  }
}

.doc-name-input:disabled {
  color: #1a6fd4;
  opacity: 1;
}

/* the page losing its composure */

.gate-panel.is-erroring {
  animation: nervous 0.14s linear infinite;
}

@keyframes nervous {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(-1px, 1px); }
  50%      { transform: translate(1px, -1px); }
  75%      { transform: translate(-1px, -1px); }
}

/* ================================================== THE GLITCH / RUPTURE */

html.is-glitching .gate-screen {
  animation:
    quake 0.09s steps(2) infinite,
    glitchFlash 0.55s steps(1) infinite;
}

@keyframes glitchFlash {
  0%, 100% { filter: none; }
  40%      { filter: invert(1) hue-rotate(80deg); }
  45%      { filter: none; }
  72%      { filter: invert(1) saturate(3.5); }
  77%      { filter: none; }
}

html.is-glitching .gate-panel {
  animation: rgbText 0.12s steps(2) infinite;
}

@keyframes rgbText {
  0% {
    text-shadow: -4px 0 rgba(255, 0, 90, 0.85), 4px 0 rgba(0, 215, 255, 0.85);
  }
  50% {
    text-shadow: 6px 0 rgba(255, 0, 90, 0.9), -6px 0 rgba(0, 215, 255, 0.9);
  }
  100% {
    text-shadow: -3px 2px rgba(255, 190, 0, 0.85), 3px -2px rgba(0, 215, 255, 0.85);
  }
}

@keyframes quake {
  0%   { transform: translate(0, 0) skewX(0deg); }
  20%  { transform: translate(-9px, 4px) skewX(1.6deg); }
  40%  { transform: translate(7px, -6px) skewX(-1.2deg); }
  60%  { transform: translate(-5px, -3px) skewX(0.8deg); }
  80%  { transform: translate(8px, 5px) skewX(-1.8deg); }
  100% { transform: translate(0, 0) skewX(0deg); }
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 4px);
  transition: opacity 0.12s;
}

html.is-glitching .scanlines {
  opacity: 1;
  animation: scanDrift 0.4s linear infinite;
}

@keyframes scanDrift {
  to {
    transform: translateY(4px);
  }
}

.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash-overlay.is-blinding {
  opacity: 1;
}

.flash-overlay.is-fading {
  opacity: 0;
  transition: opacity 0.85s ease-out;
}

/* ====================================================== BACKGROUND LAYERS */

#webgl-canvas,
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#webgl-canvas {
  z-index: 0;
}

/* a soft dark well behind the content so text always wins */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 66% 72% at 50% 48%,
      rgba(4, 2, 10, 0.93) 0%,
      rgba(4, 2, 10, 0.82) 38%,
      rgba(4, 2, 10, 0.42) 68%,
      rgba(4, 2, 10, 0.1) 88%,
      transparent 100%);
}

#confetti-canvas {
  z-index: 2;
  pointer-events: none;
}

/* during the disguise, no trace of the party */
html.phase-gate #webgl-canvas,
html.phase-gate #confetti-canvas,
html.phase-gate .vignette {
  display: none;
}

/* ============================================================ CELEBRATION */

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

.act {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: clamp(1rem, 2.2vh, 1.9rem);
  padding: clamp(1.5rem, 4vh, 3rem) clamp(1.25rem, 5vw, 4rem) clamp(6rem, 13vh, 8rem);
  text-align: center;
  overflow-y: auto;

  opacity: 0;
  visibility: hidden;
  transform: translateY(26px) scale(0.985);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
}

.act.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ---- shared act furniture ---- */

.act-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.act-step {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent-b);
  opacity: 0.85;
}

.act-title {
  font-family: 'Fredoka', 'Outfit', sans-serif;
  font-weight: 600;
  font-size: clamp(1.9rem, 5.2vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  background: linear-gradient(105deg, #fff 10%, var(--accent-b) 55%, var(--accent-a) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.act-lead {
  font-size: clamp(0.92rem, 1.7vw, 1.1rem);
  font-weight: 300;
  color: var(--ink-soft);
  max-width: 34ch;
}

.act-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.act-next {
  position: relative;
  padding: 0.85rem 1.9rem;
  border-radius: 99px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #14060f;
  background: linear-gradient(100deg, var(--accent-b), var(--accent-a));
  box-shadow: 0 8px 30px -6px rgba(255, 42, 133, 0.6);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s;
}

.act-next:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 16px 40px -8px rgba(255, 42, 133, 0.75);
}

.act-next .arrow {
  display: inline-block;
  transition: transform 0.22s;
}

.act-next:hover .arrow {
  transform: translateX(4px);
}

.ghost-btn {
  padding: 0.8rem 1.5rem;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(12px);
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

.ghost-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
  transform: translateY(-2px);
}

/* ------------------------------------------------- ACT 1 : THE BLAST */

.act-blast {
  justify-content: center;
}

.blast-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.6vh, 1.2rem);
}

.shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 3px solid #fff;
  opacity: 0;
  pointer-events: none;
}

.shockwave.is-firing {
  animation: shockwave 1.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes shockwave {
  0% {
    transform: scale(0.4);
    opacity: 0.95;
    border-width: 16px;
  }
  100% {
    transform: scale(46);
    opacity: 0;
    border-width: 0.5px;
  }
}

.kicker {
  display: flex;
  gap: clamp(0.35em, 1.1vw, 0.75em);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.62rem, 1.15vw, 0.85rem);
  font-weight: 500;
  color: var(--accent-c);
}

.kicker span {
  display: inline-block;
  opacity: 0;
  animation: kickIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.kicker span:nth-child(1) { animation-delay: 0.55s; }
.kicker span:nth-child(2) { animation-delay: 0.61s; }
.kicker span:nth-child(3) { animation-delay: 0.67s; }
.kicker span:nth-child(4) { animation-delay: 0.73s; }
.kicker span:nth-child(5) { animation-delay: 0.79s; }
.kicker span:nth-child(6) { animation-delay: 0.85s; }
.kicker span:nth-child(7) { animation-delay: 0.91s; }
.kicker span:nth-child(8) { animation-delay: 0.97s; }

@keyframes kickIn {
  from { opacity: 0; transform: translateY(-10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.mega-title {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 0.88;
}

.mega-line {
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  font-size: clamp(2.9rem, 12.5vw, 10rem);
  letter-spacing: -0.045em;
  text-transform: uppercase;
  background: linear-gradient(178deg, #ffffff 8%, #ffe9b0 40%, var(--accent-b) 72%, var(--accent-a) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 40px rgba(255, 190, 11, 0.28));
  opacity: 0;
  animation: megaSlam 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.line-1 { animation-delay: 0.1s; }
.line-2 { animation-delay: 0.26s; }

@keyframes megaSlam {
  0% {
    opacity: 0;
    transform: scale(2.4) translateY(-6%);
    filter: blur(26px) drop-shadow(0 0 0 transparent);
  }
  65% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: none;
    filter: blur(0) drop-shadow(0 10px 40px rgba(255, 190, 11, 0.28));
  }
}

.name-plate {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 1.75rem);
  margin-top: clamp(0.25rem, 1.2vh, 0.9rem);
  opacity: 0;
  animation: nameRise 0.95s 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* a pool of dark directly behind the name so nothing competes with it */
.name-plate::before {
  content: '';
  position: absolute;
  inset: -30% -8%;
  z-index: -1;
  background: radial-gradient(ellipse at center,
      rgba(4, 2, 10, 0.94) 0%,
      rgba(4, 2, 10, 0.8) 42%,
      rgba(4, 2, 10, 0.35) 68%,
      transparent 82%);
  filter: blur(16px);
  pointer-events: none;
}

@keyframes nameRise {
  from { opacity: 0; transform: translateY(28px) scale(0.9); filter: blur(10px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.name-flourish {
  height: 1px;
  width: clamp(1.5rem, 9vw, 8rem);
  background: linear-gradient(to right, transparent, var(--accent-b));
}

.name-flourish.right {
  background: linear-gradient(to left, transparent, var(--accent-b));
}

.friend-name {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: clamp(2.6rem, 9.5vw, 7rem);
  line-height: 1;
  padding: 0 0.1em;
  background: linear-gradient(96deg,
      var(--accent-c) 0%,
      #ffffff 30%,
      #ffffff 46%,
      var(--accent-a) 76%,
      var(--accent-d) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter:
    drop-shadow(0 0 14px rgba(255, 255, 255, 0.45))
    drop-shadow(0 0 40px rgba(0, 245, 212, 0.5))
    drop-shadow(0 6px 60px rgba(255, 42, 133, 0.45));
  animation: nameShimmer 5s ease-in-out infinite;
  background-size: 200% 100%;
}

@keyframes nameShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.act-blast .act-next {
  opacity: 0;
  animation: fadeUp 0.8s 1.75s ease forwards;
  margin-top: clamp(1.25rem, 4vh, 2.5rem);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------- ACT 2 : THE CAKE */

.cake-stage {
  --cake-scale: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  /* reserve the space the scaled cake will actually occupy */
  height: calc(300px * var(--cake-scale) + 12px);
  flex: 0 0 auto;
}

.cake-glow {
  position: absolute;
  width: 460px;
  height: 460px;
  max-width: 90vw;
  max-height: 46vh;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 11, 0.22) 0%, rgba(255, 120, 40, 0.1) 45%, transparent 70%);
  filter: blur(14px);
  animation: breathe 4.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.12); opacity: 1; }
}

.cake-container {
  position: relative;
  width: 356px;
  height: 300px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  transform: scale(var(--cake-scale, 1));
  transform-origin: center bottom;
  flex: 0 0 auto;
}

.cake {
  position: relative;
  width: 320px;
  height: 232px;
}

.plate {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 372px;
  height: 28px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.22));
  border-radius: 50%;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.7);
}

.layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 18px 18px 7px 7px;
  box-shadow: inset 0 -14px 28px rgba(0, 0, 0, 0.32), 0 6px 22px rgba(0, 0, 0, 0.4);
}

.layer-bottom {
  bottom: 0;
  width: 320px;
  height: 84px;
  background: linear-gradient(to right, #40152f, #8f3168 42%, #a83c78 52%, #40152f);
}

.layer-middle {
  bottom: 72px;
  width: 256px;
  height: 76px;
  background: linear-gradient(to right, #c2185b, #f0316f 40%, #ff9770 55%, #c2185b);
}

.layer-top {
  bottom: 140px;
  width: 192px;
  height: 68px;
  background: linear-gradient(to right, #e8a109, #ffc21e 42%, #ffd97a 55%, #e8a109);
}

.icing {
  position: absolute;
  bottom: 202px;
  left: 50%;
  transform: translateX(-50%);
  width: 198px;
  height: 15px;
  background: linear-gradient(to bottom, #ffffff, #f0e6ea);
  border-radius: 12px;
  box-shadow: 0 3px 16px rgba(255, 255, 255, 0.55);
}

.drips {
  position: absolute;
  bottom: 186px;
  left: 50%;
  transform: translateX(-50%);
  width: 192px;
  display: flex;
  justify-content: space-around;
}

.drip {
  width: 15px;
  height: 22px;
  background: linear-gradient(to bottom, #ffffff, #f2e7ec);
  border-radius: 0 0 12px 12px;
}

.drip:nth-child(2) { height: 30px; }
.drip:nth-child(4) { height: 26px; }

/* ---- candles ---- */

.candles-wrapper {
  position: absolute;
  bottom: 208px;
  left: 50%;
  transform: translateX(-50%);
  width: 152px;
  display: flex;
  justify-content: space-between;
  z-index: 5;
}

.candle {
  position: relative;
  width: 15px;
  height: 58px;
  background: repeating-linear-gradient(42deg,
      var(--accent-c), var(--accent-c) 6px,
      #ffffff 6px, #ffffff 12px);
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.candle::after {
  /* generous invisible tap target around the flame */
  content: '';
  position: absolute;
  top: -32px;
  left: -6px;
  right: -6px;
  height: 44px;
}

.candle:hover {
  transform: scale(1.14) translateY(-2px);
}

.flame {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 26px;
  background: radial-gradient(ellipse at bottom, #fff9d0 0%, #ffc21e 38%, #ff4500 78%, transparent 100%);
  border-radius: 50% 50% 22% 22%;
  box-shadow: 0 0 18px #ffbe0b, 0 0 42px #ff4500, 0 0 70px rgba(255, 69, 0, 0.5);
  animation: flicker 0.55s infinite alternate ease-in-out;
  transform-origin: bottom center;
  pointer-events: none;
}

@keyframes flicker {
  0% {
    transform: translateX(-50%) scale(1) rotate(-2deg);
    opacity: 0.92;
  }
  100% {
    transform: translateX(-50%) scale(1.14, 1.2) rotate(2deg);
    opacity: 1;
  }
}

.candle.extinguished {
  filter: saturate(0.5) brightness(0.75);
}

.candle.extinguished .flame {
  display: none;
}

.smoke {
  position: absolute;
  top: -26px;
  left: 50%;
  width: 9px;
  height: 9px;
  transform: translateX(-50%);
  background: rgba(215, 215, 225, 0.65);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  filter: blur(2px);
}

.candle.extinguished .smoke {
  animation: smokeRise 1.6s ease-out forwards;
}

@keyframes smokeRise {
  0%   { opacity: 0.75; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0;    transform: translate(-50%, -70px) scale(3.4); }
}

.act-cake .act-head {
  margin-bottom: 0.4rem;
}

.act-cake .act-lead.is-won {
  color: var(--accent-b);
  font-weight: 600;
}

/* ------------------------------------------------ ACT 3 : THE LETTER */

.letter {
  position: relative;
  width: min(660px, 100%);
  padding: clamp(2rem, 4.5vw, 3.25rem) clamp(1.5rem, 4vw, 3rem);
  text-align: left;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025));
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  backdrop-filter: blur(22px);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.85);
}

.letter-quote {
  position: absolute;
  top: 0.05em;
  left: 0.9rem;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(5rem, 12vw, 9rem);
  line-height: 1;
  color: var(--accent-a);
  opacity: 0.3;
  pointer-events: none;
}

.letter-line {
  position: relative;
  font-size: clamp(1rem, 2vw, 1.22rem);
  font-weight: 300;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.86);
  margin-bottom: 1.1rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.75s ease, transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.letter-line.is-shown {
  opacity: 1;
  transform: none;
}

.letter-line strong {
  font-weight: 600;
  color: var(--accent-b);
}

.letter-sign {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.letter-sign.is-shown {
  opacity: 1;
  transform: none;
}

.sign-label {
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sign-name {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  background: linear-gradient(100deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------ ACT 4 : THE FINALE */

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
  gap: clamp(0.7rem, 1.5vw, 1.1rem);
  width: min(1000px, 100%);
}

.wish-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: clamp(1.25rem, 2.5vw, 1.9rem) 1.1rem;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  backdrop-filter: blur(18px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, background 0.3s;
}

.wish-badge:hover {
  transform: translateY(-7px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.09);
}

.wish-emoji {
  font-size: 1.9rem;
  line-height: 1;
}

.wish-title {
  font-family: 'Fredoka', 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: #fff;
}

.wish-note {
  font-size: 0.83rem;
  font-weight: 300;
  line-height: 1.52;
  color: var(--ink-faint);
  max-width: 24ch;
}

.finale-close {
  font-size: clamp(1rem, 2.1vw, 1.35rem);
  font-weight: 200;
  line-height: 1.7;
  color: var(--ink-soft);
}

.finale-name {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: 1.5em;
  vertical-align: -0.08em;
  background: linear-gradient(100deg, var(--accent-c), var(--accent-a));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ============================================================ THE DOCK */

.dock {
  position: fixed;
  bottom: clamp(0.85rem, 2.2vh, 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  max-width: calc(100vw - 1.5rem);
  background: rgba(12, 8, 20, 0.72);
  border: 1px solid var(--glass-edge);
  border-radius: 99px;
  backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 18px 50px -14px rgba(0, 0, 0, 0.9);
  opacity: 0;
  animation: dockIn 0.9s 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dockIn {
  from { opacity: 0; transform: translate(-50%, 26px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.dock-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.13);
  margin: 0 0.25rem;
  flex: 0 0 1px;
}

.dock-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.dock-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-2px);
}

.theme-dot {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
}

.theme-dot[data-theme="cosmic"]    { background: linear-gradient(135deg, #ffbe0b, #ff2a85); }
.theme-dot[data-theme="synthwave"] { background: linear-gradient(135deg, #4cc9f0, #ff007f); }
.theme-dot[data-theme="fairy"]     { background: linear-gradient(135deg, #c77dff, #ffd6e0); }
.theme-dot[data-theme="rosegold"]  { background: linear-gradient(135deg, #ffd9a0, #ff8f7a); }

.theme-dot:hover {
  transform: scale(1.2);
}

.theme-dot.active {
  border-color: #fff;
  transform: scale(1.15);
}

.dock-score {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.65rem 0 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ---- act progress dots ---- */

.act-dots {
  position: fixed;
  right: clamp(0.9rem, 2.5vw, 2rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  opacity: 0;
  animation: fadeUp 0.8s 2.9s ease forwards;
}

.act-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
}

.act-dot:hover {
  background: rgba(255, 255, 255, 0.55);
}

.act-dot.is-on {
  background: var(--accent-b);
  transform: scale(1.6);
  box-shadow: 0 0 12px var(--accent-b);
}

/* ============================================================ RESPONSIVE */

@media (min-width: 1000px) and (min-height: 780px) {
  .cake-stage {
    --cake-scale: 1.15;
  }
}

@media (max-width: 720px) {
  .cake-stage {
    --cake-scale: 0.82;
  }

  /* four wishes as 2x2 rather than a single tall column */
  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .wish-badge {
    padding: 1.1rem 0.8rem;
    border-radius: 15px;
    gap: 0.3rem;
  }

  .wish-emoji {
    font-size: 1.55rem;
  }

  .wish-title {
    font-size: 0.94rem;
  }

  .wish-note {
    font-size: 0.76rem;
    line-height: 1.45;
    max-width: none;
  }

  .dock-text {
    display: none;
  }

  .dock-btn {
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
  }

  .act-dots {
    right: 0.6rem;
    gap: 0.55rem;
  }

  .letter {
    border-radius: 18px;
  }
}

@media (max-width: 420px) {
  .cake-stage {
    --cake-scale: 0.68;
  }

  .name-flourish {
    display: none;
  }
}

@media (max-height: 640px) {
  .cake-stage {
    --cake-scale: 0.72;
  }
}

/* ---- respect reduced motion, but keep the reveal legible ---- */

@media (prefers-reduced-motion: reduce) {
  .flame,
  .cake-glow,
  .friend-name,
  .kicker span,
  .mega-line,
  .name-plate,
  .act-blast .act-next,
  .dock,
  .act-dots {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    opacity: 1 !important;
  }

  html.is-glitching .gate-screen,
  html.is-glitching .gate-panel {
    animation: none;
  }
}
