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

:root {
  --cream: #fdf3e3;        /* 奶油杏色背景 */
  --cream-deep: #f7e3c3;
  --accent: #e8895c;       /* 暖橙 */
  --accent-dark: #d4703f;
  --text: #5b4636;
  --gold: #f2c14e;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--cream);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
  z-index: 1;
}

.hint {
  margin-top: 28px;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--text);
  text-align: center;
  padding: 0 24px;
  animation: breathe 2s ease-in-out infinite;
}

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

.btn-main {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 34px;
  font-size: 16px;
  letter-spacing: 2px;
  box-shadow: 0 6px 16px rgba(216, 112, 63, 0.35);
}

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

.btn-ghost {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 15px;
  padding: 8px 16px;
  text-decoration: none;
}

/* ===== 静音按钮 ===== */
.mute-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-size: 19px;
  backdrop-filter: blur(4px);
}

/* ===== 时间锁 ===== */
.lock-box { text-align: center; }
.lock-icon { font-size: 56px; margin-bottom: 18px; }
.lock-box p { font-size: 18px; }
.lock-sub { margin-top: 10px; font-size: 14px; opacity: 0.7; }

/* ===== 第一幕 · 礼盒 ===== */
.gift-wrap { display: flex; flex-direction: column; align-items: center; }

.gift-box {
  position: relative;
  width: 180px;
  height: 180px;
  cursor: pointer;
  animation: giftShake 2.4s ease-in-out infinite;
}

@keyframes giftShake {
  0%, 88%, 100% { transform: rotate(0deg); }
  90% { transform: rotate(-3deg); }
  92% { transform: rotate(3deg); }
  94% { transform: rotate(-2deg); }
  96% { transform: rotate(2deg); }
}

.gift-body {
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 160px;
  height: 120px;
  background: linear-gradient(160deg, #f0a878, var(--accent));
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(216, 112, 63, 0.3);
}

.gift-lid {
  position: absolute;
  bottom: 112px;
  left: 0;
  width: 180px;
  height: 34px;
  background: linear-gradient(160deg, #f5bd92, #eda06c);
  border-radius: 6px;
  z-index: 2;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s;
}

.gift-bow {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 22px;
}
.gift-bow::before, .gift-bow::after {
  content: "";
  position: absolute;
  top: 0;
  width: 20px;
  height: 20px;
  background: var(--gold);
  border-radius: 50% 50% 0 50%;
}
.gift-bow::before { left: 0; transform: rotate(-45deg); }
.gift-bow::after { right: 0; transform: rotate(45deg) scaleX(-1); }

.gift-ribbon {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 146px;
  background: linear-gradient(90deg, #f2c14e, #f7d87c, #f2c14e);
  z-index: 1;
}

/* 开盒动画 */
.gift-box.opened .gift-lid {
  transform: translate(60px, -140px) rotate(28deg);
  opacity: 0;
}
.gift-box.opened { animation: none; }

/* ===== 第二幕 · 相册 ===== */
.gallery { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 0 28px; }

.photo-frame {
  position: relative;
  width: min(86vw, 420px);
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  padding: 10px;
  box-shadow: 0 12px 32px rgba(91, 70, 54, 0.22);
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.photo-frame img.switching { opacity: 0; transform: scale(1.04); }

/* 视频项：完整显示不裁切 */
.photo-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  background: #1a1410;
  transition: opacity 0.6s ease;
}

/* 视频被静音自动播放时的点击提示 */
.video-tap-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.5px;
  cursor: pointer;
  white-space: nowrap;
}

.photo-text {
  margin-top: 22px;
  font-size: 17px;
  letter-spacing: 1px;
  min-height: 26px;
  transition: opacity 0.6s ease;
}
.photo-text.switching { opacity: 0; }

.photo-dots { margin-top: 14px; display: flex; gap: 12px; padding: 8px 4px; }
.photo-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(91, 70, 54, 0.25);
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
}
.photo-dots span.active { background: var(--accent-dark); transform: scale(1.25); }

#skipGallery { margin-top: 20px; }

/* ===== 第三幕 · 刮刮卡 ===== */
.scratch-wrap { display: flex; flex-direction: column; align-items: center; }

.scratch-card {
  position: relative;
  width: min(78vw, 330px, 46vh);
  aspect-ratio: 5 / 7;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(91, 70, 54, 0.25);
  background: #fdf8f0;
}

.scratch-under {
  position: absolute;
  inset: 0;
  background: #fdf8f0;
  overflow: hidden;
}

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

.scratch-caption {
  max-width: min(84vw, 340px);
  margin-top: 20px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--accent-dark);
  text-align: center;
  animation: captionIn 0.8s ease both;
}

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

#scratchCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  transition: opacity 0.8s ease;
}

.scratch-card.done #scratchCanvas { opacity: 0; pointer-events: none; }

/* ===== 第四幕 · 蜡烛 ===== */
.candle-wrap { display: flex; flex-direction: column; align-items: center; }

