
:root {
  --ink: #0a0908;
  --ink-2: #13110f;
  --paper: #ede4d3;
  --paper-2: #c9bfad;
  --paper-3: #8d8576;
  --hair: rgba(237, 228, 211, 0.16);
  --hair-2: rgba(237, 228, 211, 0.32);
  --seal: #b8372c;
  --seal-glow: rgba(214, 72, 52, 0.55);
  --serif: "DreamPi Wen", "Songti SC", "STSong", "Source Han Serif SC", serif;
  --brush: "DreamPi Wen", "Xingkai SC", "STXingkai", "Kaiti SC", "STKaiti", serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--ink); color: var(--paper); font-family: var(--serif); overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.screen { position: fixed; inset: 0; opacity: 0; visibility: hidden; transition: opacity .9s var(--ease), visibility 0s linear .9s; }
.screen.on { opacity: 1; visibility: visible; transition: opacity .9s var(--ease), visibility 0s; }

/* 纸纹颗粒：只铺在菜单和结局页上，不压在片子上 */
.grain { position: absolute; inset: -50%; pointer-events: none; opacity: .09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite; }
@keyframes grain { 0%{transform:translate(0,0)} 20%{transform:translate(-3%,2%)} 40%{transform:translate(2%,-3%)} 60%{transform:translate(-2%,-1%)} 80%{transform:translate(3%,3%)} 100%{transform:translate(0,0)} }

/* ===== 片子 ===== */
#film { position: fixed; inset: 0; background: #000; }
#film video { width: 100%; height: 100%; object-fit: contain; transition: filter 1.1s var(--ease); }
#branches video { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#branches video.show { opacity: 1; }
#film.choosing video { filter: saturate(.55) brightness(.5); }
#film.dead video { filter: grayscale(1) contrast(1.18) brightness(.34); transition: filter 1.6s var(--ease); }
#film::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,.55)); opacity: 0; transition: opacity 1s var(--ease); }
#film.choosing::after, #film.dead::after { opacity: 1; }

/* ===== 进入页 ===== */
#gate { display: grid; place-items: center; background: #000; cursor: pointer; z-index: 50; }
#gate .in { text-align: center; }
#gate img { width: 64px; opacity: .85; filter: drop-shadow(0 0 18px rgba(184,55,44,.35)); animation: breathe 3.2s ease-in-out infinite; }
#gate p { margin-top: 22px; font-size: 13px; letter-spacing: .9em; padding-left: .9em; color: var(--paper-3); }
@keyframes breathe { 50% { opacity: .5; transform: scale(.96); } }

/* ===== 标题页 ===== */
#menu { z-index: 20; background: var(--ink); overflow: hidden; }
#menu video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 3s ease; }
#menu.lit video { opacity: .9; }
#menu .shade { position: absolute; inset: 0; background:
  linear-gradient(90deg, rgba(10,9,8,.96) 0%, rgba(10,9,8,.82) 30%, rgba(10,9,8,.35) 62%, rgba(10,9,8,.2) 100%),
  linear-gradient(0deg, rgba(10,9,8,.9) 0%, transparent 34%), linear-gradient(180deg, rgba(10,9,8,.6) 0%, transparent 22%); }
