/* =======================================================================
   生日快乐 · 样式表
   ======================================================================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --gold: #ffd479;
  --gold-2: #ffb347;
  --pink: #ff7fb0;
  --violet: #a78bfa;
  --ink: #0a0818;
  --glass: rgba(255, 255, 255, .07);
  --glass-line: rgba(255, 255, 255, .16);
  --font-happy: "ZCOOL KuaiLe", "Ma Shan Zheng", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-brush: "Ma Shan Zheng", "ZCOOL KuaiLe", "KaiTi", "STKaiti", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: #07061a;
  color: #fff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-happy);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* 画布铺满 + 夜间光晕 */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 1;
  cursor: default;
  transition: opacity .6s ease;
}
body.firing #scene { cursor: crosshair; }

.sky-glow {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 108%, rgba(255, 160, 90, .16), transparent 70%),
    radial-gradient(45% 40% at 15% 10%, rgba(120, 90, 255, .22), transparent 70%),
    radial-gradient(50% 40% at 88% 20%, rgba(255, 90, 160, .14), transparent 70%),
    linear-gradient(180deg, #050418 0%, #0b0826 45%, #150c2c 72%, #1d0f2a 100%);
  animation: skyBreath 12s ease-in-out infinite alternate;
}
@keyframes skyBreath {
  from { filter: brightness(.92) saturate(1); }
  to   { filter: brightness(1.08) saturate(1.1); }
}

/* ------------------------------- 通用屏幕 ------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity .7s ease, transform .7s ease, visibility .7s;
}
.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.03);
}
#lockScreen.leaving { opacity: 0; transform: scale(1.08); filter: blur(6px); }

/* =========================== 第一幕：时间锁 =========================== */
#lockScreen { padding: 24px 16px calc(24px + var(--safe-b)); }

.lock-card {
  position: relative;
  width: min(560px, 100%);
  padding: 30px 26px 26px;
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 212, 121, .12), transparent 60%),
    linear-gradient(180deg, rgba(30, 24, 60, .82), rgba(14, 11, 32, .88));
  border: 1px solid var(--glass-line);
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, .8),
    inset 0 1px 0 rgba(255, 255, 255, .09);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  animation: cardIn .9s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(26px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* 礼物盒 + 锁 */
.lock-stage {
  position: relative;
  height: 132px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.lock-emoji {
  font-size: 40px;
  position: absolute;
  top: -2px;
  z-index: 3;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6));
  animation: lockBob 2.6s ease-in-out infinite;
}
@keyframes lockBob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-7px) rotate(4deg); }
}
.lock-gift {
  position: relative;
  width: 92px;
  height: 82px;
  margin-top: 34px;
  animation: giftPop 2.6s ease-in-out infinite;
}
@keyframes giftPop {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.gift-box {
  position: absolute;
  bottom: 0; left: 6px;
  width: 80px; height: 56px;
  border-radius: 8px;
  background: linear-gradient(160deg, #ff5d8f, #b32c6a);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, .25), 0 14px 26px -10px rgba(255, 93, 143, .7);
}
.gift-lid {
  position: absolute;
  top: 18px; left: 0;
  width: 92px; height: 18px;
  border-radius: 6px;
  background: linear-gradient(160deg, #ff86ad, #d23b78);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .6);
  z-index: 2;
}
.gift-ribbon-v {
  position: absolute;
  bottom: 0; left: 38px;
  width: 16px; height: 74px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 224, 150, .95), rgba(255, 190, 90, .9));
  z-index: 1;
  opacity: .95;
}
.gift-lid::after {
  content: "";
  position: absolute;
  left: 36px; top: -2px;
  width: 20px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffd479, #ffb347);
}

.lock-title {
  margin: 14px 0 6px;
  font-size: clamp(22px, 5.4vw, 30px);
  line-height: 1.35;
  font-weight: 400;
  letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(255, 200, 120, .28);
}
.lock-title span {
  display: block;
  margin-top: 6px;
  font-size: .78em;
  color: #ffe7b8;
  opacity: .92;
}
.lock-desc {
  margin: 10px auto 22px;
  max-width: 420px;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(255, 255, 255, .68);
}

/* 倒计时 */
.countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 auto 18px;
  max-width: 460px;
}
.unit {
  padding: 12px 4px 9px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .03));
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 10px 24px -16px #000;
}
.unit .num {
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: clamp(26px, 7.6vw, 38px);
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(180deg, #fff7e0, var(--gold) 55%, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255, 180, 70, .35));
}
.unit .lbl {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: .18em;
  color: rgba(255, 255, 255, .55);
}
.unit.tick .num { animation: tick .5s ease; }
@keyframes tick {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12); color: #fff; }
  100% { transform: scale(1); }
}

