/* ===========================================================================
 * base.css — 结构与布局
 * 所有颜色都走 CSS 变量，具体数值由 themes.css 按章节覆盖。
 * 这一层只定义「东西长在哪」，不定义「东西是什么颜色」。
 * ========================================================================= */

/* ------------------------------------------------------------------ reset */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: calc(16px * var(--font-scale, 1));
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .8s ease, color .8s ease;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button { cursor: pointer; }

::selection { background: var(--accent); color: var(--bg); }

/* 滚动条：主题色，细 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* --------------------------------------------------------------- 应用外壳 */

#app {
  position: relative;
  height: 100%;
  height: 100dvh;              /* 移动端地址栏收起时不跳动 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 主题氛围层：扫描线 / 噪点 / 星场都画在这里，永远在内容下面 */
#ambience {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
}
body.theme-has-stars #starfield { opacity: 1; }

.screen {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* =========================================================================
 * 标题界面
 * ========================================================================= */

#screen-title {
  overflow-y: auto;
  align-items: center;
  padding: clamp(24px, 6vh, 64px) 20px 48px;
}

.title-inner {
  width: 100%;
  max-width: 720px;
  margin: auto;
}

.title-mark {
  text-align: center;
  margin-bottom: clamp(28px, 7vh, 56px);
}

.title-mark h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 11vw, 68px);
  font-weight: 300;
  letter-spacing: .42em;
  text-indent: .42em;           /* 抵消末字后多出的字距，视觉居中 */
  margin: 0 0 14px;
  color: var(--fg-bright);
  animation: title-in 1.4s cubic-bezier(.2, .8, .2, 1) both;
}

.title-mark .sub {
  font-size: 13px;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--fg-dim);
  animation: title-in 1.4s .25s cubic-bezier(.2, .8, .2, 1) both;
}

.title-mark .rule {
  width: 52px;
  height: 1px;
  background: var(--accent);
  margin: 22px auto;
  animation: rule-in 1.6s .5s cubic-bezier(.2, .8, .2, 1) both;
  transform-origin: center;
}

@keyframes title-in {
  from { opacity: 0; transform: translateY(14px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes rule-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* 三部作品的卡片 */
.game-list { display: flex; flex-direction: column; gap: 14px; }

.game-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  padding: 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color .3s, transform .3s, background-color .3s, box-shadow .3s;
  animation: card-in .8s cubic-bezier(.2, .8, .2, 1) both;
  overflow: hidden;
}
.game-card:nth-child(1) { animation-delay: .55s; }
.game-card:nth-child(2) { animation-delay: .68s; }
.game-card:nth-child(3) { animation-delay: .81s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.game-card:hover, .game-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px -12px var(--accent-glow);
  outline: none;
}

.game-card .glyph {
  flex: none;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: calc(var(--radius) - 4px);
  font-family: var(--font-display);
  font-size: 30px;
  color: #fff;
  background: linear-gradient(150deg,
    hsl(var(--card-hue) 60% 42%),
    hsl(var(--card-hue) 70% 22%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}

.game-card .meta { flex: 1; min-width: 0; }
.game-card .meta .idx {
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--fg-dim);
}
.game-card .meta h2 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  margin: 3px 0 5px;
  letter-spacing: .1em;
  color: var(--fg-bright);
}
.game-card .meta p {
  margin: 0;
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.6;
}
.game-card .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  color: var(--fg-dim);
}
.badge.on { border-color: var(--accent); color: var(--accent); }

.title-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
  animation: card-in .8s .95s cubic-bezier(.2, .8, .2, 1) both;
}

.link-btn {
  font-size: 13px;
  letter-spacing: .12em;
  color: var(--fg-dim);
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: color .25s, border-color .25s;
}
.link-btn:hover { color: var(--accent); border-color: var(--line-strong); }

.title-foot {
  text-align: center;
  margin-top: 34px;
  font-size: 11px;
  color: var(--fg-faint);
  line-height: 2;
}

/* =========================================================================
 * 游戏界面
 * ========================================================================= */

#screen-game { overflow: hidden; }

