/* 梦域 11:52 —— v0.2 视觉：深夜档案馆 / 守夜人观测记录
 * 深色观测台 + 浅色纸片规矩 + 朱红印章。无外部字体、图片依赖。
 */

:root {
  --void: #060908;
  --coal: #0a0f0d;
  --panel: #0d1412;
  --line: #1d2923;
  --line2: #2b3a32;
  --bone: #d9d4c5;
  --bone-dim: #b9b7a9;
  --ash: #858d84;
  --jade: #9fbd97;
  --jade-dim: #6f8a6c;
  --verm: #b4472f;
  --verm-dim: #743226;
  --gold: #c3a468;
  --paper: #e4ddcb;
  --paper2: #d5ccb6;
  --ink: #1b1913;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", STSong, Georgia, serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--void);
  color: var(--bone);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1250px 860px at 50% -10%, rgba(132, 168, 132, .105), transparent 68%),
    radial-gradient(900px 560px at 50% 4%, rgba(159, 189, 151, .045), transparent 70%),
    radial-gradient(760px 560px at 92% 104%, rgba(150, 64, 44, .06), transparent 62%),
    radial-gradient(700px 700px at 0% 60%, rgba(96, 120, 96, .05), transparent 60%),
    var(--void);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 98;
  pointer-events: none;
  opacity: .5;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.10) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 50% 45%, transparent 52%, rgba(0,0,0,.62) 100%);
  mix-blend-mode: multiply;
}

/* ---------- 通用 ---------- */
.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: block; }

.file-no {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .26em;
  color: var(--jade-dim);
  text-transform: uppercase;
  white-space: nowrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--bone);
  font-family: var(--serif);
  font-size: 15.5px;
  letter-spacing: .18em;
  padding: 13px 28px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color .18s, color .18s, background .18s, transform .1s;
}
.btn:hover { border-color: var(--verm); color: #eadfd2; background: rgba(180, 71, 47, .07); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  border-color: #5b3a2f;
  background: linear-gradient(180deg, rgba(180, 71, 47, .18), rgba(180, 71, 47, .04));
  color: #f0e6d8;
}
.btn-primary:hover { border-color: var(--verm); background: rgba(180, 71, 47, .28); }
.btn-ghost { border-color: transparent; color: var(--ash); }
.btn-ghost:hover { border-color: var(--line2); color: var(--bone); }
.btn-small { font-size: 12.5px; letter-spacing: .06em; padding: 8px 12px; text-align: center; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------- 标题 ---------- */
#screen-title.is-active { display: flex; flex-direction: column; }
.title-wrap {
  position: relative;
  width: min(820px, 90vw);
  margin: auto;
  padding: 7vh 0 6vh;
  text-align: center;
}
.title-wrap::before,
.title-wrap::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #2c3a32 18%, #2c3a32 82%, transparent);
}
.title-wrap::before { top: 0; }
.title-wrap::after { bottom: 0; }

.title-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--ash);
  margin-bottom: 32px;
}
.title-meta .sep { width: 26px; height: 1px; background: var(--line2); }

