/* ---------- tokens ---------- */
:root {
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;

  --page: #150f0e;
  --page-2: #1d1412;
  --ink: #f7ece2;
  --ink-soft: rgba(247, 236, 226, 0.72);
  --ink-faint: rgba(247, 236, 226, 0.52);
  --line: rgba(247, 220, 190, 0.18);
  --accent: #f8c98c;
  --accent-warm: #ffb877;
  --rose: #f0a6b2;
  --glass: rgba(42, 29, 27, 0.58);
  --photo-opacity: 0.5;
  --photo-blend: normal;
  --veil:
    radial-gradient(120% 80% at 50% 8%, rgba(255, 186, 120, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(18, 12, 11, 0.62) 0%, rgba(18, 12, 11, 0.78) 46%, rgba(16, 11, 10, 0.94) 100%);

  --tier-top: #f9d2d6;
  --tier-mid: #f6dccb;
  --tier-base: #faead9;
  --icing: #fffaf3;
  --plate: #c9a68f;
  --plate-light: #ecd9ca;
  --tier-top-deep: #e79ea6;
  --tier-mid-deep: #e2ac93;
  --tier-base-deep: #eccbac;
  --coupon-open: rgba(240, 166, 178, 0.14);
  --cake-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);

  --paper: linear-gradient(180deg, #fffaf2 0%, #fbeade 100%);
  --paper-ink: #3d2824;
  --paper-ink-soft: rgba(61, 40, 36, 0.72);
  --paper-line: rgba(160, 112, 86, 0.28);
}

@media (prefers-color-scheme: light) {
  :root {
    --page: #f8ece1;
    --page-2: #fdf5ec;
    --ink: #3d2824;
    --ink-soft: rgba(61, 40, 36, 0.74);
    --ink-faint: rgba(61, 40, 36, 0.64);
    --line: rgba(110, 72, 54, 0.18);
    --accent: #b9762f;
    --accent-warm: #c98a3f;
    --rose: #c9748a;
    --glass: rgba(255, 250, 244, 0.74);
    --photo-opacity: 0.22;
    --photo-blend: multiply;
    --veil:
      radial-gradient(120% 80% at 50% 6%, rgba(255, 214, 168, 0.55), transparent 62%),
      linear-gradient(180deg, rgba(250, 238, 226, 0.72) 0%, rgba(250, 238, 226, 0.88) 52%, rgba(250, 238, 226, 0.96) 100%);

    --tier-top: #f7c3ca;
    --tier-mid: #f4cdb6;
    --tier-base: #fde4cb;
    --icing: #fffdf9;
    --plate: #c98f74;
    --plate-light: #f0d9c8;
    --tier-top-deep: #e79ba5;
    --tier-mid-deep: #dda78d;
    --tier-base-deep: #e9c5a3;
    --coupon-open: rgba(201, 116, 138, 0.12);
    --cake-shadow: 0 18px 34px rgba(126, 79, 52, 0.22);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; touch-action: manipulation; }

img { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

/* ---------- atmosphere ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.atmosphere__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: var(--photo-opacity);
  mix-blend-mode: var(--photo-blend);
  filter: saturate(0.92);
}

.atmosphere__veil {
  position: absolute;
  inset: 0;
  background: var(--veil);
}

.dust { position: absolute; inset: 0; }

.dust__mote {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 224, 176, 0.95), rgba(255, 190, 130, 0));
  opacity: 0;
  animation: drift var(--dur, 12s) linear infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes drift {
  0% { opacity: 0; transform: translate3d(0, 20px, 0) scale(0.7); }
  15% { opacity: 0.85; }
  70% { opacity: 0.5; }
  100% { opacity: 0; transform: translate3d(var(--dx, 14px), -140px, 0) scale(1.1); }
}

/* ---------- scenes ---------- */
.stage { position: relative; z-index: 1; }

.scene {
  display: none;
  max-width: 560px;
  margin: 0 auto;
  padding: 72px 22px 64px;
  min-height: 100svh;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.scene.is-active { display: flex; animation: rise 0.65s cubic-bezier(0.22, 0.61, 0.36, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.scene--cake,
.scene--letter { align-items: center; text-align: center; }

.scene--letter { justify-content: flex-start; padding-top: 60px; }

/* ---------- type ---------- */
.eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.display {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 10vw, 52px);
  line-height: 1.24;
  letter-spacing: 0.02em;
}

.display em { font-style: normal; color: var(--accent); }

.title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(24px, 7vw, 32px);
  line-height: 1.45;
  letter-spacing: 0.02em;
}

.lead {
  margin: 0 0 30px;
  max-width: 30em;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.9;
}

.lead--tight { margin-bottom: 18px; }

.note {
  margin: 14px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 30px;
  min-height: 48px;
  font-size: 15px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.btn--primary {
  background: linear-gradient(160deg, #ffd6a2, #f2a97f 70%, #e2907b);
  color: #40231c;
  box-shadow: 0 12px 28px rgba(233, 158, 105, 0.32);
  font-weight: 600;
}

.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(233, 158, 105, 0.4); }
.btn--primary:active { transform: translateY(1px) scale(0.99); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}

.btn--ghost:hover { border-color: var(--accent); color: var(--ink); }

.btn[hidden] { display: none; }

/* ---------- cake ---------- */
.scene--cake {
  overflow: clip;
  padding-top: 56px;
  padding-bottom: 44px;
}

.scene--cake .lead { max-width: 26em; font-size: 15px; }

.cake {
  position: relative;
  width: min(320px, 82vw);
  margin: 14px auto 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  --lit: 0;
}

.cake__glow {
  position: absolute;
  left: 50%;
  top: -6%;
  width: 112%;
  aspect-ratio: 1;
  transform: translate(-50%, -26%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 196, 122, 0.55), rgba(255, 148, 92, 0.16) 42%, transparent 68%);
  filter: blur(8px);
  opacity: calc(var(--lit) * 0.9);
  transition: opacity 0.55s ease;
  pointer-events: none;
}

.cake__candles {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 84px;
  margin-bottom: -6px;
}

.candle {
  position: relative;
  width: 34px;
  height: 84px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  transition: transform 0.2s ease;
}

.candle:hover { transform: translateY(-2px); }

.candle__stick {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 12px;
  height: 50px;
  transform: translateX(-50%);
  border-radius: 6px;
  background:
    repeating-linear-gradient(135deg, rgba(224, 128, 138, 0.55) 0 3px, rgba(255, 255, 255, 0) 3px 7px),
    linear-gradient(90deg, #fdf0e6, #f8dfd0 60%, #ecc3bb);
  box-shadow: inset -2px 0 3px rgba(160, 100, 90, 0.25);
}

.candle__wick {
  position: absolute;
  left: 50%;
  bottom: 47px;
  width: 2px;
  height: 8px;
  transform: translateX(-50%);
  background: #4a322c;
  border-radius: 2px;
  opacity: 0.9;
}

.candle__flame {
  position: absolute;
  left: 50%;
  bottom: 52px;
  width: 14px;
  height: 22px;
  transform: translate(-50%, 8px) scale(0.2);
  transform-origin: bottom center;
  border-radius: 50% 50% 46% 46% / 62% 62% 40% 40%;
  background: radial-gradient(ellipse at 50% 72%, #fffdf0 0%, #ffd98f 38%, #ffab4d 66%, rgba(255, 130, 54, 0.05) 100%);
  box-shadow: 0 0 16px 6px rgba(255, 170, 90, 0.55), 0 0 42px 14px rgba(255, 140, 60, 0.22);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.candle.is-lit .candle__flame {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: flicker 2.6s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { transform: translate(-50%, 0) scale(1) rotate(-1deg); }
  35% { transform: translate(-50%, -1px) scale(1.04, 0.97) rotate(1.5deg); }
  62% { transform: translate(-50%, 1px) scale(0.97, 1.05) rotate(-1deg); }
}

.candle__smoke {
  position: absolute;
  left: 50%;
  bottom: 56px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 206, 198, 0.55), rgba(214, 206, 198, 0));
  transform: translateX(-50%);
  animation: smoke 1.8s ease-out forwards;
  pointer-events: none;
}

@keyframes smoke {
  0% { opacity: 0.75; transform: translate(-50%, 0) scale(0.7); }
  100% { opacity: 0; transform: translate(-50%, -58px) scale(2.4); }
}

/* tiers */
.tier {
  position: relative;
  border-radius: 16px 16px 12px 12px;
  box-shadow: var(--cake-shadow);
}

.tier::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 24px;
  border-radius: 16px 16px 0 0;
  background:
    radial-gradient(circle 12px at 50% 0, var(--icing) 99%, transparent 100%) left top / 24px 24px repeat-x,
    linear-gradient(var(--icing), var(--icing)) left top / 100% 6px no-repeat;
}

.tier--top {
  width: 62%;
  height: 44px;
  background: linear-gradient(180deg, var(--tier-top), var(--tier-top-deep));
}

.tier--mid {
  width: 74%;
  height: 56px;
  margin-top: -2px;
  background: linear-gradient(180deg, var(--tier-mid), var(--tier-mid-deep));
}

.tier--mid::after,
.tier--base::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  height: 18px;
  background-image: radial-gradient(circle, rgba(224, 134, 143, 0.75) 1.6px, transparent 1.8px),
    radial-gradient(circle, rgba(247, 191, 116, 0.8) 1.4px, transparent 1.7px);
  background-size: 22px 18px, 17px 18px;
  background-position: 0 0, 9px 8px;
  opacity: 0.55;
  border-radius: 6px;
}

.tier--base {
  width: 90%;
  height: 66px;
  margin-top: -2px;
  background: linear-gradient(180deg, var(--tier-base), var(--tier-base-deep));
}

.plate {
  width: 104%;
  height: 20px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 25%, var(--plate-light) 0%, var(--plate) 60%, rgba(0, 0, 0, 0.25) 100%);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.counter {
  margin: 22px 0 0;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.cake__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* ---------- letter ---------- */
.scene--letter .title { margin-bottom: 26px; }

.letter { width: 100%; max-width: 440px; }

.seal {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 20px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s ease, opacity 0.4s ease;
}

.seal:hover { transform: translateY(-2px); border-color: var(--rose); }

.seal__wax {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.2;
  color: #fff4ea;
  background: radial-gradient(circle at 34% 28%, #e5838f, #b8515f 62%, #8d3b48);
  box-shadow: 0 8px 20px rgba(150, 60, 70, 0.4), inset 0 -3px 8px rgba(0, 0, 0, 0.25);
  transform: rotate(-8deg);
}

.seal__text { margin-top: 10px; font-size: 16px; letter-spacing: 0.16em; }
.seal__hint { font-size: 12px; letter-spacing: 0.2em; color: var(--ink-faint); }

.seal.is-opened { opacity: 0; transform: translateY(-8px) scale(0.96); pointer-events: none; }

.paper {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  padding: 30px 24px 28px;
  border-radius: 20px;
  background: var(--paper);
  color: var(--paper-ink);
  text-align: left;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.3);
  animation: unfold 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes unfold {
  from { opacity: 0; transform: translateY(16px) scaleY(0.96); }
  to { opacity: 1; transform: none; }
}

.paper__floral {
  position: absolute;
  right: -34px;
  top: -30px;
  width: 170px;
  opacity: 0.42;
  mix-blend-mode: multiply;
  transform: rotate(8deg);
  pointer-events: none;
}

.paper__to {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.06em;
}

.paper p {
  position: relative;
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 2;
  color: var(--paper-ink);
}

.paper__sign {
  margin-top: 22px;
  color: var(--paper-ink-soft);
  text-align: right;
}

.paper__sign span { font-size: 13px; letter-spacing: 0.06em; }

/* coupons */
.coupons {
  width: 100%;
  max-width: 440px;
  margin-top: 40px;
}

.coupons__title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.coupons__lead {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

.coupon {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 16px 18px;
  text-align: left;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--glass);
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.25s ease;
}

.coupon:hover { border-color: var(--accent); transform: translateY(-1px); }

.coupon__no {
  display: block;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.coupon__front {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.coupon__back {
  display: none;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--ink-soft);
}

.coupon.is-open { border-style: solid; border-color: var(--rose); background: var(--coupon-open); }
.coupon.is-open .coupon__front { display: none; }
.coupon.is-open .coupon__back { display: block; animation: rise 0.4s ease both; }

.coupons__fine {
  margin: 14px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.coupons[hidden] { display: none; }

/* finale */
.finale {
  margin: 46px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.finale__line {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.14em;
  color: var(--accent);
}

/* ---------- confetti ---------- */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.confetti__piece {
  position: absolute;
  top: -14px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0.95;
  animation: fall var(--dur, 3.4s) linear forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes fall {
  0% { opacity: 0; transform: translate3d(0, -10px, 0) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--dx, 30px), 108vh, 0) rotate(var(--rot, 540deg)); }
}

/* ---------- responsive ---------- */
@media (min-width: 640px) {
  .scene { padding: 88px 32px 72px; }
  .scene--letter { padding-top: 84px; }
  .paper { padding: 38px 34px 34px; }
  .display { line-height: 1.2; }
}

@media (max-width: 360px) {
  .cake { width: 92vw; }
  .cake__candles { gap: 2px; }
  .candle { width: 34px; }
  .btn { padding: 13px 22px; }
}

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

  .candle.is-lit .candle__flame { animation: none; }
  .dust { display: none; }
  .confetti { display: none; }
}
