/* ========================================
   像素可爱风庆生网页 - 全局样式
   ======================================== */

/* --- CSS Variables --- */
:root {
  --pink: #ffb3c1;
  --pink-dark: #e8879e;
  --mint: #b3ffd9;
  --sky: #b3d9ff;
  --lavender: #d9c3ff;
  --yellow: #fff3b3;
  --cream: #fff8f0;
  --chocolate: #8b5e3c;
  --dark: #3d2b3a;
  --white: #ffffff;

  --pixel-size: 4px;
  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'Courier New', monospace;

  --shadow-pixel: 4px 4px 0px rgba(0,0,0,0.2);
  --border-pixel: 4px solid var(--dark);

  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

html {
  font-size: 16px;
  overflow: hidden;
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: var(--font-pixel);
  background:
    radial-gradient(circle at 20% 20%, #fff5f8 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, #f8f0ff 0%, transparent 50%),
    radial-gradient(circle at 50% 70%, #f0f5ff 0%, transparent 50%),
    radial-gradient(circle at 30% 80%, #fff8f0 0%, transparent 50%),
    linear-gradient(180deg, #fef5f8 0%, #f6f0fc 30%, #f0f4ff 60%, #faf5f0 100%);
  color: var(--dark);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Subtle pixel-dot pattern overlay on body */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.06;
  background-image:
    radial-gradient(circle, #d0b0d0 1px, transparent 1px),
    radial-gradient(circle, #b0c0e0 1px, transparent 1px);
  background-size: 24px 24px, 32px 32px;
  background-position: 0 0, 12px 16px;
  image-rendering: pixelated;
}

/* --- Global Music Toggle --- */
.music-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 2000;
  width: clamp(36px, 9vw, 44px);
  height: clamp(36px, 9vw, 44px);
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.7);
  font-size: clamp(16px, 4vw, 22px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  line-height: 1;
}

.music-toggle:active {
  transform: scale(0.9);
}

.music-toggle.muted {
  background: rgba(200,200,200,0.5);
  border-color: rgba(0,0,0,0.08);
}

/* --- App Container --- */
#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ========================================
   开场动画覆盖层
   ======================================== */
#opening-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background:
    radial-gradient(circle at 20% 20%, #fff5f8 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, #f8f0ff 0%, transparent 50%),
    radial-gradient(circle at 50% 70%, #f0f5ff 0%, transparent 50%),
    radial-gradient(circle at 30% 80%, #fff8f0 0%, transparent 50%),
    linear-gradient(180deg, #fef5f8 0%, #f6f0fc 30%, #f0f4ff 60%, #faf5f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

/* Pixel-dot pattern matching body */
#opening-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  opacity: 0.06;
  background-image:
    radial-gradient(circle, #d0b0d0 1px, transparent 1px),
    radial-gradient(circle, #b0c0e0 1px, transparent 1px);
  background-size: 24px 24px, 32px 32px;
  background-position: 0 0, 12px 16px;
  image-rendering: pixelated;
}

#opening-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.opening-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 20px;
  pointer-events: all;
}

.opening-star-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.opening-star {
  font-size: clamp(20px, 5vw, 32px);
  animation: openingStarFloat 2s ease-in-out infinite alternate;
}

.opening-star:nth-child(2) {
  animation-delay: 0.4s;
  font-size: clamp(24px, 6vw, 36px);
}

.opening-star:nth-child(3) {
  animation-delay: 0.8s;
}

@keyframes openingStarFloat {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-12px) scale(1.15); }
}

.opening-title {
  font-family: var(--font-pixel);
  font-size: clamp(20px, 5.5vw, 36px);
  color: var(--dark);
  text-shadow:
    3px 3px 0px rgba(255, 179, 193, 0.6);
  margin-bottom: 12px;
  line-height: 1.7;
}

.opening-subtitle {
  font-family: var(--font-pixel);
  font-size: clamp(15px, 3.2vw, 20px);
  color: #7a6b8a;
  margin-bottom: 20px;
}

.opening-cake-icon {
  font-size: clamp(48px, 12vw, 72px);
  margin-bottom: 24px;
  animation: openingCakeBounce 1.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(255, 179, 193, 0.4));
}

@keyframes openingCakeBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-14px); }
  50% { transform: translateY(0); }
  70% { transform: translateY(-7px); }
  85% { transform: translateY(0); }
}

.opening-btn {
  font-size: clamp(14px, 3vw, 18px) !important;
  padding: 14px 32px !important;
  background: var(--pink) !important;
  border-color: #ff6b8a !important;
  color: #fff !important;
  text-shadow: 1px 1px 0px rgba(0,0,0,0.2) !important;
  margin-bottom: 12px;
}

.opening-hint {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 2.8vw, 18px);
  color: #9080a8;
}

/* --- Stage Visibility --- */
.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stage.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
}

/* Hide helper for non-stage elements（不影响 stage 动画） */
.el-hidden {
  display: none !important;
}

/* --- Pixel Font Titles --- */
.pixel-title {
  font-family: var(--font-pixel);
  font-size: clamp(18px, 4.5vw, 30px);
  text-align: center;
  color: var(--dark);
  text-shadow: 2px 2px 0px rgba(255,179,193,0.5);
  line-height: 1.8;
  padding: 10px 18px;
  letter-spacing: 0.5px;
}

.pixel-subtitle {
  font-family: var(--font-pixel);
  font-size: clamp(15px, 3.2vw, 20px);
  text-align: center;
  color: #7a6b8a;
  margin-top: 6px;
  letter-spacing: 0.3px;
}

/* --- Pixel Card --- */
.pixel-card {
  background: linear-gradient(180deg, #fffef8 0%, #fef8f0 40%, #fdf2e8 100%);
  border: 2px solid #e0c8b0;
  box-shadow:
    0 4px 0px #d4b896,
    0 6px 16px rgba(0,0,0,0.08);
  image-rendering: pixelated;
  position: relative;
  border-radius: 2px;
}

/* --- Pixel Buttons --- */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 2.8vw, 18px);
  background: linear-gradient(180deg, #ffc4d4 0%, #ffb3c1 40%, #f0a0b0 100%);
  color: var(--dark);
  border: 2px solid #e8879e;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow:
    0 3px 0px #d47085,
    0 4px 8px rgba(0,0,0,0.12);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.15s ease;
  image-rendering: pixelated;
  position: relative;
  white-space: nowrap;
  letter-spacing: 0.5px;
  border-radius: 2px;
}

.pixel-btn:hover {
  background: linear-gradient(180deg, #ffd4e0 0%, #ffc4d4 40%, #f5b5c5 100%);
  box-shadow:
    0 4px 0px #d47085,
    0 6px 12px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}

.pixel-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0px #d47085;
}

.pixel-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0px #d47085;
}

.pixel-btn:disabled:hover {
  background: linear-gradient(180deg, #ffc4d4 0%, #ffb3c1 40%, #f0a0b0 100%);
  transform: none;
}

/* --- Pulse Animation --- */
.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 3px 0px #d47085, 0 4px 8px rgba(0,0,0,0.12); }
  50% { transform: scale(1.04); box-shadow: 0 4px 0px #d47085, 0 8px 20px rgba(255,150,170,0.25); }
}

/* --- Stage Header --- */
.stage-header {
  text-align: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}

/* ========================================
   阶段零：回忆顺序揭示
   ======================================== */
#stage-memories {
  justify-content: center;
  padding: 20px 16px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

/* Background watermark hint */
#stage-memories::after {
  content: '点击任意位置继续';
  position: absolute;
  bottom: clamp(70px, 16vh, 110px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3.5vw, 22px);
  color: rgba(180, 160, 200, 0.22);
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
  animation: hintBlink 2s ease-in-out infinite;
}

.mem-counter {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 18px);
  color: #b0a0c0;
  margin-top: 4px;
}

