/* 生日蛋糕 */
:root {
  --bg: #0b0618; --ink: #fff7f0; --muted: rgba(255, 247, 240, .66);
  --pink: #ff8fc2; --gold: #ffd27a; --glass: rgba(24, 14, 48, .55); --line: rgba(255, 255, 255, .16);
  --serif: "Noto Serif SC", "Songti SC", "STSong", serif; --script: "Great Vibes", "Snell Roundhand", cursive;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--serif); overflow: hidden; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── 标题 ── */
.hero { position: fixed; top: max(18px, env(safe-area-inset-top)); left: 0; right: 0; text-align: center; pointer-events: none; text-shadow: 0 2px 24px rgba(255, 126, 182, .55); transition: opacity .6s; }
#eyebrow { font-size: 12px; letter-spacing: .5em; color: var(--gold); opacity: 0; animation: rise 1.2s 1.2s ease-out forwards; }
#title { margin: 6px 0 0; font-weight: 500; line-height: 1.05; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hb { font-family: var(--script); font-size: clamp(40px, 8vw, 78px); background: linear-gradient(100deg, #fff, #ffc2e0 45%, #ffe3a3); -webkit-background-clip: text; background-clip: text; color: transparent; opacity: 0; animation: rise 1.4s .6s ease-out forwards; }
#bname { font-size: clamp(20px, 3.4vw, 32px); letter-spacing: .3em; margin-left: .3em; opacity: 0; animation: rise 1.4s 1.5s ease-out forwards; }
#sub { margin: 8px 0 0; font-size: 13px; color: var(--muted); letter-spacing: .12em; opacity: 0; animation: rise 1.4s 2.2s ease-out forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

#hint { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 16px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); font-size: 13px; letter-spacing: .08em; opacity: 0; pointer-events: none; transition: opacity .8s; white-space: nowrap; }
.ready #hint { opacity: 1; animation: floaty 3s ease-in-out infinite; }
.busy #hint, .film-open #hint, .seen #hint { opacity: 0 !important; }
@keyframes floaty { 50% { transform: translate(-50%, -5px); } }
#hint span { display: inline-block; animation: twinkle 1.6s infinite; }
@keyframes twinkle { 50% { transform: scale(1.3) rotate(18deg); } }

#wishBanner { position: fixed; top: 38%; left: 50%; transform: translate(-50%, -50%) scale(.6); font-size: clamp(26px, 6vw, 48px); letter-spacing: .12em; text-shadow: 0 0 30px #ff7eb6, 0 0 60px #ffd24a; opacity: 0; pointer-events: none; }
#wishBanner.on { animation: banner 3.6s ease-out forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }

/* ── 底部工具条 ── */
.dock { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: 0 10px 40px rgba(0, 0, 0, .4); transition: opacity .5s, transform .5s; max-width: calc(100vw - 20px); }
.dbtn { display: flex; align-items: center; gap: 7px; padding: 10px 14px; border-radius: 15px; border: 1px solid transparent; background: rgba(255, 255, 255, .06); font-size: 13px; letter-spacing: .06em; white-space: nowrap; transition: background .2s, transform .2s; }
.dbtn i { font-style: normal; font-size: 16px; }
.dbtn:hover { background: rgba(255, 255, 255, .14); transform: translateY(-2px); }
.dbtn.primary { background: linear-gradient(120deg, #ff7eb6, #ffa86b); color: #2a0c24; font-weight: 700; }
.dbtn.on { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 210, 122, .4); }
.busy .dock, .film-open .dock, .busy .hero, .film-open .hero { opacity: 0; pointer-events: none; }
.busy .dock, .film-open .dock { transform: translate(-50%, 24px); }
@media (max-width: 560px) { .dbtn span { display: none; } .dbtn.primary span { display: inline; } .dbtn { padding: 11px 14px; } }

#toast { position: fixed; left: 50%; top: 22px; transform: translate(-50%, -20px); padding: 10px 18px; border-radius: 99px; background: rgba(20, 10, 40, .9); border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: .3s; z-index: 60; font-size: 14px; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────── 电影放映层 ───────── */
#film { position: fixed; inset: 0; z-index: 20; background: radial-gradient(ellipse at 50% 40%, rgba(32, 14, 56, .9), rgba(6, 3, 16, .96)); backdrop-filter: blur(10px); overflow: hidden; user-select: none; }
#film[hidden] { display: none; }
#filmStage { position: absolute; inset: 0; cursor: pointer; }
#filmFx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; z-index: 5; }
#filmBars { position: absolute; z-index: 8; top: max(12px, env(safe-area-inset-top)); left: 14px; right: 110px; display: flex; gap: 5px; }
#filmBars i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .22); overflow: hidden; }
#filmBars b { display: block; height: 100%; background: #fff; transform-origin: left; transform: scaleX(0); box-shadow: 0 0 8px var(--c, #fff); }
.fbtn { position: absolute; z-index: 9; top: max(4px, calc(env(safe-area-inset-top) - 4px)); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); backdrop-filter: blur(8px); font-size: 14px; }
#filmClose { right: 12px; } #filmPause { right: 58px; font-size: 11px; }
.fbtn:hover { background: rgba(255, 255, 255, .2); }
#filmHint { position: absolute; z-index: 8; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255, 255, 255, .45); letter-spacing: .1em; pointer-events: none; animation: fadeout 1s 3.5s forwards; }
@keyframes fadeout { to { opacity: 0; } }
.fx-avatar { position: absolute; z-index: 7; border-radius: 50%; background-size: cover; background-position: center; border: 5px solid #fff; box-shadow: 0 0 0 6px var(--c), 0 0 60px var(--c); pointer-events: none; }

.scene { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; will-change: transform, opacity, filter; }
.bgimg, .pbg { position: absolute; inset: -8%; background-size: cover; background-position: center; filter: blur(34px) saturate(1.3) brightness(.55); transform: scale(1.1); }
.bgimg.dim { filter: blur(44px) saturate(1.2) brightness(.32); }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(5, 2, 14, .65)); pointer-events: none; }
.kicker { position: relative; font-size: clamp(13px, 2.4vw, 17px); letter-spacing: .4em; color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 122, .5); }

