/* ============================================================
 * styles.css — 互动视频播放器 · 电影式游戏形态（手机优先）
 * 游玩时画面即全部；触屏用轻触与角落按钮，无键盘依赖
 * ============================================================ */

/* ============ 开场加载动画 ============ */
.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 46%, #1c1508 0%, #0c0a08 46%, #06070a 100%);
  transition: opacity 0.6s ease;
}
.boot--done {
  opacity: 0;
  pointer-events: none;
}
/* 中心柔光，随呼吸微微起伏 */
.boot-glow {
  position: absolute;
  left: 50%; top: 46%;
  width: min(72vw, 520px);
  height: min(72vw, 520px);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(232, 176, 75, 0.13) 0%, rgba(232, 176, 75, 0.04) 42%, rgba(232, 176, 75, 0) 70%);
  animation: bootBreath 4.6s ease-in-out infinite;
}
@keyframes bootBreath {
  0%, 100% { opacity: 0.65; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1;    transform: translate(-50%, -50%) scale(1.07); }
}
.boot-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}
.boot-sigil {
  width: clamp(112px, 26vw, 148px);
  height: clamp(112px, 26vw, 148px);
}
.boot-sigil svg { width: 100%; height: 100%; display: block; }
/* 细环正向转、刻度环反向转 */
.ring-a { transform-origin: 60px 60px; animation: bootSpin 22s linear infinite; }
.ring-b { transform-origin: 60px 60px; animation: bootSpin 13s linear infinite reverse; }
.sigil-core { transform-origin: 60px 60px; animation: bootCore 3.6s ease-in-out infinite; }
@keyframes bootSpin { to { transform: rotate(360deg); } }
@keyframes bootCore {
  0%, 100% { transform: scale(0.94); opacity: 0.75; }
  50%      { transform: scale(1.04); opacity: 1; }
}
/* 细进度条 */
.boot-bar {
  position: relative;
  width: clamp(190px, 46vw, 268px);
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.10);
  overflow: visible;
}
.boot-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(to right, rgba(232, 176, 75, 0.55), #f0c46c);
  box-shadow: 0 0 10px rgba(240, 196, 108, 0.55);
  transition: width 0.12s linear;
}
.boot-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: clamp(190px, 46vw, 268px);
  font-size: 12px;
  letter-spacing: 0.24em;
  color: rgba(246, 236, 218, 0.62);
}
.boot-text { text-indent: 0.24em; }
.boot-pct {
  color: rgba(240, 196, 108, 0.9);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

:root {
  --bg: #0a0c10;
  --ink: #f2f4f7;
  --ink-2: #a8b0bd;
  --ink-3: #6b7280;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #4d9be6;
  --accent-deep: #185fa5;
  --gold: #e8b04b;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; touch-action: manipulation; }

.hidden { display: none !important; }

kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 12px;
}

/* ============ 标题画面（游戏主菜单） ============
 * .title-bg-blur     铺底模糊图（填满整屏，避免黑边断层）
 * .title-art         画面盒：菜单层浮在其内部下部 → 按钮永远压在画面上
 *   ├ .title-bg      开屏主美术 / 可选背景视频
 *   ├ .title-scrim   压暗层
 *   └ .title-menu-layer  菜单（按钮 + 标签栏 + 重置）
 * 视口比 11:10 宽 → 画面盒铺满视口（cover 裁切）；更“瘦高”→ 画面盒 2:1 居中完整显示
 * ============================================ */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #05070a;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- 铺底：同一张图的模糊放大版 ---- */
.title-bg-blur {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  filter: blur(34px) brightness(0.42) saturate(1.15);
}

/* ---- 画面盒 ---- */
.title-art {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070a;
}
/* 开屏图（主美术）与可选背景视频，两者共用这套样式 */
.title-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  animation: kenburns 30s ease-in-out infinite alternate;
}
@keyframes kenburns {
  from { transform: scale(1.01); }
  to   { transform: scale(1.06); }
}
/* 压暗层：只做很轻的暗角 + 底部渐变（保证菜单可读，但不吃掉画面） */
.title-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(10, 12, 16, 0) 0%, rgba(10, 12, 16, 0.10) 70%, rgba(10, 12, 16, 0.40) 100%),
    linear-gradient(to bottom,
      rgba(10, 12, 16, 0.20) 0%,
      rgba(10, 12, 16, 0.02) 24%,
      rgba(10, 12, 16, 0.04) 50%,
      rgba(10, 12, 16, 0.40) 72%,
      rgba(10, 12, 16, 0.68) 88%,
      rgba(10, 12, 16, 0.80) 100%);
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 菜单层（浮在画面内部下部，各元素之间留足呼吸） ---- */
.title-menu-layer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  padding-bottom: calc(42px + env(safe-area-inset-bottom));
}

