/* ==========================================================================
   哥哥送给妹妹 · 隔空手势 3D 生日烛光梦境
   极简高颜值轻奢温柔生日风（手机竖屏 390×844 优先，零外链字体）
   ========================================================================== */

:root {
  --bg-top: #160e14;
  --bg-mid: #261621;
  --bg-bottom: #3c2224;

  --gold-champagne: #ffe3b0;
  --pearl-white: #fff8f0;
  --sakura-pink: #ffc2cf;
  --peach-glow: #ff9eb0;

  --glass-bg: rgba(34, 19, 27, 0.56);
  --glass-border: rgba(255, 227, 176, 0.22);
  --text-primary: #fff8f0;
  --text-soft: rgba(255, 240, 228, 0.76);
  --text-muted: rgba(255, 227, 176, 0.58);

  --serif-stack: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-top);
  color: var(--text-primary);
  font-family: var(--serif-stack);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   暖暮烛光多层氛围背景（关掉大灯、刚点亮蜡烛那一刻）
   -------------------------------------------------------------------------- */
.candlelight-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(68% 46% at 50% 88%, rgba(255, 168, 120, 0.20) 0%, rgba(60, 34, 36, 0.12) 48%, transparent 100%),
    radial-gradient(56% 42% at 50% 48%, rgba(255, 206, 152, 0.09) 0%, transparent 72%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 56%, var(--bg-bottom) 100%);
  pointer-events: none;
}

.candlelight-bloom {
  position: fixed;
  left: 50%;
  bottom: 16%;
  width: 78vw;
  max-width: 420px;
  height: 44vh;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 205, 148, 0.14) 0%, rgba(255, 158, 176, 0.05) 45%, transparent 72%);
  filter: blur(26px);
  animation: candleBreath 5.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes candleBreath {
  0%, 100% {
    opacity: 0.72;
    transform: translateX(-50%) scale(0.96);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.06);
  }
}

/* Three.js 全屏画布 */
#dream-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  cursor: grab;
}

#dream-canvas:active {
  cursor: grabbing;
}

/* --------------------------------------------------------------------------
   开场封面：柔光烛影中的奶油白封缄卡片
   -------------------------------------------------------------------------- */
.cover-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 44%, rgba(38, 22, 33, 0.56) 0%, rgba(22, 14, 20, 0.84) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1), transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.cover-layer.is-leaving {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.envelope-card {
  position: relative;
  width: 100%;
  max-width: 332px;
  padding: 40px 28px 32px;
  border-radius: 22px;
  background: linear-gradient(168deg, #fffbf6 0%, #f9efe3 62%, #f4e6d7 100%);
  color: #462f2c;
  text-align: center;
  box-shadow:
    0 24px 64px rgba(10, 4, 8, 0.58),
    0 0 42px rgba(255, 212, 160, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(214, 179, 128, 0.65);
  overflow: hidden;
  animation: cardFloatIn 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardFloatIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 卡片内层极细香槟金压纹边框 */
.envelope-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 14px;
  border: 1px solid rgba(208, 169, 114, 0.36);
  pointer-events: none;
}

/* 顶部暖金封缄火漆印章 */
.wax-seal {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 35% 32%, #f6d8a8 0%, #d4a46a 62%, #b5834b 100%);
  box-shadow:
    0 6px 18px rgba(181, 131, 75, 0.36),
    inset 0 1px 3px rgba(255, 248, 232, 0.85);
  color: #fffaf2;
}

.wax-seal svg {
  width: 22px;
  height: 22px;
}

.cover-eyebrow {
  font-size: 13px;
  letter-spacing: 0.24em;
  color: #9e7552;
  margin-bottom: 10px;
}

.cover-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.08em;
  color: #3a2322;
  margin-bottom: 16px;
}

.cover-divider {
  width: 42px;
  height: 1px;
  margin: 0 auto 16px;
  background: linear-gradient(90deg, transparent, #d4ab74, transparent);
}

.cover-subtitle {
  font-size: 13.5px;
  line-height: 1.85;
  color: #6d4f47;
  margin-bottom: 18px;
  padding: 0 4px;
}

.cover-signature {
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: #9b765b;
  margin-bottom: 26px;
}

.open-dream-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 22px;
  border: 1px solid rgba(255, 227, 176, 0.55);
  border-radius: 999px;
  background: linear-gradient(135deg, #3b222a 0%, #583138 52%, #754443 100%);
  color: #fff6e8;
  font-family: var(--serif-stack);
  font-size: 15px;
  letter-spacing: 0.14em;
  cursor: pointer;
  box-shadow:
    0 10px 26px rgba(59, 34, 42, 0.34),
    inset 0 1px 0 rgba(255, 227, 176, 0.35);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.open-dream-btn:active {
  transform: scale(0.97);
}

.btn-spark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-champagne);
  box-shadow: 0 0 10px var(--gold-champagne);
}

.cover-hint {
  margin-top: 14px;
  font-size: 11px;
  line-height: 1.6;
  color: #a18272;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   主界面极简轻奢 HUD（零监控框、零骨架、零杂乱按钮）
   -------------------------------------------------------------------------- */
.hud-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.85s ease 0.15s;
}

.hud-layer.is-ready {
  opacity: 1;
}

/* 顶部状态栏：左暖金呼吸光点 + 右旋转微光音乐开关 */
.top-bar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.magic-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(28, 16, 23, 0.38);
  border: 1px solid rgba(255, 227, 176, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.magic-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-champagne);
  box-shadow: 0 0 8px rgba(255, 227, 176, 0.9), 0 0 16px rgba(255, 194, 207, 0.45);
  animation: dotPulse 2.4s ease-in-out infinite;
}

.magic-dot[data-state="fallback"] {
  background: var(--sakura-pink);
  box-shadow: 0 0 8px rgba(255, 194, 207, 0.8);
  animation-duration: 3.4s;
}

@keyframes dotPulse {
  0%, 100% {
    opacity: 0.52;
    transform: scale(0.88);
  }
  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

.magic-label {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: rgba(255, 240, 226, 0.82);
}

/* 右上角极简旋转微光音乐开关 */
.music-toggle {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 227, 176, 0.28);
  background: rgba(34, 19, 27, 0.48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gold-champagne);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 227, 176, 0.12);
  transition: transform 0.2s ease, border-color 0.25s ease;
}

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

