/* =========================================================
   后室：阈限档案 — UI
   ========================================================= */
:root {
  --ink: #ece7d4;
  --ink-dim: #a49d86;
  --ink-faint: #6d6756;
  --yellow: #d9c46a;
  --yellow-bright: #f3e39a;
  --yellow-deep: #8c7a34;
  --bg: #080805;
  --panel: #11110c;
  --panel-2: #171712;
  --line: rgba(217, 196, 106, 0.22);
  --line-soft: rgba(236, 231, 212, 0.1);
  --danger: #c85a48;
  --good: #8fbf9f;
  --sanity: #9b8fd0;
  --mono: 'Courier New', 'Nimbus Mono PS', monospace;
  --serif: 'Songti SC', 'Noto Serif CJK SC', 'Source Han Serif SC', 'SimSun', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { overscroll-behavior: none; }
button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--yellow); outline-offset: 3px; }
.hidden { display: none !important; }
.muted { color: var(--ink-dim); }
kbd { font-family: var(--mono); border: 1px solid var(--line); padding: 1px 5px; border-radius: 2px; font-size: 11px; background: rgba(255,255,255,.04); }

#app { position: fixed; inset: 0; background: #000; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; background: #000; touch-action: none; }

/* ---------- 后期效果 ---------- */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#fx-vignette { background: radial-gradient(ellipse at center, transparent 38%, rgba(0,0,0,.5) 78%, rgba(0,0,0,.9) 100%); }
#fx-scanlines { background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 3px, rgba(0,0,0,.16) 4px); opacity: .55; mix-blend-mode: multiply; }
#fx-grain { opacity: .07; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); animation: grain .3s steps(2) infinite; }
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-2%,1%)} 50%{transform:translate(1%,-2%)} 75%{transform:translate(2%,2%)} 100%{transform:translate(-1%,1%)} }
#fx-glitch { opacity: 0; background: linear-gradient(transparent 20%, rgba(217,196,106,.08) 21%, transparent 22%, transparent 68%, rgba(200,90,72,.06) 69%, transparent 70%); mix-blend-mode: screen; }
#fx-glitch.on { animation: glitchflash .16s steps(2) 2; opacity: 1; }
@keyframes glitchflash { 0%{transform:translateX(-8px)} 50%{transform:translateX(9px) skewX(1deg)} 100%{transform:translateX(0)} }
#fx-damage { opacity: 0; background: radial-gradient(ellipse at center, transparent 30%, rgba(137,24,16,.55) 100%); transition: opacity .18s; }
#fx-flash { opacity: 0; background: #fff; transition: opacity .3s; }
body.crt-off #fx-scanlines, body.crt-off #fx-grain { display: none; }
body.glitch-off #fx-glitch { display: none; }
body.glitch-off #fx-grain { animation: none; }