/* ---- 主按钮：描金细边胶囊（呼应标题书法，低调不抢画面） ---- */
.play-wrap {
  display: flex;
  justify-content: center;
  animation: tabIn 0.6s 0.1s ease both;
}
.play-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 13px 34px;
  border-radius: 999px;
  background: rgba(14, 11, 8, 0.40);
  border: 1px solid rgba(232, 176, 75, 0.42);
  backdrop-filter: blur(6px);
  color: #f6ecda;
  font-size: 17px;
  letter-spacing: 0.36em;
  text-indent: 0.36em;                    /* 抵消末字右侧字距，视觉居中 */
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease, transform 0.2s ease;
}
.play-btn:hover {
  background: rgba(22, 16, 9, 0.56);
  border-color: rgba(240, 196, 108, 0.95);
  box-shadow: 0 0 26px rgba(232, 176, 75, 0.22);
}
.play-btn:active { transform: scale(0.98); }
/* 文字两侧的极细金线 */
.play-btn-line {
  width: 26px;
  height: 1px;
  background: linear-gradient(to right, rgba(232, 176, 75, 0), rgba(232, 176, 75, 0.85));
  transition: width 0.24s ease, background 0.24s ease;
}
.play-btn-line:last-child {
  background: linear-gradient(to left, rgba(232, 176, 75, 0), rgba(232, 176, 75, 0.85));
}
.play-btn:hover .play-btn-line {
  width: 40px;
  background: rgba(240, 196, 108, 0.95);
}

/* ---- 底部标签栏 ---- */
.tab-bar {
  display: flex;
  justify-content: center;
  gap: 46px;
  animation: tabIn 0.6s 0.28s ease both;
}
@keyframes tabIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab {
  position: relative;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 14px;
  letter-spacing: 4px;
  padding: 10px 2px;
  cursor: pointer;
  transition: color 0.18s ease;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}
.tab:hover { color: rgba(255, 255, 255, 0.85); }
.tab.active { color: #fff; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}
.tab em {
  font-style: normal;
  font-size: 11px;
  color: var(--gold);
  margin-left: 5px;
  letter-spacing: 1px;
}

/* ---- 瘦高视口（窄窗口 / 手机竖屏）：画面完整显示并居中，四周由铺底模糊图填满 ----
 * 触发条件：视口比 11:10 更“瘦高”；此时若继续 cover 会把两侧标题裁掉 */
@media (max-aspect-ratio: 11/10) {
  .title-art {
    height: auto;
    aspect-ratio: 2 / 1;   /* 与开屏图同比例 → 完整显示，绝不裁标题 */
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
  }
}

/* ---- 小屏：菜单更紧凑，别吃掉太多画面 ---- */
@media (max-width: 720px) {
  .title-menu-layer { gap: 10px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .play-btn { gap: 12px; padding: 9px 20px; font-size: 13px; letter-spacing: 0.3em; text-indent: 0.3em; }
  .play-btn-line { width: 14px; }
  .tab-bar { gap: 14px; }
  .tab { font-size: 11px; letter-spacing: 1px; padding: 4px 2px; }
}

/* ============ 游戏画面 ============ */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}
.video-frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  background: #000;
  overflow: hidden;
  /* 片段之间淡出/淡入黑场的时长：由 story.js 的 meta.cutFade 换算后写进 --cut-fade */
  transition: opacity var(--cut-fade, 0.42s) ease;
}
@supports (height: 100dvh) {
  .video-frame {
    width: min(100vw, calc(100dvh * 16 / 9));
    height: min(100dvh, calc(100vw * 9 / 16));
  }
}
.stage.fading .video-frame { opacity: 0; }
/* 演示占位层也跟着一起黑场（单链节点同样有呼吸） */
.placeholder { transition: opacity var(--cut-fade, 0.42s) ease; }
.stage.fading .placeholder { opacity: 0; }

.video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  touch-action: manipulation;
}

/* 空闲时隐藏光标（纯沉浸） */
.stage.idle { cursor: none; }

