html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-touch-callout: none;
}
canvas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#space { z-index: 0; }
#glow { z-index: 1; }
#treegl { z-index: 2; pointer-events: none; }
#tree { z-index: 2; cursor: grab; }
#tree.dragging { cursor: grabbing; }
#vignette {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%,
    rgba(0, 0, 0, 0) 30%, rgba(20, 6, 26, 0.32) 66%, rgba(8, 2, 12, 0.76) 100%);
}

/* ---- Mid-Autumn Festival Header ---- */
#festival-header {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  padding: 6px 20px;
  width: max-content;
  max-width: 90vw;
}

.lantern-icon {
  font-size: clamp(24px, 4.5vw, 40px);
  display: inline-block;
  filter: drop-shadow(0 0 12px rgba(255, 65, 35, 0.9)) drop-shadow(0 0 24px rgba(255, 175, 45, 0.65));
  transform-origin: top center;
}

.lantern-left {
  animation: lanternSwingLeft 3.6s ease-in-out infinite alternate;
}

.lantern-right {
  animation: lanternSwingRight 4s ease-in-out infinite alternate;
}

@keyframes lanternSwingLeft {
  0% { transform: rotate(-8deg); }
  100% { transform: rotate(8deg); }
}

@keyframes lanternSwingRight {
  0% { transform: rotate(8deg); }
  100% { transform: rotate(-8deg); }
}

.title-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.festival-title {
  margin: 0;
  font-family: 'Playfair Display', 'Cinzel Decorative', 'Georgia', serif;
  font-size: clamp(28px, 5.5vw, 56px);
  font-weight: 900;
  letter-spacing: clamp(3px, 0.8vw, 8px);
  text-transform: uppercase;
  background: linear-gradient(180deg, #fffdf2 0%, #ffeaa5 28%, #ffbe42 65%, #ff8326 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 205, 75, 0.85)) drop-shadow(0 0 32px rgba(255, 115, 30, 0.55));
}

.festival-subtitle {
  margin: 4px 0 0 0;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(10px, 1.6vw, 13px);
  font-weight: 600;
  letter-spacing: clamp(3px, 0.6vw, 6px);
  text-transform: uppercase;
  color: #ffdda1;
  text-shadow: 0 0 10px rgba(255, 195, 65, 0.7);
  opacity: 0.92;
}

/* ---- Wishing Stars Container ---- */
#wishes-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.wish-star {
  position: absolute;
  white-space: nowrap;
  font-family: 'Playfair Display', 'Times New Roman', serif;
  font-size: clamp(13px, 2.1vw, 18px);
  font-weight: 700;
  color: #fffbf2;
  text-shadow:
    0 0 8px rgba(255, 240, 150, 0.95),
    0 0 20px rgba(255, 175, 50, 0.85),
    0 0 35px rgba(255, 95, 25, 0.6);
  background: rgba(22, 6, 30, 0.92);
  padding: 6px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 220, 115, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 190, 50, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  animation: wishFlight 3.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
  pointer-events: none;
}

@keyframes wishFlight {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(-20px, -15px) scale(0.75);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(0, 0) scale(1.04);
  }
  25% {
    transform: translate(-50%, -50%) translate(10px, 8px) scale(1);
  }
  80% {
    opacity: 0.95;
    transform: translate(-50%, -50%) translate(45px, 28px) scale(0.98);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(65px, 42px) scale(0.9);
  }
}

/* ---- Greeting Card Gatefold (Thiệp 2 Cánh Mở) ---- */
.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(18, 5, 26, 0.96) 0%, rgba(5, 1, 8, 0.98) 100%);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.7s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
  overflow: hidden;
}

.card-overlay.is-opened {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Ambient Moonlit Aura behind Card */
.card-backdrop-aura {
  position: absolute;
  width: min(88vw, 560px);
  height: min(88vw, 560px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 195, 60, 0.18) 0%, rgba(255, 120, 25, 0.09) 45%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
  animation: auraBreathe 4.5s ease-in-out infinite alternate;
}

@keyframes auraBreathe {
  0% { transform: scale(0.92); opacity: 0.65; }
  100% { transform: scale(1.18); opacity: 1; }
}

/* Drifting Moon Clouds */
.card-cloud {
  position: absolute;
  pointer-events: none;
  opacity: 0.26;
  border-radius: 40px;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 120, 0.4), transparent);
}

.card-cloud-1 {
  width: min(320px, 60vw);
  height: 38px;
  top: 12%;
  left: 6%;
  animation: cloudDrift1 12s ease-in-out infinite alternate;
}

