/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  touch-action: manipulation;
}

/* ── Shake root — fixed shell that shakes everything inside it ─────────── */
#shakeRoot {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Pre-reveal */
#preScreen { background: #FFF9F0; inset: -50px; }

/* Reveal */
.reveal-screen {
  background: linear-gradient(to top, #9bd9f9 0%, #7ec8f4 50%, #59b2ef 100%);
  animation: revealFadeIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes revealFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Language toggle ─────────────────────────────────────────────────────── */
.lang-toggle {
  position: absolute;
  top: clamp(16px, 5vw, 24px);
  right: clamp(16px, 5vw, 24px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 245, 230, 0.92);
  border: 1.5px solid #DFC9A8;
  border-radius: 22px;
  padding: 5px 12px;
  backdrop-filter: blur(10px);
  transition: background 0.4s ease, border-color 0.4s ease;
  box-shadow: 0 2px 10px rgba(160,120,60,0.1);
}

body.revealed .lang-toggle {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 2px 10px rgba(30,90,160,0.12);
}

.lang-btn {
  font-size: 12px;
  font-weight: 700;
  color: #8a6a45;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s, padding 0.2s;
}

.lang-btn.active {
  background: #F0D59A;
  color: #4a2e08;
}

body.revealed .lang-btn       { color: rgba(255,255,255,0.72); }
body.revealed .lang-btn.active { background: rgba(255,255,255,0.28); color: #fff; }

.lang-sep {
  font-size: 12px;
  font-weight: 300;
  color: #b89a74;
}

body.revealed .lang-sep { color: rgba(255,255,255,0.45); }

/* ── Background texture dots (pre-reveal) ────────────────────────────────── */
.dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(200, 165, 110, 0.22);
  pointer-events: none;
}

/* ── Sparkles (pre-reveal) ───────────────────────────────────────────────── */
.sparkle {
  position: absolute;
  color: #E8B84B;
  font-size: clamp(14px, 4vw, 20px);
  opacity: 0;
  pointer-events: none;
  animation: sparkleFloat 3s ease-in-out infinite;
}

.sparkle.sm { font-size: clamp(10px, 3vw, 14px); }

@keyframes sparkleFloat {
  0%   { opacity: 0;    transform: translateY(4px)  scale(0.8); }
  25%  { opacity: 0.55; transform: translateY(0)    scale(1);   }
  75%  { opacity: 0.4;  transform: translateY(-6px) scale(1.1); }
  100% { opacity: 0;    transform: translateY(4px)  scale(0.8); }
}

/* ── Balloon wrap ────────────────────────────────────────────────────────── */
@keyframes floatBalloon {
  0%, 100% { transform: translateY(0px)  rotate(0deg); }
  35%       { transform: translateY(-9px) rotate(1deg); }
  70%       { transform: translateY(-4px) rotate(-0.7deg); }
}

.balloon-wrap {
  cursor: pointer;
  width: min(94vw, 52vh);
  aspect-ratio: 280 / 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* Extend touch target by 20px all around without visual change */
  padding: 20px;
  margin: -20px -20px 0;
}

#balloonSVG {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Float pivot at knot bottom — balloon tilts from the string connection point */
#balloonFloat {
  transform-origin: 140px 357px;
  animation: floatBalloon 4s ease-in-out infinite;
}

/* String path is driven by JS physics — no CSS animation needed */
#stringEl {
  transform-origin: 140px 358px;
}

/* Knot — fixed size, rotates from balloon-bottom anchor */
#knotEl {
  transform-origin: 140px 338px;
}

@keyframes knot-wobble-mild {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(-1.5deg); }
  75%       { transform: rotate(1.5deg); }
}

@keyframes knot-wobble-intense {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(-3.5deg); }
  30%  { transform: rotate(3.5deg); }
  50%  { transform: rotate(-2.5deg); }
  70%  { transform: rotate(2.5deg); }
  85%  { transform: rotate(-1.5deg); }
  100% { transform: rotate(0deg); }
}

#knotEl.wobbling-mild    { animation: knot-wobble-mild    0.5s  ease-in-out infinite; }
#knotEl.wobbling-intense { animation: knot-wobble-intense 0.28s ease-in-out infinite; }


/* Register --bs so CSS can transition it with overshoot */
@property --bs {
  syntax: "<number>";
  inherits: false;
  initial-value: 0.86;
}

/* Balloon body — drives scale via --bs so the spring transition produces visible overshoot */
#balloonBody {
  transform-origin: 140px 338px;
  transform: scale(var(--bs));
  transition: --bs 0.48s cubic-bezier(0.34, 2.4, 0.64, 1);
  will-change: transform;
}