#menu .col { position: absolute; left: clamp(28px, 8vw, 140px); top: 50%; transform: translateY(-54%); width: min(560px, 84vw, 78vh); }
#titleWrap { position: relative; width: 100%; aspect-ratio: 997 / 429; }
#titleWrap canvas, #titleWrap .fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
#titleWrap .fallback { display: none; background: url("media/title_ink.png") left center / contain no-repeat; }
#print { position: absolute; width: 21%; right: -4%; top: 22%; opacity: 0; transform: scale(1.9) rotate(-6deg); filter: blur(8px); pointer-events: none; }
#print.down { animation: press .62s var(--ease) forwards; }
#print { mix-blend-mode: normal; }
@keyframes press { 0% { opacity: 0; transform: scale(1.9) rotate(-6deg); filter: blur(8px); } 62% { opacity: .95; transform: scale(.94) rotate(0); filter: blur(0); } 100% { opacity: .78; transform: scale(1) rotate(0); filter: blur(0); } }
.shake { animation: shake .34s linear; }
@keyframes shake { 20% { transform: translate(-2px, 1px); } 40% { transform: translate(2px, -1px); } 60% { transform: translate(-1px, 1px); } 80% { transform: translate(1px, 0); } }
#menu .sub { margin-top: clamp(8px, 2vh, 18px); display: flex; align-items: center; gap: 14px; color: var(--paper-2); font-size: 14px; letter-spacing: .5em; opacity: 0; transform: translateY(6px); transition: all 1.2s var(--ease) .1s; }
#menu .sub i { width: 34px; height: 1px; background: var(--seal); }
#menu .sub b { font-weight: 500; color: var(--paper); letter-spacing: .38em; }
#menu nav { margin-top: clamp(16px, 6vh, 54px); display: flex; flex-direction: column; gap: 2px; }
#menu nav button { position: relative; display: flex; align-items: baseline; gap: 22px; padding: clamp(5px, 1.35vh, 12px) 0; text-align: left; opacity: 0; transform: translateX(-10px); transition: opacity 1s var(--ease), transform 1s var(--ease), color .3s; color: var(--paper-2); }
#menu nav button .n { font-family: var(--brush); font-size: 19px; color: var(--seal); width: 1.2em; text-align: center; transition: transform .4s var(--ease); }
#menu nav button .l { font-size: clamp(15px, 2.4vh, 21px); letter-spacing: .62em; }
#menu nav button .d { font-size: 12px; letter-spacing: .2em; color: var(--paper-3); margin-left: 4px; }
#menu nav button::before { content: ""; position: absolute; left: -26px; top: 50%; width: 16px; height: 2px; background: var(--seal); transform: scaleX(0); transform-origin: right; transition: transform .45s var(--ease); }
#menu nav button:hover, #menu nav button:focus-visible { color: var(--paper); outline: none; }
#menu nav button:hover::before, #menu nav button:focus-visible::before { transform: scaleX(1); }
#menu nav button:hover .n { transform: rotate(-8deg) scale(1.12); }
#menu nav button[disabled] { pointer-events: none; }
#menu.ready nav button[disabled] { opacity: .3; }
#menu.ready .sub, #menu.ready nav button { opacity: 1; transform: none; }
#menu.ready nav button:nth-child(2) { transition-delay: .12s; } #menu.ready nav button:nth-child(3) { transition-delay: .24s; } #menu.ready nav button:nth-child(4) { transition-delay: .36s; }
#menu .foot { position: absolute; left: clamp(28px, 8vw, 140px); bottom: max(26px, env(safe-area-inset-bottom)); font-size: 12px; letter-spacing: .22em; color: var(--paper-3); opacity: 0; transition: opacity 1.4s ease .5s; }
#menu .foot span { margin: 0 .7em; color: var(--hair-2); }
#menu .tally { position: absolute; right: clamp(24px, 5vw, 80px); bottom: max(26px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 14px; font-size: 12px; letter-spacing: .3em; color: var(--paper-3); opacity: 0; transition: opacity 1.4s ease .5s; }
#menu .tally .dots { display: flex; gap: 6px; }
#menu .tally .dots i { width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid var(--hair-2); }
#menu .tally .dots i.got { background: var(--seal); border-color: var(--seal); box-shadow: 0 0 8px var(--seal-glow); }
#menu.ready .foot, #menu.ready .tally { opacity: 1; }