.lock-time {
  margin: 0 0 14px;
  font-size: 14.5px;
  color: rgba(255, 255, 255, .72);
}
.lock-time b { color: #ffe7b8; font-weight: 400; }

.lock-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .62);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
}
.lock-hint b { color: rgba(255, 255, 255, .85); font-weight: 400; }
.lock-hint .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #5ef2a6;
  box-shadow: 0 0 0 0 rgba(94, 242, 166, .6);
  animation: pulseDot 2s infinite;
  flex: none;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(94, 242, 166, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(94, 242, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 242, 166, 0); }
}

/* =========================== 第二幕：主场景 =========================== */
#mainScreen {
  justify-content: space-between;
  z-index: 4;
  pointer-events: none;      /* 让点击穿透到 canvas */
  padding: max(14px, env(safe-area-inset-top, 0px)) 14px calc(14px + var(--safe-b));
}
#mainScreen > * { pointer-events: auto; }
#mainScreen.opened { animation: fadeIn .8s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none !important;
  background: radial-gradient(75% 60% at 50% 62%, transparent 40%, rgba(3, 2, 12, .72) 100%);
  z-index: 0;
}

.pill {
  align-self: center;
  z-index: 3;
  margin: 0;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: clamp(13px, 3.6vw, 16px);
  white-space: nowrap;
  color: #fff6df;
  background: rgba(20, 14, 44, .55);
  border: 1px solid rgba(255, 212, 121, .35);
  box-shadow: 0 8px 30px -12px rgba(255, 180, 90, .6), inset 0 1px 0 rgba(255, 255, 255, .12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity .8s ease, transform .8s ease;
}
.pill.gone { opacity: 0; transform: translateY(-14px); }

.age-badge {
  position: absolute;
  top: 18px;
  right: 16px;
  z-index: 3;
  width: 74px; height: 74px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background: radial-gradient(circle at 35% 28%, #fff3cf, var(--gold) 42%, #e8972c 100%);
  color: #4a2400;
  box-shadow: 0 0 0 3px rgba(255, 212, 121, .22), 0 14px 34px -10px rgba(255, 170, 60, .75);
  opacity: 0;
  transform: scale(.4) rotate(-25deg);
  transition: opacity .5s ease, transform .7s cubic-bezier(.2, 1.6, .4, 1);
}
.age-badge.show { opacity: 1; transform: scale(1) rotate(-8deg); animation: badgeFloat 4s ease-in-out infinite 0.7s; }
@keyframes badgeFloat {
  0%, 100% { transform: scale(1) rotate(-8deg) translateY(0); }
  50%      { transform: scale(1) rotate(-4deg) translateY(-5px); }
}
.age-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  font-family: "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.02em;
}
.age-txt { font-size: 11px; margin-top: 1px; }

.icon-btn {
  position: absolute;
  top: 18px;
  left: 16px;
  z-index: 6;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffe9c0;
  background: rgba(20, 14, 44, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform .2s ease, background .2s ease;
}
.icon-btn:hover { transform: scale(1.08); background: rgba(40, 28, 80, .7); }
.icon-btn:active { transform: scale(.94); }
.sound-btn .muted-line { display: none; }
.sound-btn.muted .wave { display: none; }
.sound-btn.muted .muted-line { display: inline; }
.sound-btn.muted { color: rgba(255, 233, 192, .5); }

.hint-bar {
  align-self: center;
  z-index: 3;
  font-size: clamp(11.5px, 3.2vw, 13.5px);
  color: rgba(255, 255, 255, .55);
  text-align: center;
  transition: opacity .6s ease;
}
.hint-bar .kbd {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 4px;
  border-radius: 6px;
  color: #ffe9c0;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  border-bottom-width: 2px;
  font-size: .92em;
}
.hint-bar.gone { opacity: 0; }
#mainScreen.done .hint-bar { opacity: 0; }

/* 贺卡 */
.card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 7;
  background: radial-gradient(60% 60% at 50% 50%, rgba(4, 3, 14, .35), rgba(4, 3, 14, .72));
  opacity: 0;
  visibility: hidden;
  transition: opacity .6s ease, visibility .6s;
}
.card.show { opacity: 1; visibility: visible; }
.card-inner {
  position: relative;
  width: min(480px, 100%);
  max-height: calc(100% - 10px);
  overflow: auto;
  padding: 34px 26px 26px;
  border-radius: 26px;
  text-align: center;
  color: #3a2416;
  background:
    radial-gradient(120% 80% at 50% 0%, #fffaf0, #ffeccd 60%, #ffe1b8 100%);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9), inset 0 0 0 6px rgba(255, 255, 255, .45), inset 0 0 60px rgba(255, 190, 110, .25);
  transform: translateY(30px) scale(.94) rotateX(8deg);
  transition: transform .7s cubic-bezier(.2, 1.2, .3, 1);
}
.card.show .card-inner { transform: none; }
.card-seal {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-size: 34px;
  filter: drop-shadow(0 6px 12px rgba(180, 110, 30, .5));
  animation: sealBob 3s ease-in-out infinite;
}
@keyframes sealBob {
  0%, 100% { transform: translateX(-50%) rotate(-6deg); }
  50%      { transform: translateX(-50%) rotate(6deg) translateY(-3px); }
}
.card-title {
  margin: 8px 0 4px;
  font-family: var(--font-brush);
  font-weight: 400;
  font-size: clamp(30px, 8.6vw, 44px);
  line-height: 1.2;
  color: #b23a1f;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .8), 0 6px 18px rgba(200, 90, 30, .25);
}
.card-sub {
  margin: 0 0 18px;
  font-size: 14px;
  letter-spacing: .1em;
  color: #8a5a33;
}
.card-text { font-size: clamp(14.5px, 4vw, 16.5px); line-height: 2; color: #55351f; }
.card-text p { margin: 0; }
.card-sign {
  margin: 18px 0 22px;
  text-align: right;
  font-family: var(--font-brush);
  font-size: 20px;
  color: #b23a1f;
}
.card-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
  color: #7a3a12;
  background: rgba(255, 255, 255, .65);
  border: 1px solid rgba(180, 110, 50, .35);
  box-shadow: 0 6px 16px -10px rgba(120, 60, 10, .8);
  transition: transform .18s ease, box-shadow .18s ease, background .18s;
}
.btn:hover { transform: translateY(-2px); background: #fff; }
.btn:active { transform: translateY(0) scale(.97); }
.btn-primary {
  color: #fff;
  background: linear-gradient(160deg, #ff7a45, #e2452c);
  border-color: rgba(255, 255, 255, .3);
  box-shadow: 0 12px 26px -12px rgba(226, 69, 44, .95);
}
.btn-primary:hover { background: linear-gradient(160deg, #ff8d5c, #ee5433); }

/* 大字横幅 */
.banner {
  position: fixed;
  left: 50%;
  top: 46%;
  z-index: 6;
  transform: translate(-50%, -50%) scale(.6);
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  text-align: center;
  font-family: var(--font-brush);
  font-size: clamp(40px, 11vw, 92px);
  line-height: 1.1;
  color: #fff;
  background: linear-gradient(180deg, #fffdf5 10%, #ffe08a 50%, #ff9f43 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 190, 90, .75)) drop-shadow(0 6px 24px rgba(255, 90, 140, .45));
  transition: opacity .9s ease, transform 1.1s cubic-bezier(.2, 1.3, .3, 1);
}
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner.hide { opacity: 0; transform: translate(-50%, -56%) scale(.94); transition: opacity 1.2s ease, transform 1.2s ease; }

.click-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(58px + var(--safe-b));
  z-index: 5;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: rgba(255, 240, 210, .85);
  background: rgba(20, 14, 44, .5);
  border: 1px solid rgba(255, 255, 255, .12);
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s ease;
  white-space: nowrap;
}
.click-prompt.show { opacity: 1; animation: promptPulse 2.4s ease-in-out infinite; }
@keyframes promptPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 212, 121, .0); }
  50%      { box-shadow: 0 0 0 6px rgba(255, 212, 121, .12); }
}

/* 手机竖屏 */
@media (max-width: 480px) {
  .lock-card { padding: 24px 16px 20px; border-radius: 24px; }
  .lock-stage { height: 112px; }
  .countdown { gap: 7px; }
  .unit { border-radius: 13px; padding: 10px 2px 8px; }
  .age-badge { width: 62px; height: 62px; top: 14px; right: 12px; }
  .age-num { font-size: 23px; }
  .age-txt { font-size: 10px; }
  .hint-bar { padding: 0 8px; line-height: 1.7; }
  .card-inner { padding: 28px 18px 20px; border-radius: 22px; }
}

/* 横屏手机：锁屏收紧一点，避免超出 */
@media (max-height: 520px) {
  .lock-stage { height: 70px; }
  .lock-emoji { font-size: 28px; }
  .lock-gift { transform: scale(.62); margin-top: 22px; }
  .lock-title { font-size: 20px; margin-top: 2px; }
  .lock-desc { margin: 6px auto 10px; font-size: 13px; }
  .countdown { margin-bottom: 10px; }
  .unit { padding: 8px 2px 6px; }
  .unit .num { font-size: 24px; }
  .card-inner { padding: 22px 18px 16px; }
  .card-text { line-height: 1.7; }
  .card-sub { margin-bottom: 8px; }
  .card-sign { margin: 8px 0 12px; }
}

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