:root {
  --bg-1: #171233;
  --bg-2: #2a1650;
  --bg-3: #4a1e4e;
  --gold: #e8c47a;
  --gold-soft: #f4e3b2;
  --rose: #f49eb7;
  --text: #f7f1e6;
  --text-dim: rgba(247, 241, 230, 0.62);
  --glass: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.16);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 48%, var(--bg-3) 100%);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

canvas#stars,
canvas#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

/* ---------- 封面 ---------- */
#cover {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  transition: opacity 0.9s ease, transform 0.9s ease;
}

#cover.fade-out {
  opacity: 0;
  transform: translateY(-24px);
  pointer-events: none;
}

.cover-inner { max-width: 720px; }

.eyebrow {
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

.title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 9vw, 5.2rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  background: linear-gradient(120deg, var(--gold-soft), var(--gold), #fff0cf);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: float-title 5s ease-in-out infinite;
}

.subtitle {
  margin: 1.4rem auto 2.4rem;
  max-width: 30em;
  color: var(--text-dim);
  line-height: 1.9;
}

.birthday-line {
  margin-top: 1.3rem;
  font-family: var(--serif);
  letter-spacing: 0.22em;
  color: var(--gold-soft);
  font-size: 1.05rem;
}

.countdown {
  margin-top: 0.9rem;
  font-size: 0.95rem;
  color: var(--rose);
  letter-spacing: 0.08em;
  min-height: 1.4em;
}

.btn-primary {
  appearance: none;
  border: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(232, 196, 122, 0.16), rgba(244, 158, 183, 0.14));
  backdrop-filter: blur(8px);
  color: var(--gold-soft);
  font-family: var(--sans);
  font-size: 1rem;
  letter-spacing: 0.12em;
  padding: 0.9rem 2.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(232, 196, 122, 0.25);
  background: linear-gradient(135deg, rgba(232, 196, 122, 0.26), rgba(244, 158, 183, 0.22));
}

.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-primary.busy {
  opacity: 0.7;
  pointer-events: none;
}

.hint {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  opacity: 0.75;
}

/* ---------- 主内容 ---------- */
#experience {
  position: relative;
  z-index: 1;
}

.scene {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 7rem) 1.4rem;
  text-align: center;
}

.section-title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4.5vw, 2.3rem);
  letter-spacing: 0.08em;
  margin-bottom: 0.7rem;
}

.section-sub {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 2.4rem;
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 2.2rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

/* ---------- 蛋糕与蜡烛 ---------- */
.cake-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2.2rem;
}

.candles {
  display: flex;
  gap: 1.1rem;
  margin-bottom: -2px;
  position: relative;
  z-index: 2;
}

.candle {
  position: relative;
  width: 10px;
  height: 64px;
  background: linear-gradient(180deg, #ffd1e3, #f49eb7 70%, #d97e9e);
  border-radius: 5px 5px 2px 2px;
  box-shadow: inset -2px 0 rgba(0, 0, 0, 0.18);
}

.candle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: -3px;
  width: 16px;
  height: 7px;
  background: repeating-linear-gradient(90deg, #ffe9b8 0 3px, #f7cf7f 3px 6px);
  border-radius: 3px;
}

.wick {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 2px;
  height: 8px;
  background: #5c4632;
  transform: translateX(-50%);
}

.flame {
  position: absolute;
  top: -26px;
  left: 50%;
  width: 15px;
  height: 24px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 80%, #fff6d8 0%, #ffd76e 40%, #ff9d3c 70%, rgba(255, 120, 60, 0) 100%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  animation: flicker 0.9s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
  box-shadow: 0 0 18px 6px rgba(255, 190, 90, 0.45);
}

@keyframes flicker {
  0%   { transform: translateX(-50%) scale(1) rotate(-2deg); }
  100% { transform: translateX(-52%) scale(1.12, 1.05) rotate(2.5deg); }
}

.candle.out .flame {
  animation: none;
  opacity: 0;
  box-shadow: none;
}

.candle.out .wick::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 4px;
  height: 4px;
  background: #b9896b;
  border-radius: 50%;
  transform: translateX(-50%);
}

.cake {
  position: relative;
  z-index: 1;
  width: min(330px, 80vw);
}

.cake-layer {
  border-radius: 8px;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.18);
}

