/* ============================================================
   3D 粒子圣诞树 —— 界面样式
   配色：粉色 / 腮红粉 + 星空暗紫（整体纯粉节日氛围）
   ============================================================ */

:root {
  --pink: #ffb3d9;        /* 主粉 */
  --pink-soft: #ffe4f0;   /* 浅粉白 */
  --rose: #ff8fc4;        /* 玫瑰粉 */
  --plum: #7a2850;        /* 深梅粉 */
  --ink: #140718;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 62%, #3d1038 0%, #1c0822 42%, #0d0413 78%, #07020c 100%);
  color: var(--pink-soft);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* WebGL 画布铺满视口 */
#scene-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}
#scene-container canvas { display: block; }

/* ---------- 顶部标题 ---------- */
.top-title {
  position: fixed;
  top: 3.2vh;
  left: 0;
  right: 0;
  z-index: 10;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.merry-title {
  margin: 0;
  font-family: "Great Vibes", "Segoe Script", "Brush Script MT", cursive;
  font-size: clamp(2.6rem, 7vw, 6.4rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff2f9 0%, #ffb3d9 45%, #ff8cc4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 170, 215, 0.55))
          drop-shadow(0 0 30px rgba(255, 100, 175, 0.35));
  animation: title-float 6s ease-in-out infinite;
}

.subtitle {
  margin: 0.2rem 0 0;
  font-size: clamp(0.7rem, 1.5vw, 0.95rem);
  letter-spacing: 0.35em;
  color: rgba(255, 205, 230, 0.75);
  text-shadow: 0 0 14px rgba(255, 140, 195, 0.5);
}

@keyframes title-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ---------- 右侧手势数字 ---------- */
.hand-number {
  position: fixed;
  top: 50%;
  right: clamp(1rem, 9vw, 8rem);
  z-index: 12;
  transform: translateY(-50%) scale(0.6);
  font-family: "Great Vibes", cursive;
  font-size: clamp(7rem, 18vw, 16rem);
  line-height: 1;
  color: #fff0f8;
  text-shadow:
    0 0 10px rgba(255, 225, 245, 0.9),
    0 0 38px rgba(255, 150, 205, 0.75),
    0 0 80px rgba(255, 90, 170, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.hand-number.is-visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ---------- 相册页码（左上角）与操作提示（右上角），均不遮挡 3D 主体 ---------- */
.photo-page {
  position: fixed;
  top: 3.4vh;
  left: clamp(16px, 4vw, 48px);
  z-index: 12;
  font-family: "Great Vibes", cursive;
  font-size: clamp(2rem, 4.5vw, 3.6rem);
  line-height: 1;
  color: #fff2f9;
  letter-spacing: 0.04em;
  text-shadow:
    0 0 12px rgba(255, 225, 245, 0.9),
    0 0 34px rgba(255, 140, 200, 0.7);
  opacity: 0;
  transform: translateX(-14px);
  pointer-events: none;
  user-select: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.photo-page.is-visible { opacity: 1; transform: translateX(0); }

.album-tip {
  position: fixed;
  top: 4vh;
  right: clamp(16px, 4vw, 48px);
  z-index: 12;
  max-width: min(46vw, 380px);
  text-align: right;
  font-size: clamp(0.7rem, 1.4vw, 0.92rem);
  letter-spacing: 0.08em;
  color: rgba(255, 220, 240, 0.9);
  text-shadow: 0 0 14px rgba(255, 140, 195, 0.6);
  opacity: 0;
  transform: translateX(14px);
  pointer-events: none;
  user-select: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.album-tip.is-visible { opacity: 1; transform: translateX(0); }

/* ---------- 背景音乐开关（右上角，可拖动，小巧不遮挡主体） ---------- */
.music-toggle {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 31; /* 高于启动面板(30)，首屏即可点击解锁音频 */
  width: 46px;
  height: 46px;
  touch-action: none; /* 允许拖动，避免移动端滚动干扰 */
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 190, 224, 0.35);
  border-radius: 50%;
  background: rgba(52, 14, 44, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 205, 232, 0.55);
  cursor: pointer;
  transition: color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease, transform 0.25s ease;
  user-select: none;
}
.music-toggle:hover {
  transform: scale(1.08);
  border-color: rgba(255, 190, 224, 0.7);
  color: rgba(255, 225, 242, 0.9);
}
.music-toggle .music-note {
  font-size: 1.4rem;
  line-height: 1;
  transform: translateY(-1px);
}
.music-toggle.is-on {
  color: #fff0f8;
  border-color: rgba(255, 170, 215, 0.85);
  box-shadow: 0 0 14px rgba(255, 140, 200, 0.55), 0 0 30px rgba(255, 120, 190, 0.3);
}
.music-toggle.is-on .music-note {
  animation: music-beat 1.8s ease-in-out infinite;
}
@keyframes music-beat {
  0%, 100% { transform: translateY(-1px) scale(1); opacity: 1; }
  50%      { transform: translateY(-1px) scale(1.12); opacity: 0.85; }
}

/* ---------- 底部状态栏 ---------- */
.hud {
  position: fixed;
  bottom: 2.4vh;
  left: 0;
  right: 0;
  z-index: 10;
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.gesture-label {
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  letter-spacing: 0.12em;
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 150, 205, 0.55);
}
.gesture-help {
  margin-top: 0.45rem;
  font-size: clamp(0.65rem, 1.2vw, 0.8rem);
  letter-spacing: 0.06em;
  color: rgba(255, 205, 228, 0.45);
}

/* ---------- 摄像头源（视觉隐藏，仅用于识别） ----------
 * 重要：不能 display:none / visibility:hidden / 0 尺寸——移动端会暂停 video 解码导致黑帧、识别失效。
 * 用 opacity:0 保留元素在渲染树与合成层，video 正常出帧，但用户完全看不到预览。 */
.preview-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: -1;
  width: 240px;
  height: 180px;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
.preview-wrap.is-hidden { opacity: 0; }
.hand-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
#hand-preview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.camera-switch, .preview-tag, .detect-hud { display: none; }
/* ---------- 启动面板 ---------- */
.start-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 2, 12, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.start-panel.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-card {
  width: min(440px, 100%);
  padding: 30px 32px 26px;
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(160deg, rgba(102, 20, 66, 0.85), rgba(34, 8, 32, 0.92));
  border: 1px solid rgba(255, 190, 225, 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 45px rgba(255, 100, 175, 0.12);
}
.start-ornament { font-size: 2.8rem; filter: drop-shadow(0 0 14px rgba(255, 150, 205, 0.55)); }
.start-card h2 {
  margin: 10px 0 4px;
  font-size: 1.45rem;
  letter-spacing: 0.06em;
  color: var(--pink);
  text-shadow: 0 0 16px rgba(255, 160, 210, 0.45);
}
.start-desc { margin: 0 0 18px; font-size: 0.85rem; color: rgba(255, 220, 240, 0.65); }

.gesture-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  text-align: left;
  font-size: 0.85rem;
}
.gesture-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  border-bottom: 1px dashed rgba(255, 200, 230, 0.14);
  color: rgba(255, 235, 245, 0.82);
}
.gesture-list .key {
  flex: 0 0 52px;
  text-align: center;
  padding: 3px 0;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #4a0e30;
  font-weight: 700;
  background: linear-gradient(135deg, #ffd9ec, #ffb0d2);
  box-shadow: 0 0 12px rgba(255, 160, 210, 0.35);
}

#start-btn {
  width: 100%;
  padding: 12px 0;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #4a0e30;
  background: linear-gradient(135deg, #ffe0f0 0%, #ffb8dc 50%, #ff93c6 100%);
  box-shadow: 0 8px 26px rgba(255, 140, 195, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#start-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(255, 140, 195, 0.5); }
#start-btn:active { transform: translateY(0); }
.skip-btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 10px 0;
  border: 1px dashed rgba(255, 190, 225, 0.4);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--pink);
  background: rgba(255, 160, 210, 0.06);
  transition: background 0.2s ease;
}
.skip-btn:active { background: rgba(255, 160, 210, 0.22); }

.start-note {
  margin: 14px 0 0;
  font-size: 0.7rem;
  line-height: 1.6;
  color: rgba(255, 210, 235, 0.55);
}
.start-note.is-error { color: #ff9ab0; }

/* ---------- 无障碍：减少动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  .merry-title { animation: none; }
  .hand-number, .preview-wrap, .start-panel { transition-duration: 0.01ms; }
  .music-toggle.is-on .music-note { animation: none; }
}