.card-cloud-2 {
  width: min(280px, 55vw);
  height: 32px;
  bottom: 14%;
  right: 6%;
  animation: cloudDrift2 15s ease-in-out infinite alternate;
}

@keyframes cloudDrift1 {
  0% { transform: translateX(0); }
  100% { transform: translateX(40px); }
}

@keyframes cloudDrift2 {
  0% { transform: translateX(0); }
  100% { transform: translateX(-35px); }
}

/* Floating Golden Fireflies / Stardust */
.card-particles-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.card-particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #ffeaa3 40%, #ff9e24 85%);
  box-shadow: 0 0 10px rgba(255, 220, 90, 0.9), 0 0 20px rgba(255, 140, 20, 0.6);
  pointer-events: none;
  animation: particleFloat var(--dur, 4s) ease-in-out infinite alternate;
}

@keyframes particleFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(0.6);
    opacity: 0.25;
  }
  50% {
    opacity: 1;
    transform: translate3d(var(--mx, 15px), var(--my, -25px), 0) scale(1.25);
  }
  100% {
    transform: translate3d(calc(var(--mx, 15px) * -1), var(--my, -50px), 0) scale(0.5);
    opacity: 0.2;
  }
}

.p1 { width: 6px; height: 6px; top: 22%; left: 16%; --dur: 3.8s; --mx: 18px; --my: -30px; animation-delay: 0s; }
.p2 { width: 4px; height: 4px; top: 38%; left: 10%; --dur: 4.5s; --mx: -20px; --my: -35px; animation-delay: 1.2s; }
.p3 { width: 5px; height: 5px; top: 66%; left: 15%; --dur: 3.6s; --mx: 15px; --my: -25px; animation-delay: 0.6s; }
.p4 { width: 7px; height: 7px; top: 78%; left: 22%; --dur: 4.2s; --mx: -16px; --my: -40px; animation-delay: 2.1s; }
.p5 { width: 5px; height: 5px; top: 18%; right: 15%; --dur: 3.9s; --mx: -18px; --my: -28px; animation-delay: 0.4s; }
.p6 { width: 4px; height: 4px; top: 42%; right: 10%; --dur: 4.8s; --mx: 22px; --my: -32px; animation-delay: 1.8s; }
.p7 { width: 6px; height: 6px; top: 64%; right: 16%; --dur: 3.5s; --mx: -15px; --my: -38px; animation-delay: 0.9s; }
.p8 { width: 7px; height: 7px; top: 82%; right: 20%; --dur: 4.4s; --mx: 16px; --my: -42px; animation-delay: 1.5s; }
.p9 { width: 4px; height: 4px; top: 14%; left: 48%; --dur: 4.1s; --mx: 12px; --my: -22px; animation-delay: 2.5s; }
.p10 { width: 5px; height: 5px; top: 88%; left: 52%; --dur: 3.7s; --mx: -14px; --my: -30px; animation-delay: 0.8s; }

/* Card Wrapper with Subtle 3D Floating Levitation */
.card-wrapper {
  position: relative;
  width: min(90vw, 440px);
  height: min(78vh, 600px);
  perspective: 1400px;
  -webkit-perspective: 1400px;
  transform: translateZ(0);
  animation: cardWrapperFloat 4.8s ease-in-out infinite alternate;
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes cardWrapperFloat {
  0% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
  50% {
    transform: translateY(-9px) rotateX(1.4deg) rotateY(-1deg);
  }
  100% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
}

.card-container {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(255, 170, 40, 0.25);
  border-radius: 12px;
  transform: translateZ(0);
}

/* Doors (Cánh trái & phải) */
.card-door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.25, 1, 0.35, 1), box-shadow 1.1s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-door-left {
  left: 0;
  transform-origin: left center;
  border-radius: 12px 0 0 12px;
  border-right: 1px solid rgba(255, 220, 120, 0.6);
}

.card-door-right {
  right: 0;
  transform-origin: right center;
  border-radius: 0 12px 12px 0;
  border-left: 1px solid rgba(255, 220, 120, 0.6);
}

/* State when card is opened */
.card-container.is-open .card-door-left {
  transform: rotateY(-118deg);
  box-shadow: 15px 15px 35px rgba(0, 0, 0, 0.85);
}

.card-container.is-open .card-door-right {
  transform: rotateY(118deg);
  box-shadow: -15px 15px 35px rgba(0, 0, 0, 0.85);
}

