/* =====================================================================
  生日祝福互动网页 —— 样式
  设计基调：温馨 + 热闹（暖色为主），375px 基准、响应式、轻量动效。
===================================================================== */

:root {
  /* 暖色调色板：奶油白 / 浅粉 / 香槟金 / 暖橙 */
  --cream:      #fff8f0;   /* 奶油白底 */
  --pink-soft:  #ffe3ec;   /* 浅粉 */
  --pink:       #ffb7cc;
  --gold:       #f5d78e;   /* 香槟金 */
  --gold-deep:  #e2a93b;
  --orange:     #ff9f68;   /* 暖橙 */
  --orange-deep:#ff7f4f;
  --ink:        #5c4636;   /* 暖棕文字（避免纯黑） */
  --ink-soft:   #8a7260;
  --white:      #ffffff;
  --shadow:     0 10px 30px rgba(224, 158, 110, 0.22);
  --radius:     22px;
  /* 圆润有温度的字体，回退到系统中文字体 */
  --font-title: "ZCOOL KuaiLe", "Ma Shan Zheng", "PingFang SC", "Hiragino Sans GB",
                "Microsoft YaHei", system-ui, sans-serif;
  --font-body:  "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 关键：保证任何带 hidden 属性的元素确实被隐藏。
   否则 .video-overlay 等元素的 display:flex 会覆盖 hidden 属性，
   导致初始就显示弹窗、拦截点击。 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(160deg, #fff6ee 0%, #ffe8ef 45%, #fff3e0 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden; /* 杜绝横向滚动条 */
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 背景光斑 ---------------- */
.bg-glow {
  position: fixed;
  width: 60vmin; height: 60vmin;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
  animation: glow-breathe 7s ease-in-out infinite;
}
.bg-glow { top: -12vmin; left: -12vmin; background: radial-gradient(circle, #ffd9e4, transparent 70%); }
.bg-glow--2 { bottom: -15vmin; right: -12vmin; background: radial-gradient(circle, #ffe3b3, transparent 70%); animation-delay: 2.5s; }
@keyframes glow-breathe {
  0%, 100% { transform: scale(1); opacity: .5; }
  50%      { transform: scale(1.15); opacity: .7; }
}

/* ---------------- 飘落装饰（彩带 / 气球 / 星光） ----------------
   数量少、用纯 CSS transform 动画，性能友好不卡顿。 */
.floaters { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; top: -60px;
  opacity: .8;
  will-change: transform;
  animation: fall linear infinite;
}
@keyframes fall {
  0%   { transform: translate3d(0, -60px, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: .85; }
  100% { transform: translate3d(var(--sway, 30px), 110vh, 0) rotate(var(--spin, 360deg)); opacity: .1; }
}

/* ---------------- 主体舞台 ---------------- */
.stage {
  position: relative; z-index: 1;
  max-width: 480px;            /* 大屏居中，限制最大宽度 */
  margin: 0 auto;
  padding: 28px 18px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------------- 卡片 ---------------- */
.card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 22px 26px;
  text-align: center;
  border: 1px solid rgba(255, 220, 190, 0.6);
  animation: rise-in .5s ease-out both;
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 10px; }
.card-title { font-family: var(--font-title); font-size: 1.55rem; letter-spacing: .5px; color: var(--ink); }
.card-sub { margin: 10px auto 20px; font-size: .95rem; line-height: 1.7; color: var(--ink-soft); }

/* ---------------- 表单入口 ---------------- */
.entry { display: flex; flex-direction: column; gap: 14px; }

.field {
  width: 100%;
  height: 52px;                 /* ≥44px，适合单手点击 */
  padding: 0 18px;
  font-size: 1.02rem;
  color: var(--ink);
  background: #fffdfa;
  border: 2px solid #ffe0d0;
  border-radius: 16px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.field::placeholder { color: #cbb3a2; }
.field:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 159, 104, 0.18);
}

/* 输入框抖动（错误提示） */
.field.shake { animation: shake .4s; border-color: #ff8f8f; box-shadow: 0 0 0 4px rgba(255,143,143,.18); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------------- 按钮 ---------------- */
.btn {
  height: 52px;
  padding: 0 22px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-body);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--orange) 0%, #ffb26b 100%);
  box-shadow: 0 6px 16px rgba(255, 127, 79, 0.35);
  transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 9px 20px rgba(255,127,79,.4); }
.btn:not(:disabled):active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn--big { margin-top: 18px; height: 58px; font-size: 1.2rem; background: linear-gradient(135deg, var(--gold-deep), var(--gold)); color: #7a4a12; box-shadow: 0 8px 22px rgba(226,169,59,.4); }
.btn--play { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.03);} }
/* 答对后出现的“下一题”按钮：淡入出现，不抢解锁动画的视觉 */
.btn--next { animation: pop-in .45s cubic-bezier(.34,1.56,.64,1); }

/* ---------------- 提示文字 ---------------- */
.hint { min-height: 1.4em; margin-top: 12px; font-size: .92rem; color: var(--ink-soft); transition: color .2s; }
.hint.ok { color: var(--gold-deep); font-weight: 600; }
.hint.err { color: #e8606b; font-weight: 600; }

/* ---------------- 进度 ---------------- */
.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress-pill {
  flex-shrink: 0;
  font-size: .82rem; font-weight: 700;
  color: #8a5a12;
  background: linear-gradient(135deg, #ffe9b8, #ffd98e);
  padding: 6px 12px;
  border-radius: 999px;
}
.progress-track { flex: 1; height: 10px; border-radius: 999px; background: #ffe8dc; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb26b, var(--gold));
  transition: width .6s ease;
}

/* ---------------- 上方大字展示区 ---------------- */
.word-area {
  display: flex;
  justify-content: center;
  gap: 14px;
  min-height: 120px;
  align-items: center;
  margin: 6px 0 6px;
}
.word-slot {
  width: 72px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  background: rgba(255, 246, 238, .75);
  border: 2px dashed #ffd2ae;
}
.word {
  font-family: var(--font-title);
  font-size: 3.3rem;
  line-height: 1;
  color: var(--orange-deep);
  /* 入场动画：淡入 + 轻微弹跳/翻转 */
  animation: pop-in .6s cubic-bezier(.34,1.56,.64,1) both;
  display: inline-block;
}
@keyframes pop-in {
  0%   { opacity: 0; transform: translateY(20px) scale(.4) rotate(-18deg); }
  60%  { opacity: 1; transform: translateY(-6px) scale(1.12) rotate(4deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}
.word-hint { font-size: .88rem; color: var(--ink-soft); margin-bottom: 18px; }

/* 已解锁的字可点击，回顾对应信件 */
.word--clickable { cursor: pointer; transition: transform .15s, filter .2s; }
.word--clickable:hover { transform: translateY(-3px); filter: brightness(1.06); }
.word--clickable:active { transform: translateY(0); }

/* 引导语 */
.guide { font-size: .98rem; color: var(--ink); line-height: 1.6; margin-bottom: 2px; min-height: 1.6em; }

/* 下方提示：可点击已解锁的字回顾信件 */
.letter-hint { margin-top: 16px; font-size: .85rem; color: var(--ink-soft); text-align: center; line-height: 1.6; }

/* ---------------- 惊喜信件弹框 ---------------- */
.letter-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(60, 38, 28, 0.55);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.letter-card {
  position: relative;
  width: 100%; max-width: 440px;
  max-height: 74vh;
  background: linear-gradient(160deg, #fffdf7 0%, #fff3e0 100%);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  border: 1px solid rgba(226,169,59,.45);
  padding: 34px 24px 28px;
  overflow-y: auto;
}
.letter-body {
  font-family: var(--font-body);
  font-size: 1.02rem; line-height: 1.9; color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}
/* 首次答对：展开信件动画（较慢，信封展开 + 纸张摊开） */
.letter-card--open { animation: letter-unfold .8s cubic-bezier(.22,1,.36,1) both; }
@keyframes letter-unfold {
  0%   { opacity: 0; transform: translateY(32px) scale(.55); }
  55%  { opacity: 1; transform: translateY(-6px) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
/* 点击重读：更快一点的淡入淡出 */
.letter-card--quick { animation: letter-pop .3s ease both; }
@keyframes letter-pop {
  0%   { opacity: 0; transform: scale(.92); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---------------- 视频弹窗 ---------------- */
.video-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(60, 38, 28, 0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: fade-in .3s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.video-card {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
  animation: pop-in .4s cubic-bezier(.34,1.56,.64,1);
}
.video {
  display: block; width: 100%; height: auto;
  max-height: 70vh;
  background: #000;
}
.close-btn {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none; cursor: pointer;
  font-size: 1rem; color: var(--ink);
  background: rgba(255,255,255,.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* 视频兜底提示 */
.video-fallback { padding: 56px 24px; text-align: center; }
.fallback-cake { font-size: 4rem; margin-bottom: 12px; animation: bounce-soft 1.6s ease-in-out infinite; }
@keyframes bounce-soft { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }
.fallback-title { font-family: var(--font-title); font-size: 1.3rem; color: var(--ink); margin-bottom: 8px; }
.fallback-text { color: var(--ink-soft); font-size: .95rem; line-height: 1.7; }

/* 结尾祝福语 */
.final-block { padding: 22px 20px 26px; text-align: center; }
.final-message {
  font-family: var(--font-title);
  font-size: 1.5rem; color: var(--orange-deep);
  margin-bottom: 16px;
  animation: pop-in .5s cubic-bezier(.34,1.56,.64,1);
}

/* ---------------- 彩带爆发 ---------------- */
.burst-layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.burst-particle {
  position: absolute; bottom: 20%;
  width: 8px; height: 12px; border-radius: 3px;
  animation: burst ease-out forwards;
}
@keyframes burst {
  0%   { opacity: 1; transform: translate(0,0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--bx), var(--by)) rotate(420deg); }
}

/* ---------------- 移动端微调（375px 基准下的留白） ---------------- */
@media (max-width: 420px) {
  .stage { padding: 18px 14px 40px; }
  .card { padding: 24px 16px 22px; }
  .word-area { gap: 10px; }
  .word-slot { width: 64px; height: 78px; }
  .word { font-size: 2.9rem; }
}

/* 大屏时轻微加宽留白，仍限制在 480px */
@media (min-width: 760px) {
  .stage { padding-top: 40px; }
}