/* ---- 无素材演示占位层 ---- */
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16202e 0%, #0b0e14 100%);
  text-align: center;
}
.placeholder-inner { padding: 20px; }
.placeholder-node {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 4px;
  margin-bottom: 10px;
}
.placeholder-line { font-size: 14px; color: var(--ink-2); margin-bottom: 26px; }
.count-ring { position: relative; width: 84px; height: 84px; margin: 0 auto 16px; }
.count-ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.14); stroke-width: 5; }
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 213.6;
  stroke-dashoffset: 0;
}
.count-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.placeholder-tip { font-size: 12px; color: var(--ink-3); }

/* ---- 播放前点击层 ---- */
.play-gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}
.play-gate-btn {
  width: 76px;
  height: 76px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.play-gate-btn:hover { transform: scale(1.08); }

/* ---- 触屏角落按钮 ---- */
.touch-ui {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 5;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.stage.idle .touch-ui { opacity: 0; pointer-events: none; }
.touch-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.touch-btn:active { transform: scale(0.9); }

/* ---- 缓冲指示（首次加载 / 中途卡顿） ---- */
.buffering {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 10, 0.28);
  pointer-events: none;
}
.spin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(240, 196, 108, 0.95);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 右上角播放控件（倍速 / 跳过） ---- */
.play-ui {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.35s ease;
}
.play-ui button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(12, 14, 19, 0.5);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.play-ui button:hover {
  border-color: rgba(240, 196, 108, 0.9);
  background: rgba(22, 16, 9, 0.62);
  color: #f6ecda;
}
.play-ui button:active { transform: scale(0.97); }
.speed-btn { min-width: 54px; font-variant-numeric: tabular-nums; }

/* ---- 跳过：本段「完整缓冲」前只是一枚等待中的胶囊（环走满才可点） ---- */
.skip-btn { position: relative; }
.skip-btn .skip-ring { display: block; transform: rotate(-90deg); }
.skip-btn .skip-ring .ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 2; }
.skip-btn .skip-ring .ring-fg {
  fill: none;
  stroke: rgba(240, 196, 108, 0.95);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 37.7;      /* 2πr，r = 6 */
  stroke-dashoffset: 37.7;
  transition: stroke-dashoffset 0.2s linear;
}
.skip-btn .skip-cue { display: none; }
.skip-btn.ready .skip-ring { display: none; }
.skip-btn.ready .skip-cue { display: block; }

/* 未就绪：淡一档、不给点击反馈（避免观众以为点了没反应） */
.skip-btn:not(.ready) {
  opacity: 0.6;
  cursor: default;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 14, 19, 0.38);
  color: rgba(255, 255, 255, 0.72);
}
.skip-btn:not(.ready):hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(12, 14, 19, 0.38);
  color: rgba(255, 255, 255, 0.72);
}
.skip-btn:not(.ready):active { transform: none; }
/* 2 倍速开启中 */
.speed-btn.active {
  border-color: rgba(240, 196, 108, 0.95);
  background: rgba(64, 46, 16, 0.6);
  color: #f8dfae;
}
/* 触屏：静音/全屏仍在左上角，右上角留给播放控件 */
@media (pointer: coarse) {
  .touch-ui {
    left: calc(12px + env(safe-area-inset-left));
    right: auto;
  }
}