/* Door Face & Aesthetic Styling */
.door-face {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.door-front {
  background:
    radial-gradient(ellipse at 50% 30%, #85162a 0%, #520916 55%, #2a030a 100%);
  padding: 18px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.door-back {
  background:
    radial-gradient(ellipse at 50% 40%, #520d1a 0%, #32050e 65%, #180105 100%);
  border: 1px solid rgba(255, 215, 100, 0.45);
  transform: rotateY(180deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 10px;
}

.door-inner-pattern {
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(255, 220, 120, 0.35);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(circle at center, rgba(255, 215, 100, 0.08) 0%, transparent 72%);
}

.inner-lotus {
  font-size: clamp(28px, 4.5vw, 40px);
  filter: drop-shadow(0 0 12px rgba(255, 180, 50, 0.75));
}

.inner-wish-text {
  font-family: 'Playfair Display', 'Cinzel Decorative', serif;
  font-size: clamp(14px, 2.4vw, 18px);
  font-weight: 800;
  letter-spacing: 4px;
  color: #ffd978;
  text-shadow: 0 0 10px rgba(255, 200, 70, 0.75);
}

.door-border {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255, 220, 125, 0.75);
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 8px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55);
}

.door-border::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(255, 210, 100, 0.45);
  pointer-events: none;
}

.door-lantern {
  font-size: clamp(26px, 4vw, 38px);
  filter: drop-shadow(0 0 12px rgba(255, 60, 30, 0.95)) drop-shadow(0 0 24px rgba(255, 180, 50, 0.75));
  animation: lanternSwing 3.4s ease-in-out infinite alternate;
  transform-origin: top center;
}

@keyframes lanternSwing {
  0% { transform: rotate(-7deg); }
  100% { transform: rotate(7deg); }
}

.door-calligraphy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: auto 0;
}

.verse-word {
  font-family: 'Playfair Display', 'Cinzel Decorative', 'Georgia', serif;
  font-size: clamp(20px, 3.8vw, 32px);
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fffbe8 0%, #ffd978 20%, #ffffff 42%, #ffae32 70%, #ff7315 100%);
  background-size: 100% 250%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 205, 80, 0.8)) drop-shadow(0 0 22px rgba(255, 110, 20, 0.5));
  animation: calligraphyShimmer 4.2s ease-in-out infinite alternate;
}

@keyframes calligraphyShimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 100%; }
}

.door-cloud-bottom {
  width: 40px;
  height: 16px;
  border-top: 2px solid rgba(255, 215, 100, 0.55);
  border-radius: 50% 50% 0 0;
  opacity: 0.75;
}

/* Center Seal (Huy Hiệu / Khóa Ngọc Hoàng Kim) */
.card-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  outline: none;
  transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.5s ease;
  touch-action: manipulation;
}

.card-container.is-open .card-seal {
  transform: translate(-50%, -50%) scale(1.4);
  opacity: 0;
  pointer-events: none;
}

/* Expanding Golden Halo Pulse Rings */
.seal-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(86px, 16vw, 104px);
  height: clamp(86px, 16vw, 104px);
  margin-top: calc(-1 * clamp(86px, 16vw, 104px) / 2);
  margin-left: calc(-1 * clamp(86px, 16vw, 104px) / 2);
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 85, 0.75);
  box-shadow: 0 0 16px rgba(255, 185, 45, 0.5);
  pointer-events: none;
  animation: sealPulseWave 2.6s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
}

.seal-pulse-ring.ring-2 {
  animation-delay: 1.3s;
}

@keyframes sealPulseWave {
  0% {
    transform: scale(0.95);
    opacity: 0.95;
  }
  100% {
    transform: scale(1.95);
    opacity: 0;
  }
}