.game-title {
  margin: 0;
  font-size: clamp(56px, 11vw, 118px);
  font-weight: 500;
  letter-spacing: .1em;
  line-height: 1;
  color: var(--bone);
  text-shadow: 0 0 120px rgba(159, 189, 151, .17);
}
.title-clock {
  display: inline-block;
  margin-left: .18em;
  font-family: var(--mono);
  font-size: .44em;
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--verm);
  vertical-align: .22em;
  transform: rotate(-2deg);
  text-shadow: 0 0 30px rgba(180, 71, 47, .35);
}
.tagline { margin: 26px 0 0; font-size: 14px; letter-spacing: .38em; color: var(--bone-dim); }
.lede { margin: 42px auto 0; max-width: 28em; color: #8f978d; font-size: 15.5px; line-height: 2.15; }
.title-actions { margin-top: 48px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.credit {
  margin: 52px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: #55605a;
  line-height: 2;
}
.title-foot {
  display: flex;
  justify-content: center;
  gap: 34px;
  padding: 18px 20px 22px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: #4d5852;
}

/* ---------- HUD ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  height: 62px;
  padding: 0 clamp(14px, 3vw, 34px);
  background: rgba(7, 10, 9, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.hud-left { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.hud-node {
  font-size: 14.5px;
  letter-spacing: .12em;
  color: var(--bone-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-clock { text-align: center; line-height: 1; }
.hud-clock b {
  display: block;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: .16em;
  color: var(--bone);
}
.hud-clock i {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 8px;
  letter-spacing: .34em;
  color: var(--verm-dim);
}
.hud-stats { display: flex; gap: 7px; justify-self: end; align-items: center; }
.chip {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ash);
  border: 1px solid var(--line);
  padding: 4px 8px;
  white-space: nowrap;
  background: rgba(255, 255, 255, .012);
}
.chip b { color: var(--bone); font-weight: 400; }
.chip i { color: #4f5a53; font-style: normal; }
.chip-hp b { color: #d59a8a; }
.chip-dice b { color: #b9c9d6; }
.chip-rem b { color: var(--jade); }
.hud-btns { display: flex; gap: 6px; justify-self: end; }
.icon-btn {
  width: 36px; height: 32px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--bone-dim);
  font-family: var(--serif);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.icon-btn:hover { border-color: var(--verm); color: #eadfd2; }
#btn-side { display: none; }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 322px;
  max-width: 1340px;
  margin: 0 auto;
  min-height: calc(100dvh - 62px);
}

/* 深度尺 */
.rail {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 34px;
  position: sticky;
  top: 62px;
  height: calc(100dvh - 62px);
  gap: 16px;
}
.rail-cap {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .28em;
  color: #4e5a53;
  writing-mode: vertical-rl;
}
.rail-track {
  position: relative;
  flex: 1;
  width: 1px;
  background: linear-gradient(180deg, transparent, #2b3a32 10%, #2b3a32 90%, transparent);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  max-height: 300px;
}
.rail-track i {
  position: relative;
  width: 24px;
  text-align: center;
  background: var(--void);
  font-family: var(--mono);
  font-style: normal;
  font-size: 9px;
  letter-spacing: .1em;
  color: #5d6a62;
  padding: 5px 0;
}
.rail-track i.on { color: var(--verm); }
.rail-track i::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--line2);
}
.rail-mark {
  position: absolute;
  left: -20px;
  width: 40px;
  height: 2px;
  background: var(--verm);
  box-shadow: 0 0 14px rgba(180, 71, 47, .55);
  transition: top .5s cubic-bezier(.2,.7,.2,1);
}
.rail-mark::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -3px;
  border-left: 5px solid var(--verm);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.story { padding: 44px clamp(22px, 4.4vw, 62px) 80px; min-width: 0; }
.side {
  border-left: 1px solid var(--line);
  padding: 26px 18px 40px;
  background: linear-gradient(180deg, rgba(200, 190, 160, .018), transparent 240px);
  position: sticky;
  top: 62px;
  align-self: start;
  max-height: calc(100dvh - 62px);
  overflow-y: auto;
}

/* ---------- 正文 ---------- */
.log { max-width: 47em; }
.b-head {
  position: relative;
  padding: 4px 0 0 20px;
  margin: 62px 0 26px;
  border-left: 2px solid var(--verm);
}
.b-head:first-child { margin-top: 8px; }
.b-head h2 {
  margin: 0;
  font-size: 31px;
  font-weight: 500;
  letter-spacing: .12em;
  color: #e7e1d2;
  line-height: 1.3;
}
.b-head .sub {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--ash);
  line-height: 1.9;
}
.b-text { animation: rise .5s ease both; }
.b-text p {
  margin: 0 0 19px;
  color: #c8c4b6;
  font-size: 17.5px;
  line-height: 2.02;
}
.b-sys {
  margin: 15px 0;
  padding-left: 14px;
  border-left: 1px solid var(--line2);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: #7a857c;
  line-height: 1.9;
}
.b-roll {
  margin: 24px 0;
  border: 1px dashed #38463c;
  background: rgba(200, 190, 160, .035);
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .03em;
  color: #b9c6b2;
}
.b-roll.ok { border-color: #3f5742; color: #cfe0c2; }
.b-roll.bad { border-color: #6a3a30; color: #e3b3a5; }
.b-dmg {
  margin: 13px 0;
  padding-left: 12px;
  border-left: 2px solid var(--verm);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .05em;
  color: #d99a8c;
}
.b-item {
  margin: 11px 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .05em;
  color: var(--gold);
}
.b-item::before { content: "＋ "; color: var(--gold); }
.b-alert {
  margin: 24px 0;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(150, 55, 38, .16), rgba(150, 55, 38, .03));
  border-left: 3px solid var(--verm);
  color: #e4bcae;
  font-size: 16px;
  letter-spacing: .02em;
  animation: pulseIn .55s ease both;
}

/* 规矩：浅色纸片 + 朱红印章 */
.b-rules {
  position: relative;
  margin: 34px -6px 30px;
  padding: 24px 28px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .18), transparent 30%),
    linear-gradient(180deg, var(--paper), var(--paper2));
  color: var(--ink);
  transform: rotate(-.35deg);
  box-shadow: 0 20px 46px rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 255, 255, .35) inset;
  animation: paperIn .5s cubic-bezier(.2,.8,.2,1) both;
}
.b-rules::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(27, 25, 19, .16);
  pointer-events: none;
}
.b-rules::after {
  content: "守则";
  position: absolute;
  right: -13px;
  top: -16px;
  width: 56px;
  height: 56px;
  border: 2px solid rgba(160, 48, 32, .55);
  border-radius: 50%;
  color: rgba(160, 48, 32, .8);
  font-size: 14px;
  letter-spacing: .08em;
  display: grid;
  place-items: center;
  transform: rotate(13deg);
  background: rgba(228, 221, 203, .6);
}
.b-rules h3 {
  margin: 0 0 13px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .34em;
  color: #6e5c45;
}
.b-rules ol { margin: 0; padding-left: 1.5em; }
.b-rules li {
  margin: 8px 0;
  color: #23211a;
  font-size: 15.5px;
  line-height: 1.85;
}
.b-rules li::marker { color: #8e3b2b; font-family: var(--mono); font-size: 11px; }

/* ---------- 选项 ---------- */
.choices { max-width: 47em; margin-top: 42px; display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: grid;
  grid-template-columns: 2.8em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 17px;
  border: 1px solid #1d2822;
  border-left: 2px solid #2b3a32;
  background: #0b110f;
  color: var(--bone);
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color .16s, background .16s, transform .14s;
  animation: rise .35s ease both;
}
.choice:hover {
  border-left-color: var(--verm);
  background: #101814;
  transform: translateX(4px);
}
.choice:active { transform: translateX(2px); }
.choice .idx {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #59655d;
  letter-spacing: .06em;
}
.choice .label { min-width: 0; }
.choice .hint {
  font-family: var(--mono);
  font-size: 10px;
  color: #636f66;
  letter-spacing: .04em;
  white-space: nowrap;
}
.choice.risk { border-left-color: #5d2c22; background: #0f0c0b; }
.choice.risk .label { color: #d9bdb1; }
.choice.risk:hover { border-left-color: var(--verm); background: #17100d; }
.choice.move .label { color: #c3cfc0; }
.choice.rest .label { color: #b7c7cd; }
.choice[disabled] { opacity: .42; cursor: not-allowed; }
.choice[disabled]:hover { border-left-color: var(--line2); background: #0b110f; transform: none; }
.choice .locked {
  font-family: var(--mono);
  font-size: 10px;
  color: #7c5a50;
  letter-spacing: .02em;
}

/* 追加骰 */
.extra-slot {
  max-width: 47em;
  margin-top: 32px;
  padding: 18px 20px;
  border: 1px dashed #3a4a3e;
  background: rgba(159, 189, 151, .04);
}
.extra-slot p { margin: 0 0 14px; color: var(--bone-dim); font-size: 15px; }
.extra-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.extra-actions .btn { font-size: 13.5px; padding: 9px 16px; letter-spacing: .06em; }

/* ---------- 侧栏 ---------- */
.panel { margin-bottom: 26px; }
.panel h3 {
  margin: 0 0 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: .3em;
  color: var(--jade-dim);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.count { color: #56635a; letter-spacing: .04em; font-size: 9.5px; text-align: right; }
.meter {
  display: grid;
  grid-template-columns: 3em 1fr 2.6em;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ash);
}
.meter b { text-align: right; color: #a9ada2; font-weight: 400; }
.meter .bar {
  height: 4px;
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(255,255,255,.08) 9px 10px),
    #18221c;
  overflow: hidden;
}
.meter .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #54704f, var(--jade));
  transition: width .45s ease;
}
.meter[data-k="hp"] .bar i { background: linear-gradient(90deg, #5f2a21, #c07a66); }
.meter[data-k="clarity"] .bar i { background: linear-gradient(90deg, #3f5563, #8fb3c4); }
.meter[data-k="hunger"] .bar i,
.meter[data-k="thirst"] .bar i,
.meter[data-k="fatigue"] .bar i { background: linear-gradient(90deg, #5a5334, #b8a86f); }

.items { list-style: none; margin: 0; padding: 0; }
.items li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dotted #1b2620;
  font-size: 13px;
  color: var(--bone-dim);
}
.items li:last-child { border-bottom: none; }
.items .iname { flex: 1; min-width: 0; }
.items .icount { font-family: var(--mono); font-size: 10px; color: #5d6a61; }
.items .use {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .02em;
  border: 1px solid #2a3a31;
  background: transparent;
  color: var(--jade-dim);
  padding: 2px 7px;
  cursor: pointer;
}
.items .use:hover { border-color: var(--jade); color: var(--jade); }
.items .empty { color: #4b574f; font-size: 12px; border: none; }

.stamps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stamp {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed #26342c;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 10px;
  color: #445149;
  background: rgba(255, 255, 255, .01);
}
.stamp.got {
  color: #e8dcc4;
  border: 1px solid #7a3c2c;
  background: rgba(160, 60, 44, .35);
  box-shadow: 0 0 0 2px rgba(160, 60, 44, .12) inset;
  transform: rotate(-6deg);
}

.panel-tools { display: flex; flex-direction: column; gap: 6px; }

/* ---------- 结局：一张纸 ---------- */
#screen-end.is-active { display: flex; align-items: center; justify-content: center; padding: 6vh 0; }
.end-wrap { width: min(760px, 90vw); }
.end-sheet {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.2), transparent 28%),
    linear-gradient(180deg, var(--paper), #cfc5ae);
  color: var(--ink);
  padding: 54px clamp(26px, 5vw, 62px) 44px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .6);
  transform: rotate(-.25deg);
}
.end-sheet::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(27, 25, 19, .18);
  pointer-events: none;
}
.end-seal {
  position: absolute;
  top: 34px; right: 40px;
  width: 66px; height: 66px;
  border: 2px solid rgba(160, 48, 32, .6);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(160, 48, 32, .8);
  font-size: 22px;
  transform: rotate(11deg);
  letter-spacing: .1em;
}
.end-sheet .kicker {
  margin: 0 0 22px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .36em;
  color: #7a6349;
}
.end-name {
  margin: 0 0 30px;
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1.15;
  color: var(--ink);
}
.end-wrap[data-tone="bad"] .end-name { color: #8e3327; }
.end-wrap[data-tone="true"] .end-name { color: #7a5a1f; }
.end-text p {
  margin: 0 0 18px;
  color: #2a271f;
  font-size: 16.5px;
  line-height: 2;
  animation: rise .55s ease both;
}
.end-stats {
  margin: 30px 0 4px;
  padding: 16px 0;
  border-top: 1px solid rgba(27, 25, 19, .22);
  border-bottom: 1px solid rgba(27, 25, 19, .22);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 2;
  color: #5b5242;
  white-space: pre-wrap;
}
.end-actions { margin-top: 26px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- 支点图 ---------- */
.graph-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background:
    radial-gradient(900px 600px at 50% 40%, rgba(60, 80, 60, .10), transparent 70%),
    #050807;
  display: flex;
  flex-direction: column;
}
.graph-modal[hidden] { display: none; }
.graph-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 44px) 14px;
  border-bottom: 1px solid var(--line);
}
.graph-title h2 {
  margin: 8px 0 4px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: .14em;
}
.graph-title h2 b { font-family: var(--mono); font-size: 13px; color: var(--jade); font-weight: 400; letter-spacing: .06em; }
.graph-title p { margin: 0; font-size: 12.5px; color: var(--ash); letter-spacing: .04em; }
.graph-actions { display: flex; gap: 8px; }
.graph-stage { position: relative; flex: 1 1 0; min-height: 0; }
#graph-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.graph-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px clamp(18px, 4vw, 44px) 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ash);
  letter-spacing: .06em;
}
.graph-legend span { display: flex; align-items: center; gap: 7px; }
.graph-legend .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.graph-legend .dot.cur { background: var(--verm); box-shadow: 0 0 10px rgba(180, 71, 47, .6); }
.graph-legend .dot.seen { background: var(--jade); }
.graph-legend .dot.unknown { border: 1px solid #5b6a60; }
.graph-tip { margin-left: auto; color: #4f5b53; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 5, 4, .86);
  backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative;
  width: min(860px, 94vw);
  max-height: 86dvh;
  overflow-y: auto;
  background: #0a100e;
  border: 1px solid var(--line2);
  border-top: 2px solid var(--verm);
  padding: 34px clamp(20px, 4vw, 42px) 42px;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  color: var(--ash);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--bone); }
.modal h2 { margin: 0 0 6px; font-size: 22px; font-weight: 500; letter-spacing: .16em; }
.modal .modal-sub { margin: 0 0 24px; color: var(--ash); font-size: 11px; font-family: var(--mono); letter-spacing: .1em; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.tab {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--ash);
  font-family: var(--serif);
  font-size: 13.5px;
  letter-spacing: .14em;
  padding: 8px 14px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab.on { color: var(--bone); border-bottom-color: var(--verm); }
.tab-body h3 { margin: 22px 0 8px; font-size: 15px; font-weight: 500; letter-spacing: .1em; color: var(--jade); }
.tab-body p { margin: 0 0 12px; color: var(--bone-dim); font-size: 14.5px; }
.tab-body a { color: var(--jade); }
.tab-body .locked { color: #4f5b53; }
.entry { padding: 14px 0; border-bottom: 1px dotted #1b2620; }
.entry b { color: var(--bone); font-weight: 500; letter-spacing: .06em; }
.entry .tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--gold);
  border: 1px solid #40361f;
  padding: 1px 6px;
  margin-left: 8px;
  letter-spacing: .04em;
}
.entry p { margin: 6px 0 0; font-size: 14px; color: var(--ash); }
.dist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.dist { border: 1px solid var(--line); padding: 12px 13px; font-size: 13px; color: var(--ash); }
.dist b { display: block; margin-bottom: 4px; color: var(--bone-dim); font-weight: 500; letter-spacing: .1em; }
.dist.open { border-color: #35473a; }
.dist.open b { color: var(--jade); }
.dist.open::after { content: "可进入"; font-family: var(--mono); font-size: 9px; color: var(--jade-dim); letter-spacing: .1em; }
.dist.blank { border-style: dashed; color: #4f5b53; }
.dist.blank b { color: #6a756c; }
.dist.blank::after { content: "空白"; font-family: var(--mono); font-size: 9px; color: #46524a; letter-spacing: .1em; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 95;
  background: #111a15;
  border: 1px solid var(--line2);
  border-left: 2px solid var(--verm);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .05em;
  padding: 11px 20px;
  animation: rise .25s ease both;
}
.toast[hidden] { display: none; }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes paperIn { from { opacity: 0; transform: rotate(-.35deg) translateY(10px); } to { opacity: 1; transform: rotate(-.35deg); } }
@keyframes pulseIn { 0% { opacity: 0; transform: scaleX(.96); } 100% { opacity: 1; transform: none; } }

/* ---------- 编辑器 ---------- */
.editor-body { background: var(--void); }
.ed-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding: 26px clamp(18px, 4vw, 44px) 20px;
  border-bottom: 1px solid var(--line);
}
.ed-title h1 { margin: 8px 0 6px; font-size: 26px; font-weight: 500; letter-spacing: .18em; }
.ed-title p { margin: 0; max-width: 46em; color: var(--ash); font-size: 12.5px; line-height: 1.9; }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ed-actions .btn { font-size: 12.5px; padding: 9px 14px; letter-spacing: .06em; }

.ed-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100dvh - 140px);
}
.ed-side { border-right: 1px solid var(--line); padding: 20px 14px 30px; }
.ed-search {
  width: 100%;
  background: #0a100d;
  border: 1px solid var(--line2);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 9px 11px;
  margin-bottom: 18px;
  outline: none;
}
.ed-search:focus { border-color: var(--jade-dim); }
.ed-side h3 {
  margin: 20px 0 8px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: .3em;
  color: var(--jade-dim);
  display: flex;
  justify-content: space-between;
}
.ed-list { list-style: none; margin: 0; padding: 0; }
.ed-item {
  padding: 7px 9px;
  font-size: 12.5px;
  color: var(--bone-dim);
  cursor: pointer;
  border-left: 2px solid transparent;
}
.ed-item:hover { background: rgba(255, 255, 255, .025); }
.ed-item.on { border-left-color: var(--verm); background: rgba(180, 71, 47, .08); color: var(--bone); }

.ed-main { padding: 26px clamp(18px, 3.4vw, 44px) 60px; min-width: 0; }
.ed-pane { max-width: 62em; }
.ed-pane-head { margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ed-pane-head h2 { margin: 6px 0 4px; font-size: 24px; font-weight: 500; letter-spacing: .12em; }
.ed-pane-head p { margin: 0; font-family: var(--mono); font-size: 10.5px; color: var(--ash); letter-spacing: .04em; }
.ed-field { display: block; margin: 0 0 16px; }
.ed-field span {
  display: block;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: var(--ash);
}
.ed-field input,
.ed-field textarea {
  width: 100%;
  background: #090f0c;
  border: 1px solid var(--line);
  color: #cfcabb;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.9;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
}
.ed-field input:focus,
.ed-field textarea:focus { border-color: var(--jade-dim); background: #0b1210; }
.ed-subhead { margin: 34px 0 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.ed-subhead h3 { margin: 6px 0 0; font-size: 17px; font-weight: 500; letter-spacing: .14em; }
.ed-action {
  margin: 0 0 18px;
  padding: 14px 16px 2px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .012);
}
.ed-action-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ed-action-head b { font-family: var(--mono); font-size: 11px; color: var(--jade); font-weight: 400; letter-spacing: .04em; }
.ed-action-head i { font-family: var(--mono); font-style: normal; font-size: 10px; color: #5e6b62; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  #btn-side { display: block; }
  .side {
    position: fixed;
    inset: 62px 0 0 auto;
    width: min(340px, 88vw);
    z-index: 30;
    transform: translateX(102%);
    transition: transform .26s ease;
    background: #080e0b;
    border-left: 1px solid var(--line2);
    max-height: none;
    padding-bottom: 60px;
  }
  .side.open { transform: none; box-shadow: -30px 0 70px rgba(0, 0, 0, .6); }
  .story { padding: 32px 20px 80px; }
  .b-rules { margin-left: 0; margin-right: 0; }
  .ed-layout { grid-template-columns: 1fr; }
  .ed-side { border-right: none; border-bottom: 1px solid var(--line); }
  .ed-side-scroll { max-height: 220px; overflow-y: auto; }
  .graph-head { flex-direction: column; }
  .graph-tip { margin-left: 0; }
}

@media (max-width: 620px) {
  html, body { font-size: 16px; }
  .hud { grid-template-columns: minmax(0, 1fr) auto auto; height: 58px; gap: 8px; }
  .hud-clock { display: none; }
  .hud-stats .chip-rem { display: none; }
  .b-head h2 { font-size: 24px; }
  .game-title { font-size: 54px; }
  .tagline { letter-spacing: .2em; font-size: 12px; }
  .title-clock { font-size: .5em; }
  .choice { grid-template-columns: 2.2em minmax(0, 1fr); }
  .choice .hint { display: none; }
  .choice .locked { grid-column: 2; }
  .end-sheet { padding: 40px 20px 30px; }
  .end-seal { top: 18px; right: 18px; width: 48px; height: 48px; font-size: 16px; }
  .graph-title h2 { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *:not(.char):not(.char-wrap):not(.tagline):not(.choice):not(.battle-block) { animation: none !important; transition: none !important; }
}

/* ================= v0.3 追加：入梦序幕 / 可查看物 / 背包 / 配图端口 ================= */

/* ---------- 入梦（序幕） ---------- */
#screen-prologue.is-active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 20px 6vh;
}
.prologue-wrap {
  width: min(780px, 92vw);
  position: relative;
  padding: 44px clamp(22px, 4vw, 54px) 40px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(196, 182, 150, .035), transparent 200px),
    rgba(6, 10, 8, .5);
}
.prologue-wrap::before,
.prologue-wrap::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 1px solid var(--verm-dim);
}
.prologue-wrap::before { left: -1px; top: -1px; border-right: none; border-bottom: none; }
.prologue-wrap::after { right: -1px; bottom: -1px; border-left: none; border-top: none; }
.prologue-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--ash);
  margin-bottom: 26px;
}
.prologue-sep { flex: 0 0 40px; height: 1px; background: var(--line2); }
.prologue-title {
  margin: 0 0 8px;
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 500;
  letter-spacing: .24em;
  color: #e8e2d3;
  line-height: 1.2;
}
.prologue-sub {
  margin: 0 0 30px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--ash);
}
#prologue-log { max-width: none; }
#prologue-log .b-rules { margin-top: 26px; }
.prologue-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.prologue-hint { font-family: var(--mono); font-size: 10.5px; color: #5d6a61; letter-spacing: .06em; }

/* ---------- 场景可查看物 ---------- */
.b-objects {
  margin: 22px 0 30px;
  padding: 14px 0 2px;
  border-top: 1px dashed #2a3830;
}
.b-objects .obj-label {
  display: block;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .3em;
  color: #62706a;
}
.obj-list { display: flex; flex-wrap: wrap; gap: 7px; }
.obj-btn {
  appearance: none;
  border: 1px solid #27362d;
  background: rgba(255, 255, 255, .015);
  color: #b9c1b4;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .04em;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color .16s, color .16s, background .16s;
}
.obj-btn::before { content: "◇ "; color: #6c7a70; font-size: 10px; }
.obj-btn:hover { border-color: var(--jade-dim); color: var(--jade); background: rgba(159, 189, 151, .05); }

/* ---------- 配图端口 ---------- */
.img-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px dashed #33433a;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.018) 0 6px, transparent 6px 12px),
    #0a100d;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 18px;
}
.img-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-slot .ph {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  color: #56635a;
  text-align: center;
  line-height: 2;
}
.img-slot .ph b { display: block; color: #6f7d72; font-weight: 400; margin-bottom: 4px; }
.img-slot.small { aspect-ratio: 1; margin: 0; }
.img-slot.small .ph { font-size: 8.5px; }

/* ---------- 背包 ---------- */
.bag-box { width: min(920px, 94vw); }
.bag-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.bag-head h2 { margin: 6px 0 4px; font-size: 24px; font-weight: 500; letter-spacing: .16em; }
.bag-head p { margin: 0; font-family: var(--mono); font-size: 10.5px; color: var(--ash); letter-spacing: .08em; }
.bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.item-card {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  background: #0a100d;
  color: var(--bone);
  cursor: pointer;
  font-family: var(--serif);
  transition: border-color .16s, background .16s;
}
.item-card:hover { border-color: var(--jade-dim); background: #0d1511; }
.item-card .item-thumb {
  width: 54px; height: 54px;
  flex: 0 0 54px;
  border: 1px solid #26342c;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 16px;
  color: #4f5c53;
  background: rgba(255, 255, 255, .02);
  overflow: hidden;
}
.item-card .item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-card .item-meta { min-width: 0; }
.item-card b { display: block; font-weight: 500; font-size: 14.5px; letter-spacing: .06em; }
.item-card span { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9.5px; color: var(--ash); }
.item-card .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
}
.bag-empty { color: #55625a; font-size: 14px; padding: 30px 0; }

.detail { max-width: 560px; }
.detail-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-head h2 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: .12em; }
.detail-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  border: 1px solid #40361f;
  color: var(--gold);
  padding: 2px 7px;
}
.detail-sub { margin: 0 0 20px; font-family: var(--mono); font-size: 10px; color: var(--ash); letter-spacing: .08em; }
.detail-desc { color: #c6c3b5; font-size: 15.5px; line-height: 2; margin: 0 0 22px; white-space: pre-wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.back-link {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--ash);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--jade); }

/* ---------- 档案页修复：tab 吸顶 ---------- */
.modal-box { scrollbar-width: thin; }
.tabs {
  position: sticky;
  top: -34px;
  z-index: 3;
  background: #0a100e;
  padding-top: 6px;
}
.bag-link { margin-top: 10px; width: 100%; }

/* ---------- HUD 四键 ---------- */
.hud-btns .icon-btn { width: 34px; }
@media (max-width: 620px) {
  .hud { grid-template-columns: minmax(0, 1fr) auto auto; }
  .hud-left .file-no { display: none; }
  .hud-btns .icon-btn { width: 32px; }
}

/* 修正：配图绝对铺满，占位文字留在底下 */
.img-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* 修正：档案 tab 吸顶位置 */
.tabs { top: 0; padding-right: 40px; padding-top: 8px; box-shadow: 0 8px 18px rgba(6, 9, 8, .9); }

/* 序幕：底部固定「睁开眼」，不用滚到底 */
#screen-prologue .prologue-wrap { padding-bottom: 130px; }
#screen-prologue.is-active .prologue-actions {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 12;
  width: min(780px, 92vw);
  margin: 0;
  padding: 12px 18px;
  border: 1px solid var(--line2);
  background: rgba(6, 10, 8, .94);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
  justify-content: space-between;
}
#screen-prologue.is-active .prologue-actions .btn { padding: 11px 26px; }
@media (max-width: 620px) {
  #screen-prologue.is-active .prologue-actions { bottom: 12px; }
  .prologue-hint { display: none; }
}

/* ================= v0.4：身份卡 / 落点 / 多存档 / 乱码 ================= */
.section-label {
  margin: 26px 0 12px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .28em;
  color: var(--jade-dim);
}
.identity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.identity-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  background: #0a100d;
  color: var(--bone);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color .16s, background .16s;
}
.identity-card:hover { border-color: var(--jade-dim); background: #0d1511; }
.identity-card.on { border-color: var(--verm); background: rgba(180, 71, 47, .07); }
.identity-card b { font-size: 18px; font-weight: 500; letter-spacing: .1em; }
.id-stats { font-family: var(--mono); font-size: 10.5px; color: var(--jade); letter-spacing: .04em; }
.id-desc { font-size: 12.5px; line-height: 1.75; color: var(--ash); }
.id-items { font-family: var(--mono); font-size: 9px; color: var(--gold); letter-spacing: .02em; }

.entry-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border: 1px dashed #33433a;
  background: rgba(159, 189, 151, .03);
  padding: 16px 18px;
}
.entry-card.drawn { border-style: solid; border-color: #3d5142; }
.entry-card p { margin: 0; font-size: 13.5px; color: var(--ash); line-height: 1.9; }
.entry-card b { font-size: 21px; font-weight: 500; letter-spacing: .1em; }
.entry-tag { font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: var(--verm); }
.entry-meta { font-family: var(--mono); font-size: 10px; color: var(--ash); letter-spacing: .04em; }

.save-list { display: flex; flex-direction: column; gap: 8px; }
.save-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #0a100d;
}
.save-row.backup { border-left-color: var(--gold); }
.save-row.auto { border-style: dashed; }
.save-main { min-width: 0; }
.save-main b { display: block; font-size: 14.5px; font-weight: 500; letter-spacing: .08em; }
.save-main span { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9.5px; color: var(--ash); letter-spacing: .02em; }
.save-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.save-actions .btn { font-size: 10.5px; padding: 5px 9px; letter-spacing: .04em; }

.node-chips { display: flex; gap: 7px; flex-wrap: wrap; margin: 0 0 16px; }
.node-chips span {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: var(--ash);
  border: 1px solid var(--line);
  padding: 4px 8px;
}

.mosaic {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  height: 68px;
  margin: 10px 0;
  padding: 4px;
  background: #070c0a;
  border: 1px solid #1c2821;
  overflow: hidden;
}
.mosaic i {
  font-style: normal;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  text-align: center;
  color: #61746a;
}

@media (max-width: 720px) {
  .identity-grid { grid-template-columns: 1fr; }
  .save-row { flex-direction: column; align-items: flex-start; }
  .save-actions { width: 100%; }
}

/* ================= v0.5：理智 / 启用道具 / 印章回归 ================= */
.equip { margin: 0 0 10px; }
.equip > span {
  display: block;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .22em;
  color: #5d6a61;
}
.equip-list { display: flex; gap: 5px; flex-wrap: wrap; }
.equip-chip {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .02em;
  color: var(--bone-dim);
  border: 1px solid #2a3a31;
  padding: 3px 7px;
  background: transparent;
}
button.equip-chip { cursor: pointer; }
.equip-chip.on { color: #efe3cf; border-color: var(--verm); background: rgba(180, 71, 47, .16); }
.equip-empty { font-family: var(--mono); font-size: 9.5px; color: #46524a; }

.b-text.low p { color: #d9b9ad; }
body.low-sanity::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 97;
  background: radial-gradient(circle at 50% 50%, transparent 35%, rgba(120, 36, 26, .16) 100%);
  animation: lowFog 5s ease-in-out infinite alternate;
}
@keyframes lowFog { from { opacity: .45; } to { opacity: .9; } }

/* ================= v0.5：惊厥期 ================= */
.panic-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  background:
    radial-gradient(900px 600px at 50% 45%, rgba(60, 80, 60, .10), transparent 70%),
    #050807;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(12px, 3vw, 34px);
}
.panic-modal[hidden] { display: none; }
.panic-head {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--line);
}
.panic-head h2 { margin: 6px 0 2px; font-size: 20px; font-weight: 500; letter-spacing: .12em; }
.panic-head p { margin: 0; font-family: var(--mono); font-size: 10px; color: var(--ash); letter-spacing: .06em; }
.panic-hud { display: flex; gap: 14px; margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--ash); }
.panic-hud b { color: var(--bone); font-weight: 400; }
.panic-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 12px 0;
  border: 1px solid var(--line);
  background: #070b09;
  overflow: hidden;
}
#panic-canvas { width: 100%; height: 100%; display: block; }
.panic-fog {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(5, 8, 7, .92) 100%);
  backdrop-filter: blur(1.5px);
  mask-image: radial-gradient(ellipse at center, transparent 45%, #000 100%);
}
.panic-combat {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 88%);
  background: rgba(9, 14, 11, .97);
  border: 1px solid #6a3a30;
  padding: 20px 22px;
  z-index: 3;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .7);
}
.panic-combat p { color: var(--bone-dim); font-size: 14px; line-height: 1.9; margin: 8px 0; }
.panic-combat-stats { font-family: var(--mono); font-size: 10.5px; color: var(--ash); }
.panic-combat-stats b { color: var(--bone); font-weight: 400; }
.panic-combat-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 14px; }
.panic-foot {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 10px 0 16px;
  border-top: 1px solid var(--line);
}
.panic-pad { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.panic-pad > div { display: flex; gap: 4px; }
.pad-btn {
  width: 42px; height: 34px;
  border: 1px solid var(--line2);
  background: #0a100d;
  color: var(--bone);
  font-family: var(--mono);
  font-size: 14px;
  cursor: pointer;
}
.pad-btn:active { border-color: var(--verm); }
.panic-tip { margin: 0; font-size: 12.5px; color: var(--ash); max-width: 46em; line-height: 1.8; }
@media (max-width: 620px) {
  .panic-hud { margin-left: 0; }
  .panic-head { padding-top: 12px; }
  .panic-stage { margin: 8px 0; }
}

/* 五张身份卡 */
.identity-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.identity-card { cursor: pointer; }
.id-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.id-pending {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  color: #9b7d4d;
  border: 1px solid #4a3f24;
  padding: 1px 5px;
}
.id-custom { display: flex; gap: 6px; margin-top: 6px; }
.id-custom input {
  flex: 1;
  min-width: 0;
  background: #090f0c;
  border: 1px solid var(--line2);
  color: var(--bone);
  font-family: var(--serif);
  font-size: 12.5px;
  padding: 6px 8px;
  outline: none;
}
.id-custom input:focus { border-color: var(--verm); }
.id-custom .btn { padding: 6px 10px; font-size: 11px; }

/* ================= 身份卡：单按钮 + 卡组轮播 ================= */
.identity-trigger {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: 1px dashed #3a4b3e;
  background: rgba(159, 189, 151, .035);
  color: var(--bone);
  font-family: var(--serif);
  cursor: pointer;
  text-align: left;
  transition: border-color .18s, background .18s;
}
.identity-trigger:hover { border-color: var(--verm); background: rgba(180, 71, 47, .06); }
.identity-trigger.chosen { border-style: solid; border-color: #4b5f4d; }
.identity-trigger .it-label { font-family: var(--mono); font-size: 9px; letter-spacing: .24em; color: var(--jade-dim); }
.identity-trigger b { font-size: 20px; font-weight: 500; letter-spacing: .1em; }
.identity-trigger .it-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: .04em; color: var(--ash); }

.deck-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  background:
    radial-gradient(800px 600px at 50% 42%, rgba(60, 80, 60, .12), transparent 70%),
    rgba(4, 7, 6, .96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.deck-modal[hidden] { display: none; }
.deck-head { text-align: center; margin-bottom: 6px; }
.deck-head h2 { margin: 8px 0 4px; font-size: 22px; font-weight: 500; letter-spacing: .18em; }
.deck-head p { margin: 0; font-family: var(--mono); font-size: 9.5px; color: var(--ash); letter-spacing: .08em; }
.deck-stage {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 400px;
  perspective: 1200px;
  overflow: hidden;
  touch-action: pan-y;
}
.deck-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(330px, 74vw);
  min-height: 300px;
  padding: 22px 24px;
  background: #0e1712;
  border: 1px solid #2b3a31;
  color: var(--bone);
  transform-style: preserve-3d;
  transition: transform .28s ease, opacity .28s ease, filter .28s ease;
  cursor: pointer;
  overflow: hidden;
}
.deck-card:not(.center) { border-color: #34463b; }
.deck-card.center {
  border-color: var(--verm);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .7), 0 0 0 1px rgba(180, 71, 47, .25) inset;
  cursor: default;
}
.deck-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 100%;
  background: var(--verm);
  opacity: 0;
}
.deck-card.center::before { opacity: .8; }
.dc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dc-head b { font-size: 21px; font-weight: 500; letter-spacing: .1em; }
.dc-stats { margin: 10px 0; font-family: var(--mono); font-size: 11px; color: var(--jade); letter-spacing: .06em; }
.dc-desc { margin: 0 0 16px; color: #aeb2a6; font-size: 13.5px; line-height: 1.9; }
.dc-items { font-family: var(--mono); font-size: 9.5px; color: var(--gold); letter-spacing: .04em; }
.deck-card .id-custom { margin-top: 14px; }
.deck-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.deck-arrow {
  width: 42px; height: 38px;
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 15px;
  cursor: pointer;
}
.deck-arrow:hover { border-color: var(--verm); color: #f0e5d5; }
.deck-close {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--ash);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  cursor: pointer;
}
.deck-close:hover { color: var(--bone); }
@media (max-width: 620px) {
  .deck-stage { height: 360px; }
  .deck-card { min-height: 290px; padding: 18px; }
  .dc-head b { font-size: 18px; }
}

/* 身份卡：属性 / 被动 / 隐藏卡 */
.dc-attrs {
  margin: -4px 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: #9fb9a4;
  letter-spacing: .04em;
}
.dc-passive {
  margin: 0 0 12px;
  padding-top: 8px;
  border-top: 1px dashed rgba(159, 185, 164, .2);
  color: #c6b58d;
  font-size: 11.5px;
  line-height: 1.75;
  white-space: pre-line;
}
.id-hidden {
  font-family: var(--mono);
  font-size: 8px;
  color: #d8b96a;
  border: 1px solid #6b5528;
  padding: 1px 5px;
}
.deck-card.hidden-card { border-color: #6b5528; }
.deck-card { min-height: 360px; overflow-y: auto; }

.dc-desc { white-space: pre-line; }

/* 梦境骰说明 / 卡面全属性 */
.stat-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  margin-left: 4px;
  border: 1px solid rgba(216, 185, 106, .7);
  border-radius: 50%;
  color: #d8b96a;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.stat-help:hover { background: rgba(216, 185, 106, .15); }
.dc-vitals {
  margin: -4px 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: #879b8b;
  letter-spacing: .03em;
}
.dice-num { color: #e8d9a0; font-weight: 500; }
.deck-card { min-height: 420px; }

/* 文本端口：左右独立滚动 */
.ed-layout {
  height: calc(100dvh - 132px);
  min-height: 540px;
  align-items: stretch;
}
.ed-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ed-side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.ed-main {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 980px) {
  .ed-layout { height: auto; min-height: 0; }
  .ed-side { overflow: visible; }
  .ed-side-scroll { max-height: 240px; overflow-y: auto; }
  .ed-main { height: auto; overflow: visible; }
}

/* 标题：内层持续浮动，外层点击散开 */
.game-title {
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.char-wrap {
  display: inline-block;
  will-change: transform;
  transform: translate(0, 0) rotate(0deg);
}
.char {
  display: inline-block;
  will-change: transform;
  animation: floatChar var(--dur, 4.5s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  --fx1: 0px;
  --fy1: 0px;
  --fx2: 0px;
  --fy2: 0px;
  --rot1: 0deg;
  --rot2: 0deg;
}
.tagline, .lede {
  position: relative;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.secret-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: block;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1800ms ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.temp-glitch {
  display: inline-block;
  min-width: 6.8em;
  font-family: var(--mono);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  color: var(--jade-dim);
  white-space: nowrap;
}
.glitch-word {
  display: inline-block;
  min-width: 2em;
  color: var(--ash);
  filter: blur(.5px);
  will-change: transform, filter, opacity;
}
@keyframes subFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(0, -3px) rotate(-0.6deg); }
  66% { transform: translate(1.5px, 1px) rotate(0.5deg); }
}
@keyframes floatChar {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(var(--fx1), var(--fy1)) rotate(var(--rot1)); }
  50% { transform: translate(var(--fx2), var(--fy2)) rotate(var(--rot2)); }
  75% { transform: translate(var(--fx1), var(--fy2)) rotate(var(--rot1)); }
}

/* 文本端口：可折叠目录树 */
.ed-tree { padding: 4px 0 30px; }
.ed-group { margin: 0; }
.ed-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border: 0;
  border-bottom: 1px solid rgba(159, 189, 151, .08);
  background: transparent;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-align: left;
  cursor: pointer;
}
.ed-group-head:hover { color: var(--bone); background: rgba(255, 255, 255, .025); }
.ed-group.lv1 > .ed-group-head { color: var(--jade); font-size: 11px; letter-spacing: .18em; margin-top: 6px; }
.ed-group-head span { flex: 1 1 auto; }
.ed-group-head b { font-weight: 400; color: var(--ash); font-size: 9px; }
.ed-group-head i { font-style: normal; color: var(--jade-dim); transition: transform .18s ease; }
.ed-group.closed > .ed-group-head i { transform: rotate(-90deg); }
.ed-group.closed > .ed-group-body { display: none; }
.ed-group-body { padding-left: 9px; }
.ed-group.lv2 > .ed-group-head { border-bottom: 0; padding-top: 6px; padding-bottom: 6px; color: var(--ash); }
.ed-leaf {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  text-align: left;
  font-family: var(--serif);
}
.ed-leaf:hover { background: rgba(255, 255, 255, .03); }
.ed-leaf.on { border-left-color: var(--verm); background: rgba(180, 71, 47, .08); color: var(--bone); }
.ed-leaf-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-leaf-meta { flex: 0 0 auto; font-family: var(--mono); font-size: 8px; color: var(--jade-dim); }
.ed-empty { color: var(--ash); font-family: var(--mono); font-size: 10px; padding: 12px 6px; }
.chip-dice { cursor: pointer; }

/* 未醒的梦域名：标题两侧散射 */
#screen-title { position: relative; }
#screen-title .title-wrap { z-index: 2; }
#screen-title.scatter-active .title-wrap { width: min(820px, 76vw); }
#dream-scatter {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}
.dream-node-float {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .16em;
  color: rgba(159, 189, 151, .72);
  text-shadow: 0 0 20px rgba(159, 189, 151, .3);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 2400ms ease;
  animation: dreamNodeFloat var(--dur, 9s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}
#dream-scatter.show .dream-node-float { opacity: var(--max-op, .68); }
@keyframes dreamNodeFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(var(--dx, 4px), var(--dy, -6px)) rotate(var(--rot, .6deg)); }
  66% { transform: translate(calc(var(--dx, 4px) * -0.5), calc(var(--dy, -6px) * 0.5)) rotate(calc(var(--rot, .6deg) * -1)); }
}
@media (max-width: 760px) {
  .dream-node-float { font-size: 8px; letter-spacing: .08em; opacity: 0; }
  #dream-scatter.show .dream-node-float { opacity: .42; }
}

/* 标题页版本号与更新简报入口 */
.version-line {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.version-help {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid rgba(159, 189, 151, .45);
  border-radius: 50%;
  background: transparent;
  color: var(--jade-dim);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.version-rollback {
  margin-left: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--ash);
  text-decoration: none;
  border-bottom: 1px solid var(--line2);
}
.version-rollback:hover { color: var(--jade); border-color: var(--jade-dim); }
.version-help:hover {
  border-color: var(--jade);
  color: var(--jade);
  background: rgba(159, 189, 151, .08);
}

/* 更新简报 */
#modal-body .codex-text p {
  margin: 0 0 10px;
  color: #c3c2b4;
  font-size: 14px;
  line-height: 1.9;
}
#modal-body .codex-text p b { color: var(--bone); font-weight: 500; }
#modal-body .codex-text .muted { color: var(--ash); font-size: 12px; margin-top: 18px; }

/* 更新简报：日期条目 */
.changelog-list { max-height: 52vh; overflow-y: auto; padding-right: 6px; }
.log-entry { padding: 14px 0 12px; border-top: 1px solid var(--line); }
.log-entry:first-child { border-top: 0; padding-top: 0; }
.log-date { font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: var(--jade-dim); margin-bottom: 4px; }
.log-entry h3 { margin: 0 0 7px; font-size: 15px; font-weight: 500; letter-spacing: .08em; color: var(--bone); }
.log-entry ul { margin: 0; padding-left: 17px; }
.log-entry li { color: #b9b7a9; font-size: 13px; line-height: 1.85; margin: 0 0 3px; }
.changelog-toggle { margin-top: 16px; }
.changelog-versions { margin: 16px 0 0; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }
.changelog-versions a { color: var(--jade-dim); text-decoration: none; border-bottom: 1px solid var(--line2); }
.changelog-versions a:hover { color: var(--jade); }

/* 文字块战斗 */
.panic-combat.battle-panel {
  width: min(680px, 92%);
  max-height: 82vh;
  overflow-y: auto;
  padding: 20px 22px 18px;
}
.battle-head {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--jade-dim);
  margin-bottom: 8px;
}
.battle-name { font-family: var(--serif); font-size: 15px; letter-spacing: .18em; color: var(--bone); }
.battle-head b { margin-left: auto; color: var(--bone-dim); font-weight: 400; }
.battle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ash);
  margin: 8px 0 14px;
}
.battle-meta b { color: var(--bone-dim); font-weight: 400; }
.battle-blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.battle-block {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line2);
  background: rgba(9, 14, 11, .72);
  color: var(--bone-dim);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
}
.battle-block:hover:not(:disabled) { border-color: var(--jade); color: var(--bone); background: rgba(159, 189, 151, .06); }
.battle-block:disabled { cursor: default; }
.battle-block .bb-text { flex: 1 1 auto; }
.battle-block .bb-meta { flex: 0 0 auto; font-family: var(--mono); font-size: 9px; color: var(--jade-dim); letter-spacing: .08em; }
.battle-block.flee { border-color: rgba(180, 71, 47, .45); }
.battle-block.struck { opacity: .32; }
.battle-block.struck .bb-text { text-decoration: line-through; }
.battle-result {
  min-height: 2.6em;
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.8;
  color: var(--ash);
}
#battle-exit { margin-top: 12px; }
@media (max-width: 620px) {
  .battle-blocks { grid-template-columns: 1fr; }
}

/* 通用战斗：独立覆盖在任意界面上 */
#panic-modal.battle-only > *:not(#panic-combat) { display: none !important; }
#panic-modal.battle-only {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 6, .9);
}
#panic-modal.battle-only #panic-combat {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  margin: auto;
}

/* 躁动刻：选项高频小幅颤抖 */
body.restless .choice,
body.restless .battle-block {
  animation: restlessShake .11s linear infinite;
  will-change: transform;
}
@keyframes restlessShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(1px, -1px); }
  40% { transform: translate(-1px, 1px); }
  60% { transform: translate(1px, 1px); }
  80% { transform: translate(-1px, -1px); }
}

/* 低血量：页面缓慢变暗，像闭眼再睁眼，但不全黑 */
body.low-hp::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 97;
  pointer-events: none;
  background: #000;
  opacity: .12;
  animation: lowHpBlink 9s ease-in-out infinite;
}
@keyframes lowHpBlink {
  0%, 100% { opacity: .1; }
  38% { opacity: .3; }
  50% { opacity: .38; }
  62% { opacity: .24; }
  76% { opacity: .34; }
}