/* ---- A/B 选择浮层（播完浮现） ---- */
.choice-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 130px 24px calc(44px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 55%, transparent 100%);
  animation: choiceIn 0.35s ease;
}
@keyframes choiceIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.choice-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 15px 32px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  background: rgba(16, 20, 28, 0.8);
  backdrop-filter: blur(10px);
  color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  animation: btnIn 0.4s backwards ease;
}
.choice-btn:nth-child(2) { animation-delay: 0.08s; }
@keyframes btnIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.choice-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 36px rgba(77, 155, 230, 0.25);
}
.choice-btn:active { transform: scale(0.97); }
.choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.choice-btn:hover .choice-key { background: var(--accent-deep); color: #fff; }

/* ---- 结局卡 ---- */
.ending-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(8px);
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  animation: fadeIn 0.5s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.ending-kicker {
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 12px;
}
.ending-name {
  font-size: 46px;
  font-weight: 600;
  letter-spacing: 12px;
  text-indent: 12px;
  margin-bottom: 14px;
  text-shadow: 0 4px 40px rgba(232, 176, 75, 0.25);
}
.ending-desc { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; letter-spacing: 1px; }
.ending-progress { font-size: 13px; color: var(--gold); margin-bottom: 30px; }
.ending-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---- 结局卡上的「史实档案」入口 ---- */
.ending-history-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 2px 0 20px;
  padding: 10px 24px 9px;
  border: 1px solid rgba(232, 176, 75, 0.34);
  border-radius: 3px;
  background: rgba(232, 176, 75, 0.07);
  color: var(--ink-1);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.ending-history-link:hover {
  border-color: rgba(232, 176, 75, 0.62);
  background: rgba(232, 176, 75, 0.1);
  transform: translateY(-1px);
}
.ending-history-link:active { transform: translateY(0); }
.ehl-kicker { font-size: 10px; letter-spacing: 3px; color: var(--gold); opacity: 0.85; }
.ehl-title { font-size: 14px; letter-spacing: 1px; color: #efe3cd; }

/* ---- 按钮 ---- */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent-deep); color: #fff; }
.btn-primary:hover { background: #1e74c4; }
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

/* ---- 横屏建议 ---- */
.rotate-hint {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 1px;
  white-space: nowrap;
  touch-action: manipulation;
  animation: fadeIn 0.4s ease;
}
.rotate-icon { display: inline-block; font-size: 15px; animation: rot 2.6s ease-in-out infinite; }
@keyframes rot {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
/* 选项或结局出现时让位 */
.choice-overlay:not(.hidden) ~ .rotate-hint,
.ending-card:not(.hidden) ~ .rotate-hint { display: none; }

/* ============ 结局册抽屉 ============ */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  z-index: 60;
  animation: fadeIn 0.2s ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(400px, 92vw);
  background: #10131a;
  border-left: 1px solid var(--line);
  z-index: 70;
  display: flex;
  flex-direction: column;
  padding: 26px;
  padding-top: calc(26px + env(safe-area-inset-top));
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  animation: slideIn 0.28s ease;
  overflow-y: auto;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.drawer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.drawer-head h3 { font-size: 18px; font-weight: 600; letter-spacing: 3px; }
.drawer-count { font-size: 13px; color: var(--gold); font-weight: 600; }
.drawer-close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--ink-3);
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
}
.drawer-close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.ending-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ending-cell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  text-align: left;
  background: rgba(255,255,255,0.03);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.ending-cell.unlocked {
  background: rgba(232, 176, 75, 0.07);
  border-color: rgba(232, 176, 75, 0.35);
}
.ending-cell.unlocked:hover { border-color: rgba(232, 176, 75, 0.7); transform: translateY(-1px); }
/* 剧照（16:9） */
.ec-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0b0e14;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ec-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ending-cell.locked .ec-thumb {
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.03) 0 6px, transparent 6px 12px),
    #0b0e14;
}
.ec-q { font-size: 22px; color: var(--ink-3); }
.ec-body { padding: 10px 12px 12px; }
.ending-cell .ec-name { font-size: 14px; font-weight: 600; letter-spacing: 2px; }
.ending-cell .ec-desc { font-size: 11px; color: var(--ink-2); margin-top: 5px; line-height: 1.5; }
.ending-cell.locked .ec-name,
.ending-cell.locked .ec-desc { color: var(--ink-3); }
.drawer-foot { margin-top: auto; padding-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* 已解锁且有档案的卡片：整卡可点，打开史实档案 */
.ending-cell.readable { cursor: pointer; }
.ending-cell.readable:hover { background: rgba(232, 176, 75, 0.11); }
.ending-cell.readable:focus-visible { outline: 2px solid rgba(232, 176, 75, 0.6); outline-offset: 2px; }
.ending-cell.readable::after {
  content: "档案";
  position: absolute;
  top: 8px; right: 8px;
  padding: 2px 6px;
  font-size: 9px;
  letter-spacing: 1px;
  color: #f0dfc0;
  background: rgba(10, 8, 5, 0.72);
  border: 1px solid rgba(232, 176, 75, 0.4);
  border-radius: 2px;
  pointer-events: none;
}

/* ============ 史实档案（阅读面板） ============ */
.dossier-mask {
  position: fixed;
  inset: 0;
  z-index: 86;
  background: rgba(4, 6, 9, 0.74);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.dossier {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 87;
  width: min(92vw, 660px);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 34px 36px 26px;
  background:
    linear-gradient(180deg, rgba(232, 176, 75, 0.05), rgba(232, 176, 75, 0) 150px),
    #0d1016;
  border: 1px solid rgba(232, 176, 75, 0.22);
  border-radius: 4px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--ink-1);
  animation: fadeIn 0.24s ease;
  scrollbar-width: thin;
}
.dossier:focus { outline: none; }
.dossier-close {
  position: absolute;
  top: 8px; right: 10px;
  width: 34px; height: 34px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease;
}
.dossier-close:hover { color: var(--gold); }
.dossier-kicker {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--gold);
  opacity: 0.8;
  margin-bottom: 12px;
}
.dossier-title {
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  font-size: 25px;
  line-height: 1.46;
  letter-spacing: 2px;
  font-weight: 500;
  color: #f3ead9;
  margin-bottom: 11px;
}
.dossier-lead {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-2);
  padding-left: 12px;
  border-left: 2px solid rgba(232, 176, 75, 0.4);
  margin-bottom: 20px;
}
.dossier-figure {
  margin: 0 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
  background: #06080b;
}
.dossier-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.02);
}
.dossier-figure figcaption {
  padding: 7px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.02);
}
.dossier-body p {
  font-size: 14.5px;
  line-height: 2;
  color: #cfd5df;
  text-align: justify;
  margin-bottom: 15px;
}
.dossier-body p:last-child { margin-bottom: 0; }
.dossier-source {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
  line-height: 1.75;
  letter-spacing: 0.3px;
  color: var(--ink-3);
}

