/* 《天外来财》theme tokens：黑金 Art Deco · 档案纸 · 沙漏 · 七芒星 */
:root {
  --ink: #0e0c0a; --coal: #1a1612; --coal-2: #241e17; --gold: #c9a45c; --gold-hi: #f0d79a; --gold-dim: #8a7040;
  --paper: #e9dfc8; --paper-dim: #b3a88f; --wine: #7a1f2b; --wine-hi: #c8475a; --omen: #3f6b5c; --omen-hi: #7fc7ad; --line: #4a3d27;
  --cut: 10px; --gap: 12px; --fast: 160ms; --mid: 240ms; --slow: 900ms;
  --font-title: var(--yoroll-font-title, serif); --font-body: var(--yoroll-font-body, sans-serif);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper);
  font-family: var(--font-body); font-size: 16px; line-height: 1.6; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; }
.screen { position: absolute; inset: 0; }

/* ── 共享组件：panel（切角面板，图片外壳就绪后由 .skin-panel 叠加九宫格） ── */
.panel { position: relative; background: linear-gradient(180deg, rgba(30,25,19,.96), rgba(14,12,10,.97));
  border: 1px solid var(--gold-dim); box-shadow: 0 0 0 3px rgba(14,12,10,.9), 0 0 0 4px var(--line), 0 18px 48px rgba(0,0,0,.6);
  clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut)); }
/* ── 共享组件：btn ── */
.btn { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 48px; min-width: 0; padding: 8px 22px; border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, var(--coal-2), var(--ink)); color: var(--paper);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0 50%);
  transition: transform var(--fast) ease-out, filter var(--fast) ease-out, border-color var(--fast); overflow-wrap: anywhere; }
.btn:hover, .btn:focus-visible { filter: brightness(1.3); border-color: var(--gold-hi); outline: none; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: default; filter: grayscale(.6); }
.btn.primary { color: var(--gold-hi); border-color: var(--gold); }
.btn.danger { border-color: var(--wine-hi); color: #f3c9cf; }
.btn .label { min-width: 0; }
.tag { flex: none; font-size: 12px; line-height: 1; padding: 4px 6px; border: 1px solid currentColor; white-space: nowrap; }
.tag.mem { color: var(--omen-hi); } .tag.long { color: var(--wine-hi); } .tag.prev { color: var(--gold); }

/* ── 生成外壳九宫格（源图 1516×226 / 1515×224，切片 上下44 左右120，含 fill）。
      侧边带凹口与星饰，只适合横向拉伸：用于对话框与按钮；高面板(抽屉/卡片)沿用上面的同色板代码面板。 ── */
.skinned .dialog { clip-path: none; background: none; box-shadow: none; border-style: solid; border-color: transparent; border-width: 30px 82px;
  border-image: var(--ui-panel) 44 120 fill / 30px 82px stretch; padding: 0 4px 6px; filter: drop-shadow(0 10px 24px rgba(0,0,0,.6)); }
.skinned .btn { clip-path: none; background: none; border-style: solid; border-color: transparent; border-width: 11px 30px;
  border-image: var(--ui-btn) 44 120 fill / 11px 30px stretch; padding: 4px 2px; min-height: 56px; }
.skinned .btn.primary { text-shadow: 0 0 12px rgba(240,215,154,.45); }
.skinned .choices .btn { padding: 4px 2px; min-height: 56px; }
.skinned .dialog .next { right: 4px; bottom: -8px; }

/* ── 标题屏：左下标题 + 右侧竖排按钮 ── */
#title { display: grid; grid-template-columns: 1.4fr minmax(240px, 360px); align-items: end; gap: 32px;
  padding: calc(48px + var(--safe-t)) calc(64px + var(--safe-r)) calc(64px + var(--safe-b)) calc(64px + var(--safe-l)); }