.seal-ring {
  width: clamp(86px, 16vw, 104px);
  height: clamp(86px, 16vw, 104px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff7d6 0%, #ffd46b 35%, #f29a24 75%, #ab5608 100%);
  padding: 4px;
  box-sizing: border-box;
  box-shadow:
    0 0 25px rgba(255, 195, 60, 0.95),
    0 0 50px rgba(255, 110, 20, 0.6),
    0 8px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Gleam highlight sweep across gold ring */
.seal-ring::after {
  content: '';
  position: absolute;
  inset: -120%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.75) 50%, transparent 60%);
  transform: rotate(25deg) translateX(-120%);
  animation: sealGleam 3.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sealGleam {
  0%, 35% {
    transform: rotate(25deg) translateX(-120%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  70%, 100% {
    transform: rotate(25deg) translateX(120%);
    opacity: 0;
  }
}

.card-seal:hover .seal-ring,
.card-seal:active .seal-ring {
  transform: scale(1.08);
  box-shadow:
    0 0 35px rgba(255, 215, 80, 1),
    0 0 65px rgba(255, 120, 25, 0.75),
    0 10px 28px rgba(0, 0, 0, 0.7);
}

.seal-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(115, 45, 5, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, #ffeaa3 0%, #f7ab2e 85%, #d1750e 100%);
}

.seal-icon {
  font-size: clamp(26px, 5vw, 34px);
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
}

.seal-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(10px, 1.8vw, 12px);
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #5c2002;
  margin-top: 2px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

.seal-prompt {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(12px, 2vw, 14px);
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffebaa;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(255, 195, 60, 0.85);
  animation: promptPulse 2s ease-in-out infinite alternate;
}

.prompt-sparkle {
  font-size: 14px;
  animation: sparkleTwinkle 1.6s ease-in-out infinite alternate;
}

@keyframes sparkleTwinkle {
  0% { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.3); opacity: 1; filter: drop-shadow(0 0 6px #ffe27a); }
}

@keyframes promptPulse {
  0% { opacity: 0.8; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(3px); }
}

.seal-tap-icon {
  margin-top: 6px;
  font-size: clamp(20px, 3.6vw, 26px);
  filter: drop-shadow(0 0 10px rgba(255, 215, 80, 0.85));
  animation: tapBounce 1.4s ease-in-out infinite alternate;
}

@keyframes tapBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-7px) scale(1.12); }
}

/* Seal Unlocking Sparkle Burst */
.seal-burst-container {
  position: absolute;
  pointer-events: none;
  z-index: 120;
}

.seal-burst-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #ffe994 45%, #ff951e 100%);
  box-shadow: 0 0 12px rgba(255, 220, 80, 0.95), 0 0 24px rgba(255, 140, 20, 0.7);
  top: -3.5px;
  left: -3.5px;
  animation: burstFly 0.85s cubic-bezier(0.12, 0.8, 0.3, 1) forwards;
}

@keyframes burstFly {
  0% {
    transform: translate(0, 0) scale(1.4);
    opacity: 1;
  }
  100% {
    transform: translate(var(--bx), var(--by)) scale(var(--bs));
    opacity: 0;
  }
}

/* Reopen Card Floating Button */
.reopen-card-btn {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 25px;
  background: rgba(28, 8, 38, 0.92);
  border: 1px solid rgba(255, 215, 110, 0.6);
  color: #fff2cc;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), 0 0 14px rgba(255, 180, 50, 0.35);
  transition: opacity 0.35s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1), background 0.25s ease;
  outline: none;
  opacity: 0;
  pointer-events: none;
  touch-action: manipulation;
  white-space: nowrap;
}

.reopen-card-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.reopen-card-btn:hover {
  background: rgba(56, 16, 76, 0.96);
  border-color: rgba(255, 225, 130, 0.95);
  color: #ffffff;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7), 0 0 22px rgba(255, 200, 60, 0.6);
}

/* Door Mascot Vignette on Card Doors */
.door-mascot-wrap {
  width: clamp(55px, 12vw, 88px);
  height: clamp(55px, 12vw, 88px);
  margin-top: auto;
  position: relative;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6))
         drop-shadow(0 0 14px rgba(255, 185, 50, 0.7));
  animation: doorMascotFloat 3.8s ease-in-out infinite alternate;
  pointer-events: none;
}

.door-mascot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

@keyframes doorMascotFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px) scale(1.04); }
}

/* ---- Mascots (Lân & Thỏ Ngọc) on Main Festival Scene ---- */
.mascot-stage {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  overflow: visible;
}

.mascot-item {
  position: fixed;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  outline: none;
  transition: filter 0.3s ease;
  z-index: 15;
}

.mascot-left {
  left: clamp(12px, 3vw, 42px);
  animation: mascotFloatLeft 4.6s ease-in-out infinite alternate;
}

.mascot-right {
  right: clamp(12px, 3vw, 42px);
  animation: mascotFloatRight 4.9s ease-in-out infinite alternate;
}

@keyframes mascotFloatLeft {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(1.8deg); }
  100% { transform: translateY(-3px) rotate(-1deg); }
}

@keyframes mascotFloatRight {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-11px) rotate(-1.8deg); }
  100% { transform: translateY(-4px) rotate(1deg); }
}