/* ============ 章节字幕卡（type: chapter） ============ */
.chapter {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070a;
  cursor: pointer;
  /* 不带 fill-mode：万一动画没跑起来，元素也保持可见（只是少一次淡入），不会黑屏 */
  animation: chapterIn 0.85s ease-out;
  transition: opacity 0.55s ease;
}
@keyframes chapterIn { from { opacity: 0; } to { opacity: 1; } }
/* 黑幕揭晓：整张章节卡淡出，露出下面已经就绪的新画面 */
.chapter.reveal {
  animation: none;
  opacity: 0;
  pointer-events: none;
}
.chapter-inner {
  text-align: center;
  padding: 0 8vw;
  /* 明确宽度：否则作为 flex 子项会按内容撑开，长副题在手机上会溢出屏幕 */
  width: 100%;
  max-width: 760px;
  box-sizing: border-box;
  /* 只动位移与缩放，不动透明度：动画失效时文字照样可见 */
  animation: chapterText 1s 0.12s cubic-bezier(0.22, 0.61, 0.36, 1);
  transition: opacity 0.5s ease, transform 0.7s ease;
}
@keyframes chapterText {
  from { transform: translateY(18px) scale(0.985); }
  to   { transform: translateY(0) scale(1); }
}
/* 离场：文字先淡出上浮，黑幕留住，等下一段画面就绪再揭开 */
.chapter-inner.leaving {
  animation: none;
  opacity: 0;
  transform: translateY(-10px) scale(0.99);
}
.chapter-kicker {
  font-size: 12px;
  letter-spacing: 0.5em;
  color: rgba(232, 176, 75, 0.85);
  margin-bottom: 18px;
  text-indent: 0.5em;
}
.chapter-title {
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 600;
  color: #f6ecda;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.8);
}
.chapter-rule {
  display: block;
  width: 62px;
  height: 1px;
  margin: 22px auto 18px;
  background: linear-gradient(90deg, transparent, rgba(232, 176, 75, 0.9), transparent);
}
.chapter-line {
  font-size: 13px;
  letter-spacing: 0.34em;
  color: rgba(255, 255, 255, 0.55);
  text-indent: 0.34em;
}

/* ============ 落幕卡（结局专属） ============
 * 和章节卡的区别：宋体大字、更宽的金线、更松的副题、中心一点暖光。
 * 它承担「这场故事到此为止」的重量，节奏也更慢（holdSeconds 3.4s）。 */