/* 顶栏 */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--panel-solid);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.topbar .who { flex: 1; min-width: 0; }
.topbar .who .name {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .16em;
  color: var(--fg-bright);
}
.topbar .who .chap {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--fg-dim);
  transition: color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--accent); background: var(--hover); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.mini { width: 30px; height: 30px; }
.icon-btn.mini svg { width: 16px; height: 16px; }

/* 进度条 */
.progress {
  flex: none;
  height: 2px;
  background: var(--line);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 1s ease;
}

/* 消息流 */
.stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 8px;
  scroll-behavior: smooth;
}
.stream-inner {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  /* 底部锚定：消息少的时候贴着选项区往上长，跟真实聊天软件一致。
     顶对齐会在中间留一大片空，看着像页面没加载完。 */
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: 8px;
}

/* 消息气泡 */
.msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: var(--bubble-radius);
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
  animation: msg-in .45s cubic-bezier(.2, .9, .3, 1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.msg.them {
  align-self: flex-start;
  background: var(--bubble-them);
  color: var(--bubble-them-fg);
  border: 1px solid var(--bubble-them-line);
  border-bottom-left-radius: 5px;
}

.msg.me {
  align-self: flex-end;
  background: var(--bubble-me);
  color: var(--bubble-me-fg);
  border: 1px solid var(--bubble-me-line);
  border-bottom-right-radius: 5px;
}

/* 说话人署名。连续同一个人说话时只出现一次，说话人一换就重新出现。 */
.speaker {
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--fg-faint);
  margin: 6px 0 -4px;
  animation: msg-in .35s both;
}
.speaker.s-them { align-self: flex-start; padding-left: 3px; }
.speaker.s-me   { align-self: flex-end;   padding-right: 3px; }
.speaker.s-radio {
  align-self: stretch;
  padding-left: 2px;
  color: hsl(var(--radio-hue, 200) 55% 62%);
  opacity: .85;
}
/* 亮色主题下要压暗才看得清 */
body.th-sanctum .speaker.s-radio,
body.th-null .speaker.s-radio { color: hsl(var(--radio-hue, 200) 60% 38%); }

/* 串进来的别的频率：只有玩家听得见。
   必须一眼看出「这不是对方说的」——所以居中、等宽字、带标签、虚线框，
   和左右两侧的对话气泡在形状上就是两类东西。 */
.msg.radio {
  align-self: stretch;
  max-width: 100%;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 9px 13px;
  border: 1px dashed hsl(var(--radio-hue, 200) 45% 42% / .55);
  border-left: 2px solid hsl(var(--radio-hue, 200) 60% 55% / .75);
  border-radius: 3px;
  background:
    linear-gradient(90deg, hsl(var(--radio-hue, 200) 60% 45% / .07), transparent 55%),
    repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255, 255, 255, .012) 6px 12px);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: hsl(var(--radio-hue, 200) 25% 72%);
  animation: radio-in .5s cubic-bezier(.2, .9, .3, 1) both;
}
.msg.radio .radio-tag {
  flex: none;
  font-size: 10px;
  letter-spacing: .12em;
  padding: 1px 6px;
  border: 1px solid hsl(var(--radio-hue, 200) 50% 50% / .5);
  border-radius: 2px;
  color: hsl(var(--radio-hue, 200) 55% 65%);
  white-space: nowrap;
}
/* 亮色主题（圣所 / 归零）下要压暗，否则看不见 */
body.th-sanctum .msg.radio,
body.th-null .msg.radio { color: hsl(var(--radio-hue, 200) 30% 32%); }
body.th-sanctum .msg.radio .radio-tag,
body.th-null .msg.radio .radio-tag { color: hsl(var(--radio-hue, 200) 55% 35%); }
.msg.radio .radio-body { flex: 1; min-width: 0; }

