/* ====================================================
   全场景浪漫互动卡片 · 电影级沉浸式视觉样式库 V3.0
   ==================================================== */

:root {
  --primary-pink: #ff4d79;
  --primary-gradient: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
  --gold-gradient: linear-gradient(135deg, #ffe066 0%, #f77f00 100%);
  --bg-gradient: radial-gradient(circle at 50% 10%, #201138 0%, #090514 100%);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.75);
}

* {
  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, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
}

/* 动效 Canvas */
#bg-canvas, #fireworks-canvas, #trail-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#bg-canvas { z-index: 1; }
#trail-canvas { z-index: 98; }
#fireworks-canvas { z-index: 99; }

/* 核心移动端容器 */
.app-container {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom)) 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 序章：信封拆封遮罩层 */
.envelope-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #2d1847 0%, #0d0617 100%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
  padding: 24px;
}

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

.envelope-box {
  width: 280px;
  height: 200px;
  background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(255, 77, 121, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  animation: floatEnvelope 3s ease-in-out infinite;
}

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

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

.envelope-seal {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #ffd166;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  margin-bottom: 12px;
}

.envelope-text {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.envelope-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 6px;
  animation: pulseHint 1.5s infinite;
}

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

/* 顶部悬浮控制栏 */
.top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.theme-badge {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  color: #ff9ebb;
  letter-spacing: 1px;
}

.music-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.music-btn.playing {
  animation: rotateDisc 4s linear infinite;
  border-color: var(--primary-pink);
  box-shadow: 0 0 16px rgba(255, 77, 121, 0.4);
}

.music-btn svg { width: 18px; height: 18px; fill: #fff; }
@keyframes rotateDisc { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 通用玻璃拟态卡片 */
.glass-card {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.section-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #ff9ebb;
  margin-bottom: 6px;
  display: inline-block;
}

.main-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #ffbcd4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 计时器与宇宙指标 */
.timer-box {
  text-align: center;
  margin: 16px 0;
}

.timer-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.timer-days {
  font-size: 54px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  line-height: 1;
  text-shadow: 0 6px 24px rgba(255, 117, 140, 0.35);
}

.timer-days-unit {
  font-size: 16px;
  color: var(--primary-pink);
  margin-left: 4px;
  font-weight: 700;
}

.timer-subunits {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.subunit-pill {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 12px;
  border-radius: 12px;
  color: var(--text-muted);
}

.subunit-pill span {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  margin-right: 2px;
}

.cosmic-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.metric-item { text-align: center; }
.metric-val { font-size: 16px; font-weight: 700; color: #ffd166; }
.metric-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* 专属亲口语音胶囊 (Voice Message Bar) */
.voice-capsule-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 14px 18px;
  margin-top: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.voice-capsule-card:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.12);
}

.voice-play-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255, 77, 121, 0.4);
}

.voice-play-icon svg { width: 18px; height: 18px; fill: #fff; }

.voice-meta {
  flex: 1;
}

.voice-sender {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
  height: 14px;
}

.waveform-bar {
  width: 3px;
  height: 6px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  transition: height 0.2s ease;
}

.voice-capsule-card.playing .waveform-bar {
  background: #ff758c;
  animation: wavePulse 1s ease-in-out infinite alternate;
}

.voice-capsule-card.playing .waveform-bar:nth-child(1) { animation-delay: 0.1s; }
.voice-capsule-card.playing .waveform-bar:nth-child(2) { animation-delay: 0.3s; }
.voice-capsule-card.playing .waveform-bar:nth-child(3) { animation-delay: 0.5s; }
.voice-capsule-card.playing .waveform-bar:nth-child(4) { animation-delay: 0.2s; }
.voice-capsule-card.playing .waveform-bar:nth-child(5) { animation-delay: 0.4s; }
.voice-capsule-card.playing .waveform-bar:nth-child(6) { animation-delay: 0.6s; }

@keyframes wavePulse {
  0% { height: 4px; }
  100% { height: 14px; }
}

.voice-duration {
  font-size: 12px;
  color: var(--text-muted);
}

/* 弹性自适应照片放映室 (支持 1~9 张) */
.photo-stream-container {
  width: 100%;
  overflow-x: auto;
  padding: 10px 0 20px 0;
  display: flex;
  gap: 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.photo-stream-container::-webkit-scrollbar { display: none; }

.polaroid-card {
  flex: 0 0 260px;
  scroll-snap-align: center;
  background: #ffffff;
  padding: 12px 12px 20px 12px;
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
  transform: rotate(-1deg);
  transition: transform 0.3s ease;
}

.polaroid-card:nth-child(even) { transform: rotate(1.5deg); }

.polaroid-img-box {
  width: 100%;
  height: 240px;
  border-radius: 6px;
  overflow: hidden;
  background: #eee;
}

.polaroid-img-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.polaroid-meta {
  margin-top: 12px;
  text-align: center;
}

.polaroid-caption {
  font-size: 14px;
  color: #2b2b2b;
  font-weight: 600;
}

.polaroid-date {
  font-size: 11px;
  color: #888888;
  margin-top: 3px;
}

/* 打字机情书 */
.letter-box {
  line-height: 1.85;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.92);
  min-height: 100px;
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 16px;
  background-color: var(--primary-pink);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 0.8s infinite;
}

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

/* 多张自定义愿望/特权兑换券网格与核销印章 */
.coupons-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.coupon-ticket {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.05) 100%);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.coupon-info {
  flex: 1;
}

.coupon-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffd166;
  margin-bottom: 4px;
}

.coupon-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.coupon-use-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 77, 121, 0.35);
  transition: all 0.2s ease;
}

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

/* 核销盖章特效 */
.coupon-stamp {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%) rotate(-15deg) scale(2);
  border: 3px solid #ff4d79;
  color: #ff4d79;
  font-size: 14px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 2px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.coupon-ticket.redeemed {
  opacity: 0.8;
  border-color: rgba(255, 77, 121, 0.4);
}

.coupon-ticket.redeemed .coupon-use-btn {
  display: none;
}

.coupon-ticket.redeemed .coupon-stamp {
  opacity: 1;
  transform: translateY(-50%) rotate(-15deg) scale(1);
}

/* 按钮组 */
.btn-group-dual {
  width: 100%;
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.btn-group-dual button {
  flex: 1;
}

.poster-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 16px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.interactive-action-btn {
  width: 100%;
  padding: 16px;
  border-radius: 20px;
  border: none;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 10px 24px rgba(255, 77, 121, 0.4);
  cursor: pointer;
  transition: all 0.25s ease;
}

.interactive-action-btn:active, .poster-btn:active {
  transform: scale(0.97);
}

/* 海报预览模态弹窗 */
.poster-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.poster-modal.active {
  display: flex;
}

.poster-img-preview {
  max-width: 85%;
  max-height: 70vh;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.poster-close-btn {
  margin-top: 16px;
  padding: 10px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 14px;
  cursor: pointer;
}

.footer-credits {
  margin-top: 24px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}
