:root {
  --primary-color: #ff5e7e;
  --secondary-color: #ff9966;
  --gold-color: #ffd700;
  --bg-gradient: radial-gradient(circle at 50% 20%, #2c1654 0%, #130924 60%, #07030d 100%);
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.18);
  --text-main: #ffffff;
  --text-sub: #f0d5ff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  user-select: none;
}

#bg-canvas, #fireworks-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#fireworks-canvas {
  z-index: 10;
  pointer-events: none;
}

/* 漂浮弹幕层 */
.barrage-container {
  position: fixed;
  top: 20px;
  left: 0;
  width: 100%;
  height: 140px;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}

.barrage-item {
  position: absolute;
  white-space: nowrap;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  animation: barrageSlide linear forwards;
}

@keyframes barrageSlide {
  from {
    transform: translateX(100vw);
  }
  to {
    transform: translateX(-100%);
  }
}

/* 顶部音效控制悬浮球 */
.audio-control {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.audio-control.playing {
  animation: rotateDisc 4s linear infinite;
  border-color: #ff758c;
  box-shadow: 0 0 15px rgba(255, 117, 140, 0.6);
}

@keyframes rotateDisc {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 主内容容器 */
.main-wrapper {
  position: relative;
  z-index: 20;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
}

/* 阶段容器淡入淡出过渡 */
.stage {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 680px;
  animation: fadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  text-align: center;
}

.stage.active {
  display: flex;
}

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

/* 阶段 1：礼盒封面 */
.gift-box-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.gift-box {
  width: 150px;
  height: 150px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
  animation: gentleBounce 2.5s ease-in-out infinite;
}

.gift-box:hover {
  transform: scale(1.08);
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-15px) rotate(2deg); }
}

.gift-lid {
  width: 160px;
  height: 38px;
  background: linear-gradient(135deg, #ff4e50, #f9d423);
  position: absolute;
  top: 0;
  left: -5px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(255, 78, 80, 0.4);
  z-index: 2;
  transition: transform 0.5s ease;
}

.gift-body {
  width: 140px;
  height: 110px;
  background: linear-gradient(135deg, #f857a6, #ff5858);
  position: absolute;
  bottom: 0;
  left: 5px;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35);
}

.gift-ribbon-v {
  width: 26px;
  height: 100%;
  background: linear-gradient(to right, #ffd700, #fff275, #ffd700);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.gift-ribbon-h {
  width: 100%;
  height: 24px;
  background: linear-gradient(to bottom, #ffd700, #fff275, #ffd700);
  position: absolute;
  top: 40%;
}

.gift-bow {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.3));
}

.gift-tag {
  margin-top: 35px;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-sub);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  line-height: 1.6;
}

.pulse-btn {
  margin-top: 25px;
  padding: 14px 38px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  box-shadow: 0 8px 25px rgba(255, 65, 108, 0.5);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulseGlow 2s infinite;
}

.pulse-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 65, 108, 0.7);
}

.pulse-btn:active {
  transform: scale(0.96);
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(255, 75, 43, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(255, 75, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 75, 43, 0); }
}

/* 阶段 2：生日蛋糕与许愿 */
.cake-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin: 30px 0;
}

.cake {
  position: relative;
  width: 220px;
  height: 170px;
}