@keyframes radio-in {
  from { opacity: 0; transform: translateX(-6px); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* 终端读数：时间戳、遥测。不是任何人在说话，所以没有气泡也没有署名。 */
.msg.meta {
  align-self: stretch;
  max-width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .02em;
  line-height: 1.6;
  color: var(--fg-faint);
  animation: msg-in .35s both;
}

/* 系统提示（章节、解锁档案、回溯等） */
.msg.sys {
  align-self: center;
  max-width: 100%;
  background: none;
  border: none;
  color: var(--fg-faint);
  font-size: 12px;
  letter-spacing: .14em;
  text-align: center;
  padding: 6px 0;
}
.msg.sys .tag {
  display: inline-block;
  padding: 3px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
}

/* 正在输入 */
.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px 16px;
  border-radius: var(--bubble-radius);
  border-bottom-left-radius: 5px;
  background: var(--bubble-them);
  border: 1px solid var(--bubble-them-line);
  animation: msg-in .3s both;
}
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-dim);
  animation: dot 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes dot {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* 选项区 */
.choices {
  flex: none;
  padding: 10px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel-solid);
  backdrop-filter: blur(12px);
  z-index: 4;
}
.choices-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  padding-left: 34px;
  font-size: 14.5px;
  line-height: 1.6;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--choice-bg);
  color: var(--fg);
  transition: border-color .2s, background-color .2s, transform .12s, color .2s;
  animation: choice-in .4s cubic-bezier(.2, .9, .3, 1) both;
}
.choice:nth-child(1) { animation-delay: .04s; }
.choice:nth-child(2) { animation-delay: .11s; }
.choice:nth-child(3) { animation-delay: .18s; }
.choice:nth-child(4) { animation-delay: .25s; }

@keyframes choice-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.choice::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  border: 1px solid var(--fg-dim);
  transition: background-color .2s, border-color .2s, box-shadow .2s;
}
.choice:hover, .choice:focus-visible {
  border-color: var(--accent);
  background: var(--choice-bg-hover);
  color: var(--fg-bright);
  outline: none;
}
.choice:hover::before, .choice:focus-visible::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.choice:active { transform: scale(.985); }

.choice .hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-faint);
}

/* 「继续」按钮：无选项节点用 */
.continue-btn {
  align-self: center;
  padding: 9px 26px;
  font-size: 13px;
  letter-spacing: .28em;
  text-indent: .28em;
  color: var(--fg-dim);
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  transition: color .2s, border-color .2s;
  animation: choice-in .4s both;
}
.continue-btn:hover { color: var(--accent); border-color: var(--accent); }

/* 自动推进时的占位：存在感要弱，它只是「可以点一下加速」，不是必须点的按钮 */
.continue-btn.ghost {
  border-color: transparent;
  color: var(--fg-faint);
  letter-spacing: .1em;
  text-indent: 0;
  padding: 9px 30px;
}
.continue-btn.ghost:hover { border-color: var(--line-strong); color: var(--fg-dim); }

/* 跳过打字动画的热区 */
.skip-hint {
  position: absolute;
  right: 14px;
  bottom: 8px;
  font-size: 11px;
  color: var(--fg-faint);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.skip-hint.show { opacity: 1; }

/* =========================================================================
 * 章节转场卡片
 * ========================================================================= */

#chapter-card {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 30px;
  background: var(--bg);
  text-align: center;
}
#chapter-card.show { display: grid; }
#chapter-card.out { animation: card-out 1s ease forwards; }

@keyframes card-out { to { opacity: 0; visibility: hidden; } }

#chapter-card .cc-inner { max-width: 460px; }
#chapter-card .cc-idx {
  font-size: 12px;
  letter-spacing: .5em;
  text-indent: .5em;
  color: var(--accent);
  animation: cc-in 1.1s .1s both;
}
#chapter-card .cc-name {
  font-family: var(--font-display);
  font-size: clamp(32px, 9vw, 52px);
  font-weight: 300;
  letter-spacing: .3em;
  text-indent: .3em;
  margin: 16px 0;
  color: var(--fg-bright);
  animation: cc-in 1.2s .3s both;
}
#chapter-card .cc-rule {
  width: 64px;
  height: 1px;
  background: var(--accent);
  margin: 20px auto;
  animation: rule-in 1.2s .55s both;
}
#chapter-card .cc-sub {
  font-size: 13px;
  line-height: 2.1;
  color: var(--fg-dim);
  white-space: pre-line;
  animation: cc-in 1.2s .7s both;
}