.mascot-img-wrapper {
  position: relative;
  width: clamp(110px, 14vw, 205px);
  height: clamp(110px, 14vw, 205px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mascot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.65))
         drop-shadow(0 0 20px rgba(255, 175, 50, 0.45));
  transition: transform 0.25s ease, filter 0.25s ease;
}

.mascot-item:hover .mascot-img {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.75))
         drop-shadow(0 0 30px rgba(255, 205, 80, 0.85))
         drop-shadow(0 0 12px rgba(255, 255, 255, 0.95));
  transform: scale(1.06);
}

/* Mascot Click Bounce Animation */
.mascot-item.is-bouncing .mascot-img-wrapper {
  animation: mascotBounce 0.65s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes mascotBounce {
  0% { transform: scale(1) translateY(0); }
  35% { transform: scale(1.15, 0.88) translateY(-26px); }
  60% { transform: scale(0.95, 1.08) translateY(-6px); }
  80% { transform: scale(1.03, 0.98) translateY(-2px); }
  100% { transform: scale(1) translateY(0); }
}

/* Warm ambient glowing puddle beneath mascot */
.mascot-glow {
  position: absolute;
  bottom: 8px;
  width: 80%;
  height: 22px;
  background: radial-gradient(ellipse at center, rgba(255, 190, 60, 0.5) 0%, rgba(255, 110, 30, 0.18) 50%, transparent 80%);
  border-radius: 50%;
  filter: blur(5px);
  pointer-events: none;
  animation: puddlePulse 3.5s ease-in-out infinite alternate;
}

@keyframes puddlePulse {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

/* Mascot Speech Bubble */
.mascot-speech-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: clamp(170px, 32vw, 260px);
  background: rgba(22, 6, 32, 0.95);
  border: 1.5px solid rgba(255, 215, 100, 0.8);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75), 0 0 20px rgba(255, 180, 50, 0.4);
  border-radius: 14px;
  padding: 9px 13px;
  color: #fff9e6;
  font-family: 'Playfair Display', 'Times New Roman', serif;
  font-size: clamp(12px, 1.8vw, 14px);
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translateY(10px) scale(0.85);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28),
              transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 20;
}

.mascot-speech-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid rgba(255, 215, 100, 0.85);
}

.mascot-left .mascot-speech-bubble {
  left: 0;
}
.mascot-left .mascot-speech-bubble::after {
  left: 32px;
}

.mascot-right .mascot-speech-bubble {
  right: 0;
}
.mascot-right .mascot-speech-bubble::after {
  right: 32px;
}

.mascot-speech-bubble.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mascot Nameplate Tag */
.mascot-nameplate {
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.mascot-tag {
  background: linear-gradient(135deg, rgba(255, 195, 60, 0.95), rgba(255, 120, 25, 0.95));
  color: #2b0b02;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(10px, 1.5vw, 12px);
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 2px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 195, 60, 0.4);
}

.mascot-hint {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(9px, 1.4vw, 10.5px);
  color: rgba(255, 235, 175, 0.85);
  text-shadow: 0 0 6px rgba(255, 190, 50, 0.6);
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.mascot-item:hover .mascot-hint {
  opacity: 1;
  color: #fff2b8;
}

/* Sparkle particles spawned by mascot */
.mascot-particle {
  position: fixed;
  font-size: clamp(16px, 2.5vw, 24px);
  pointer-events: none;
  z-index: 30;
  user-select: none;
  animation: mascotParticleFly 1.2s cubic-bezier(0.12, 0.8, 0.3, 1) forwards;
}

@keyframes mascotParticleFly {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 1;
  }
  50% {
    opacity: 1;
    transform: translate(var(--mx), var(--my)) scale(1.3) rotate(var(--mr));
  }
  100% {
    transform: translate(calc(var(--mx) * 1.3), calc(var(--my) - 25px)) scale(0.4) rotate(calc(var(--mr) * 1.5));
    opacity: 0;
  }
}

@media (max-width: 600px) {
  .mascot-img-wrapper {
    width: clamp(82px, 22vw, 110px);
    height: clamp(82px, 22vw, 110px);
  }
  .mascot-left {
    left: 8px;
    bottom: 6px;
  }
  .mascot-right {
    right: 8px;
    bottom: 6px;
  }
  .mascot-hint {
    display: none;
  }
  .reopen-card-btn {
    bottom: 12px;
    padding: 7px 14px;
    font-size: 11.5px;
  }
}