.mem-sequential-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

.mem-card-reveal {
  background: linear-gradient(180deg, #fffef9 0%, #fef8f0 30%, #fdf2e8 100%);
  border: 2px solid #e8c8b8;
  box-shadow:
    0 4px 0px #d4b896,
    0 8px 24px rgba(0,0,0,0.06);
  padding: 28px 22px;
  width: 100%;
  text-align: center;
  border-radius: 2px;
  position: relative;
}

/* Decorative corner accents */
.mem-card-reveal::before,
.mem-card-reveal::after {
  content: '❤';
  position: absolute;
  font-size: 10px;
  color: #e8c0c0;
  opacity: 0.5;
}

.mem-card-reveal::before { top: 8px; left: 12px; }
.mem-card-reveal::after  { bottom: 8px; right: 12px; transform: rotate(180deg); }

.mem-title {
  font-family: var(--font-pixel);
  font-size: clamp(16px, 4vw, 26px);
  color: var(--dark);
  margin-bottom: 8px;
  line-height: 1.7;
}

.mem-date {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 18px);
  color: #a090b0;
  margin-bottom: 16px;
}

.mem-text {
  font-family: var(--font-pixel);
  font-size: clamp(15px, 3.2vw, 20px);
  line-height: 2;
  color: #4d3d5a;
  text-align: left;
}