/* 1 · 人像 */
.sc-portrait .orb { position: relative; width: min(52vw, 52vh, 420px); aspect-ratio: 1; border-radius: 50%; border: 6px solid #fff; box-shadow: 0 0 0 10px var(--c), 0 0 90px var(--c), 0 30px 80px rgba(0, 0, 0, .5); }
.sc-portrait .orb img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.sc-portrait .orb::after { content: ""; position: absolute; inset: -34px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .35); animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sc-portrait .who { position: relative; margin-top: clamp(26px, 5vh, 52px); text-align: center; }
.sc-portrait h2 { margin: 10px 0 0; font-size: clamp(34px, 7vw, 64px); font-weight: 700; letter-spacing: .18em; text-shadow: 0 4px 30px var(--c); }

/* 2 · 许愿 */
.sc-wish { gap: 22px; padding: 0 8vw; text-align: center; }
.candle-big { position: relative; width: 46px; height: clamp(120px, 24vh, 210px); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; margin-top: 4vh; }
.candle-big .wax { width: 40px; flex: 1; border-radius: 6px 6px 3px 3px; background: repeating-linear-gradient(135deg, #fff7ef 0 12px, var(--c) 12px 24px); box-shadow: 0 0 40px color-mix(in srgb, var(--c) 50%, transparent), inset -8px 0 14px rgba(0, 0, 0, .18); }
.candle-big .wick { width: 3px; height: 14px; background: #2a1a14; border-radius: 2px; }
.candle-big .flame { position: absolute; top: -52px; left: 50%; width: 30px; height: 64px; margin-left: -15px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; background: radial-gradient(ellipse at 50% 78%, #fffbe0 0 22%, #ffd36a 45%, #ff8f2e 80%); box-shadow: 0 0 40px 18px rgba(255, 170, 60, .55), 0 0 140px 70px rgba(255, 140, 60, .28); transform-origin: 50% 100%; animation: flick .18s ease-in-out infinite alternate; }
@keyframes flick { from { transform: scale(1, 1) rotate(-2deg); } to { transform: scale(.92, 1.08) rotate(2.5deg); } }
.candle-big.out .flame { animation: poof 1s forwards; }
@keyframes poof { to { transform: scale(0, .1) translateY(14px); opacity: 0; box-shadow: none; } }
.sc-wish .kicker { margin-top: 2vh; }
.wish-text { position: relative; margin: 0; min-height: 5em; max-width: 24em; font-size: clamp(20px, 3.6vw, 34px); line-height: 1.8; letter-spacing: .08em; text-shadow: 0 2px 20px rgba(0, 0, 0, .6); }

/* 3 · 合照 */
.sc-photo .pbg { filter: blur(40px) saturate(1.4) brightness(.5); }
.frame { position: relative; margin: 0; width: min(92vw, 150vh, 1200px); height: min(72vh, 64vw); border-radius: 18px; overflow: hidden; box-shadow: 0 30px 90px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .12); }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: center; }
.cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 70px clamp(18px, 4vw, 44px) clamp(16px, 3vh, 30px); display: flex; flex-direction: column; gap: 4px; text-align: left; background: linear-gradient(transparent, rgba(0, 0, 0, .62)); }
.cap-who { font-size: 12px; letter-spacing: .3em; color: var(--gold); }
.cap p { margin: 0; font-size: clamp(18px, 3vw, 28px); letter-spacing: .06em; text-shadow: 0 2px 16px rgba(0, 0, 0, .8); }

/* 4 · 结尾 */
.sc-end { gap: 6px; text-align: center; padding: 0 6vw; }
.end-hb { position: relative; font-family: var(--script); font-size: clamp(52px, 12vw, 120px); background: linear-gradient(100deg, #fff, #ffc2e0 45%, #ffe3a3); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 24px rgba(255, 126, 182, .6)); }
.end-name { position: relative; font-size: clamp(24px, 5vw, 44px); letter-spacing: .4em; margin-left: .4em; }
.end-msg { position: relative; margin: 14px 0 0; color: var(--muted); letter-spacing: .12em; font-size: clamp(14px, 2.4vw, 18px); }
.faces { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: clamp(18px, 4vh, 36px); max-width: 80vw; }
.faces img { width: clamp(38px, 7vw, 58px); height: clamp(38px, 7vw, 58px); border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, .85); opacity: 0; animation: pop .6s calc(1s + var(--i) * .12s) cubic-bezier(.2, 1.6, .4, 1) forwards; }
.faces img.me { border-color: var(--gold); box-shadow: 0 0 18px var(--gold); }
@keyframes pop { from { opacity: 0; transform: scale(.2) translateY(20px); } to { opacity: 1; transform: none; } }

/* ── 弹窗：点亮我的蜡烛 ── */
#modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 3, 16, .72); backdrop-filter: blur(8px); }
#modal[hidden] { display: none; }
.sheet { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px 22px 18px; border-radius: 24px; background: linear-gradient(160deg, rgba(48, 24, 86, .96), rgba(22, 11, 44, .98)); border: 1px solid var(--line); box-shadow: 0 30px 90px rgba(0, 0, 0, .6); animation: sheetIn .45s cubic-bezier(.2, .9, .2, 1); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(30px) scale(.96); } }
.sheet h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: .1em; }
.lead { margin: 0 0 16px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.sheet label { display: block; font-size: 12px; letter-spacing: .12em; color: var(--muted); margin-top: 12px; }
.sheet input[type=text], .sheet input:not([type]), .sheet textarea { display: block; width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--ink); font: inherit; font-size: 15px; outline: none; }
.sheet textarea { resize: vertical; line-height: 1.6; }
.sheet input:focus, .sheet textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 143, 194, .2); }
@media (max-width: 560px) {
  .sc-portrait .orb { width: min(66vw, 46vh); }
  .frame { width: 94vw; height: 56vh; }
  #filmBars { right: 100px; }
}
@media (prefers-reduced-motion: reduce) { .sc-portrait .orb::after, .flame, #hint { animation: none !important; } }

/* ── 祝福 ── */
#wLen { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }
.sheet label.chk { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; letter-spacing: .04em; font-size: 13px; color: var(--ink); cursor: pointer; }
.chk input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--pink); flex: none; }
.chk small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.sheet.read { text-align: center; }
#rIcon { font-size: 40px; }
#rFrom { margin-top: 6px; font-size: 13px; letter-spacing: .24em; color: var(--gold); }
#rTo { margin-top: 14px; font-family: var(--script); font-size: 30px; }
#rMsg { margin: 10px 0 0; font-size: 18px; line-height: 1.9; letter-spacing: .05em; white-space: pre-wrap; word-break: break-word; }
#rTime { margin-top: 14px; font-size: 12px; color: var(--muted); }
.sheet.read .actions { justify-content: center; }
.dbtn.primary i { font-size: 15px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.actions button { padding: 11px 20px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); letter-spacing: .08em; }
.actions .primary { border: 0; background: linear-gradient(120deg, #ff7eb6, #ffa86b); color: #2a0c24; font-weight: 700; }
.actions button:disabled { opacity: .55; }