@keyframes cc-in {
  from { opacity: 0; transform: translateY(16px); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* =========================================================================
 * 结局界面
 * ========================================================================= */

#screen-ending {
  overflow-y: auto;
  align-items: center;
  padding: clamp(30px, 8vh, 70px) 20px 50px;
}
.ending-inner {
  max-width: 560px;
  width: 100%;
  margin: auto;
  text-align: center;
}
.ending-kind {
  font-size: 12px;
  letter-spacing: .5em;
  text-indent: .5em;
  color: var(--end-accent);
  animation: cc-in 1.1s both;
}
.ending-glyph {
  width: 76px;
  height: 76px;
  margin: 22px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--end-accent);
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--end-accent);
  box-shadow: 0 0 40px -8px var(--end-accent);
  animation: cc-in 1.2s .2s both;
}
.ending-name {
  font-family: var(--font-display);
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 300;
  letter-spacing: .26em;
  text-indent: .26em;
  margin: 0 0 26px;
  color: var(--fg-bright);
  animation: cc-in 1.2s .35s both;
}
.ending-text {
  text-align: left;
  font-size: 15px;
  line-height: 2.05;
  color: var(--fg);
  animation: cc-in 1.2s .5s both;
}
.ending-text p { margin: 0 0 1.1em; white-space: pre-wrap; }
.ending-epilogue {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 2;
  color: var(--fg-dim);
  font-style: italic;
  text-align: left;
  white-space: pre-wrap;
  animation: cc-in 1.2s .7s both;
}
.ending-hint {
  margin-top: 22px;
  padding: 13px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.9;
  color: var(--fg-dim);
  text-align: left;
  animation: cc-in 1.2s .8s both;
}
.ending-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
  animation: cc-in 1.2s .95s both;
}

.btn {
  padding: 11px 24px;
  font-size: 13.5px;
  letter-spacing: .16em;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  color: var(--fg);
  transition: border-color .25s, color .25s, background-color .25s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
}
.btn.primary:hover { filter: brightness(1.12); color: var(--bg); }

/* =========================================================================
 * 弹层面板（档案 / 设置 / 存档 / 图鉴）
 * ========================================================================= */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(3px);
}
.sheet.show { display: block; animation: fade-in .25s both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border-left: 1px solid var(--line-strong);
  animation: slide-in .34s cubic-bezier(.2, .85, .25, 1) both;
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .24em;
  color: var(--fg-bright);
}
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.sheet-tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.sheet-tabs button {
  flex: none;
  padding: 11px 12px;
  font-size: 13px;
  color: var(--fg-dim);
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
}
.sheet-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* 面板内的通用块 */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .label { flex: 1; min-width: 0; }
.row .label b {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-bright);
}
.row .label span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-faint);
}

.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; flex: none; }
.seg button {
  padding: 6px 11px;
  font-size: 12.5px;
  color: var(--fg-dim);
  transition: background-color .2s, color .2s;
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent); color: var(--bg); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 118px;
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
  flex: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

textarea.code-box {
  width: 100%;
  min-height: 108px;
  padding: 11px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  word-break: break-all;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  resize: vertical;
}

/* 档案条目 */
.codex-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.codex-item h4 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--fg-bright);
}
.codex-item .cat {
  display: inline-block;
  margin-bottom: 7px;
  padding: 1px 8px;
  font-size: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  color: var(--fg-faint);
}
.codex-item p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--fg-dim);
  white-space: pre-line;
}
.codex-item.locked h4 { color: var(--fg-faint); }
.codex-item.locked p { font-style: italic; opacity: .5; }