.music-toggle svg {
  width: 17px;
  height: 17px;
}

.music-toggle.is-playing {
  border-color: rgba(255, 227, 176, 0.56);
  box-shadow: 0 0 22px rgba(255, 227, 176, 0.26);
}

.music-toggle.is-playing .music-disc {
  animation: spinDisc 7s linear infinite;
}

.music-toggle:not(.is-playing) {
  opacity: 0.56;
}

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

/* 顶部温柔诗意标题 */
.mode-header {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  left: 24px;
  right: 24px;
  text-align: center;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.hud-layer.is-photo-focused .mode-header {
  opacity: 0;
  transform: translateY(-8px);
}

.mode-title {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--pearl-white);
  text-shadow: 0 2px 18px rgba(255, 210, 165, 0.34);
  margin-bottom: 6px;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.mode-subtitle {
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  max-width: 310px;
  margin: 0 auto;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.mode-title.is-switching,
.mode-subtitle.is-switching {
  opacity: 0;
  transform: translateY(4px);
}

/* 轻量微光浮层提示 */
.gentle-toast {
  position: absolute;
  top: calc(134px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -6px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(34, 19, 27, 0.68);
  border: 1px solid rgba(255, 227, 176, 0.22);
  color: var(--gold-champagne);
  font-size: 12px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.gentle-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   拍立得照片聚焦时的电影感暖心回忆字幕
   -------------------------------------------------------------------------- */
.photo-subtitle-panel {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  margin: 0 auto;
  max-width: 350px;
  padding: 18px 20px 15px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(32, 18, 26, 0.68) 0%, rgba(22, 13, 19, 0.84) 100%);
  border: 1px solid rgba(255, 227, 176, 0.26);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  box-shadow: 0 14px 40px rgba(8, 3, 7, 0.45);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1), transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.photo-subtitle-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.subtitle-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.subtitle-tag {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--gold-champagne);
  opacity: 0.85;
}

.subtitle-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--sakura-pink);
}

.subtitle-title {
  font-size: 13.5px;
  letter-spacing: 0.1em;
  color: var(--sakura-pink);
}

.subtitle-caption {
  font-size: 14.5px;
  line-height: 1.85;
  letter-spacing: 0.05em;
  color: var(--pearl-white);
  margin-bottom: 10px;
}

.subtitle-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 227, 176, 0.12);
  font-size: 11px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   底部极轻薄半透明毛玻璃胶囊 + 可折叠手势图例
   -------------------------------------------------------------------------- */
.bottom-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

/* 可折叠手势魔法图例卡 */
.gesture-legend {
  pointer-events: none;
  width: 100%;
  max-width: 326px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(29, 17, 24, 0.82);
  border: 1px solid rgba(255, 227, 176, 0.22);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 14px 36px rgba(8, 3, 7, 0.48);
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.gesture-legend.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.legend-header {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold-champagne);
  text-align: center;
  margin-bottom: 10px;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.4;
}

.legend-item.legend-wide {
  grid-column: span 2;
}

.legend-emoji {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* 底部极简毛玻璃胶囊 */
.glass-capsule {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 6px;
  max-width: calc(100vw - 24px);
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 10px 30px rgba(8, 3, 7, 0.42),
    inset 0 1px 0 rgba(255, 244, 226, 0.12);
}

.capsule-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 35px;
  padding: 0 9px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 240, 226, 0.76);
  font-family: var(--serif-stack);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.18s ease;
}

.capsule-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.capsule-btn:active {
  transform: scale(0.94);
}

.capsule-btn.is-active {
  background: linear-gradient(135deg, rgba(255, 227, 176, 0.24) 0%, rgba(255, 194, 207, 0.18) 100%);
  color: var(--gold-champagne);
  box-shadow: inset 0 0 0 1px rgba(255, 227, 176, 0.28);
}

.capsule-divider {
  width: 1px;
  height: 16px;
  margin: 0 2px;
  background: rgba(255, 227, 176, 0.18);
}

.capsule-icon-only {
  padding: 0 9px;
}

@media (max-width: 360px) {
  .capsule-btn {
    padding: 0 7px;
    font-size: 10.5px;
  }
  .mode-title {
    font-size: 19px;
  }
}