.cake-top {
  height: 52px;
  background: linear-gradient(180deg, #ffe9f1, #ffc7da);
  color: #a04b6b;
  font-family: var(--serif);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px 8px 4px 4px;
  padding-top: 0.6rem;
}

.cake-mid {
  height: 44px;
  background: linear-gradient(180deg, #f3b0c6, #e58caa);
  margin-top: 6px;
  border-radius: 4px;
  box-shadow: inset 0 -6px 14px rgba(0, 0, 0, 0.15);
}

.cake-bot {
  height: 40px;
  background: linear-gradient(180deg, #e58caa, #cd6f90);
  margin-top: 6px;
  border-radius: 4px 4px 10px 10px;
}

.plate {
  width: calc(100% + 26px);
  height: 14px;
  background: radial-gradient(ellipse at center, #f7e9d8 0%, #d9c3aa 70%, #b89c84 100%);
  border-radius: 50%;
  margin: 0 auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.wind {
  position: absolute;
  top: -120px;
  left: 50%;
  width: 70px;
  height: 110px;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: translateX(-50%);
  animation: wind-pulse 0.5s ease-out infinite;
}

@keyframes wind-pulse {
  from { transform: translateX(-50%) scale(0.6); opacity: 0.9; }
  to   { transform: translateX(-50%) scale(1.5); opacity: 0; }
}

.smoke {
  position: absolute;
  top: -60px;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  animation: smoke-rise 1.6s ease-out infinite;
}

@keyframes smoke-rise {
  from { transform: translate(-50%, 0) scale(0.5); opacity: 0.8; }
  to   { transform: translate(calc(-50% + 18px), -90px) scale(1.8); opacity: 0; }
}

.status {
  margin-top: 1.1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  min-height: 1.4em;
}

/* ---------- 祝福卡 ---------- */
.reveal-card {
  position: relative;
  overflow: hidden;
  animation: pop-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  border-color: rgba(232, 196, 122, 0.45);
  background: linear-gradient(160deg, rgba(232, 196, 122, 0.12), rgba(244, 158, 183, 0.1)), var(--glass);
}

.reveal-title {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  letter-spacing: 0.1em;
  margin: 0.4rem 0 1rem;
  background: linear-gradient(120deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.reveal-text {
  color: var(--text);
  line-height: 2;
  max-width: 30em;
  margin: 0 auto;
}

.confetti-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 18%, var(--gold) 0 5px, transparent 6px),
    radial-gradient(circle at 86% 12%, var(--rose) 0 4px, transparent 5px),
    radial-gradient(circle at 22% 82%, var(--rose) 0 4px, transparent 5px),
    radial-gradient(circle at 76% 78%, var(--gold) 0 5px, transparent 6px),
    radial-gradient(circle at 52% 8%, #fff 0 3px, transparent 4px);
  opacity: 0;
}

.reveal-card.show-burst .confetti-burst { animation: burst 1.4s ease-out 1; }

@keyframes burst {
  0%   { opacity: 0; transform: scale(0.4) rotate(0deg); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.6) rotate(12deg); }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- 信 ---------- */
.letter-card {
  text-align: left;
  position: relative;
}

.letter-card::before {
  content: "❝";
  position: absolute;
  top: -26px;
  left: 22px;
  font-size: 4rem;
  color: var(--gold);
  opacity: 0.55;
  font-family: var(--serif);
}

.letter-date {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
  letter-spacing: 0.06em;
}

.letter-body {
  font-family: var(--serif);
  line-height: 2.2;
  font-size: 1.02rem;
  color: var(--text);
  min-height: 8em;
  white-space: pre-wrap;
}

.letter-body .caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.letter-sign {
  margin-top: 1.6rem;
  text-align: right;
  color: var(--gold);
  font-family: var(--serif);
  letter-spacing: 0.05em;
}

.btn-ghost {
  margin-top: 1.4rem;
  display: inline-block;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.btn-ghost:hover {
  color: var(--gold-soft);
  border-color: var(--gold);
}

/* ---------- 星空愿望 ---------- */
.star-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  margin-bottom: 1.4rem;
}

.star {
  position: relative;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gold);
  font-size: 1.5rem;
  transition: transform 0.25s ease, filter 0.25s ease;
  animation: twinkle 2.6s ease-in-out infinite;
}

.star:nth-child(2n) { animation-delay: 0.4s; }
.star:nth-child(3n) { animation-delay: 0.9s; }
.star:nth-child(5n) { animation-delay: 1.4s; }

.star:hover { transform: scale(1.35) rotate(8deg); filter: drop-shadow(0 0 8px var(--gold)); }
.star.picked { animation: none; transform: scale(1.2); color: var(--rose); }

@keyframes twinkle {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50%      { opacity: 1; transform: scale(1.08); }
}

.star-message {
  min-height: 2.4em;
  color: var(--text-dim);
  font-family: var(--serif);
  font-size: 1rem;
  margin-bottom: 2rem;
  transition: color 0.4s ease;
}

.star-message.lit {
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(232, 196, 122, 0.4);
}

.wish-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  padding: 1.6rem;
}

#wishInput {
  flex: 1 1 260px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 0.8rem 1.4rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.25s ease;
}

#wishInput:focus { border-color: var(--gold); }
#wishInput::placeholder { color: var(--text-dim); }

.lanterns {
  position: relative;
  height: 120px;
  margin-top: 1.4rem;
  overflow: hidden;
}

.lantern {
  position: absolute;
  bottom: -60px;
  left: 50%;
  font-size: 1.6rem;
  filter: drop-shadow(0 0 10px rgba(232, 196, 122, 0.6));
  animation: lantern-float 7s linear forwards;
  white-space: nowrap;
}

.lantern .tip {
  display: block;
  font-size: 0.75rem;
  color: var(--gold-soft);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes lantern-float {
  0%   { transform: translate(-50%, 0) rotate(-3deg); opacity: 0; }
  8%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(-50%, -190px) rotate(4deg); opacity: 0; }
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  padding: 2rem 1.4rem 3rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 2;
}

.heart {
  color: var(--rose);
  display: inline-block;
  animation: heartbeat 1.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  12%      { transform: scale(1.25); }
  24%      { transform: scale(1); }
  36%      { transform: scale(1.18); }
  48%      { transform: scale(1); }
}

/* ---------- 动效辅助 ---------- */
@keyframes float-title {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

@media (max-width: 520px) {
  .card { padding: 1.6rem; }
  .candles { gap: 0.8rem; }
  .candle { height: 56px; }
  .flame { top: -24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