/* 结局图鉴 */
.ending-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ending-item .dot {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-family: var(--font-display);
  font-size: 15px;
}
.ending-item.t-true  { color: #e8c66a; }
.ending-item.t-good  { color: #7fc99a; }
.ending-item.t-gray  { color: #8b93a3; }
.ending-item.t-death { color: #c4646a; }
.ending-item .info { flex: 1; min-width: 0; }
.ending-item .info b { display: block; font-size: 14px; color: var(--fg-bright); }
.ending-item .info span { font-size: 12px; color: var(--fg-faint); }
.ending-item.locked { color: var(--fg-faint); opacity: .45; }
.ending-item.locked .info b { color: var(--fg-faint); }

.empty-note {
  padding: 40px 20px;
  text-align: center;
  font-size: 13px;
  line-height: 2;
  color: var(--fg-faint);
}

/* 提示条 */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  padding: 10px 20px;
  font-size: 13px;
  border-radius: 99px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  color: var(--fg-bright);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  max-width: calc(100vw - 40px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================================
 * 全屏特效
 * ========================================================================= */

#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.fx-flash {
  position: absolute; inset: 0;
  background: #fff;
  animation: fx-flash .45s ease-out forwards;
}
@keyframes fx-flash { from { opacity: .85; } to { opacity: 0; } }

.fx-blood {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center,
    rgba(120, 8, 12, 0) 38%, rgba(120, 8, 12, .62) 100%);
  animation: fx-pulse 1.9s ease-out forwards;
}
.fx-pulse-ring {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center,
    var(--accent-glow) 0%, transparent 62%);
  animation: fx-pulse 1.7s ease-out forwards;
}
@keyframes fx-pulse {
  0%   { opacity: 0; }
  22%  { opacity: 1; }
  100% { opacity: 0; }
}

.fx-static {
  position: absolute; inset: 0;
  opacity: .5;
  background-image: repeating-linear-gradient(0deg,
    rgba(255,255,255,.08) 0 1px, transparent 1px 2px);
  animation: fx-static .7s steps(8) forwards;
}
@keyframes fx-static {
  0%   { opacity: .55; transform: translateY(0); }
  100% { opacity: 0;   transform: translateY(-8px); }
}

.fx-dust { position: absolute; inset: 0; overflow: hidden; }
.fx-dust i {
  position: absolute;
  top: -12px;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: rgba(200, 196, 186, .55);
  animation: fx-fall linear forwards;
}
@keyframes fx-fall {
  to { transform: translateY(110vh) translateX(var(--dx, 0)); opacity: 0; }
}

body.fx-shake #app { animation: fx-shake .5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes fx-shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-6px, 2px); }
  40%, 60% { transform: translate(6px, -1px); }
}

body.fx-glitch #app { animation: fx-glitch .55s steps(3) both; }
@keyframes fx-glitch {
  0%   { filter: none; transform: none; }
  20%  { filter: hue-rotate(80deg) saturate(2.4); transform: translateX(-4px) skewX(-1.5deg); }
  40%  { filter: invert(1); transform: translateX(5px); }
  60%  { filter: hue-rotate(-60deg) saturate(3); transform: translateX(-3px) skewX(1.5deg); }
  100% { filter: none; transform: none; }
}

body.fx-fade #app { animation: fx-fade 2.6s ease both; }
@keyframes fx-fade {
  0% { filter: none; }
  60% { filter: brightness(.18) saturate(.2); }
  100% { filter: none; }
}

/* 关掉动效：晕动症 / 低端机 */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}
body.reduce-motion #ambience { display: none; }

@media (prefers-reduced-motion: reduce) {
  html:not(.motion-ok) * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --------------------------------------------------------------- 窄屏适配 */

@media (max-width: 480px) {
  .msg { max-width: 90%; font-size: 14.5px; }
  .stream { padding: 16px 12px 6px; }
  .choices { padding: 9px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .choice { padding: 12px 14px 12px 32px; font-size: 14px; }
  .game-card { padding: 15px; gap: 13px; }
  .game-card .glyph { width: 52px; height: 52px; font-size: 25px; }
  .title-mark h1 { letter-spacing: .3em; text-indent: .3em; }
  .sheet-panel { width: 100%; border-left: none; }
}

/* 桌面端：把聊天流限制在舒服的阅读宽度内，两侧留白交给氛围层 */
@media (min-width: 900px) {
  .stream { padding: 26px 24px 10px; }
}