/* Near-burst wobble — two intensities */
@keyframes wobble-mild {
  0%, 100% { transform: rotate(0deg)    scale(var(--bs, 1)); }
  25%       { transform: rotate(-1.5deg) scale(var(--bs, 1)); }
  75%       { transform: rotate(1.5deg)  scale(var(--bs, 1)); }
}

@keyframes wobble-intense {
  0%   { transform: rotate(0deg)    scale(var(--bs, 1)); }
  15%  { transform: rotate(-3.5deg) scale(var(--bs, 1)); }
  30%  { transform: rotate(3.5deg)  scale(var(--bs, 1)); }
  50%  { transform: rotate(-2.5deg) scale(var(--bs, 1)); }
  70%  { transform: rotate(2.5deg)  scale(var(--bs, 1)); }
  85%  { transform: rotate(-1.5deg) scale(var(--bs, 1)); }
  100% { transform: rotate(0deg)    scale(var(--bs, 1)); }
}

#balloonBody.wobbling-mild {
  animation: wobble-mild 0.5s ease-in-out infinite;
  transition: none;
}

#balloonBody.wobbling-intense {
  animation: wobble-intense 0.28s ease-in-out infinite;
  transition: none;
}

/* Burst pop animation — expands outward and fades, not shrinks */
@keyframes popOut {
  0%   { transform: scale(var(--bs, 1));                opacity: 1;   }
  8%   { transform: scale(calc(var(--bs, 1) * 1.18));   opacity: 1;   }
  100% { transform: scale(calc(var(--bs, 1) * 3.80));   opacity: 0;   }
}

#balloonBody.popping {
  animation: popOut 0.18s cubic-bezier(0.12, 0, 0.28, 1) forwards;
  transition: none;
}

/* ── Tap hint ────────────────────────────────────────────────────────────── */
.tap-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.tap-line {
  width: 38px; height: 1.5px;
  background: rgba(160, 125, 80, 0.4);
  border-radius: 1px;
}

#tapText {
  font-size: clamp(13px, 3.8vw, 16px);
  color: #9a7a58;
  letter-spacing: 0.04em;
  font-weight: 400;
}

/* ── Reveal screen elements ───────────────────────────────────────────────── */
.bokeh {
  position: absolute;
  background: white;
  border-radius: 50%;
  pointer-events: none;
}