/* ---------- 通用屏幕 ---------- */
.screen { position: absolute; inset: 0; z-index: 30; display: none; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }
.modal-screen { z-index: 40; align-items: center; justify-content: center; background: rgba(3,3,2,.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 24px; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { position: relative; background: linear-gradient(160deg, #15150f, #0c0c08 65%); border: 1px solid var(--line); box-shadow: 0 40px 120px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.04); width: min(540px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; padding: 30px; animation: modalUp .3s cubic-bezier(.2,.8,.2,1); }
@keyframes modalUp { from { opacity: 0; transform: translateY(16px) scale(.99); } to { opacity: 1; transform: none; } }
.modal::-webkit-scrollbar, .codex-content::-webkit-scrollbar, .settings-body::-webkit-scrollbar, .about-body::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-thumb, .codex-content::-webkit-scrollbar-thumb { background: var(--line); }
.wide-modal { width: min(980px, 100%); height: min(760px, calc(100vh - 48px)); display: flex; flex-direction: column; padding: 0; }
.eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: .22em; color: var(--yellow); text-transform: uppercase; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 34px; letter-spacing: .04em; margin: 8px 0 6px; }
h3 { font-size: 13px; letter-spacing: .12em; color: var(--yellow); font-family: var(--mono); font-weight: 500; }
.modal-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 26px 30px 18px; border-bottom: 1px solid var(--line-soft); flex: none; }
.modal-topbar h2 { font-size: 28px; margin: 6px 0 0; }
.close-btn { width: 34px; height: 34px; border: 1px solid var(--line); color: var(--ink-dim); display: grid; place-items: center; font-size: 13px; flex: none; transition: .2s; }
.close-btn:hover { color: var(--ink); border-color: var(--yellow); background: rgba(217,196,106,.08); }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions.vertical { flex-direction: column; }

/* 按钮 */
.solid-btn { background: var(--yellow); color: #17150b; border: 1px solid var(--yellow); padding: 13px 22px; font-size: 13px; font-weight: 600; letter-spacing: .06em; transition: .18s; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.solid-btn:hover { background: var(--yellow-bright); box-shadow: 0 0 24px rgba(217,196,106,.28); }
.solid-btn:active { transform: translateY(1px); }
.solid-btn.wide { width: 100%; }
.ghost-btn { border: 1px solid var(--line); padding: 12px 20px; color: var(--ink-dim); font-size: 13px; letter-spacing: .04em; transition: .18s; }
.ghost-btn:hover { border-color: rgba(217,196,106,.5); color: var(--ink); background: rgba(217,196,106,.04); }
.ghost-btn.wide { width: 100%; }
.danger-btn { border: 1px solid rgba(200,90,72,.35); padding: 12px 20px; color: #d68a7c; font-size: 12px; transition: .18s; }
.danger-btn:hover { background: rgba(200,90,72,.1); border-color: var(--danger); }
.danger-text { color: #a86457; font-size: 12px; letter-spacing: .04em; text-decoration: underline; text-underline-offset: 4px; }
.danger-text:hover { color: var(--danger); }
.text-btn { color: var(--ink-faint); font-size: 11px; font-family: var(--mono); letter-spacing: .16em; padding: 10px; }
.text-btn:hover { color: var(--ink-dim); }

/* =========================================================
   主菜单
   ========================================================= */
#screen-menu { background: #0a0905; overflow-y: auto; overflow-x: hidden; justify-content: space-between; }
.menu-scene { position: fixed; inset: 0; overflow: hidden; perspective: 420px; pointer-events: none; z-index: 0; }
.corridor { position: absolute; left: 50%; top: 47%; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(-1deg); }
.wall { position: absolute; top: -260px; width: 460px; height: 560px; background:
  repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, transparent 2px 9px),
  repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 1px, transparent 1px 42px),
  linear-gradient(90deg, #665a2c, #9a8a45 40%, #7d6f34);
  box-shadow: inset 0 0 100px rgba(0,0,0,.4);
  filter: sepia(.3) brightness(.68);
}
.wall.left { left: -460px; transform: rotateY(32deg) translateZ(60px); transform-origin: right center; }
.wall.right { left: 0; transform: rotateY(-32deg) translateZ(60px); transform-origin: left center; }
.floor { position: absolute; left: -700px; top: 240px; width: 1400px; height: 900px; transform: rotateX(90deg); transform-origin: top center; background:
  repeating-linear-gradient(90deg, rgba(0,0,0,.08) 0 2px, transparent 2px 44px),
  repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 44px),
  linear-gradient(#3c341b, #191509);
  filter: blur(1px);
}
.ceiling { position: absolute; left: -700px; top: -530px; width: 1400px; height: 900px; transform: rotateX(-90deg); transform-origin: bottom center; background: linear-gradient(#151207, #4b4222); filter: blur(2px); }
.door-end { position: absolute; left: -70px; top: -20px; width: 140px; height: 230px; background: linear-gradient(90deg, #161308, #332c15 50%, #161308); border: 3px solid #5f5326; box-shadow: 0 0 60px rgba(230,212,130,.2); }
.door-end i { position: absolute; left: 50%; top: 12%; width: 2px; height: 76%; background: rgba(255,235,160,.12); }
.light { position: absolute; height: 8px; background: #fff8d2; box-shadow: 0 0 40px 12px rgba(255,244,190,.6), 0 0 130px 60px rgba(220,204,130,.13); border-radius: 2px; animation: flicker 7s infinite; }
.light.l1 { width: 190px; left: -95px; top: -250px; }
.light.l2 { width: 90px; left: -45px; top: -160px; opacity: .8; animation-delay: 1.4s; }
.light.l3 { width: 40px; left: -20px; top: -75px; opacity: .6; animation-delay: 3s; }
.light.l4 { width: 14px; left: -7px; top: -10px; opacity: .4; animation-delay: .6s; }
@keyframes flicker { 0%,88%,100% { opacity: 1; } 89% { opacity: .35; } 90% { opacity: 1; } 92% { opacity: .2; } 93% { opacity: .9; } 95% { opacity: .45; } 96% { opacity: 1; } }
.menu-fog { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 0%, rgba(8,8,4,.2) 35%, rgba(8,8,4,.86) 72%, #080804 100%), linear-gradient(180deg, rgba(8,8,4,.85), transparent 30%, transparent 60%, rgba(8,8,4,.75)); }
.dust { position: absolute; inset: 0; opacity: .4; background-image: radial-gradient(1px 1px at 20% 30%, rgba(255,244,200,.5), transparent), radial-gradient(1px 1px at 70% 60%, rgba(255,244,200,.3), transparent), radial-gradient(1px 1px at 40% 80%, rgba(255,244,200,.4), transparent), radial-gradient(1px 1px at 85% 20%, rgba(255,244,200,.25), transparent); background-size: 220px 220px; animation: drift 30s linear infinite; }
@keyframes drift { to { background-position: 220px 220px; } }

.menu-header { position: relative; z-index: 3; display: flex; justify-content: space-between; align-items: center; padding: 22px 40px; border-bottom: 1px solid rgba(217,196,106,.14); font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--ink-dim); flex: none; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--yellow); }
.brand-mark { font-size: 16px; }
.header-right { display: flex; gap: 24px; align-items: center; }
.rec { display: flex; align-items: center; gap: 6px; color: #c9705e; }
.rec i { width: 6px; height: 6px; background: #d65a45; border-radius: 50%; box-shadow: 0 0 8px #d65a45; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.signal-bars { letter-spacing: -2px; color: var(--yellow); font-size: 12px; }

.menu-main { position: relative; z-index: 3; flex: 1; display: grid; grid-template-columns: 1.2fr minmax(340px, .8fr); gap: 60px; align-items: center; padding: 40px 7vw; min-height: 0; }
.title-block { max-width: 700px; }
.title-kicker { font-family: var(--mono); font-size: 9px; letter-spacing: .4em; color: var(--yellow-deep); margin-bottom: 18px; }
.logo { margin: 0; line-height: 1; }
.logo-cn { display: block; font-family: var(--serif); font-size: clamp(68px, 11vw, 148px); letter-spacing: .16em; color: #e8ddb4; text-shadow: 0 0 60px rgba(217,196,106,.18), 4px 0 0 rgba(200,90,72,.18), -4px 0 0 rgba(90,130,200,.12); position: relative; font-weight: 500; }
.logo-en { display: block; font-family: var(--mono); font-size: clamp(16px, 2.6vw, 34px); letter-spacing: .38em; color: var(--yellow); margin-top: 12px; font-weight: 400; }
.title-sub { margin-top: 24px; display: flex; align-items: center; gap: 12px; color: var(--ink-dim); font-size: 12px; letter-spacing: .5em; }
.title-sub i { width: 36px; height: 1px; background: var(--yellow-deep); }
.title-sub span { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--ink-faint); }
.title-desc { margin-top: 26px; font-size: 13px; line-height: 2.05; color: #a9a28a; letter-spacing: .03em; border-left: 1px solid var(--line); padding-left: 18px; }
.title-meta { display: flex; gap: 42px; margin-top: 36px; flex-wrap: wrap; }
.title-meta div { display: flex; flex-direction: column; gap: 4px; }
.title-meta b { font-family: var(--mono); font-size: 22px; font-weight: 400; color: var(--ink); }
.title-meta small { font-size: 9px; color: var(--ink-faint); letter-spacing: .16em; }

.menu-panel { border: 1px solid var(--line); background: rgba(12,12,8,.72); backdrop-filter: blur(14px); padding: 20px; min-width: 0; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.panel-label { font-family: var(--mono); font-size: 9px; letter-spacing: .24em; color: var(--ink-faint); margin: 2px 4px 12px; }
.menu-btn { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 14px; border: 1px solid rgba(255,255,255,.06); margin-bottom: 6px; text-align: left; background: rgba(255,255,255,.015); transition: .18s; position: relative; }
.menu-btn:hover { background: rgba(217,196,106,.07); border-color: rgba(217,196,106,.35); transform: translateX(2px); }
.menu-btn.primary { background: linear-gradient(90deg, rgba(217,196,106,.16), rgba(217,196,106,.03)); border-color: rgba(217,196,106,.45); }
.menu-btn.primary:hover { background: linear-gradient(90deg, rgba(217,196,106,.24), rgba(217,196,106,.06)); }
.btn-no { font-family: var(--mono); font-size: 10px; color: var(--yellow-deep); }
.menu-btn.primary .btn-no { color: var(--yellow); }
.btn-main { flex: 1; font-size: 14px; letter-spacing: .06em; display: flex; flex-direction: column; gap: 2px; }
.btn-main small { font-family: var(--mono); font-size: 8px; letter-spacing: .18em; color: var(--ink-faint); }
.btn-arrow { color: var(--ink-faint); font-size: 16px; transition: .18s; }
.menu-btn:hover .btn-arrow { color: var(--yellow); transform: translateX(3px); }
.btn-badge { font-size: 9px; color: #d9a05b; border: 1px solid rgba(217,160,91,.4); padding: 2px 5px; letter-spacing: .1em; }
.menu-divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mini-btn { padding: 10px 12px; border: 1px solid rgba(255,255,255,.06); font-size: 11px; color: var(--ink-dim); text-align: left; letter-spacing: .06em; transition: .16s; background: rgba(255,255,255,.01); }
.mini-btn:hover { border-color: var(--line); color: var(--ink); background: rgba(217,196,106,.05); }
.menu-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--ink-faint); }
#online-count { color: var(--good); white-space: nowrap; }
.menu-footer { position: relative; z-index: 3; display: flex; justify-content: space-between; gap: 20px; padding: 16px 40px calc(16px + var(--safe)); border-top: 1px solid rgba(217,196,106,.12); font-family: var(--mono); font-size: 8px; color: #665f4b; letter-spacing: .08em; flex: none; }

/* =========================================================
   加载 / 过场
   ========================================================= */
#screen-loading { background: #080805; align-items: center; justify-content: center; z-index: 50; }
.loading-box { width: min(520px, 86vw); text-align: center; }
.load-mark { font-size: 44px; color: var(--yellow); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .4; text-shadow: 0 0 30px var(--yellow); } }
.load-title { font-family: var(--serif); font-size: 22px; letter-spacing: .2em; margin: 22px 0 8px; }
.load-level { font-family: var(--mono); font-size: 10px; color: var(--yellow); letter-spacing: .22em; }
.load-bar { height: 1px; background: rgba(255,255,255,.1); margin: 30px 0 16px; overflow: hidden; }
.load-bar i { display: block; width: 0; height: 100%; background: var(--yellow); box-shadow: 0 0 12px var(--yellow); transition: width .15s linear; }
.load-tip { color: var(--ink-dim); font-size: 11px; line-height: 1.8; min-height: 20px; }
.load-sub { margin-top: 30px; font-family: var(--mono); font-size: 8px; letter-spacing: .18em; color: var(--ink-faint); }

#screen-intro { background: radial-gradient(ellipse at 50% 50%, #14120a, #050503 70%); align-items: center; justify-content: center; z-index: 50; }
#screen-intro::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.22) 4px); pointer-events: none; }
.intro-box { width: min(720px, 86vw); position: relative; }
.intro-label { font-family: var(--mono); font-size: 10px; letter-spacing: .25em; color: var(--yellow); margin-bottom: 30px; }
.intro-text { font-family: var(--serif); font-size: clamp(17px, 2.1vw, 22px); line-height: 2.15; color: #d4cdb1; min-height: 260px; white-space: pre-wrap; letter-spacing: .04em; }
.intro-text .cursor { color: var(--yellow); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.intro-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 36px; border-top: 1px solid var(--line-soft); padding-top: 18px; }
.intro-hint { text-align: right; font-size: 9px; color: var(--ink-faint); font-family: var(--mono); letter-spacing: .1em; margin-top: 8px; }

/* =========================================================
   HUD
   ========================================================= */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; color: var(--ink); text-shadow: 0 1px 3px rgba(0,0,0,.9); }
#hud-top { position: absolute; top: calc(14px + env(safe-area-inset-top,0px)); left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
#chapter-box { border-left: 2px solid var(--yellow); padding: 2px 0 2px 11px; min-width: 150px; }
#hud-level-num { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--yellow); }
#hud-level-name { font-family: var(--serif); font-size: 21px; letter-spacing: .12em; margin-top: 2px; }
#objective-box { text-align: right; min-width: 200px; }
#objective-box .eyebrow { font-size: 8px; color: var(--ink-faint); }
#hud-objective { font-size: 12px; margin-top: 4px; color: #ddd5ba; letter-spacing: .03em; }
#hud-signal { font-family: var(--mono); font-size: 9px; color: var(--yellow); margin-top: 3px; letter-spacing: .08em; }
#compass { position: absolute; left: 50%; transform: translateX(-50%); top: 4px; width: 190px; height: 24px; overflow: hidden; opacity: .8; }
#compass-track { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-family: var(--mono); font-size: 8px; color: var(--ink-faint); }
#compass-track i { width: 1px; height: 4px; background: var(--ink-faint); }
#compass-needle { position: absolute; left: 50%; bottom: 0; width: 1px; height: 7px; background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
#compass-target { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 6px; color: var(--yellow-bright); text-shadow: 0 0 6px var(--yellow); transition: left .25s linear; opacity: .85; }

#minimap-wrap { position: absolute; top: calc(74px + env(safe-area-inset-top,0px)); right: 18px; width: 132px; height: 132px; border: 1px solid rgba(217,196,106,.26); background: rgba(3,4,3,.58); backdrop-filter: blur(3px); overflow: hidden; opacity: .9; }
#minimap { width: 100%; height: 100%; display: block; }
#minimap-label { position: absolute; bottom: 2px; right: 4px; font-family: var(--mono); font-size: 7px; color: var(--ink-faint); letter-spacing: .08em; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; transform: translate(-50%,-50%); opacity: .75; }
#crosshair span { position: absolute; background: rgba(236,231,212,.8); }
#crosshair span:first-child { left: 0; top: 9px; width: 7px; height: 1px; }
#crosshair span:last-child { right: 0; top: 9px; width: 7px; height: 1px; }
#crosshair-dot { position: absolute; left: 9px; top: 9px; width: 2px; height: 2px; background: var(--yellow); box-shadow: 0 0 4px var(--yellow); }
#crosshair.active { opacity: 1; transform: translate(-50%,-50%) scale(1.25); }

#interact-prompt { position: absolute; left: 50%; top: calc(50% + 42px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; font-size: 11px; background: rgba(5,5,3,.7); border: 1px solid var(--line); padding: 7px 12px; letter-spacing: .04em; backdrop-filter: blur(4px); }
#interact-prompt kbd { color: var(--yellow); border-color: rgba(217,196,106,.5); }
#interact-prompt .hold { color: var(--yellow); font-family: var(--mono); font-size: 9px; }

#hud-bottom { position: absolute; left: 20px; right: 20px; bottom: calc(20px + var(--safe)); display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
#vitals { display: flex; flex-direction: column; gap: 5px; width: 190px; }
.vital { display: flex; align-items: center; gap: 6px; }
.vital-icon { width: 12px; font-size: 9px; color: var(--ink-faint); text-align: center; }
.vital .bar { flex: 1; height: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.vital .bar i { display: block; height: 100%; width: 100%; transition: width .25s; background: #c9705e; }
.vital:nth-child(2) .bar i { background: var(--sanity); }
.vital:nth-child(3) .bar i { background: var(--yellow); }
.vital.stamina .bar { height: 2px; }
.vital.stamina .bar i { background: var(--good); }
.vital b { font-family: var(--mono); font-size: 9px; font-weight: 400; width: 22px; text-align: right; color: var(--ink-dim); }
.vital.stamina b { display: none; }
#inventory { display: flex; gap: 8px; }
.inv-slot { width: 68px; height: 58px; border: 1px solid var(--line); background: rgba(5,5,3,.62); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; position: relative; backdrop-filter: blur(3px); }
.inv-slot span { font-size: 14px; color: var(--yellow); line-height: 1; }
.inv-slot b { font-family: var(--mono); font-size: 10px; font-weight: 400; }
.inv-slot small { font-size: 7px; color: var(--ink-faint); letter-spacing: .05em; }
.inv-slot.objective-slot { border-color: rgba(217,196,106,.4); }
.inv-slot.flash { animation: slotFlash .3s; }
@keyframes slotFlash { 0% { background: rgba(217,196,106,.4); } 100% { background: rgba(5,5,3,.62); } }
#run-timer { text-align: right; display: flex; flex-direction: column; gap: 2px; }
#timer-value { font-family: var(--mono); font-size: 17px; letter-spacing: .06em; color: var(--ink-dim); }
#run-timer small { font-family: var(--mono); font-size: 7px; color: var(--ink-faint); letter-spacing: .16em; }

#message-log { position: absolute; left: 22px; bottom: calc(112px + var(--safe)); display: flex; flex-direction: column; gap: 4px; max-width: 340px; }
.msg { font-size: 11px; color: #d8d0b6; background: rgba(5,5,3,.58); padding: 5px 9px; border-left: 1px solid var(--yellow); animation: msgIn .25s ease, msgOut .4s ease 4.2s forwards; backdrop-filter: blur(2px); }
.msg.warn { border-color: var(--danger); color: #e1a08f; }
.msg.good { border-color: var(--good); color: #b8d8c4; }
@keyframes msgIn { from { opacity: 0; transform: translateX(-8px); } }
@keyframes msgOut { to { opacity: 0; transform: translateY(-3px); } }

#subtitle { position: absolute; left: 50%; bottom: calc(120px + var(--safe)); transform: translateX(-50%); max-width: 640px; width: 86%; text-align: center; font-family: var(--serif); font-size: 15px; line-height: 1.7; color: #efe7cd; text-shadow: 0 2px 10px #000; opacity: 0; transition: opacity .4s; letter-spacing: .05em; }
#subtitle.show { opacity: 1; }
#danger-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 40%, rgba(90,15,10,.55)); transition: opacity .4s; }
#hint-bar { position: absolute; top: 50%; right: 22px; transform: translateY(-50%) rotate(180deg); writing-mode: vertical-rl; font-family: var(--mono); font-size: 7px; letter-spacing: .16em; color: rgba(236,231,212,.3); text-transform: uppercase; }
#hud.hide-help #hint-bar, #hud.hide-help #minimap-wrap { opacity: 0; }

/* 触控 */
#touch-ui { position: absolute; inset: 0; display: none; pointer-events: none; }
#joystick { position: absolute; left: 26px; bottom: calc(88px + var(--safe)); width: 112px; height: 112px; border-radius: 50%; border: 1px solid rgba(236,231,212,.22); background: rgba(10,10,6,.28); pointer-events: auto; touch-action: none; display: none; }
#joystick::after { content: ''; position: absolute; inset: 36%; border-radius: 50%; border: 1px solid rgba(236,231,212,.1); }
#joystick-knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(217,196,106,.22); border: 1px solid rgba(217,196,106,.55); }
#touch-actions { position: absolute; right: 18px; bottom: calc(84px + var(--safe)); display: grid; grid-template-columns: repeat(2, 56px); gap: 8px; pointer-events: auto; }
.tbtn { width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(236,231,212,.28); background: rgba(10,10,6,.4); color: var(--ink); font-family: var(--mono); font-size: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; touch-action: none; backdrop-filter: blur(4px); }
.tbtn small { font-size: 7px; color: var(--ink-faint); font-family: var(--sans); }
.tbtn:active, .tbtn.on { background: rgba(217,196,106,.24); border-color: var(--yellow); }
.tbtn.small { width: 44px; height: 44px; font-size: 12px; justify-self: center; }
body.touch #touch-ui { display: block; }
body.touch #joystick { display: block; }
body.touch #hud-bottom { bottom: calc(8px + var(--safe)); }
body.touch #inventory { display: none; }
body.touch #message-log { bottom: calc(146px + var(--safe)); }
body.touch #minimap-wrap { width: 104px; height: 104px; }
body.touch #hint-bar { display: none; }
body.touch #screen-menu .menu-btn:hover { transform: none; }

/* =========================================================
   暂停 / 死亡 / 结局
   ========================================================= */
.pause-modal { width: min(420px, 100%); }
.pause-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 4px; }
.pause-stats div { border: 1px solid var(--line-soft); padding: 12px; display: flex; flex-direction: column; gap: 5px; }
.pause-stats small { font-size: 8px; color: var(--ink-faint); letter-spacing: .08em; }
.pause-stats b { font-family: var(--mono); font-size: 17px; font-weight: 400; }
.pause-note { text-align: center; font-size: 9px; color: var(--ink-faint); margin-top: 16px; }

.death-screen { background: radial-gradient(ellipse at center, rgba(60,10,6,.55), rgba(3,3,2,.96) 70%); }
.death-noise { position: absolute; inset: 0; opacity: .2; background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(200,90,72,.15) 3px, transparent 4px); animation: grain .2s steps(2) infinite; pointer-events: none; }
.death-modal { text-align: center; background: linear-gradient(170deg, #170d0a, #090705); border-color: rgba(200,90,72,.28); }
.death-mark { font-size: 32px; color: var(--danger); margin-bottom: 12px; opacity: .8; }
.death-modal .eyebrow { color: #b5786b; }
.death-modal h2 { font-size: 30px; color: #e3d4c2; }
.death-cause { font-family: var(--serif); font-size: 17px; color: #d18b78; margin: 6px 0 16px; letter-spacing: .06em; }
.death-flavor { font-size: 11px; line-height: 1.9; color: var(--ink-dim); max-width: 360px; margin: 0 auto 24px; }
.death-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 14px 0; margin-bottom: 22px; }
.death-stats div { display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line-soft); }
.death-stats div:last-child { border: 0; }
.death-stats small { font-size: 8px; color: var(--ink-faint); }
.death-stats b { font-family: var(--mono); font-size: 13px; font-weight: 400; }
.death-actions { display: flex; gap: 8px; justify-content: center; }
.death-tip { margin-top: 20px; font-size: 10px; color: var(--ink-faint); line-height: 1.7; }

.choice-screen { background: radial-gradient(ellipse at 50% 35%, rgba(240,232,190,.1), rgba(3,3,2,.97) 68%); }
.choice-glow { position: absolute; left: 50%; top: 30%; width: 640px; height: 640px; transform: translate(-50%,-50%); background: radial-gradient(circle, rgba(255,248,207,.12), transparent 62%); pointer-events: none; }
.choice-box { position: relative; width: min(820px, 100%); text-align: center; }
.choice-box h2 { font-size: clamp(34px, 6vw, 56px); color: var(--yellow-bright); margin: 14px 0; }
.choice-lead { font-family: var(--serif); font-size: 14px; color: var(--ink-dim); line-height: 1.9; margin: 0 auto 30px; max-width: 560px; }
.choice-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.choice-card { position: relative; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(24,23,15,.9), rgba(10,10,7,.9)); padding: 26px 24px; transition: .2s; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.choice-card::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 80% 0%, rgba(217,196,106,.12), transparent 55%); opacity: 0; transition: .25s; }
.choice-card:hover { border-color: var(--yellow); transform: translateY(-3px); box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.choice-card:hover::before { opacity: 1; }
.cc-no { font-family: var(--mono); font-size: 9px; color: var(--yellow-deep); letter-spacing: .2em; }
.cc-icon { font-size: 30px; color: var(--yellow); line-height: 1; }
.cc-title { font-family: var(--serif); font-size: 26px; letter-spacing: .08em; display: flex; flex-direction: column; gap: 3px; }
.cc-title small { font-family: var(--mono); font-size: 8px; letter-spacing: .2em; color: var(--ink-faint); }
.cc-desc { font-size: 11px; color: var(--ink-dim); line-height: 1.8; min-height: 44px; }
.cc-go { margin-top: 10px; font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--yellow); }
.choice-foot { margin-top: 24px; font-size: 9px; color: var(--ink-faint); }
@media (max-width: 620px) {
  .choice-options { grid-template-columns: 1fr; }
  .choice-card { padding: 18px; gap: 5px; }
  .cc-title { font-size: 21px; }
  .cc-desc { min-height: 0; }
  .choice-box h2 { font-size: 34px; }
  .choice-lead { margin-bottom: 20px; }
}

.ending-screen { background: radial-gradient(ellipse at 50% 40%, rgba(240,232,190,.12), rgba(3,3,2,.96) 70%); }
.ending-glow { position: absolute; left: 50%; top: 40%; width: 500px; height: 500px; transform: translate(-50%,-50%); background: radial-gradient(circle, rgba(255,248,207,.14), transparent 60%); pointer-events: none; }
.ending-modal { text-align: center; background: linear-gradient(170deg, #17160e, #080805); }
.ending-modal h2 { font-size: 40px; color: var(--yellow-bright); }
.ending-text { font-family: var(--serif); font-size: 14px; line-height: 2.1; color: #cdc5aa; max-width: 420px; margin: 20px auto; white-space: pre-wrap; text-align: left; }
.ending-modal blockquote { font-family: var(--serif); font-size: 13px; color: var(--yellow); border-left: 1px solid var(--yellow-deep); text-align: left; margin: 22px 0; padding: 4px 0 4px 16px; line-height: 1.8; }
.ending-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 14px 0; }
.ending-stats div { display: flex; flex-direction: column; gap: 4px; }
.ending-stats small { font-size: 8px; color: var(--ink-faint); }
.ending-stats b { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--yellow); }
.ending-actions { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.ending-hint { font-size: 9px; color: var(--ink-faint); margin-top: 16px; }

/* =========================================================
   档案库
   ========================================================= */
.codex-tabs { display: flex; gap: 2px; padding: 0 30px; border-bottom: 1px solid var(--line-soft); flex: none; overflow-x: auto; }
.tab { padding: 12px 16px; font-size: 11px; color: var(--ink-faint); border-bottom: 1px solid transparent; margin-bottom: -1px; letter-spacing: .08em; white-space: nowrap; }
.tab b { font-family: var(--mono); font-size: 9px; color: var(--yellow-deep); font-weight: 400; margin-left: 3px; }
.tab.active { color: var(--yellow); border-color: var(--yellow); }
.tab:hover { color: var(--ink-dim); }
.codex-body { display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0; }
.codex-side { border-right: 1px solid var(--line-soft); overflow-y: auto; padding: 12px; }
.codex-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 10px; border: 1px solid transparent; margin-bottom: 2px; transition: .15s; }
.codex-item:hover { background: rgba(255,255,255,.03); }
.codex-item.active { background: rgba(217,196,106,.08); border-color: rgba(217,196,106,.22); }
.codex-item.locked { opacity: .35; cursor: default; }
.codex-item .ci-no { font-family: var(--mono); font-size: 9px; color: var(--yellow-deep); padding-top: 2px; min-width: 22px; }
.codex-item .ci-main { flex: 1; min-width: 0; }
.codex-item .ci-title { font-size: 11px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codex-item .ci-sub { font-size: 8px; color: var(--ink-faint); margin-top: 3px; font-family: var(--mono); letter-spacing: .06em; }
.codex-item .ci-lock { font-size: 9px; color: var(--ink-faint); }
.codex-content { overflow-y: auto; padding: 32px 40px; }
.codex-doc h3 { font-family: var(--serif); font-size: 26px; color: var(--ink); letter-spacing: .06em; margin: 0 0 4px; }
.codex-doc .doc-meta { font-family: var(--mono); font-size: 9px; color: var(--yellow-deep); letter-spacing: .12em; margin-bottom: 24px; border-bottom: 1px solid var(--line-soft); padding-bottom: 14px; }
.codex-doc .doc-body { font-family: var(--serif); font-size: 14px; line-height: 2.1; color: #c8c0a7; white-space: pre-wrap; }
.codex-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--ink-faint); font-size: 11px; gap: 12px; text-align: center; }
.codex-empty .big { font-size: 36px; color: var(--line); }
.entity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.entity-card { border: 1px solid var(--line-soft); padding: 18px; background: rgba(255,255,255,.015); }
.entity-card.locked { opacity: .4; }
.entity-card .ec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.entity-card h4 { font-family: var(--serif); font-size: 18px; margin: 0; letter-spacing: .08em; }
.entity-card .ec-threat { font-family: var(--mono); font-size: 8px; border: 1px solid currentColor; padding: 2px 6px; color: var(--danger); }
.entity-card p { font-size: 11px; line-height: 1.9; color: var(--ink-dim); margin: 0 0 10px; }
.entity-card .ec-tip { font-size: 10px; color: var(--yellow); border-left: 1px solid var(--yellow-deep); padding-left: 9px; line-height: 1.8; }
.achv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.achv { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--line-soft); align-items: center; }
.achv.locked { opacity: .38; filter: grayscale(1); }
.achv-icon { width: 34px; height: 34px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--yellow); font-size: 15px; flex: none; }
.achv b { display: block; font-size: 11px; font-weight: 500; }
.achv small { display: block; font-size: 9px; color: var(--ink-faint); margin-top: 3px; line-height: 1.5; }
.level-list { display: flex; flex-direction: column; gap: 6px; }
.level-row { display: grid; grid-template-columns: 70px 1fr 100px; gap: 12px; align-items: center; padding: 13px 14px; border: 1px solid var(--line-soft); }
.level-row.locked { opacity: .35; }
.level-row.unlocked { border-color: rgba(217,196,106,.2); }
.level-row .lr-num { font-family: var(--mono); font-size: 9px; color: var(--yellow); letter-spacing: .08em; }
.level-row .lr-name { font-family: var(--serif); font-size: 15px; }
.level-row .lr-name small { display: block; font-family: var(--sans); font-size: 9px; color: var(--ink-faint); margin-top: 2px; letter-spacing: .05em; }
.level-row .lr-status { font-family: var(--mono); font-size: 8px; color: var(--ink-faint); text-align: right; }

/* =========================================================
   排行榜
   ========================================================= */
.board-summary { display: flex; gap: 26px; flex-wrap: wrap; padding: 18px 30px; border-bottom: 1px solid var(--line-soft); }
.board-summary div { display: flex; flex-direction: column; gap: 3px; }
.board-summary small { font-size: 8px; color: var(--ink-faint); letter-spacing: .1em; }
.board-summary b { font-family: var(--mono); font-weight: 400; font-size: 17px; color: var(--yellow); }
.board-tabs { display: flex; padding: 10px 30px 0; gap: 4px; flex: none; }
.board-list { flex: 1; overflow-y: auto; padding: 14px 30px 24px; }
.loading-row { text-align: center; color: var(--ink-faint); font-size: 11px; padding: 60px; font-family: var(--mono); animation: pulse 1.5s infinite; }
.board-row { display: grid; grid-template-columns: 38px 1fr 90px 80px 78px; gap: 12px; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--line-soft); }
.board-row.head { font-family: var(--mono); font-size: 8px; color: var(--ink-faint); letter-spacing: .12em; border-bottom-color: var(--line); }
.board-row .br-rank { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.board-row:nth-child(2) .br-rank, .board-row:nth-child(3) .br-rank, .board-row:nth-child(4) .br-rank { color: var(--yellow); }
.board-row .br-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .br-name small { display: block; font-family: var(--mono); font-size: 8px; color: var(--ink-faint); margin-top: 2px; }
.board-row .br-score { font-family: var(--mono); font-size: 13px; color: var(--yellow); text-align: right; }
.board-row .br-level, .board-row .br-time { font-family: var(--mono); font-size: 9px; color: var(--ink-dim); text-align: right; }
.board-foot { padding: 12px 30px 20px; font-size: 9px; color: var(--ink-faint); border-top: 1px solid var(--line-soft); line-height: 1.7; flex: none; }

/* =========================================================
   设置
   ========================================================= */
.settings-modal { width: min(620px, 100%); padding: 0; }
.settings-body { padding: 8px 30px 20px; overflow-y: auto; }
.setting-group { padding: 20px 0; border-bottom: 1px solid var(--line-soft); }
.setting-group:last-child { border: 0; }
.setting-group h3 { margin: 0 0 6px; font-size: 9px; letter-spacing: .2em; color: var(--yellow); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 0; font-size: 12px; color: var(--ink-dim); }
.setting-row > span { display: flex; flex-direction: column; gap: 2px; }
.setting-row small { font-size: 9px; color: var(--ink-faint); }
.setting-row input[type=range] { width: 150px; accent-color: var(--yellow); height: 2px; }
.setting-row select { background: #0d0d09; border: 1px solid var(--line); color: var(--ink); padding: 7px 8px; font-size: 11px; }
.setting-row input[type=checkbox] { width: 34px; height: 18px; appearance: none; border: 1px solid var(--line); background: rgba(0,0,0,.4); position: relative; cursor: pointer; transition: .2s; flex: none; }
.setting-row input[type=checkbox]::after { content: ''; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; background: var(--ink-faint); transition: .2s; }
.setting-row input[type=checkbox]:checked { border-color: var(--yellow); background: rgba(217,196,106,.15); }
.setting-row input[type=checkbox]:checked::after { left: 18px; background: var(--yellow); }
.setting-row b { font-family: var(--mono); font-size: 10px; color: var(--yellow); width: 34px; text-align: right; }
.key-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-top: 14px; padding-top: 16px; border-top: 1px dashed var(--line-soft); }
.key-guide div { display: flex; align-items: center; gap: 10px; font-size: 10px; color: var(--ink-dim); }
.key-guide kbd { min-width: 58px; text-align: center; }
.settings-foot { display: flex; align-items: center; justify-content: space-between; padding: 18px 30px; border-top: 1px solid var(--line-soft); flex: none; }

/* =========================================================
   新游戏 / 章节
   ========================================================= */
.newgame-modal { width: min(600px, 100%); }
.newgame-lead { font-size: 12px; color: var(--ink-dim); line-height: 1.8; margin: 18px 0; }
.difficulty-list { display: flex; flex-direction: column; gap: 7px; }
.diff-card { display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 14px 16px; border: 1px solid var(--line-soft); transition: .16s; background: rgba(255,255,255,.012); }
.diff-card:hover { border-color: var(--line); background: rgba(217,196,106,.04); }
.diff-card.active { border-color: var(--yellow); background: rgba(217,196,106,.08); }
.diff-card .dc-radio { width: 12px; height: 12px; border: 1px solid var(--ink-faint); border-radius: 50%; margin-top: 3px; flex: none; }
.diff-card.active .dc-radio { border-color: var(--yellow); box-shadow: inset 0 0 0 3px #0c0c08, inset 0 0 0 8px var(--yellow); }
.diff-card .dc-main { flex: 1; }
.diff-card .dc-name { font-family: var(--serif); font-size: 16px; letter-spacing: .08em; }
.diff-card .dc-name small { font-family: var(--mono); font-size: 8px; color: var(--ink-faint); margin-left: 6px; letter-spacing: .1em; }
.diff-card .dc-desc { font-size: 10px; color: var(--ink-faint); line-height: 1.7; margin-top: 4px; }
.diff-card .dc-mul { font-family: var(--mono); font-size: 9px; color: var(--yellow-deep); white-space: nowrap; margin-top: 3px; }
.seed-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.seed-row label { font-size: 11px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 2px; }
.seed-row label small { font-size: 9px; color: var(--ink-faint); }
.seed-row input { background: rgba(0,0,0,.35); border: 1px solid var(--line); padding: 9px 11px; font-family: var(--mono); font-size: 11px; width: 180px; }
.daily-notice { margin-top: 12px; border: 1px solid rgba(217,160,91,.3); background: rgba(217,160,91,.06); padding: 10px 12px; font-size: 10px; line-height: 1.7; color: #cfa87b; }
.newgame-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; }
.newgame-hint { font-size: 9px; color: var(--ink-faint); }

.chapters-modal { width: min(760px, 100%); padding-bottom: 24px; }
.chapters-modal > .muted, .chapters-modal > .chapter-list { padding-left: 30px; padding-right: 30px; }
.chapters-modal .muted { font-size: 11px; margin: 14px 0; }
.chapter-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.chapter-card { display: flex; align-items: center; gap: 16px; padding: 13px 16px; border: 1px solid var(--line-soft); text-align: left; transition: .16s; }
.chapter-card:hover { border-color: var(--line); background: rgba(217,196,106,.04); }
.chapter-card.locked { opacity: .32; cursor: not-allowed; }
.chapter-card .cc-num { font-family: var(--mono); font-size: 9px; color: var(--yellow); width: 64px; flex: none; }
.chapter-card .cc-main { flex: 1; }
.chapter-card .cc-main b { display: block; font-family: var(--serif); font-size: 15px; font-weight: 500; letter-spacing: .06em; }
.chapter-card .cc-main small { font-size: 9px; color: var(--ink-faint); }
.chapter-card .cc-go { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }

/* =========================================================
   地图 / 档案阅读 / 关于 / 提交
   ========================================================= */
.map-modal { width: min(740px, 100%); padding-bottom: 22px; }
.big-map-wrap { margin: 20px 30px 12px; border: 1px solid var(--line); background: #050503; aspect-ratio: 1; max-height: calc(100vh - 280px); display: flex; align-items: center; justify-content: center; }
#big-map { max-width: 100%; max-height: 100%; width: auto; height: 100%; aspect-ratio: 1; image-rendering: pixelated; }
.map-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 30px; font-size: 9px; color: var(--ink-faint); }
.map-legend span { display: flex; align-items: center; gap: 5px; }
.map-legend i { width: 7px; height: 7px; display: inline-block; }
.lg-you { background: var(--yellow); border-radius: 50%; }
.lg-goal { background: #f3e39a; transform: rotate(45deg); }
.lg-exit { background: var(--good); }
.lg-entity { background: var(--danger); border-radius: 50%; }
.lg-note { background: #9aa9d8; }
.map-hint { font-size: 9px; color: var(--ink-faint); padding: 10px 30px 0; }

.note-modal { width: min(510px, 100%); background: transparent; border: 0; box-shadow: none; padding: 0; }
.note-paper { background: linear-gradient(160deg, #d8d0b3, #bcb294); color: #2a271c; padding: 34px 34px 24px; box-shadow: 0 30px 90px rgba(0,0,0,.75); position: relative; transform: rotate(-.35deg); }
.note-paper::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.4), transparent 50%), radial-gradient(ellipse at 90% 90%, rgba(80,60,30,.2), transparent 60%); pointer-events: none; mix-blend-mode: multiply; }
.note-stamp { font-family: var(--mono); font-size: 7px; letter-spacing: .16em; color: #7a6c48; border-bottom: 1px solid rgba(60,50,25,.25); padding-bottom: 8px; }
.note-paper h2 { font-family: var(--serif); font-size: 25px; color: #242116; margin: 20px 0 4px; letter-spacing: .06em; }
.note-meta { font-family: var(--mono); font-size: 8px; color: #786b4b; letter-spacing: .1em; margin-bottom: 20px; }
.note-body { font-family: var(--serif); font-size: 13px; line-height: 2; white-space: pre-wrap; color: #322d20; min-height: 160px; }
.note-footer { display: flex; justify-content: space-between; margin-top: 26px; padding-top: 10px; border-top: 1px solid rgba(60,50,25,.2); font-family: var(--mono); font-size: 7px; color: #786b4b; letter-spacing: .12em; }
#btn-note-close { margin-top: 14px; }

.about-modal { width: min(680px, 100%); padding: 0; }
.about-body { padding: 22px 32px; overflow-y: auto; font-size: 12px; line-height: 1.95; color: var(--ink-dim); }
.about-lead { font-family: var(--serif); font-size: 16px; line-height: 2; color: #d6cdb0; border-left: 2px solid var(--yellow-deep); padding-left: 16px; }
.about-body h3 { margin: 22px 0 6px; }
.about-body ul { padding-left: 18px; margin: 6px 0; }
.about-body li { margin-bottom: 4px; }
.about-sig { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 9px; color: var(--ink-faint); text-align: right; letter-spacing: .08em; }
.about-foot { display: flex; align-items: center; justify-content: space-between; padding: 16px 30px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 8px; color: var(--ink-faint); }

.submit-modal { width: min(450px, 100%); text-align: center; }
.submit-modal h2 { font-size: 30px; }
.submit-score { font-family: var(--mono); font-size: 52px; color: var(--yellow); letter-spacing: .04em; margin: 18px 0; text-shadow: 0 0 40px rgba(217,196,106,.25); }
.submit-label { display: flex; flex-direction: column; gap: 8px; text-align: left; font-size: 10px; color: var(--ink-faint); letter-spacing: .1em; }
.submit-label input { background: rgba(0,0,0,.35); border: 1px solid var(--line); padding: 12px; font-size: 14px; color: var(--ink); text-align: center; letter-spacing: .08em; }
.submit-status { font-size: 10px; color: var(--ink-faint); min-height: 18px; margin-top: 10px; }
.submit-modal .modal-actions { justify-content: center; }

/* Toast */
#toast-container { position: absolute; z-index: 80; top: calc(24px + env(safe-area-inset-top,0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: rgba(10,10,6,.92); border: 1px solid var(--line); color: var(--ink); font-size: 11px; padding: 9px 16px; letter-spacing: .04em; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastIn .25s, toastOut .3s 3.5s forwards; white-space: nowrap; }
.toast.achievement { border-color: var(--yellow); display: flex; gap: 9px; align-items: center; }
.toast.achievement b { color: var(--yellow); font-weight: 500; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

#rotate-hint { display: none; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 900px) {
  .menu-main { grid-template-columns: 1fr; gap: 32px; padding: 36px 6vw 40px; align-items: start; }
  .menu-panel { max-width: 480px; width: 100%; }
  .title-desc br { display: none; }
  .menu-header { padding: 16px 22px; }
  .menu-footer { padding: 12px 22px calc(12px + var(--safe)); flex-direction: column; gap: 4px; }
  .header-right #clock { display: none; }
  .menu-scene { opacity: .8; }
  .logo-cn { font-size: clamp(58px, 17vw, 100px); }
  .logo-en { font-size: clamp(14px, 4vw, 24px); letter-spacing: .28em; }
  .title-meta { gap: 26px; margin-top: 24px; }
  .codex-body { grid-template-columns: 210px 1fr; }
  .codex-content { padding: 24px; }
  .entity-grid, .achv-grid { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 30px 1fr 72px 54px; }
  .board-row .br-time { display: none; }
}

@media (max-width: 620px) {
  .modal-screen { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); padding: 22px 18px; }
  .wide-modal { height: calc(100vh - 20px); }
  .modal-topbar { padding: 18px 18px 14px; }
  .modal-topbar h2 { font-size: 23px; }
  h2 { font-size: 27px; }
  .menu-header { padding: 12px 16px; font-size: 8px; }
  .menu-main { padding: 24px 16px 30px; gap: 22px; }
  .title-kicker { font-size: 7px; letter-spacing: .24em; margin-bottom: 12px; }
  .logo-cn { font-size: 19vw; }
  .logo-en { font-size: 3.6vw; letter-spacing: .22em; margin-top: 7px; }
  .title-sub { margin-top: 16px; font-size: 10px; letter-spacing: .35em; }
  .title-desc { font-size: 11px; line-height: 1.9; margin-top: 18px; padding-left: 12px; }
  .title-meta { gap: 18px; margin-top: 20px; }
  .title-meta b { font-size: 17px; }
  .title-meta small { font-size: 7px; }
  .menu-panel { padding: 14px; }
  .menu-btn { padding: 12px; }
  .btn-main { font-size: 13px; }
  .menu-grid { grid-template-columns: 1fr 1fr; }
  .menu-foot { font-size: 7px; }
  .menu-footer { display: none; }
  .panel-label { margin-bottom: 9px; }
  .intro-text { min-height: 220px; font-size: 16px; }
  .intro-actions { margin-top: 24px; }
  .death-stats { grid-template-columns: 1fr 1fr; gap: 10px 0; }
  .death-stats div:nth-child(2) { border: 0; }
  .ending-stats { grid-template-columns: 1fr 1fr; gap: 12px 0; }
  .ending-modal h2 { font-size: 30px; }
  .ending-text { font-size: 13px; }
  .pause-stats { grid-template-columns: 1fr 1fr 1fr; }
  .codex-body { grid-template-columns: 1fr; position: relative; }
  .codex-side { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); padding: 8px; }
  .codex-item { min-width: 150px; margin: 0 2px; }
  .codex-content { padding: 20px 18px; }
  .codex-doc h3 { font-size: 21px; }
  .codex-tabs { padding: 0 12px; }
  .tab { padding: 10px 11px; font-size: 10px; }
  .codex-modal .modal-topbar { padding: 14px 16px; }
  .codex-modal .modal-topbar h2 { font-size: 21px; }
  .settings-body { padding: 4px 18px 14px; }
  .setting-row input[type=range] { width: 108px; }
  .settings-foot { padding: 14px 18px; }
  .key-guide { grid-template-columns: 1fr; }
  .seed-row { flex-direction: column; align-items: stretch; }
  .seed-row input { width: 100%; }
  .newgame-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .newgame-hint { text-align: center; }
  .chapters-modal > .muted, .chapters-modal > .chapter-list { padding-left: 16px; padding-right: 16px; }
  .chapter-card { padding: 11px 12px; gap: 10px; }
  .chapter-card .cc-num { width: 54px; font-size: 8px; }
  .chapter-card .cc-main b { font-size: 13px; }
  .board-summary { padding: 12px 16px; gap: 18px; }
  .board-tabs { padding: 8px 16px 0; }
  .board-list { padding: 8px 12px 18px; }
  .board-row { grid-template-columns: 26px 1fr 68px; gap: 8px; padding: 10px 4px; }
  .board-row .br-level { display: none; }
  .board-foot { padding: 10px 16px 16px; }
  .big-map-wrap { margin: 14px 16px 10px; max-height: calc(100vh - 250px); }
  .map-legend { padding: 0 16px; gap: 12px; }
  .map-hint { padding: 8px 16px 0; }
  .note-paper { padding: 24px 22px 18px; }
  .note-paper h2 { font-size: 21px; }
  .note-body { font-size: 12px; min-height: 120px; }
  .about-body { padding: 16px 20px; font-size: 11px; }
  .about-lead { font-size: 14px; }
  .about-foot { padding: 12px 18px; }
  .submit-modal { padding: 24px 18px; }
  .submit-score { font-size: 42px; }
  #hud-top { left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top,0px)); }
  #chapter-box { min-width: 100px; }
  #hud-level-name { font-size: 16px; }
  #objective-box { min-width: 138px; }
  #hud-objective { font-size: 10px; }
  #hud-signal { font-size: 8px; }
  #compass { width: 110px; opacity: .55; }
  #minimap-wrap { top: calc(62px + env(safe-area-inset-top,0px)); right: 10px; width: 96px; height: 96px; }
  #hud-bottom { left: 12px; right: 12px; bottom: calc(10px + var(--safe)); }
  #vitals { width: 132px; }
  #run-timer { display: none; }
  #inventory { gap: 4px; }
  .inv-slot { width: 50px; height: 44px; }
  .inv-slot small { display: none; }
  #message-log { left: 12px; bottom: calc(82px + var(--safe)); max-width: 250px; }
  .msg { font-size: 10px; }
  #subtitle { bottom: calc(92px + var(--safe)); font-size: 13px; }
  #interact-prompt { top: calc(50% + 30px); font-size: 10px; }
  .pause-modal { padding: 24px 18px; }
  .pause-stats { grid-template-columns: 1fr 1fr 1fr; }
  .pause-stats b { font-size: 14px; }
  .achievements .achv b { font-size: 10px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .menu-main { padding-top: 18px; padding-bottom: 18px; grid-template-columns: 1fr .9fr; gap: 26px; }
  .logo-cn { font-size: 72px; }
  .title-desc { margin-top: 12px; line-height: 1.7; }
  .title-meta { margin-top: 14px; }
  .menu-header { padding: 10px 24px; }
  .menu-panel { padding: 12px; }
  .menu-btn { padding: 9px 12px; margin-bottom: 4px; }
  .menu-divider { margin: 8px 0; }
  .mini-btn { padding: 7px 10px; }
  .menu-footer { padding: 8px 24px; }
  #screen-intro .intro-text { min-height: 150px; font-size: 15px; }
  .intro-box { width: min(680px, 90vw); }
  .intro-actions { margin-top: 14px; }
  #minimap-wrap { width: 90px; height: 90px; }
  .modal-screen { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); }
}

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

/* 补充 */
.intro-text.typing::after { content: '▌'; color: var(--yellow); animation: blink 1s steps(1) infinite; margin-left: 2px; }
#lock-hint { position: absolute; left: 50%; top: calc(50% + 70px); transform: translateX(-50%); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: rgba(236,231,212,.5); background: rgba(5,5,3,.55); padding: 5px 10px; border: 1px solid var(--line-soft); pointer-events: none; white-space: nowrap; }
body.touch #lock-hint { display: none !important; }
body.in-game #screen-menu { display: none; }
/* 模态界面时把提示移到下方，避免遮住标题 */
body.modal-open #toast-container { top: auto; bottom: calc(16px + var(--safe)); left: 18px; transform: none; align-items: flex-start; }
body.modal-open .toast { font-size: 10px; padding: 7px 12px; }
@media (max-width: 620px) {
  body.modal-open #toast-container { bottom: calc(8px + var(--safe)); left: 8px; right: 8px; align-items: center; }
  body.modal-open .toast { max-width: 100%; white-space: normal; text-align: center; }
}
body.touch.no-joystick #joystick { display: none; }
body.touch #interact-prompt kbd { display: none; }
body.toast-hide #toast-container { display: none; }
@media (max-width: 620px) {
  .ending-actions, .death-actions { flex-direction: column; }
  .ending-actions > button, .death-actions > button { width: 100%; }
  .ending-actions { margin-top: 18px; }
  .death-actions { gap: 6px; }
  .choice-foot { margin-top: 18px; }
}
#screen-choice { overflow-y: auto; padding: 24px 16px; }
#screen-choice .choice-box { margin: auto; }