.chapter.is-ending {
  background:
    radial-gradient(ellipse at 50% 48%, #131009 0%, #08090d 58%, #05070a 100%);
}
.chapter.is-ending .chapter-kicker {
  font-size: 11px;
  letter-spacing: 0.62em;
  text-indent: 0.62em;
  color: rgba(232, 176, 75, 0.72);
  margin-bottom: 24px;
}
.chapter.is-ending .chapter-title {
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(38px, 7.4vw, 68px);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: #f8f0e0;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.9), 0 0 70px rgba(232, 176, 75, 0.13);
}
.chapter.is-ending .chapter-rule {
  width: 96px;
  margin: 30px auto 24px;
  animation: ruleGrow 1.15s 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes ruleGrow {
  from { transform: scaleX(0); opacity: 0.25; }
  to   { transform: scaleX(1); opacity: 1; }
}
.chapter.is-ending .chapter-line {
  font-size: 15px;
  line-height: 2.05;
  letter-spacing: 0.12em;
  text-indent: 0;
  color: rgba(226, 214, 194, 0.86);
  max-width: min(27em, 100%);
  margin: 0 auto;
  text-wrap: balance;   /* 需要换行时让两行长度均衡，避免末行只剩两三个字 */
}

/* ============ 通关战报 ============ */
.report {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(5, 7, 10, 0.94);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: calc(30px + env(safe-area-inset-top)) 22px calc(26px + env(safe-area-inset-bottom));
  animation: fadeIn 0.35s ease;
}
.report-inner { width: min(560px, 100%); }
.report-kicker {
  font-size: 11px;
  letter-spacing: 0.42em;
  color: rgba(232, 176, 75, 0.8);
  text-align: center;
  text-indent: 0.42em;
}
.report-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-align: center;
  margin: 8px 0 6px;
  color: #f6ecda;
}
.report-sub { text-align: center; font-size: 12px; color: var(--ink-3); letter-spacing: 1px; }
.report-list { list-style: none; margin: 22px 0 0; padding: 0; }
.rl-chapter {
  margin: 18px 0 10px;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: rgba(232, 176, 75, 0.75);
  text-align: center;
}
.rl-chapter::before,
.rl-chapter::after { content: "—"; margin: 0 8px; color: rgba(232, 176, 75, 0.35); }
.rl-row {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
}
.rl-idx {
  flex: 0 0 auto;
  width: 24px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.rl-body { flex: 1 1 auto; min-width: 0; }
.rl-title { font-size: 14px; font-weight: 600; letter-spacing: 1px; }
.rl-line { font-size: 12px; color: var(--ink-2); margin-top: 3px; line-height: 1.5; }
.rl-choice {
  font-size: 12px;
  color: rgba(232, 176, 75, 0.92);
  margin-top: 5px;
  letter-spacing: 0.5px;
}
.report-foot {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-2);
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.7;
}
.report-actions { display: flex; justify-content: center; margin-top: 20px; }

/* ============ 成就弹窗 ============ */
.achieve {
  position: fixed;
  top: calc(22px + env(safe-area-inset-top));
  right: calc(22px + env(safe-area-inset-right));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(16, 20, 28, 0.92);
  border: 1px solid rgba(232, 176, 75, 0.4);
  border-radius: 12px;
  padding: 12px 20px 12px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: achieveIn 0.35s ease;
}
@keyframes achieveIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.achieve-star {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(232, 176, 75, 0.15);
  color: var(--gold);
  font-size: 17px;
}
.achieve-kicker { font-size: 11px; color: var(--gold); letter-spacing: 2px; margin-bottom: 2px; }
.achieve-name { font-size: 15px; font-weight: 600; letter-spacing: 2px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(16, 20, 28, 0.95);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 999px;
  z-index: 90;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 触屏适配 ============ */
@media (pointer: coarse) {
  .choice-key { display: none; }          /* 触屏没有键盘，隐藏按键徽标 */
  .touch-btn { width: 44px; height: 44px; }
}

/* ============ 小屏适配（玩法界面；标题画面见上方 720px 规则） ============ */
@media (max-width: 640px) {
  .choice-btns { flex-direction: column; width: 100%; max-width: 320px; }
  .choice-btn { justify-content: center; padding: 14px 20px; font-size: 16px; }
  .ending-name { font-size: 32px; letter-spacing: 6px; }
  .choice-overlay { padding-top: 100px; }
  /* 史实档案：小屏占满，留出安全区 */
  .dossier {
    width: 94vw;
    max-height: 92vh;
    padding: 26px 20px 20px;
  }
  .dossier-title { font-size: 21px; letter-spacing: 1.5px; }
  .dossier-lead { font-size: 13px; }
  .dossier-body p { font-size: 14px; line-height: 1.95; }
  .ending-history-link { padding: 8px 16px 7px; margin-bottom: 16px; }
  .ehl-title { font-size: 13px; }
}

/* ============ 无障碍 / 省电：用户在系统里选择“减少动态效果”时全部静态 ============ */
@media (prefers-reduced-motion: reduce) {
  .title-bg { animation: none; }
  .title-menu-layer,
  .play-wrap,
  .tab-bar,
  .play-ui,
  .choice-overlay,
  .choice-btn,
  .ending-card,
  .skip-btn,
  .achieve,
  .toast,
  .chapter,
  .chapter-inner,
  .chapter.is-ending .chapter-rule { animation: none !important; }
  .spin { animation: spin 1.4s linear infinite; }
}