.burst-ring {
  position: absolute;
  top: 50%; left: 50%;
  width:  min(220px, 55vw);
  height: min(220px, 55vw);
  transform: translate(-50%, -80%);
  border: 1.5px dashed rgba(255,255,255,0.22);
  border-radius: 50%;
  pointer-events: none;
  animation: ringExpand 0.6s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ringExpand {
  from { transform: translate(-50%, -80%) scale(0.4); opacity: 0; }
  to   { transform: translate(-50%, -80%) scale(1);   opacity: 1; }
}

/* Stars on reveal screen */
.star {
  position: absolute;
  color: rgba(255,255,255,0.65);
  font-size: clamp(14px, 4.5vw, 22px);
  pointer-events: none;
  animation: starPulse 2.4s ease-in-out infinite;
}

.star.sm { font-size: clamp(10px, 3vw, 15px); }

@keyframes starPulse {
  0%, 100% { opacity: 0.55; transform: scale(1);    }
  50%       { opacity: 0.9;  transform: scale(1.18); }
}

/* ── Reveal content ──────────────────────────────────────────────────────── */
.reveal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 3.5vw, 20px);
  padding: 0 20px;
  animation: contentSlideUp 0.65s 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes contentSlideUp {
  from { transform: translateY(28px) scale(0.92); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.reveal-main {
  font-size: clamp(42px, 14.8vw, 64px);
  font-weight: 800;
  color: #fff;
  text-align: center;
  line-height: 1.08;
  text-shadow: 0 6px 20px rgba(46, 122, 191, 0.35);
  letter-spacing: -0.01em;
}

.reveal-divider {
  width: 60px; height: 2px;
  background: rgba(255,255,255,0.50);
  border-radius: 1px;
}

.reveal-sub {
  font-size: clamp(20px, 6.6vw, 30px);
  font-weight: 700;
  color: rgba(255,255,255,0.88);
  text-align: center;
  letter-spacing: 0.03em;
}

.reveal-hearts {
  display: flex;
  align-items: center;
  gap: clamp(28px, 9vw, 44px);
  color: rgba(255,255,255,0.70);
  animation: heartPulse 1.9s ease-in-out infinite;
}

.heart-sm { font-size: clamp(20px, 7vw, 28px); }
.heart-lg { font-size: clamp(26px, 9vw, 36px); }

@keyframes heartPulse {
  0%, 100% { transform: scale(1);    opacity: 0.6; }
  50%       { transform: scale(1.09); opacity: 0.9; }
}

/* ── Static confetti pieces (Figma reveal screen) ───────────────────────── */
.confetti-piece {
  position: absolute;
  border-radius: 2px;
  pointer-events: none;
}

@keyframes confettiDrift1 {
  0%, 100% { translate: 0 0;      }
  50%       { translate: 0 -7px;   }
}
@keyframes confettiDrift2 {
  0%, 100% { translate: 0 0;      }
  50%       { translate: 3px -5px; }
}
@keyframes confettiDrift3 {
  0%, 100% { translate: 0 0;       }
  50%       { translate: -3px -6px; }
}

/* ── Tap balloon particles ───────────────────────────────────────────────── */
.tap-balloon {
  position: absolute;
  pointer-events: none;
  z-index: 500;
  width: var(--sz, 18px);
  height: calc(var(--sz, 18px) * 1.55);
  animation: balloonBurst linear forwards;
}

.tap-balloon svg { width: 100%; height: 100%; }

@keyframes balloonSpin {
  from { rotate: var(--rot0, 0deg); }
  to   { rotate: var(--rot1, 0deg); }
}

@keyframes balloonBurst {
  /* Parabolic arc: X decelerates with friction, Y = burst + gravity*t²
     gravity constant G=380px over full duration → at each t: G*t²
     t=0.20 → 15px  t=0.40 → 61px  t=0.65 → 161px  t=1.0 → 380px   */
  0%   {
    transform: translate(calc(-50% + 0px),                          calc(-50% + 0px))                                  scale(1);    opacity: 0.95;
  }
  20%  {
    transform: translate(calc(-50% + var(--bx) * 0.40),             calc(-50% + var(--by) * 0.40 + 15px))              scale(0.91); opacity: 0.92;
  }
  40%  {
    transform: translate(calc(-50% + var(--bx) * 0.72),             calc(-50% + var(--by) * 0.72 + 61px))              scale(0.78); opacity: 0.84;
  }
  65%  {
    transform: translate(calc(-50% + var(--bx) * 0.92),             calc(-50% + var(--by) * 0.92 + 161px))             scale(0.52); opacity: 0.60;
  }
  100% {
    transform: translate(calc(-50% + var(--bx) * 1.02),             calc(-50% + var(--by) + 380px))                    scale(0.13); opacity: 0;
  }
}

/* ── Cat paw ─────────────────────────────────────────────────────────────── */
#catPaw {
  position: absolute;
  left: 50%;
  top: 0;
  width: clamp(160px, 52vw, 260px);
  transform: translateX(-50%) translateY(-115%);
  z-index: 500;
  pointer-events: none;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.28));
  will-change: transform;
}

/* ── Mute button ─────────────────────────────────────────────────────────── */
.mute-btn {
  position: absolute;
  bottom: clamp(24px, 6vw, 40px);
  left:   clamp(18px, 5vw, 28px);
  width: 50px; height: 50px;
  border-radius: 16px;
  border: 1.5px solid #DFC9A8;
  background: rgba(255, 245, 230, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(160,120,60,0.1);
  color: #8a6a45;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease, transform 0.15s;
}

.mute-btn:active { transform: scale(0.93); }

body.revealed .mute-btn {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 2px 10px rgba(30,90,160,0.12);
  color: rgba(255,255,255,0.90);
}

/* ── QR button ───────────────────────────────────────────────────────────── */
.qr-btn {
  position: absolute;
  bottom: clamp(24px, 6vw, 40px);
  right:  clamp(18px, 5vw, 28px);
  width: 62px; height: 62px;
  border-radius: 16px;
  border: 1.5px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(10px);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s;
  animation: contentSlideUp 0.65s 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.qr-btn:active { background: rgba(255,255,255,0.28); transform: scale(0.95); }

/* ── QR Modal ────────────────────────────────────────────────────────────── */
.qr-modal {
  position: absolute;
  inset: 0;
  background: rgba(20, 70, 130, 0.52);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.qr-box {
  background: #fff;
  border-radius: 28px;
  padding: 34px 30px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
  box-shadow: 0 24px 60px rgba(15, 55, 120, 0.28);
  animation: boxPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes boxPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.qr-label {
  font-size: 15px;
  font-weight: 700;
  color: #4a8cc4;
}

#qrCanvas { border-radius: 10px; }

.qr-url {
  font-size: 11px;
  color: #aaa;
  letter-spacing: 0.04em;
  max-width: 200px;
  text-align: center;
  word-break: break-all;
}

.qr-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  color: #ccc;
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.15s;
}

.qr-close:active { color: #999; }