.mem-media {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 2px solid var(--pink-dark);
  margin-bottom: 12px;
  image-rendering: pixelated;
}

.mem-hint {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 18px);
  color: #c0b0d0;
  text-align: center;
  padding: 14px 0;
  animation: hintBlink 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes hintBlink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes memFadeInUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.mem-btn-area {
  flex-shrink: 0;
  padding: 8px 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-to-game {
  font-size: clamp(9px, 1.8vw, 11px);
}

/* ========================================
   阶段一：跳跃游戏
   ======================================== */
#stage-jumpgame {
  background: #1a1a2e;
  overflow: hidden;
}
#stage-jumpgame::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  opacity: 0.08;
  background-image: radial-gradient(circle, #fff 1px, transparent 1px);
  background-size: 20px 20px;
  image-rendering: pixelated;
}

#game-canvas {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-ui {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.game-balloons-count {
  font-family: var(--font-pixel);
  font-size: clamp(10px, 2.2vw, 15px);
  color: white;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 6px;
}

.balloon-icon {
  font-size: clamp(14px, 3vw, 20px);
}

.game-progress {
  width: 40%;
  max-width: 200px;
}

.progress-bar {
  width: 100%;
  height: clamp(8px, 2vw, 12px);
  background: rgba(255,255,255,0.3);
  border: 2px solid white;
  image-rendering: pixelated;
}

.progress-fill {
  height: 100%;
  background: var(--pink);
  width: 0%;
  transition: width 0.2s;
}

/* --- Mobile Virtual Controls --- */
.mobile-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
  pointer-events: none;
  z-index: 30;
}

.mc-dpad {
  display: flex;
  gap: 8px;
  pointer-events: all;
}

.mc-btn {
  width: clamp(55px, 14vw, 75px);
  height: clamp(55px, 14vw, 75px);
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: clamp(18px, 4.5vw, 26px);
  font-family: var(--font-pixel);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: all;
}

.mc-btn:active {
  background: rgba(255,255,255,0.5);
  border-color: white;
}

.mc-jump {
  width: clamp(60px, 16vw, 85px);
  height: clamp(60px, 16vw, 85px);
  font-size: clamp(10px, 2.5vw, 14px);
  line-height: 1.2;
  text-align: center;
  pointer-events: all;
}

@media (min-width: 769px) {
  .mobile-controls {
    display: none;
  }
}

/* --- Game Start / End overlay --- */
.game-start-overlay,
.game-end-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 20;
  pointer-events: all;
}

.game-start-overlay .pixel-title,
.game-end-overlay .pixel-title {
  color: white;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
  margin-bottom: 16px;
}

/* ========================================
   阶段二：拼蛋糕
   ======================================== */
#stage-cakebuild {
  padding: 16px;
  justify-content: flex-start;
}

.cake-area {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
  min-height: 240px;
  width: 100%;
}