.title-bg { position: absolute; inset: 0; background: radial-gradient(90% 70% at 30% 20%, #3a2c17 0%, #14100b 55%, #070605 100%) center/cover no-repeat; }
.title-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7,6,5,.88) 0%, rgba(7,6,5,.35) 55%, rgba(7,6,5,.8) 100%), linear-gradient(0deg, rgba(7,6,5,.9), transparent 55%); }
.title-main, .title-menu { position: relative; z-index: 1; min-width: 0; }
.kicker { margin: 0; letter-spacing: .5em; color: var(--gold); font-size: 14px; }
.title-main h1 { margin: 4px 0 12px; font-family: var(--font-title); font-weight: 700; font-size: clamp(52px, 9vw, 120px); line-height: 1.05; letter-spacing: .08em;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #7d6231); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 0; max-width: 34em; color: var(--paper-dim); min-height: 3.2em; }
.title-menu { display: flex; flex-direction: column; gap: 14px; }
.title-menu .btn { min-height: 56px; font-size: 18px; }

/* ── 主玩法屏 ── */
#play { background: #000; }
.stage { position: absolute; inset: 0; overflow: hidden; }
.bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: filter var(--slow) ease, opacity var(--mid); }
.bg.bg-apartment { background-image: linear-gradient(180deg, #27303a, #14161a 70%); }
.bg.bg-office { background-image: linear-gradient(180deg, #33261a, #120e0a 75%); }
.bg.bg-hall { background-image: radial-gradient(80% 60% at 50% 10%, #5a4320, #17120c 70%); }
.bg.bg-study { background-image: linear-gradient(180deg, #2c2318, #0f0c09 75%); }
.bg.bg-archive { background-image: radial-gradient(70% 60% at 50% 60%, #1f3a31, #070908 75%); }
.bg.bg-white { background: radial-gradient(60% 60% at 50% 40%, #ffffff, #e9e4d8 80%) !important; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 40%, transparent 50%, rgba(0,0,0,.72) 100%); transition: box-shadow var(--mid); }
.portrait { position: absolute; right: 12%; bottom: 0; height: 88%; max-width: 46%; object-fit: contain; object-position: bottom;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.6)); transition: opacity var(--mid), transform var(--mid), filter var(--mid); pointer-events: none; }
.portrait.off { opacity: 0; transform: translateX(16px); }
.portrait.dim { filter: brightness(.6) drop-shadow(0 12px 28px rgba(0,0,0,.6)); }
.portrait.hero { right: auto; left: 7%; height: 82%; max-width: 40%; }
.portrait.hero.off { transform: translateX(-16px); }
.portrait.hero.dim { filter: brightness(.5) drop-shadow(0 12px 28px rgba(0,0,0,.6)); }
[hidden] { display: none !important; }

.portrait.noimg { opacity: 0; }
.bg.bg-exterior { background-image: linear-gradient(180deg, #3b4038, #12130f 75%); }
.bg.bg-corridor { background-image: linear-gradient(180deg, #33281a, #0f0c09 75%); }
.bg.bg-dining { background-image: radial-gradient(70% 60% at 50% 30%, #4a3418, #120e0a 75%); }

/* ── 屏上题字：旁白逐字自左而右、逐行自上而下写在画面上（不进对话框） ── */
.narr { position: fixed; z-index: -1; left: 0; right: 0; top: calc(56px + var(--safe-t)); bottom: 0; display: flex; align-items: center; cursor: pointer; user-select: none;
  padding: 0 calc(84px + var(--safe-r)) 96px calc(9vw + var(--safe-l));
  background: linear-gradient(90deg, rgba(5,4,3,.86) 0%, rgba(5,4,3,.66) 42%, rgba(5,4,3,.16) 74%, transparent 100%); animation: fadein var(--mid) ease-out; }
.narr:focus-visible { outline: none; }
.narr-in { width: min(34em, 46vw); font-size: clamp(17px, 1.5vw, 21px); line-height: 2; letter-spacing: .08em; color: var(--paper); text-shadow: 0 1px 3px #000; }
.narr-in p { margin: 0 0 .5em; overflow-wrap: anywhere; }
.narr-in p.old { color: var(--paper-dim); opacity: .62; }
.narr-in p.cur { padding-left: .8em; border-left: 2px solid var(--gold); }
.narr-in p.cur span { opacity: 0; animation: glyph .2s ease-out forwards; }
.narr-in p.cur.done span { animation: none; opacity: 1; }
@keyframes glyph { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
.narr .next { color: var(--gold); font-size: 12px; margin-left: .8em; animation: pulse 1.2s infinite; }
#play.narrating .portrait.hero { opacity: 0; }
#play.narrating .portrait:not(.hero):not(.off) { filter: brightness(.55) drop-shadow(0 12px 28px rgba(0,0,0,.6)); }
#play.tone-white .narr { background: none; }
#play.tone-white .narr-in { color: #3a332a; text-shadow: none; }
#play.tone-white .narr-in p.old { color: #7a7060; }

/* ── 实物展示：文件 / 手机 / 标签……关键信息清晰，其余糊掉 ── */
.prop { position: absolute; z-index: 2; left: 0; right: 0; top: calc(64px + var(--safe-t)); bottom: 212px; display: grid; place-items: center; pointer-events: none; }
.prop.off { display: none; }
#play.propping .portrait { opacity: 0; }
.card-prop { height: 100%; max-height: 520px; font-size: 13px; line-height: 1.5; box-shadow: 0 18px 44px rgba(0,0,0,.7); overflow: hidden; text-align: left; }
.card-prop.enter { animation: propin .32s ease-out both; }
@keyframes propin { from { opacity: 0; transform: translateY(18px) rotate(2deg); } }
.card-prop.paper { aspect-ratio: 0.74; padding: 2em 2.2em; background: linear-gradient(170deg, #f1e8d3, #e2d6ba); color: #2b2219; transform: rotate(-1.2deg); display: flex; flex-direction: column; }
.card-prop.paper.label { aspect-ratio: 1.45; height: 70%; transform: rotate(1.5deg); }
.card-prop.paper.note { aspect-ratio: 0.8; background: repeating-linear-gradient(180deg, #efe6cf 0, #efe6cf 2.05em, #cdbf9f 2.05em, #cdbf9f 2.12em); transform: rotate(1deg); }
.card-prop h3 { margin: .3em 0 .9em; font-family: var(--font-title); font-size: 1.5em; letter-spacing: .14em; text-align: center; }
.p-no { font-size: .78em; letter-spacing: .08em; opacity: .7; align-self: flex-end; padding: 0 .3em; }
.p-row { display: flex; gap: .8em; align-items: baseline; padding: .28em .3em; border-bottom: 1px solid rgba(43,34,25,.22); font-size: 1.02em; }
.p-row b { flex: none; min-width: 4.6em; font-weight: 400; opacity: .68; }
.p-row span { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.bar { display: block; height: .5em; margin: .62em .3em; border-radius: 2px; background: currentColor; opacity: .26; filter: blur(1.5px); }
.p-foot { margin-top: auto; font-size: .8em; padding: .25em .4em; opacity: .75; }
.p-sign { margin-top: auto; display: flex; align-items: flex-end; gap: .8em; padding: 0 .3em; }
.p-sign b { flex: none; font-weight: 400; opacity: .68; }
.p-sign .line { flex: 1; height: 2.4em; border-bottom: 1.5px solid #2b2219; display: flex; align-items: flex-end; }
.p-sign svg { height: 2.3em; width: auto; }
.p-sign .ink { stroke-dasharray: 100; stroke-dashoffset: 100; animation: ink 1.1s ease-out .15s forwards; }
@keyframes ink { to { stroke-dashoffset: 0; } }
.card-prop .hl { opacity: 1; background: rgba(200,71,90,.16); outline: 1.5px solid #a13a48; outline-offset: 1px; color: #7a1f2b; animation: hl 1.4s ease-in-out infinite; }
@keyframes hl { 50% { background: rgba(200,71,90,.32); } }
.chart { width: 100%; height: auto; margin: 0 0 .5em; }
.nt-code { align-self: center; margin: 1.2em 0; padding: .1em .6em; font-size: 3em; letter-spacing: .2em; font-family: var(--font-title); color: #5a5248; }
.nt-photo { display: flex; gap: 1em; align-items: center; margin-top: auto; transform: rotate(-3deg); }
.nt-photo i { flex: none; width: 5.2em; height: 6.4em; background: radial-gradient(circle at 50% 36%, #d9c7a6 0 22%, transparent 23%), radial-gradient(ellipse at 50% 100%, #d9c7a6 0 46%, transparent 47%), #8c7a62; border: .35em solid #f7f1e2; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.nt-photo span { font-style: italic; }
.card-prop.phone { aspect-ratio: 0.52; padding: 1.2em 1.3em 1.6em; border-radius: 2em; border: .3em solid #2c2f36; background: linear-gradient(180deg, #14171c, #0b0d10); color: #e8eaee; display: flex; flex-direction: column; }
.ph-bar { display: flex; justify-content: center; margin-bottom: 1em; } .ph-bar span { width: 32%; height: .5em; border-radius: 1em; background: #2c2f36; }
.ph-title { text-align: center; font-size: 1.15em; letter-spacing: .3em; margin-bottom: .8em; opacity: .8; }
.phone .p-row { border-bottom-color: rgba(255,255,255,.12); flex-direction: column; gap: 0; } .phone .p-row b { font-size: .82em; }
.ph-amt { margin: .7em 0; text-align: center; font-size: 1.9em; font-weight: 700; color: #f0d79a; font-variant-numeric: tabular-nums; }
.ph-btn { margin-top: auto; padding: .7em; text-align: center; border-radius: .6em; background: #c9a45c; color: #14100b; font-weight: 700; letter-spacing: .2em; }
.ph-ok { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: .2em; color: #7fc7ad; font-weight: 700; letter-spacing: .12em; animation: propin .3s ease-out both; }
.ph-ok i { width: 2.6em; height: 2.6em; display: grid; place-items: center; border-radius: 50%; border: .16em solid currentColor; font-style: normal; font-size: 1.3em; }
.ph-ok small { font-weight: 400; opacity: .7; }
.ph-call { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5em; text-align: center; }
.ph-call b { font-size: 1.7em; letter-spacing: .12em; } .ph-call small { opacity: .6; }
.ph-keys { display: flex; justify-content: space-around; } .ph-keys i { width: 3.4em; height: 3.4em; border-radius: 50%; }
.ph-keys .no { background: #c8475a; } .ph-keys .yes { background: #4fae7e; animation: pulse 1s infinite; }
.card-prop.invite { aspect-ratio: 1.42; height: 66%; padding: 1.6em 2.4em; background: linear-gradient(160deg, #1d1711, #0c0a08); color: #f0d79a; border: 1px solid #c9a45c; outline: 1px solid #8a7040; outline-offset: -.6em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35em; text-align: center; transform: rotate(-1.5deg); }
.invite h3 { margin: .1em 0; font-size: 2em; } .iv-small { font-size: .85em; letter-spacing: .4em; opacity: .8; } .iv-date { font-size: 1.15em; letter-spacing: .12em; } .iv-star { font-size: 1.3em; }
.iv-foot { margin-top: .8em; font-size: .72em; opacity: .55; padding: .1em .5em; } .invite .iv-foot.hl { color: #f3c9cf; opacity: 1; }
.card-prop.keypad { aspect-ratio: 0.7; height: 86%; padding: 1.4em; background: linear-gradient(160deg, #6a5630, #3a2e18); border: .2em solid #8a7040; border-radius: .5em; color: #f0d79a; display: flex; flex-direction: column; gap: .9em; }
.kp-tag { font-size: .78em; padding: .3em .5em; background: #d8cba8; color: #4a3d27; text-align: center; }
.kp-led { padding: .3em; text-align: center; font-size: 1.8em; letter-spacing: .3em; background: #0d1a14; color: #7fc7ad; font-variant-numeric: tabular-nums; }
.kp-keys { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: .5em; } .kp-keys i { display: grid; place-items: center; font-style: normal; font-size: 1.2em; background: #2a2114; border: 1px solid #8a7040; border-radius: .3em; }
.card-prop.files { aspect-ratio: 0.9; padding: 1.4em 1.6em; background: linear-gradient(170deg, #cbb98f, #a8946a); color: #2b2219; display: flex; flex-direction: column; gap: .4em; transform: rotate(-1deg); }
.fl-head { font-family: var(--font-title); font-size: 1.3em; letter-spacing: .3em; text-align: center; margin-bottom: .3em; }
.fl { flex: 1; display: flex; align-items: center; gap: .9em; padding: 0 .8em; background: #e9dfc8; border-left: .4em solid #7a1f2b; } .fl b { flex: none; font-family: var(--font-title); letter-spacing: .1em; } .fl span { flex: 1; min-width: 0; } .fl em { flex: none; font-style: normal; font-weight: 700; }
.fl.dim { opacity: .6; }

/* ── 场景转场：黑场 + 日期 / 地点 / 时间 ── */
.scene-cut { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #050403; opacity: 0; transition: opacity .32s ease-in; cursor: pointer; }
.scene-cut.on { opacity: 1; }
.scene-cut.out { opacity: 0; transition: opacity .42s ease-out; }
.cut-in { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; text-align: center; max-width: 92%; }
.cut-day { color: var(--gold); font-size: 15px; letter-spacing: .28em; }
.cut-place { color: var(--paper); font-family: var(--font-title); font-size: clamp(26px, 5vw, 44px); letter-spacing: .12em; line-height: 1.3; overflow-wrap: anywhere; }
.cut-place::before, .cut-place::after { content: ''; display: block; width: 120px; height: 1px; margin: 12px auto; background: linear-gradient(90deg, transparent, var(--gold-dim), transparent); }
.cut-time { color: var(--paper-dim); font-size: 16px; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.scene-cut.on .cut-in { animation: fadein .5s ease-out both; }

/* ── 提示卡 ── */
.mask.guide-mask { background: rgba(5,4,3,.5); }
.sheet.guide .guide-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.sheet.guide .guide-icon { flex: none; width: 48px; height: 48px; display: grid; place-items: center; color: var(--gold-hi); border: 1px solid var(--gold-dim); transform: rotate(45deg); }
.sheet.guide .guide-icon svg { width: 22px; height: 22px; transform: rotate(-45deg); }
.sheet.guide h3 { margin: 0; color: var(--gold-hi); font-family: var(--font-title); font-size: 20px; letter-spacing: .08em; }
.sheet.guide .sub { color: var(--paper-dim); font-size: 13px; margin-top: 2px; }
.sheet.guide p { margin: 0 0 6px; line-height: 1.75; }
.guide-on { animation: guidepulse 1.1s ease-in-out infinite; }
@keyframes guidepulse { 0%, 100% { filter: drop-shadow(0 0 2px var(--gold-hi)); } 50% { filter: drop-shadow(0 0 14px var(--gold-hi)) brightness(1.5); } }
body.calm .guide-on { animation: none; filter: drop-shadow(0 0 8px var(--gold-hi)); }
#play.cold .bg { filter: saturate(.7) hue-rotate(28deg) brightness(.82); }
#play.omen .vignette { box-shadow: inset 0 0 120px 30px rgba(63,107,92,.75); }
#play.dying .stage { filter: grayscale(1) brightness(.5); transition: filter var(--slow); }
#play.shake .stage { animation: shake .45s; }
@keyframes shake { 20% { transform: translate(-8px, 3px); } 40% { transform: translate(7px, -4px); } 60% { transform: translate(-5px, 2px); } 80% { transform: translate(3px, -1px); } }
#play.tone-white .vignette { background: none; }
#play.tone-white .hud { color: #3a332a; background: none; border: 0; text-shadow: none; }

.hud { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 20px; min-height: 56px;
  padding: calc(8px + var(--safe-t)) calc(84px + var(--safe-r)) 8px calc(20px + var(--safe-l));
  background: linear-gradient(180deg, rgba(8,7,6,.92), rgba(8,7,6,.55) 70%, transparent); border-top: 2px solid var(--gold-dim); text-shadow: 0 1px 2px #000; }
.hud-date { display: flex; align-items: baseline; gap: 10px; min-width: 0; white-space: nowrap; }
.hud-date b { font-family: var(--font-title); color: var(--gold-hi); font-size: 20px; }
.hud-date .time { font-variant-numeric: tabular-nums; color: var(--paper); }
.hud-date .place { color: var(--paper-dim); font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.hud-loop { white-space: nowrap; color: var(--paper-dim); font-size: 14px; }
.hourglasses { display: flex; gap: 4px; flex: none; }
.hourglass { width: 22px; height: 26px; color: var(--gold); transition: opacity var(--mid), color var(--mid); }
.hourglass.broken { color: var(--line); opacity: .7; }
.hourglass.last { color: var(--wine-hi); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.hud-goal { margin-left: auto; min-width: 0; text-align: right; font-size: 14px; color: var(--paper-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud.final { border-top-color: var(--wine-hi); }
.hud.final .hud-goal { color: var(--wine-hi); }
.meters { display: inline-flex; gap: 10px; margin-left: 10px; color: var(--omen-hi); }

.rail { position: absolute; z-index: 4; right: calc(14px + var(--safe-r)); top: calc(66px + var(--safe-t)); display: flex; flex-direction: column; gap: 10px; }
.rail-btn { position: relative; width: 52px; height: 52px; padding: 0; display: grid; place-items: center; border: 0; background: none; color: var(--gold); }
.rail-btn::before { content: ''; position: absolute; inset: 6px; transform: rotate(45deg); background: rgba(14,12,10,.86); border: 1px solid var(--gold-dim); transition: border-color var(--fast), background var(--fast); }
.rail-btn:hover::before, .rail-btn:focus-visible::before { border-color: var(--gold-hi); background: rgba(40,32,22,.95); }
.rail-btn:focus-visible { outline: none; }
.rail-btn svg { position: relative; width: 22px; height: 22px; }
.rail-btn .dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--wine-hi); box-shadow: 0 0 6px var(--wine-hi); }
.rail-btn .tip { position: absolute; right: 58px; top: 50%; transform: translateY(-50%); padding: 2px 8px; font-size: 12px; white-space: nowrap; background: rgba(14,12,10,.9); border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: opacity var(--fast); }
.rail-btn:hover .tip, .rail-btn:focus-visible .tip { opacity: 1; }

.bottom { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: var(--gap);
  padding: 0 calc(84px + var(--safe-r)) calc(18px + var(--safe-b)) calc(24px + var(--safe-l)); pointer-events: none; }
.bottom > * { pointer-events: auto; }
.choices { align-self: flex-end; display: flex; flex-direction: column; gap: 10px; width: min(560px, 100%); }
.choices .hint { align-self: flex-end; font-size: 13px; color: var(--wine-hi); background: rgba(14,12,10,.8); padding: 2px 10px; }
.choices .btn { justify-content: flex-start; text-align: left; padding: 10px 28px; min-height: 52px; animation: rise var(--mid) ease-out both; }
.choices .btn .label { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.tools { display: flex; gap: 8px; align-self: flex-start; }
.tool { min-height: 44px; padding: 4px 14px; font-size: 13px; color: var(--paper-dim); background: rgba(14,12,10,.78); border: 1px solid var(--line); }
.tool:hover, .tool:focus-visible { color: var(--gold-hi); border-color: var(--gold-dim); outline: none; }
.tool[disabled] { opacity: .35; cursor: default; }
.dialog { min-height: 150px; padding: 18px 30px 22px; cursor: pointer; user-select: none; }
.dialog:focus-visible { outline: 1px solid var(--gold-hi); outline-offset: -6px; }
.dialog .who { font-family: var(--font-title); color: var(--gold-hi); font-size: 18px; min-height: 1.5em; letter-spacing: .1em; }
.dialog .text { margin: 4px 0 0; font-size: 18px; line-height: 1.75; overflow-wrap: anywhere; animation: fadein var(--mid) ease-out; }
.dialog .text.inner { color: var(--paper-dim); font-style: normal; }
.dialog .text.narr { color: #d8cfb9; }
.dialog .next { position: absolute; right: 22px; bottom: 10px; color: var(--gold); font-size: 12px; animation: pulse 1.2s infinite; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } }

.toasts { position: absolute; z-index: 6; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { padding: 8px 18px; background: rgba(14,12,10,.94); border: 1px solid var(--gold-dim); color: var(--gold-hi); font-size: 14px; text-align: center; animation: toast 3.2s ease-out both; }
.toast.ev { border-color: var(--omen-hi); color: var(--omen-hi); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ── 浮层（抽屉 / 死亡卡 / 结局卡 / 确认） ── */
#layer { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.mask { position: absolute; inset: 0; pointer-events: auto; display: grid; place-items: center; background: rgba(5,4,3,.78);
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); animation: fadein var(--mid) ease-out; }
.sheet { width: min(980px, 100%); max-height: 100%; display: flex; flex-direction: column; padding: 22px 26px; }
.sheet.narrow { width: min(560px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--font-title); color: var(--gold-hi); font-size: 22px; letter-spacing: .12em; min-width: 0; }
.x { flex: none; width: 44px; height: 44px; border: 1px solid var(--line); background: var(--ink); color: var(--gold); font-size: 20px; line-height: 1; }
.x:hover, .x:focus-visible { border-color: var(--gold-hi); outline: none; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { min-height: 44px; padding: 4px 16px; border: 1px solid var(--line); background: none; color: var(--paper-dim); }
.tab.on { color: var(--gold-hi); border-color: var(--gold); background: rgba(201,164,92,.08); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: 4px; }
.empty { color: var(--paper-dim); padding: 24px 0; text-align: center; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.item { min-width: 0; padding: 10px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.item h4 { margin: 0 0 2px; color: var(--gold-hi); font-size: 16px; overflow-wrap: anywhere; }
.item p { margin: 0; font-size: 14px; color: var(--paper-dim); overflow-wrap: anywhere; }
.item.locked h4 { color: var(--line); } .item.locked p { color: var(--line); }
.item .sub { font-size: 12px; color: var(--gold-dim); }
.item.ev h4 { color: var(--omen-hi); }
.sec { margin: 16px 0 8px; font-size: 14px; color: var(--gold); letter-spacing: .2em; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
/* 时间轴 */
.timeline { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 0; overflow-x: auto; padding: 8px 0 12px; }
.tl-day { position: relative; padding: 26px 8px 0; min-width: 0; border-top: 1px solid var(--gold-dim); }
.tl-day::before { content: ''; position: absolute; top: -6px; left: 8px; width: 10px; height: 10px; transform: rotate(45deg); background: var(--ink); border: 1px solid var(--gold); }
.tl-day.now::before { background: var(--gold-hi); } .tl-day.dead::before { background: var(--wine-hi); border-color: var(--wine-hi); }
.tl-day .d { font-size: 12px; color: var(--gold); } .tl-day .n { font-family: var(--font-title); font-size: 15px; color: var(--paper); }
.tl-day ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--paper-dim); }
.tl-day li { margin-bottom: 4px; overflow-wrap: anywhere; } .tl-day li.death { color: var(--wine-hi); }
.loops { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* 死亡卡 / 结局卡 */
.card { text-align: center; align-items: center; gap: 6px; }
.stamp { display: inline-block; padding: 2px 14px; border: 2px solid var(--wine-hi); color: var(--wine-hi); letter-spacing: .3em; transform: rotate(-4deg); font-size: 14px; animation: stamp .35s ease-out both; }
@keyframes stamp { from { opacity: 0; transform: rotate(-4deg) scale(1.8); } }
.card h2 { margin: 8px 0 0; font-family: var(--font-title); font-size: clamp(28px, 5vw, 44px); color: var(--paper); letter-spacing: .12em; }
.card .meta { color: var(--paper-dim); font-size: 14px; }
.card .cause { margin: 6px 0 0; }
.card .epitaph { margin: 8px 0; color: var(--gold-hi); max-width: 30em; }
.card .gain { color: var(--omen-hi); font-size: 14px; }
.card .whisper { margin: 6px 0; font-size: 14px; color: var(--paper-dim); font-style: italic; }
.card .hourglasses { justify-content: center; margin: 6px 0; }
.card .hourglass { width: 26px; height: 32px; }
.card .lines p { margin: 4px 0; } .card .lines p.q { color: var(--gold-hi); }
.status { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; font-size: 14px; text-align: left; }
.status li { display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px dashed var(--line); }
.status b { color: var(--gold-hi); font-weight: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 14px; width: 100%; }
.actions .btn { flex: 1 1 200px; max-width: 320px; }
.notice { color: var(--paper-dim); font-size: 13px; min-height: 1.4em; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.setrow .btn { min-width: 110px; }

/* 回溯：逆向扫光 */
.rewind-fx { position: absolute; inset: 0; z-index: 30; pointer-events: auto; background: linear-gradient(100deg, transparent 0%, rgba(240,215,154,.9) 45%, #fff 55%, #fff 100%); background-size: 300% 100%; animation: sweep var(--slow) ease-in both; }
@keyframes sweep { from { background-position: 100% 0; opacity: .2; } to { background-position: 0 0; opacity: 1; } }
.rewind-fx.out { animation: fadeout .6s ease-out both; background: #fff; }
@keyframes fadeout { to { opacity: 0; } }

/* 睁眼：上下眼睑先合拢（陷入黑暗），再眨一下、缓缓睁开；画面由模糊过曝恢复清晰 */
.eye-fx { position: absolute; inset: 0; z-index: 30; pointer-events: auto; overflow: hidden; }
.eye-fx .lid { position: absolute; left: -5%; width: 110%; height: 0; background: #000; box-shadow: 0 0 46px 34px #000; transition: height .6s ease-in; }
.eye-fx .lid.top { top: 0; } .eye-fx .lid.bot { bottom: 0; }
.eye-fx.shut .lid { height: 53%; }
.eye-fx.open .lid { transition: none; animation: eye-open 2.6s cubic-bezier(.4,0,.2,1) both; }
@keyframes eye-open { 0% { height: 53%; } 20% { height: 43%; } 32% { height: 53%; } 46% { height: 53%; } 68% { height: 30%; } 78% { height: 35%; } 100% { height: 0; box-shadow: none; } }
#play.waking .stage, #play.waking .bottom, #play.waking .hud { animation: wake-blur 2.7s ease-out both; }
@keyframes wake-blur { 0% { filter: blur(14px) brightness(1.5); } 55% { filter: blur(7px) brightness(1.25); } 100% { filter: blur(0) brightness(1); } }
/* 退出后的告别页：整屏压黑 */
.mask.bye-mask { background: #050403; }

body.calm *, body.calm *::before, body.calm *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }

/* ── 竖屏 / 窄屏：场景在上，对话与选项在下 ── */
@media (max-aspect-ratio: 4/5), (max-width: 640px) {
  #title { grid-template-columns: 1fr; align-content: end; gap: 24px; padding: calc(24px + var(--safe-t)) 24px calc(32px + var(--safe-b)); }
  .stage { bottom: auto; height: 34%; }
  .choices { gap: 6px; } .choices .hint { font-size: 12px; }
  .choices .btn, .skinned .choices .btn { font-size: 14px; line-height: 1.35; min-height: 48px; padding: 2px; }
  .skinned .choices .btn { border-width: 10px 22px; border-image-width: 10px 22px; }
  .bottom.choosing .dialog { min-height: 0; } .bottom.choosing .dialog .text { font-size: 15px; line-height: 1.6; }
  .bottom.choosing .tools .tool[disabled] { display: none; }
  .portrait { right: 2%; height: 84%; max-width: 56%; }
  .portrait.hero { left: 0; height: 66%; max-width: 46%; }
  .scene-cut { z-index: 5; }
  /* 竖屏：题字写在场景下方的整块留白里（无外框），实物展示时场景区加高 */
  .narr { position: static; z-index: auto; order: 1; align-items: flex-start; min-height: 150px; padding: 14px 8px 8px; background: none; animation: none; }
  .narr-in { width: 100%; font-size: 16px; line-height: 1.85; letter-spacing: .05em; }
  .bottom.choosing .narr { min-height: 0; } .bottom.choosing .narr-in p.old { display: none; }
  #play.tone-white .narr-in { color: var(--paper); } #play.tone-white .narr-in p.old { color: var(--paper-dim); }
  .prop { top: calc(86px + var(--safe-t)); bottom: 56px; }
  #play.propping .stage { height: 58%; } #play.propping .bottom { top: 58%; } #play.propping .rail { bottom: 43%; }
  .hud { flex-wrap: wrap; gap: 4px 12px; padding-right: 12px; padding-left: 12px; }
  .hud-goal { flex-basis: 100%; text-align: left; margin-left: 0; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.5; }
  .rail { top: auto; bottom: 67%; right: 6px; flex-direction: row; gap: 2px; }
  .rail-btn { width: 46px; height: 46px; } .rail-btn .tip { display: none; }
  .bottom { top: 34%; gap: 8px; padding: 10px 12px calc(12px + var(--safe-b)); justify-content: flex-start; overflow-y: auto; pointer-events: auto; background: linear-gradient(180deg, #14100c, var(--ink)); }
  .bottom .dialog { order: 1; } .bottom .tools { order: 2; } .bottom .choices { order: 3; width: 100%; }
  .dialog { min-height: 120px; padding: 14px 18px 20px; } .dialog .text { font-size: 16px; }
  .skinned .dialog { border-width: 22px 46px; border-image-width: 22px 46px; padding: 0 0 4px; } .skinned .dialog .next { right: 8px; }
  .sheet { padding: 16px; } .timeline { grid-template-columns: repeat(7, 130px); }
}
/* 矮横屏（手机横置）：压缩对话框，保持场景可见 */
@media (max-height: 460px) and (min-aspect-ratio: 4/5) {
  .hud { min-height: 44px; } .hud-date b { font-size: 16px; }
  .rail { gap: 2px; top: calc(48px + var(--safe-t)); } .rail-btn { width: 44px; height: 44px; }
  .dialog { min-height: 96px; padding: 10px 22px 14px; } .dialog .text { font-size: 15px; line-height: 1.6; } .dialog .who { font-size: 15px; }
  .skinned .dialog { border-width: 18px 56px; border-image-width: 18px 56px; padding: 0 0 2px; }
  .choices .btn, .skinned .choices .btn { min-height: 44px; } .skinned .btn { border-width: 9px 24px; border-image-width: 9px 24px; min-height: 44px; }
  .choices .btn { padding: 4px 24px; } .skinned .choices .btn { padding: 2px; } .choices { gap: 6px; width: min(460px, 100%); max-height: calc(100vh - 168px - var(--safe-b)); overflow-y: auto; }
  .bottom { gap: 6px; padding-bottom: calc(8px + var(--safe-b)); } .tools { position: absolute; left: calc(24px + var(--safe-l)); bottom: calc(116px + var(--safe-b)); }
  #title { padding: 20px 32px; } .title-menu .btn { min-height: 44px; font-size: 16px; } .title-menu { gap: 8px; }
  .prop { top: calc(46px + var(--safe-t)); bottom: 118px; } .narr { top: calc(44px + var(--safe-t)); padding-bottom: 60px; } .narr-in { font-size: 15px; line-height: 1.75; }
}