#candleCanvas { width: min(72vw, 300px); height: auto; }

.privacy-note {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(91, 70, 54, 0.55);
}

.candle-tip {
  max-width: min(88vw, 340px);
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(91, 70, 54, 0.75);
  text-align: center;
}

/* ===== 第五幕 · 心意卡 ===== */
.card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 24px;
  max-height: 100%;
  overflow-y: auto;
}

/* ===== 第五幕 · 烟花高潮（文字浮在烟花之上） ===== */
body.finale {
  background: radial-gradient(130% 90% at 50% 26%, #1d1546 0%, #0d0922 52%, #05040c 100%);
}
#scene-card { z-index: 60; }
body.finale #scene-card { background: transparent; }

.wish-block {
  text-align: center;
  animation: fadeUp 1.2s ease both;
  max-height: 72vh;
  overflow-y: auto;
  padding: 4px 6px 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.wish-block::-webkit-scrollbar { display: none; }
.wish-block p {
  font-size: 15px;
  line-height: 2;
  max-width: 26em;
  margin: 0 auto;
  text-align: justify;
  color: #fdf6ea;
  white-space: pre-line;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}
/* 打字机光标 */
.wish-block p.typing::after {
  content: "▍";
  margin-left: 1px;
  color: var(--gold);
  animation: caret 0.9s step-end infinite;
}
@keyframes caret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

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

.heart-card {
  margin-top: 30px;
  width: min(84vw, 360px);
  background: linear-gradient(150deg, #fffdf7, #ffeedd);
  border: 1px solid rgba(232, 137, 92, 0.35);
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 14px 36px rgba(91, 70, 54, 0.2);
  animation: fadeUp 1.2s ease both;
}

.heart-card-inner {
  border: 1px dashed rgba(232, 137, 92, 0.5);
  border-radius: 13px;
  padding: 26px 22px;
  text-align: center;
}

.hc-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center 32%;
  border-radius: 10px;
  background: rgba(232, 137, 92, 0.12);
}
#hcSignature { margin-top: 18px; font-size: 14px; color: var(--accent-dark); }
#hcDate { margin-top: 6px; font-size: 13px; opacity: 0.6; }

.card-actions { margin-top: 26px; text-align: center; padding-bottom: 30px; }
.card-actions .btn-main { margin-bottom: 12px; }
.card-actions a { display: block; margin-bottom: 10px; }
.share-hint { font-size: 12px; color: rgba(91, 70, 54, 0.55); }

/* ===== 烟花层 ===== */
.firework-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* ===== 桌面端适配 ===== */
@media (min-width: 768px) {
  .scene { background: #2b2620; }
  .scene > * {
    max-width: 430px;
  }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    margin: auto;
    max-width: 430px;
    background: linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
    z-index: 0;
  }
}

/* ===== 减弱动效 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.15s !important;
  }
}

/* ===== 全局黑场转场遮罩 ===== */
.black-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  z-index: 200;
  pointer-events: none;
  transition: opacity 1s ease;
}
.black-overlay.show { opacity: 1; pointer-events: auto; }

/* ===== 底部进度圆点 ===== */
.scene-dots {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 150;
}
.scene-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(91, 70, 54, 0.28);
  transition: all 0.4s ease;
}
.scene-dots span.active {
  background: var(--accent-dark);
  transform: scale(1.35);
  box-shadow: 0 0 8px rgba(212, 112, 63, 0.5);
}

/* ===== 第一幕 · 信纸展开 ===== */
.letter-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(82vw, 360px);
  z-index: 5;
}
.envelope {
  position: relative;
  background: linear-gradient(150deg, #fff8ec, #ffe3b8);
  border-radius: 12px;
  padding: 34px 24px 30px;
  box-shadow: 0 16px 40px rgba(91, 70, 54, 0.3);
  transform: scale(0.3) rotate(-8deg);
  opacity: 0;
  animation: envelopeOpen 1.2s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}
@keyframes envelopeOpen {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: linear-gradient(180deg, #f2c14e, #e0a83a);
  border-radius: 12px 12px 0 0;
  transform-origin: top center;
  transform: rotateX(0deg);
  animation: flapOpen 0.9s 0.3s ease-out forwards;
}
@keyframes flapOpen {
  from { transform: rotateX(0deg); }
  to { transform: rotateX(-160deg); }
}
.letter-paper {
  margin-top: 6px;
}
.letter-line {
  font-size: 17px;
  line-height: 2;
  color: var(--text);
  min-height: 1.6em;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.letter-line.visible { opacity: 1; }
.letter-line::after {
  content: "|";
  color: var(--accent);
  animation: cursorBlink 0.8s step-end infinite;
  opacity: 0;
}
.letter-line.typing::after { opacity: 1; }
@keyframes cursorBlink {
  50% { opacity: 0; }
}

/* ===== 相册两行文案 ===== */
.photo-text {
  white-space: pre-line;
  text-align: center;
  line-height: 1.7;
  max-width: 86vw;
  padding: 0 4px;
}