/* ===== 游戏中 ===== */
#hud { z-index: 10; pointer-events: none; }
#hud .tag { position: absolute; left: clamp(20px, 4vw, 56px); top: max(28px, env(safe-area-inset-top)); display: flex; gap: 14px; align-items: stretch; opacity: 0; transform: translateY(-6px); transition: all 1.2s var(--ease); }
#hud .tag.show { opacity: 1; transform: none; }
#hud .tag i { width: 2px; background: var(--seal); }
#hud .tag b { display: block; font-weight: 500; font-size: 17px; letter-spacing: .4em; text-shadow: 0 1px 10px #000; }
#hud .tag em { display: block; margin-top: 5px; font-style: normal; font-size: 12px; letter-spacing: .5em; color: var(--paper-2); text-shadow: 0 1px 8px #000; }
#hud .ctl { position: absolute; right: clamp(16px, 3vw, 40px); top: max(22px, env(safe-area-inset-top)); display: flex; gap: 6px; opacity: 0; transition: opacity .5s ease; pointer-events: auto; }
#hud.awake .ctl { opacity: 1; }
#hud .ctl button { font-size: 12px; letter-spacing: .3em; padding: 8px 12px 8px 15px; color: var(--paper-2); border: 1px solid var(--hair); background: rgba(10,9,8,.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: color .25s, border-color .25s; }
#hud .ctl button:hover { color: var(--paper); border-color: var(--hair-2); }
#hud .pips { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px; opacity: 0; transition: opacity .5s ease; }
#hud.awake .pips { opacity: 1; }
#hud .pips i { width: 6px; height: 6px; transform: rotate(45deg); border: 1px solid var(--hair-2); }
#hud .pips i.done { background: var(--paper-2); border-color: var(--paper-2); }
#toast { position: absolute; left: 0; top: 22%; max-width: 70vw; display: flex; align-items: center; gap: 16px; padding: 16px 90px 16px clamp(20px, 4vw, 56px); background: linear-gradient(90deg, rgba(10,9,8,.82) 0%, rgba(10,9,8,.6) 60%, transparent 100%); border-left: 2px solid var(--seal); opacity: 0; transform: translateX(-20px); transition: all .9s var(--ease); }
#toast.show { opacity: 1; transform: none; }
#toast img { width: 22px; opacity: .85; }
#toast span { font-size: 17px; letter-spacing: .26em; }

/* ===== 选择 ===== */
#choice { z-index: 12; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 0 20px max(8vh, env(safe-area-inset-bottom)); }
#choice .kicker { font-size: clamp(13px, 1.4vw, 15px); letter-spacing: .32em; color: var(--paper-2); text-align: center; opacity: 0; transform: translateY(6px); transition: all .9s var(--ease) .1s; text-shadow: 0 1px 10px #000; }
#choice .prompt { margin-top: 14px; font-family: var(--brush); font-size: clamp(30px, 4.2vw, 50px); letter-spacing: .12em; text-align: center; line-height: 1.25; opacity: 0; transform: translateY(8px); transition: all 1s var(--ease) .2s; text-shadow: 0 2px 24px rgba(0,0,0,.8); }
#fuse { position: relative; width: min(880px, 86vw); height: 1px; margin: 30px 0 4px; }
#fuse .rest { position: absolute; inset: 0; background: var(--hair); }
#fuse .burn { position: absolute; top: 0; bottom: 0; left: 0; right: 0; background: linear-gradient(90deg, var(--seal), rgba(237,228,211,.55) 12%, rgba(237,228,211,.55) 88%, var(--seal)); transform-origin: center; }
#fuse .burn::before, #fuse .burn::after { content: ""; position: absolute; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: #ff9a6b; box-shadow: 0 0 10px 3px var(--seal-glow), 0 0 22px 6px rgba(184,55,44,.25); }
#fuse .burn::before { left: -2px; } #fuse .burn::after { right: -2px; }
#fuse.hurry .burn::before, #fuse.hurry .burn::after { animation: flick .22s steps(2) infinite; }
@keyframes flick { 50% { opacity: .35; } }
#opts { display: flex; justify-content: center; width: min(960px, 92vw); }
.opt { position: relative; flex: 1 1 0; max-width: 320px; padding: 22px 22px 18px; text-align: center; opacity: 0; transform: translateY(10px); transition: opacity .7s var(--ease), transform .7s var(--ease), color .3s, filter .5s; color: var(--paper-2); }
.opt + .opt::before { content: ""; position: absolute; left: 0; top: 26px; bottom: 22px; width: 1px; background: var(--hair); }
.opt .n { display: block; font-family: var(--brush); font-size: 22px; color: var(--seal); margin-bottom: 10px; transition: transform .4s var(--ease); }
.opt .l { position: relative; display: inline-block; font-size: clamp(16px, 1.65vw, 19px); letter-spacing: .14em; line-height: 1.6; }
.opt svg { position: absolute; left: -4%; right: -4%; bottom: -10px; width: 108%; height: 12px; overflow: visible; }
.opt svg path { fill: none; stroke: var(--seal); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 260; stroke-dashoffset: 260; transition: stroke-dashoffset .55s var(--ease); }
.opt:hover, .opt:focus-visible { color: var(--paper); outline: none; }
.opt:hover .n, .opt:focus-visible .n { transform: scale(1.15) rotate(-6deg); }
.opt:hover svg path, .opt:focus-visible svg path, .opt.picked svg path { stroke-dashoffset: 0; }
#choice.on .kicker, #choice.on .prompt, #choice.on .opt { opacity: 1; transform: none; }
#choice.on .opt:nth-child(1) { transition-delay: .45s, .45s, 0s, 0s; } #choice.on .opt:nth-child(2) { transition-delay: .58s, .58s, 0s, 0s; } #choice.on .opt:nth-child(3) { transition-delay: .71s, .71s, 0s, 0s; }
#choice.decided .opt:not(.picked) { opacity: 0 !important; filter: blur(6px); transition-delay: 0s !important; }
#choice.decided .opt.picked { color: var(--paper); }
#choice.decided .kicker, #choice.decided .prompt { opacity: 0; transition-delay: .2s; }