.cake-plate {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  height: 16px;
  background: radial-gradient(ellipse at center, #eee 0%, #b8b8b8 100%);
  border-radius: 50%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.cake-layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 12px 12px 6px 6px;
}

.layer-bottom {
  bottom: 0;
  width: 210px;
  height: 65px;
  background: linear-gradient(to right, #6d3319, #8d4825, #6d3319);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.3);
}

.layer-middle {
  bottom: 55px;
  width: 165px;
  height: 55px;
  background: linear-gradient(to right, #ff8da1, #ffa8b8, #ff8da1);
}

.layer-top {
  bottom: 102px;
  width: 120px;
  height: 45px;
  background: linear-gradient(to right, #fff1eb, #ace0f9, #fff1eb);
  border-radius: 10px 10px 4px 4px;
}

.frosting-drips {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 12px;
  background: #ffffff;
  border-radius: 8px 8px 4px 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.strawberry {
  position: absolute;
  font-size: 22px;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
}

/* 蜡烛 */
.candle {
  position: absolute;
  bottom: 142px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 48px;
  background: repeating-linear-gradient(45deg, #ffffff, #ffffff 6px, #ff416c 6px, #ff416c 12px);
  border-radius: 5px;
  cursor: pointer;
}

.candle-flame {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 24px;
  background: radial-gradient(ellipse at bottom, #fff7a0 0%, #ff8300 65%, rgba(255, 0, 0, 0.2) 100%);
  border-radius: 50% 50% 35% 35%;
  animation: flicker 1s infinite alternate ease-in-out;
  box-shadow: 0 0 16px #ffbe0b, 0 0 32px #fb5607;
  cursor: pointer;
}

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

@keyframes flicker {
  0% { transform: translateX(-50%) rotate(-2deg) scale(1); }
  50% { transform: translateX(-50%) rotate(2deg) scale(1.08, 0.95); }
  100% { transform: translateX(-50%) rotate(-1deg) scale(0.95, 1.05); }
}

.smoke-puff {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  opacity: 0;
  color: #ccc;
  pointer-events: none;
}

.smoke-puff.show {
  animation: riseSmoke 1.5s forwards ease-out;
}

@keyframes riseSmoke {
  0% { opacity: 0.8; transform: translateX(-50%) translateY(0) scale(0.8); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-35px) scale(1.6); }
}

/* 阶段 3：祝福长卷卡片 */
.wishes-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 35px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), inset 0 0 15px rgba(255, 255, 255, 0.05);
  margin-bottom: 25px;
}

.badge {
  display: inline-block;
  padding: 6px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 94, 126, 0.25), rgba(255, 153, 102, 0.25));
  border: 1px solid rgba(255, 153, 102, 0.4);
  color: #ffb88c;
  margin-bottom: 15px;
  text-transform: uppercase;
}

.target-greeting {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #ffcad4 50%, #ff9a9e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.sub-title {
  font-size: 1.1rem;
  color: var(--text-sub);
  margin-bottom: 25px;
  line-height: 1.6;
}

.divider {
  width: 60px;
  height: 3px;
  background: linear-gradient(to right, #ff758c, #ff7eb3);
  margin: 0 auto 25px auto;
  border-radius: 2px;
}

.letter-content {
  text-align: left;
  font-size: 1.05rem;
  line-height: 2;
  color: #eae6f4;
  min-height: 160px;
  margin-bottom: 20px;
  word-break: break-word;
}

.letter-content p {
  margin-bottom: 12px;
  transition: opacity 0.4s ease;
}

.typing-cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background-color: #ff758c;
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink 0.8s infinite;
}

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

/* 照片墙 / 轮播区 */
.photo-gallery {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin: 25px 0 10px 0;
}

.photo-card {
  width: 140px;
  background: #ffffff;
  padding: 8px 8px 18px 8px;
  border-radius: 6px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  transform: rotate(-3deg);
  transition: transform 0.3s ease;
}

.photo-card:nth-child(even) {
  transform: rotate(3deg);
}

.photo-card:hover {
  transform: scale(1.1) rotate(0deg);
  z-index: 5;
}

.photo-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 4px;
}

.photo-caption {
  margin-top: 6px;
  font-size: 11px;
  color: #555;
  text-align: center;
  font-weight: 500;
}

/* 底部互动操作栏 */
.action-bar {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 15px;
}

.btn-secondary {
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-secondary:active {
  transform: scale(0.95);
}

.btn-firework {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.3), rgba(255, 159, 67, 0.3));
  border-color: #ff9f43;
  color: #ffeaa7;
}

.btn-firework:hover {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.5), rgba(255, 159, 67, 0.5));
  box-shadow: 0 4px 15px rgba(255, 159, 67, 0.4);
}

/* 屏幕点击放烟花提示小徽标 */
.screen-tap-tip {
  margin-top: 15px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  animation: pulseOpacity 2s infinite ease-in-out;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.85; }
}

/* 移动端适配 */
@media (max-width: 480px) {
  .target-greeting {
    font-size: 1.8rem;
  }
  .wishes-card {
    padding: 26px 18px;
  }
  .letter-content {
    font-size: 0.98rem;
    line-height: 1.85;
  }
  .pulse-btn {
    padding: 12px 30px;
    font-size: 1rem;
  }
}