/* --- Elegant cake stand / pedestal --- */
.cake-plate {
  width: clamp(220px, 58vw, 360px);
  height: clamp(20px, 4vw, 32px);
  background: linear-gradient(180deg,
    #fdf5ec 0%, #f5e6d5 20%, #e8d5bc 50%, #dcc8a8 80%, #c8b090 100%);
  border: 2px solid #b89870;
  border-radius: 0 0 20px 20px;
  box-shadow:
    0 4px 0px #a08060,
    0 6px 16px rgba(0,0,0,0.12),
    inset 0 2px 0 rgba(255,255,255,0.4);
  position: relative;
  image-rendering: pixelated;
}

/* Plate rim highlight */
.cake-plate::before {
  content: '';
  position: absolute;
  top: 2px; left: 5%; right: 5%;
  height: 3px;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
}

/* Plate decorative edge */
.cake-plate::after {
  content: '';
  position: absolute;
  bottom: -6px; left: -4px; right: -4px;
  height: 8px;
  background: linear-gradient(180deg, #c8b090 0%, #b89870 50%, #a08060 100%);
  border-radius: 0 0 18px 18px;
  border: 2px solid #907050;
  border-top: none;
  z-index: -1;
}

.cake-layers-container {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.cake-layer {
  image-rendering: pixelated;
  animation: layerSlideIn 0.5s ease-out;
  position: relative;
}

/* ===== BASE LAYER: Rich chocolate sponge ===== */
.cake-layer-base {
  width: clamp(180px, 46vw, 300px);
  height: clamp(42px, 9vw, 60px);
  background:
    repeating-linear-gradient(
      90deg,
      #5a3020 0px, #69402e 4px, #583020 8px,
      #734a35 8px, #69402e 12px, #5a3020 16px
    );
  border: 2px solid #452015;
  border-radius: 4px;
  box-shadow:
    inset 0 6px 0 rgba(255,255,255,0.05),
    inset 0 -4px 8px rgba(0,0,0,0.25),
    0 1px 2px rgba(0,0,0,0.1);
}

/* Chocolate chip flecks */
.cake-layer-base::before {
  content: '';
  position: absolute;
  top: 8px; left: 12px; right: 12px; bottom: 8px;
  background:
    radial-gradient(circle 2px at 20px 8px, #3a1a0a 50%, transparent 50%),
    radial-gradient(circle 2px at 55px 14px, #3a1a0a 50%, transparent 50%),
    radial-gradient(circle 2px at 90px 6px, #3a1a0a 50%, transparent 50%),
    radial-gradient(circle 2px at 130px 10px, #3a1a0a 50%, transparent 50%),
    radial-gradient(circle 1.5px at 40px 18px, #3a1a0a 40%, transparent 50%),
    radial-gradient(circle 1.5px at 80px 20px, #3a1a0a 40%, transparent 50%),
    radial-gradient(circle 1.5px at 110px 15px, #3a1a0a 40%, transparent 50%),
    radial-gradient(circle 1.5px at 150px 8px, #3a1a0a 40%, transparent 50%);
  opacity: 0.6;
  pointer-events: none;
}

/* ===== CREAM LAYER: Vanilla buttercream with drips ===== */
.cake-layer-cream {
  width: clamp(190px, 48vw, 310px);
  height: clamp(30px, 7vw, 44px);
  background: linear-gradient(180deg,
    #fffefb 0%, #fefbf5 10%, #fdf7ed 30%,
    #faf3e4 55%, #f7edd6 80%, #f3e6cc 100%);
  border: 2px solid #d8c4a0;
  border-radius: 3px;
  box-shadow:
    inset 0 5px 0 rgba(255,255,255,0.95),
    inset 0 -3px 6px rgba(0,0,0,0.04),
    0 2px 0 rgba(0,0,0,0.03);
}

/* Cream swirl texture */
.cake-layer-cream::before {
  content: '';
  position: absolute;
  top: 6px; left: 8px; right: 8px; bottom: 6px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px, rgba(255,255,255,0.3) 2px,
      transparent 4px, rgba(0,0,0,0.02) 6px
    );
  pointer-events: none;
}

/* Frosting drip border - 5 drips */
.cake-layer-cream::after {
  content: '';
  position: absolute;
  bottom: -16px; left: -2px; right: -2px;
  height: 18px;
  background:
    /* Drip 1 */ linear-gradient(180deg, #faf3e4 0%, #f3e6cc 100%) 10px 0 / 14px 16px,
    /* Drip 2 */ linear-gradient(180deg, #faf3e4 0%, #f3e6cc 100%) 55px 0 / 10px 12px,
    /* Drip 3 */ linear-gradient(180deg, #faf3e4 0%, #f3e6cc 100%) 95px 0 / 18px 18px,
    /* Drip 4 */ linear-gradient(180deg, #faf3e4 0%, #f3e6cc 100%) 140px 0 / 12px 14px,
    /* Drip 5 */ linear-gradient(180deg, #faf3e4 0%, #f3e6cc 100%) 175px 0 / 15px 15px;
  background-repeat: no-repeat;
  border-radius: 0 0 4px 4px;
  border: 2px solid #d8c4a0; border-top: none;
  clip-path: inset(0 0 -4px 0);
}

/* ===== TOP LAYER: Golden vanilla sponge with piped pink frosting ===== */
.cake-layer-top {
  width: clamp(170px, 44vw, 280px);
  height: clamp(36px, 8vw, 52px);
  background: linear-gradient(180deg,
    #fef2d5 0%, #fde8bc 15%, #fadc9e 40%,
    #f6d088 65%, #f0c878 100%);
  border: 2px solid #c89840;
  border-radius: 6px 6px 0 0;
  box-shadow:
    inset 0 6px 0 rgba(255,255,255,0.3),
    inset 0 -2px 6px rgba(0,0,0,0.05);
  position: relative;
}

/* Frosting piping border - rosette scallops */
.cake-layer-top::before {
  content: '';
  position: absolute;
  top: -10px; left: -3px; right: -3px;
  height: 16px;
  background:
    radial-gradient(circle 7px at 10px 8px, #ffc0d0 40%, #f090a8 90%) 0 0,
    radial-gradient(circle 7px at 26px 8px, #ffceda 40%, #f5a0b5 90%) 16px 0,
    radial-gradient(circle 7px at 42px 8px, #ffc0d0 40%, #f090a8 90%) 32px 0,
    radial-gradient(circle 7px at 58px 8px, #ffceda 40%, #f5a0b5 90%) 48px 0;
  background-size: 64px 16px;
  background-repeat: repeat-x;
  border-radius: 10px 10px 0 0;
  border: 2px solid #e07090; border-bottom: none;
}

/* Surface texture */
.cake-layer-top::after {
  content: '';
  position: absolute;
  top: 5px; left: 10%; right: 10%;
  height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
}

@keyframes layerSlideIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Cake decorations */
.cake-decoration {
  position: absolute;
  font-size: clamp(24px, 6vw, 38px);
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(2px 3px 3px rgba(0,0,0,0.35));
  animation: decoPopIn 0.4s ease-out;
  z-index: 5;
}

@keyframes decoPopIn {
  from { transform: translate(-50%, -50%) scale(0); }
  to { transform: translate(-50%, -50%) scale(1); }
}

.cake-controls {
  width: 100%;
  max-width: 480px;
  padding: 12px 0;
  flex-shrink: 0;
}

.layer-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.layer-btn {
  font-size: clamp(10px, 2vw, 13px);
  padding: 10px 14px;
}

.layer-btn.completed {
  background: var(--mint);
  border-color: #7dcc9a;
  opacity: 0.7;
}

.decoration-panel {
  text-align: center;
  animation: fadeInUp 0.4s ease-out;
}

.deco-options {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.deco-btn {
  font-size: clamp(20px, 4.5vw, 30px);
  padding: 8px 10px;
  background: var(--cream);
  border-color: #d4c4b0;
  min-width: clamp(36px, 9vw, 48px);
}

.deco-btn.selected {
  background: #fff3cd;
  border-color: #ffc107;
  box-shadow: 0 0 16px rgba(255,193,7,0.5);
  transform: scale(1.1);
}

.deco-hint {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 2.8vw, 18px);
  color: #8b7b9a;
  margin-bottom: 8px;
}

@keyframes fadeInUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.deco-drop-zone {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(130px, 36vw, 220px);
  height: 100%;
  pointer-events: all;
  cursor: crosshair;
}

/* ========================================
   阶段三：关灯插蜡烛
   ======================================== */
#stage-candle {
  background: radial-gradient(ellipse at center, #2a1a3e 0%, #1a1025 60%, #0d0a18 100%);
}
#stage-candle::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  opacity: 0.1;
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1px),
    radial-gradient(circle, #ffb3c6 1px, transparent 1px);
  background-size: 30px 30px, 50px 50px;
  background-position: 0 0, 15px 20px;
  image-rendering: pixelated;
}

.candle-dark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 10;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.candle-dark-overlay.lights-on {
  opacity: 0;
}

.candle-cake-display {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.candle-cake-final {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.candle-cake-final .cake-layer-base,
.candle-cake-final .cake-layer-cream,
.candle-cake-final .cake-layer-top {
  animation: none;
}

.candle-flame-area {
  position: relative;
  margin-top: -4px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.candle-stick {
  width: 8px;
  height: 30px;
  background: linear-gradient(180deg, #fff 0%, #ffe0e0 30%, #ffb3c1 100%);
  border-radius: 0;
  image-rendering: pixelated;
}

.candle-flame {
  width: 16px;
  height: 20px;
  background: radial-gradient(ellipse at bottom, #ff6b35 0%, #ffb833 40%, #fff3b3 100%);
  border-radius: 50% 50% 30% 30%;
  animation: flameFlicker 0.3s ease-in-out infinite alternate;
  position: relative;
  top: -4px;
}

@keyframes flameFlicker {
  0% { transform: scaleX(1) scaleY(1); }
  25% { transform: scaleX(0.85) scaleY(1.1); }
  50% { transform: scaleX(1.1) scaleY(0.9); }
  75% { transform: scaleX(0.9) scaleY(1.05); }
  100% { transform: scaleX(1.05) scaleY(0.95); }
}

.candle-instruction {
  color: white;
  z-index: 15;
  margin-top: 20px;
  text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
  font-size: clamp(13px, 2.8vw, 18px);
}

.countdown-display {
  font-family: var(--font-pixel);
  font-size: clamp(50px, 12vw, 90px);
  color: var(--yellow);
  text-shadow: 3px 3px 0px rgba(0,0,0,0.5);
  z-index: 15;
  margin-top: 12px;
  animation: countdownBounce 0.8s ease-out;
}

@keyframes countdownBounce {
  0% { transform: scale(2); opacity: 0; }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.balloons-surround {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.surround-balloon {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  animation: balloonFloat 3s ease-in-out infinite alternate;
  pointer-events: none;
}

.surround-balloon-body {
  width: clamp(24px, 6vw, 40px);
  height: clamp(30px, 7.5vw, 50px);
  border-radius: 50% 50% 45% 45%;
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
}

/* Highlight on balloon */
.surround-balloon-body::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 25%;
  width: 25%;
  height: 20%;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
}

.surround-balloon-string {
  width: 2px;
  height: clamp(20px, 5vw, 30px);
  background: rgba(255,255,255,0.5);
  margin-top: -1px;
}

@keyframes balloonFloat {
  0% { transform: translateY(0px) rotate(-3deg); }
  100% { transform: translateY(-20px) rotate(3deg); }
}

.birthday-text {
  z-index: 15;
  margin-top: 20px;
  text-align: center;
}

.birthday-text h1 {
  font-family: var(--font-pixel);
  font-size: clamp(17px, 4.2vw, 28px);
  color: #fff;
  text-shadow:
    2px 2px 0px var(--pink),
    0 0 20px rgba(255,179,193,0.5);
  line-height: 1.8;
}

/* Draggable candle */
.draggable-candle {
  position: fixed;
  z-index: 20;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  touch-action: none;
  transform: translate(-50%, -50%);
}

.draggable-candle:active {
  cursor: grabbing;
}

/* Locked/placed state - candle stays exactly where dropped */
.draggable-candle.candle-placed {
  cursor: default;
  filter: drop-shadow(0 0 12px rgba(255,200,100,0.5));
  transition: filter 0.3s ease;
}

.drag-candle-stick {
  width: 10px;
  height: 36px;
  background: linear-gradient(180deg, #fff 0%, #ffe0e0 30%, #ffb3c1 100%);
  image-rendering: pixelated;
}

.drag-candle-flame {
  width: 20px;
  height: 24px;
  background: radial-gradient(ellipse at bottom, #ff6b35 0%, #ffb833 40%, #fff3b3 100%);
  border-radius: 50% 50% 30% 30%;
  animation: flameFlicker 0.3s ease-in-out infinite alternate;
  margin-bottom: -2px;
}

/* Drop zone highlight */
.drop-zone-highlight {
  outline: 3px dashed var(--yellow);
  outline-offset: 6px;
  border-radius: 8px;
}

/* ========================================
   阶段四：选礼物
   ======================================== */
#stage-giftbox {
  padding: 24px 16px;
}

.gift-boxes {
  display: flex;
  gap: clamp(12px, 4vw, 32px);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

.gift-box {
  width: clamp(90px, 22vw, 140px);
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s ease;
  position: relative;
}

.gift-box:hover {
  transform: translateY(-8px);
}

.gift-box:active {
  transform: scale(0.95);
}

.gift-box.opened {
  transform: scale(1.2);
  z-index: 10;
}

.gift-box.fading {
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.6s, transform 0.6s;
}

.gift-lid {
  width: 100%;
  height: clamp(16px, 4vw, 28px);
  background: linear-gradient(180deg, #f0e0d0 0%, #d4c4b0 100%);
  border: 3px solid #b8956e;
  border-radius: 4px 4px 0 0;
  margin-bottom: -2px;
  position: relative;
  z-index: 2;
  transition: transform 0.5s ease, opacity 0.5s ease;
  transform-origin: bottom right;
}

.gift-box.opening .gift-lid {
  transform: rotate(-25deg) translate(-10px, -10px);
}

.gift-body {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  image-rendering: pixelated;
}

.gift-ribbon {
  font-size: clamp(24px, 6vw, 40px);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.gift-label {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 18px);
  margin-top: 8px;
  color: var(--dark);
}

.gift-surprise {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(34px, 8vw, 56px);
  animation: surpriseReveal 0.8s ease-out;
  pointer-events: none;
  z-index: 20;
}

.gift-msg {
  font-family: var(--font-pixel);
  font-size: clamp(8px, 1.8vw, 12px);
  display: block;
  color: white;
  text-shadow: 1px 1px 0px rgba(0,0,0,0.5);
  margin-top: 4px;
  line-height: 1.8;
}

@keyframes surpriseReveal {
  0% { transform: translateX(-50%) scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.3) rotate(5deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 1; }
}

#btn-to-celebration {
  margin-top: 32px;
  animation: fadeInUp 0.6s ease-out;
}

/* ========================================
   阶段五：庆典终幕
   ======================================== */
#stage-celebration {
  background: radial-gradient(ellipse at center, #2a1a3e 0%, #1a1025 60%, #0d0a18 100%);
  overflow: hidden;
}
#stage-celebration::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
  opacity: 0.1;
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1px),
    radial-gradient(circle, #ffb3c6 1px, transparent 1px);
  background-size: 30px 30px, 50px 50px;
  background-position: 0 0, 15px 20px;
  image-rendering: pixelated;
}

#celebration-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.celebration-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

.celebration-overlay .pixel-btn {
  pointer-events: all;
}

.celebration-title {
  font-family: var(--font-pixel);
  font-size: clamp(18px, 5vw, 34px);
  color: #fff;
  text-shadow:
    3px 3px 0px var(--pink),
    0 0 30px rgba(255,179,193,0.5);
  line-height: 1.8;
  margin-bottom: 12px;
  animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0% { text-shadow: 3px 3px 0px var(--pink), 0 0 20px rgba(255,179,193,0.3); }
  100% { text-shadow: 3px 3px 0px var(--pink), 0 0 40px rgba(255,179,193,0.8), 0 0 60px rgba(179,217,255,0.5); }
}

.celebration-subtitle {
  font-family: var(--font-pixel);
  font-size: clamp(13px, 2.8vw, 20px);
  color: #e0d8ff;
  margin-bottom: 24px;
}

.balloons-celebration {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
  animation: balloonFloat 2s ease-in-out infinite alternate;
}

.cel-balloon {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cel-balloon-body {
  width: clamp(20px, 5vw, 32px);
  height: clamp(24px, 6vw, 40px);
  border-radius: 50% 50% 45% 45%;
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
}

.cel-balloon-body::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 25%;
  width: 25%;
  height: 20%;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
}

.cel-balloon-string {
  width: 2px;
  height: clamp(16px, 4vw, 24px);
  background: rgba(255,255,255,0.5);
  margin-top: -1px;
}

#btn-replay {
  font-size: clamp(8px, 1.5vw, 10px);
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.3);
  margin-top: 16px;
}

/* ========================================
   阶段：打气筒吹气球
   ======================================== */

#stage-balloonpump {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  gap: 16px;
}

.pump-header {
  text-align: center;
}

.pump-header .pixel-title {
  font-size: clamp(20px, 5vw, 34px);
  margin-bottom: 8px;
}

.pump-header .pixel-subtitle {
  font-size: clamp(12px, 2.8vw, 18px);
  color: #8b7b8b;
}

/* --- Pump Machine Area --- */
.pump-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 0 4px;
}

/* Balloon spawn zone - positioned above the pump nozzle */
.pump-balloon-spawn {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 260px;
  pointer-events: none;
  z-index: 5;
}

/* --- Individual Pump Balloon --- */
.pump-balloon {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: balloonFloatAway 2.8s ease-out forwards;
  pointer-events: none;
}

.pump-balloon-body {
  width: 36px;
  height: 44px;
  border-radius: 50% 50% 45% 45%;
  border: 2px solid rgba(255,255,255,0.4);
  position: relative;
  animation: balloonPopIn 0.35s ease-out;
}

.pump-balloon-body::after {
  content: '';
  position: absolute;
  top: 12%;
  left: 25%;
  width: 30%;
  height: 22%;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
}

.pump-balloon-string {
  width: 2px;
  height: 28px;
  background: rgba(180,180,180,0.6);
  margin-top: -1px;
  animation: balloonPopIn 0.35s ease-out;
}

@keyframes balloonPopIn {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.15); }
  80%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes balloonFloatAway {
  0%   { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  15%  { transform: translateX(-50%) translateY(-20px) scale(1.05); opacity: 1; }
  40%  { transform: translateX(calc(-50% + 30px)) translateY(-100px) scale(0.85); opacity: 0.9; }
  65%  { transform: translateX(calc(-50% - 20px)) translateY(-180px) scale(0.7); opacity: 0.6; }
  85%  { transform: translateX(calc(-50% + 10px)) translateY(-230px) scale(0.5); opacity: 0.3; }
  100% { transform: translateX(calc(-50% - 15px)) translateY(-270px) scale(0.35); opacity: 0; }
}

/* --- Pump Machine --- */
.pump-machine {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease;
  z-index: 10;
}

.pump-machine:active {
  transform: scale(0.97);
}

/* Handle bar - T-shaped top */
.pump-handle-bar {
  width: 64px;
  height: 14px;
  background: linear-gradient(180deg, #ffb3c6 0%, #e8879e 100%);
  border-radius: 7px;
  border: 3px solid #d4708a;
  box-shadow: 0 3px 6px rgba(0,0,0,0.15), inset 0 2px 0 rgba(255,255,255,0.4);
  z-index: 3;
  position: relative;
}

/* Handle rod */
.pump-handle-rod {
  width: 12px;
  height: 32px;
  background: linear-gradient(90deg, #d4708a, #e8879e, #d4708a);
  border-left: 2px solid #c0607a;
  border-right: 2px solid #c0607a;
  z-index: 2;
}

/* Body top cap */
.pump-body-top {
  width: 68px;
  height: 10px;
  background: linear-gradient(180deg, #f0d0d8, #e8b8c8);
  border-radius: 4px 4px 0 0;
  border: 3px solid #d4a0b0;
  border-bottom: none;
}

/* Main body */
.pump-body {
  width: 68px;
  height: 80px;
  background: linear-gradient(180deg, #ffe0ec 0%, #ffd0e0 30%, #ffc4d8 100%);
  border: 3px solid #d4a0b0;
  border-top: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Decorations on the body */
.pump-body-deco {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  pointer-events: none;
}

.pump-deco-star {
  animation: pumpDecoBounce 2s ease-in-out infinite;
}

.pump-deco-heart {
  animation: pumpDecoBounce 2s ease-in-out 0.5s infinite;
  font-size: 12px;
}

@keyframes pumpDecoBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Nozzle - where balloon comes out */
.pump-nozzle {
  position: absolute;
  right: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 16px;
  background: linear-gradient(90deg, #d4a0b0, #c090a0);
  border: 2px solid #b08090;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

.pump-nozzle-tip {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 10px;
  background: #b08090;
  border-radius: 50%;
}

/* Base */
.pump-base {
  width: 84px;
  height: 16px;
  background: linear-gradient(180deg, #ffb3c6 0%, #e8879e 100%);
  border-radius: 8px;
  border: 3px solid #d4708a;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
  margin-top: -1px;
}

/* Label text */
.pump-label {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: #d4708a;
  margin-top: 6px;
  letter-spacing: 2px;
  text-align: center;
}

/* --- Handle Press Animation --- */
@keyframes pumpPress {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(18px); }
  70%  { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

@keyframes pumpRodPress {
  0%   { transform: scaleY(1); }
  40%  { transform: scaleY(0.45); }
  70%  { transform: scaleY(1.08); }
  100% { transform: scaleY(1); }
}

/* --- Counter --- */
.pump-counter {
  font-size: clamp(16px, 3.5vw, 24px);
  color: #d4708a;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(212,112,138,0.2);
}

/* --- Hint --- */
.pump-hint {
  font-family: var(--font-pixel);
  font-size: clamp(11px, 2.2vw, 16px);
  color: #a090a0;
  text-align: center;
  min-height: 1.6em;
}

/* --- Go to game button --- */
#btn-to-game-from-pump {
  font-size: clamp(12px, 2.4vw, 16px);
}

/* ========================================
   响应式适配
   ======================================== */

@media (max-width: 480px) {
  .pixel-btn {
    padding: 8px 14px;
  }

  .gift-boxes {
    gap: 10px;
  }

  .memories-list {
    gap: 8px;
  }
}

@media (min-width: 768px) {
  .memories-list {
    max-width: 560px;
  }

  .cake-area {
    min-height: 280px;
  }
}

@media (min-width: 1024px) {
  #stage-memories {
    padding: 40px 24px;
  }

  .gift-box {
    max-width: 160px;
  }
}

/* --- Orientation warning for game --- */
.orientation-hint {
  display: none;
}

@media (orientation: landscape) and (max-height: 500px) {
  .orientation-hint {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 200;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: var(--font-pixel);
    font-size: 14px;
    text-align: center;
    flex-direction: column;
    gap: 16px;
  }
}