/* ===== 结局 ===== */
#ending { z-index: 14; display: grid; place-items: center; padding: 24px; background: radial-gradient(80% 90% at 42% 48%, rgba(10,9,8,.72) 0%, rgba(10,9,8,.5) 55%, rgba(10,9,8,.78) 100%); }
#ending .bg { position: absolute; inset: 0; background: center / cover no-repeat; filter: grayscale(.35) brightness(.38) blur(1.5px); opacity: 0; transition: opacity 1.6s ease; }
#ending .bg.on { opacity: 1; }
#ending .card { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: clamp(26px, 4vw, 60px); align-items: start; width: min(860px, 100%); }
#ending .sealbox { width: clamp(82px, 9vw, 116px); aspect-ratio: 1; margin-top: 6px; opacity: 0; transform: scale(2.1) rotate(-14deg); filter: blur(10px); }
#ending.on .sealbox { animation: seal .7s var(--ease) .25s forwards; }
@keyframes seal { 0% { opacity: 0; transform: scale(2.1) rotate(-14deg); filter: blur(10px); } 60% { opacity: 1; transform: scale(.93) rotate(-6deg); filter: blur(0); } 100% { opacity: .95; transform: scale(1) rotate(-6deg); filter: blur(0); } }
.seal { width: 100%; height: 100%; display: grid; place-items: center; border: 3px solid var(--seal); border-radius: 6px; color: var(--seal); font-family: var(--brush); line-height: 1; box-shadow: inset 0 0 0 3px rgba(184,55,44,.25); filter: url(#rough); }
.seal.one { font-size: clamp(48px, 5.6vw, 72px); }
.seal.two { font-size: clamp(26px, 3vw, 38px); writing-mode: vertical-rl; letter-spacing: .08em; }
#ending .kind { font-size: 13px; letter-spacing: .6em; color: var(--paper-3); }
#ending h2 { margin-top: 10px; font-family: var(--brush); font-weight: 400; font-size: clamp(46px, 6.4vw, 82px); letter-spacing: .14em; line-height: 1.1; }
#ending .body { margin-top: 26px; font-size: clamp(15px, 1.55vw, 18px); line-height: 2.15; letter-spacing: .06em; color: var(--paper); }
#ending .body span { display: block; opacity: 0; transform: translateY(6px); transition: all .9s var(--ease); }
#ending .body span.show { opacity: 1; transform: none; }
#ending .hint { margin-top: 26px; display: flex; gap: 14px; align-items: baseline; font-size: 14px; letter-spacing: .14em; color: var(--paper-2); opacity: 0; transition: opacity 1s ease; }
#ending .hint b { font-weight: 500; color: var(--seal); letter-spacing: .3em; white-space: nowrap; }
#ending .recap { margin-top: 26px; display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 14px; letter-spacing: .1em; opacity: 0; transition: opacity 1s ease; }
#ending .recap dt { font-family: var(--brush); color: var(--seal); font-size: 16px; }
#ending .recap dd { color: var(--paper-2); }
#ending .meta { margin-top: 22px; font-size: 12px; letter-spacing: .28em; color: var(--paper-3); opacity: 0; transition: opacity 1s ease; line-height: 2; white-space: pre-line; }
#ending .acts { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 0; opacity: 0; transition: opacity 1s ease; }
#ending.late .hint, #ending.late .recap, #ending.late .meta, #ending.late .acts { opacity: 1; }
.act { position: relative; padding: 10px 22px 10px 0; margin-right: 22px; font-size: 15px; letter-spacing: .4em; color: var(--paper-2); transition: color .25s; }
.act:not(:last-child)::after { content: ""; position: absolute; right: 0; top: 13px; bottom: 13px; width: 1px; background: var(--hair); }
.act::before { content: ""; position: absolute; left: 0; right: 26px; bottom: 4px; height: 1px; background: var(--seal); transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease); }
.act:hover, .act:focus-visible { color: var(--paper); outline: none; }
.act:hover::before, .act:focus-visible::before { transform: scaleX(1); }
.act.primary { color: var(--paper); }
.act.primary::before { transform: scaleX(1); opacity: .65; }

/* ===== 剧情树 ===== */
#tree { z-index: 30; background: radial-gradient(130% 120% at 30% 0%, #1b1815 0%, var(--ink) 60%); overflow: hidden; }
#tree .top { position: absolute; left: clamp(24px, 5vw, 72px); right: clamp(24px, 5vw, 72px); top: max(30px, env(safe-area-inset-top)); display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
#tree h3 { font-family: var(--brush); font-weight: 400; font-size: clamp(34px, 4vw, 48px); letter-spacing: .2em; }
#tree h3 small { display: block; margin-top: 8px; font-family: var(--serif); font-size: 12px; letter-spacing: .5em; color: var(--paper-3); }
#tree .stats { font-size: 13px; letter-spacing: .26em; color: var(--paper-2); text-align: right; line-height: 2; }
#tree .stats b { color: var(--paper); font-weight: 500; }
#tree .close { position: absolute; right: clamp(24px, 5vw, 72px); bottom: max(26px, env(safe-area-inset-bottom)); }
#track { position: absolute; left: 0; right: 0; top: max(150px, 22vh); bottom: 80px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; }
#rail { position: relative; height: 100%; min-width: max-content; padding: 0 clamp(24px, 5vw, 72px); display: flex; align-items: flex-start; }
.node { position: relative; width: 230px; flex: none; margin-right: 46px; }
.node .shot { position: relative; width: 100%; aspect-ratio: 560 / 234; overflow: hidden; border: 1px solid var(--hair); background: var(--ink-2); }
.node .shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease), filter .6s; }
.node.locked .shot img { filter: blur(10px) grayscale(1) brightness(.4); }
.node.reached .shot { cursor: pointer; }
.node.reached .shot:hover img { transform: scale(1.05); }
.node.reached .shot:hover::after { content: "从 这 里 开 始"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,9,8,.55); font-size: 13px; letter-spacing: .3em; }
.node .cap { margin-top: 12px; display: flex; gap: 10px; align-items: baseline; }
.node .cap .n { font-family: var(--brush); color: var(--seal); font-size: 18px; }
.node .cap b { font-weight: 500; font-size: 16px; letter-spacing: .3em; }
.node.locked .cap b { color: var(--paper-3); }
.node .link { position: absolute; top: 48px; left: 100%; width: 46px; height: 1px; border-top: 1px dashed var(--hair-2); }
.node.passed .link { border-top: 1px solid var(--seal); box-shadow: 0 0 6px var(--seal-glow); }
.leaves { margin-top: 18px; padding-left: 12px; border-left: 1px solid var(--hair); display: flex; flex-direction: column; gap: 12px; }
.leaf { position: relative; display: flex; gap: 10px; align-items: center; }
.leaf::before { content: ""; position: absolute; left: -12px; top: 50%; width: 10px; border-top: 1px solid var(--hair); }
.leaf .th { width: 64px; aspect-ratio: 420 / 176; flex: none; border: 1px solid var(--hair); background: var(--ink-2) center / cover no-repeat; }
.leaf.unknown .th { background-image: none !important; }
.leaf .tx { font-size: 12px; line-height: 1.6; letter-spacing: .1em; color: var(--paper-2); }
.leaf .tx b { display: block; font-family: var(--brush); font-weight: 400; font-size: 17px; letter-spacing: .14em; color: var(--paper); }
.leaf.dead .tx b { color: #d5c7b1; }
.leaf.unknown .tx b { color: var(--paper-3); }
.leaf.canon .tx { color: var(--paper-3); }
.final { width: 230px; flex: none; }
.final .shot { aspect-ratio: 560 / 234; border: 1px solid var(--hair); background: var(--ink-2) center / cover no-repeat; display: grid; place-items: center; }
.final.got .shot { border-color: rgba(184,55,44,.7); box-shadow: 0 0 18px rgba(184,55,44,.18); }
.final.unknown .shot { background-image: none !important; }
.final .cap { margin-top: 12px; }
.final .cap b { font-family: var(--brush); font-weight: 400; font-size: 22px; letter-spacing: .18em; }
.final .cap small { display: block; font-size: 12px; letter-spacing: .4em; color: var(--paper-3); margin-top: 4px; }

/* ===== 暂停 ===== */
#pause { z-index: 16; display: grid; place-items: center; background: rgba(10,9,8,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#pause .box { text-align: center; }
#pause h4 { font-family: var(--brush); font-weight: 400; font-size: 44px; letter-spacing: .3em; padding-left: .3em; }
#pause .acts { margin-top: 30px; display: flex; justify-content: center; }

@media (max-height: 520px) {
  #choice { padding-bottom: 14px; }
  #choice .prompt { font-size: clamp(24px, 6vh, 40px); margin-top: 6px; }
  #fuse { margin-top: 14px; }
  .opt { padding: 12px 16px 10px; }
  .opt .n { margin-bottom: 4px; font-size: 18px; }
  #ending .body { margin-top: 12px; line-height: 1.85; }
  #ending h2 { font-size: clamp(34px, 9vh, 64px); }
  #ending .hint, #ending .recap, #ending .meta { margin-top: 12px; }
  #ending .acts { margin-top: 16px; }
  #track { top: 110px; bottom: 60px; }
  #tree .top { top: 16px; }
}
@media (max-width: 720px) and (orientation: portrait) {
  #menu .col { top: auto; bottom: 120px; transform: none; width: 84vw; }
  #menu nav { margin-top: 30px; }
  #menu nav button { padding: 9px 0; }
  #menu nav button .l { font-size: 18px; }
  #menu .tally { display: none; }
  #menu .foot { font-size: 10px; letter-spacing: .1em; }
  #opts { flex-direction: column; align-items: stretch; }
  .opt { max-width: none; padding: 14px 10px 12px; }
  .opt + .opt::before { left: 18%; right: 18%; top: 0; bottom: auto; width: auto; height: 1px; }
  .opt .n { display: inline; margin: 0 10px 0 0; font-size: 18px; }
  #ending .card { grid-template-columns: 1fr; }
  #ending .sealbox { width: 74px; margin-bottom: 18px; }
  #track { top: 132px; }
}

/* Website integration: keep all actions reachable on narrow and short screens. */
#ending { overflow-y:auto; align-items:safe center; overscroll-behavior:contain; }
#ending .card { margin:auto; min-height:0; }
#tree #track { overflow-y:auto; }
@media (max-width:720px) { #ending { padding:22px 18px; } #ending .recap { font-size:12px; gap:6px 12px; } #ending h2 { font-size:42px; } }
@media (max-height:520px) { #ending { display:block; } #ending .sealbox { width:60px; } #ending .body { font-size:14px; } #ending .recap { font-size:12px; gap:4px 12px; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; animation-iteration-count:1!important; transition-duration:.01ms!important; } .grain { animation:none; } }

#mediaRecovery { z-index:50; background:rgba(10,9,8,.92); display:grid; place-items:center; padding:24px; text-align:center; }
#mediaRecovery p { margin:16px 0; line-height:1.8; } #mediaRecovery button { padding:14px; border-bottom:1px solid var(--seal); }
#branchNotice { color:var(--paper-2); font-size:13px; line-height:1.8; margin-top:14px; }

.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;}
