/* ==========================================================================
   少卿令 · UI
   分工（别再混着改）：
     A. 首页：#home-view —— 新做的（紧凑、现场条可左右滑、像素字、按现场主色上色）
     B. 关卡页：#game-view —— 用正式版原来那套样式（墨底描金、楷宋、760px 居中、
        通用规则在棋盘上方、嫌疑人网格铺开、底部 fixed 操作条），
        唯一新增：底部四个按钮 ×标记 / 橡皮擦 / 重置 / 提交（原来只有 断案/重置）。
     C. 结算卡 / 抽屉：沿用正式版的纸面金框样式。
   ========================================================================== */

@font-face {
  font-family: "Zpix";
  src: url("assets/fonts/zpix-subset.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
}

:root {
  --cell: 68px;
  --ink: #2b2118;
  --paper: #f3e9d7;
  --paper-dark: #e8d9bd;
  --gold: #b08a3e;
  --gold-light: #d4b672;
  --cinnabar: #9c2f1d;
  --region-colors: #c9b48a #b7a077 #d8c4a0 #a98f6b #8f7657 #c2ab86 #9d8a66 #b6a582;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font-pixel: "Zpix", "STKaiti", "KaiTi", "Songti SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "STKaiti", "KaiTi", "Songti SC", "SimSun", serif;
  background: #2a2218 radial-gradient(circle at 50% -10%, #4a3a28 0%, #2a2218 55%);
  color: var(--ink);
  min-height: 100vh;
  display: flex; flex-direction: column;
  touch-action: manipulation; -webkit-touch-callout: none; user-select: none;
  padding-bottom: calc(64px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
/* 关卡页正常一屏；内容真的超了（矮屏+详情展开）允许滚动，别裁掉内容 */
body.playing { overflow-y: auto; }
img { max-width: 100%; display: block; }
.sc-thumb img, .char-token img, .cd-portrait img, .game-icon img { image-rendering: pixelated; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 50%; translate: -50% -150%; z-index: 60;
  background: #1f1a13; color: var(--gold-light); padding: 8px 14px; border: 2px solid var(--gold); }
.skip-link:focus { translate: -50% 0; }
.view { max-width: 760px; margin: 0 auto; width: 100%; }
.app { width: 100%; flex: 1; display: flex; flex-direction: column; }

/* ==========================================================================
   A. 首页（新）
   字号约定：能读的最小 13px；比这更小的字（进度点点之类）一律不写，
   进度这类信息等"打开某个现场"时在列表头上展示。
   ========================================================================== */
#home-view {
  font-family: var(--font-pixel);
  color: #e2d6bd;                 /* 深底默认浅字：任何忘了设色的元素也不会变成"深底深字" */
  --accent: var(--gold);
  --accent-2: var(--gold-light);
  --accent-deep: #4a3a28;
  --night-2: #1f1a13;
  position: relative;
  font-size: 15px;
}
#home-view::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 50% -6%, var(--accent-deep) 0%, transparent 62%);
  opacity: .78;                   /* 底色跟着现场主色走，六个现场一眼看出不是同一个色 */
}
/* 六个现场＝六种色相，彼此拉开（原先"客栈/宫阙/武林"三个都是红，难怪看着像一种）；
   每行注释里标了色相角度，改色时按角度挑，别再挑到邻近色。
   客栈 橘红 32° · 宫阙 紫 275° · 仙宗 青碧 175° · 武林 赤 352° · 书院 靛蓝 213° · 军营 军绿 78° */
#home-view[data-scene="inn"]         { --accent: #e0743a; --accent-2: #f7c76b; --accent-deep: #4a1a0e; }
#home-view[data-scene="deep_palace"] { --accent: #9b5fd6; --accent-2: #f0c94a; --accent-deep: #2c1150; }
#home-view[data-scene="immortal"]    { --accent: #33c2b4; --accent-2: #a8ecdd; --accent-deep: #073832; }
#home-view[data-scene="martial"]     { --accent: #c62d3e; --accent-2: #a8bccf; --accent-deep: #3a0a15; }
#home-view[data-scene="academy"]     { --accent: #4a8ede; --accent-2: #a9d8ff; --accent-deep: #0f2a48; }
#home-view[data-scene="frontier"]    { --accent: #7d9a3a; --accent-2: #e0b45c; --accent-deep: #26330f; }

.home-head { text-align: center; padding: calc(var(--safe-t) + 12px) 0 2px; }
.home-head h1 { font-size: 30px; letter-spacing: 8px; color: var(--accent-2); font-weight: 400; }
.home-head .subtitle { font-size: 13px; letter-spacing: 3px; color: #a89070; margin-top: 4px; }

/* hero：当前现场的像素大图垫底；两层交叉淡入，换现场不闪 */
.hero {
  position: relative; min-height: 158px; margin: 8px 12px 0; padding: 13px;
  display: flex; flex-direction: column; justify-content: flex-end;
  border: 2px solid var(--accent); overflow: hidden; background: var(--night-2);
}
.hero-art {
  position: absolute; inset: 0; z-index: 0; background-size: cover; background-position: center right;
  image-rendering: pixelated; opacity: 0; transition: opacity 240ms steps(5, end);
}
.hero-art.on { opacity: .8; }
.hero-scrim {
  position: absolute; inset: 0; z-index: 1;
  background-image: linear-gradient(90deg, rgba(20,16,12,.96) 0%, rgba(20,16,12,.86) 44%, rgba(20,16,12,.32) 74%, rgba(20,16,12,.08) 100%);
}
.hero-help {
  position: absolute; z-index: 3; top: 8px; right: 8px; min-height: 40px; padding: 6px 12px;
  border: 2px solid var(--accent); border-radius: 0; background: rgba(20,16,12,.66);
  color: var(--accent-2); font-family: var(--font-pixel); font-size: 14px; letter-spacing: 1px;
}
.hero-help:hover { background: var(--accent); color: #1f1a13; }
.hero-inner { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; }
.hero-logo { font-size: clamp(24px, 6.4vw, 34px); color: var(--accent-2); font-weight: 400;
  writing-mode: vertical-rl; text-orientation: upright; line-height: 1; letter-spacing: 4px; }
.hero-sub-line { font-size: 12px; color: #c8b08a; letter-spacing: 3px; margin-bottom: 3px; }
.hero-copy { min-width: 0; flex: 1; }
.hero-copy .scene-name { font-size: clamp(21px, 5.6vw, 26px); color: var(--accent-2); letter-spacing: 3px; font-weight: 400; }
.hero-copy .scene-desc { font-size: 13.5px; color: #d8cbb0; line-height: 1.55; margin-top: 4px; }

/* 现场条：手机上三列两行，把一行占满（不再留右边空隙），字也放大到看得清 */
.rail-wrap { margin-top: 12px; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 12px; margin-bottom: 6px; }
.section-title { font-size: 14px; letter-spacing: 3px; color: var(--accent); font-weight: 400; }
.rail-hint { font-size: 13px; color: var(--accent-2); }
.rail-outer { position: relative; }
.scene-rail {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 12px;
}
/* 现场 = 大图标 + 名字，整块像按钮：有立体边、按下会陷下去，一眼知道能点 */
.scene-card {
  min-height: 92px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 2px solid var(--accent); border-radius: 0; background: rgba(243,233,215,.1);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.14), inset -2px -2px 0 rgba(0,0,0,.35);
  transition: transform 80ms steps(2, end), background 120ms steps(3, end);
}
.scene-card:hover { background: rgba(243,233,215,.2); }
.scene-card:active { transform: translate(2px, 2px); box-shadow: none; }
.scene-card[aria-current="true"] { background: var(--accent-deep); border-color: var(--accent-2);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.18), 0 0 0 2px var(--accent-2); }
.scene-card[aria-current="true"] .sc-name { color: #fff6e2; }
.sc-thumb { width: 44px; height: 44px; flex: none; }
.sc-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sc-name { font-size: 13px; color: #f2ead8; white-space: nowrap; line-height: 1.1; }
/* 「已开的案/共几案」不写小字了：打开这个现场时在列表头看进度 */
.sc-hint { font-size: 12px; color: #a89070; }
@media (min-width: 700px) {
  .scene-rail { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
  .scene-card { min-height: 104px; }
  .sc-thumb { width: 52px; height: 52px; }
  .sc-name { font-size: 14px; }
}

/* 进度 + 案卷列表：打开的现场才显示进度 */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 14px; }
.list-head .section-title { color: #d8cbb0; }
.progress-text { font-size: 13px; color: var(--accent-2); }
.progress-track { height: 8px; border: 1px solid var(--accent); margin-top: 6px; background: rgba(0,0,0,.35); }
.progress-fill { height: 100%; background: var(--accent); }
.level-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 7px; }
.level-group { display: contents; }
.group-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; padding-top: 8px; }
.group-dot { width: 8px; height: 8px; flex: none; }
.group-name { font-size: 13px; letter-spacing: 2px; color: #d8cbb0; }
.group-count { font-size: 12px; color: #a89070; margin-left: auto; }
/* 关卡条目：没图就不硬做图 —— 标题 + 难度（按难度上色）；尺寸并到标题后面的小字里 */
.level-btn {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; width: 100%; text-align: left;
  border: 2px solid var(--accent); border-left-width: 5px; border-radius: 0;
  background: rgba(0,0,0,.24); color: #d8cbb0; padding: 9px 8px;
  font-size: 15px; letter-spacing: 1px; line-height: 1.15;
  transition: transform 80ms steps(2, end), background 120ms steps(3, end);
}
.level-btn:hover { background: var(--accent-deep); }
.level-btn:active { transform: translate(2px, 2px); }
.level-btn.done { border-color: #06d6a0; }
.level-btn.todo { opacity: .5; }
.lv-row { display: flex; align-items: center; gap: 5px; }
.lv-meta { display: flex; align-items: center; gap: 5px; }
.lv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f2ead8; }
.lv-size { font-size: 12px; color: #c8b891; flex: none; }
.lv-diff { font-size: 12px; padding: 1px 5px; border: 1px solid currentColor; white-space: nowrap; flex: none; }
.lv-diff[data-diff="入门"], .lv-diff[data-diff="简单"] { color: #7fbf8a; }
.lv-diff[data-diff="中等"] { color: #e0a96b; }
.lv-diff[data-diff="困难"], .lv-diff[data-diff="专家"] { color: #e07a6b; }
.lv-diff[data-diff="草稿"], .lv-diff[data-diff="待录"] { color: #a89070; }
.lv-ok { color: #06d6a0; flex: none; font-size: 14px; }
@media (min-width: 620px) { .level-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .level-list { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.empty { grid-column: 1 / -1; padding: 22px 14px; text-align: center; border: 2px dashed var(--accent); }
.empty-seal { font-size: 22px; color: var(--accent-2); margin-bottom: 8px; }
.empty-title { font-size: 16px; color: var(--accent-2); }
.empty-text { font-size: 13px; color: #a89070; margin-top: 5px; }
.section { padding: 0 12px; }

/* ==========================================================================
   B. 关卡页（正式版原样；只有底部四个按钮是新的）
   ========================================================================== */
#game-view { position: relative; font-family: "STKaiti", "KaiTi", "Songti SC", "SimSun", serif; }
/* 关卡页也用本场主色：正式版的框/标题/按钮都是 var(--gold) 系的，
   所以只要按现场把这两个变量换掉，整页（含通用规则框、嫌疑人卡、底部条、桌牌圆牌）一起变色，
   不再满屏土黄。变量值跟首页 #home-view[data-scene] 一套。 */
#game-view[data-scene="inn"]         { --gold: #e0743a; --gold-light: #f7c76b; }
#game-view[data-scene="deep_palace"] { --gold: #9b5fd6; --gold-light: #f0c94a; }
#game-view[data-scene="immortal"]    { --gold: #33c2b4; --gold-light: #a8ecdd; }
#game-view[data-scene="martial"]     { --gold: #c62d3e; --gold-light: #a8bccf; }
#game-view[data-scene="academy"]     { --gold: #4a8ede; --gold-light: #a9d8ff; }
#game-view[data-scene="frontier"]    { --gold: #7d9a3a; --gold-light: #e0b45c; }
/* 唯一加的东西：一层现场像素图做背景（很淡，不抢棋盘） */
.scene-bg {
  position: fixed; inset: 0; z-index: -1; display: none;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  image-rendering: pixelated; opacity: .16;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.85) 0%, rgba(0,0,0,.3) 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.85) 0%, rgba(0,0,0,.3) 55%, transparent 100%);
}
/* 关卡页也铺一层"本场主色"的水洗，不然整页还是一块土黄（背景原本固定的暖褐） */
#game-view::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(circle at 50% 0%, var(--gold) 0%, transparent 62%);
  opacity: .16;
}
.frame { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 8px 16px; position: relative; }
.game-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; padding: 0 4px; min-height: 36px; }
.back-btn { border: 2px solid var(--gold); background: transparent; color: var(--gold); padding: 4px 10px; }
.back-txt { font-size: 14px; letter-spacing: 1px; }
.game-title { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; min-width: 0; }
.game-title h1 { font-size: 16px; letter-spacing: 3px; color: var(--gold-light); font-weight: 400;
  line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 关卡页标题旁的场景首图：只留图，不要外面的金框（用户要求） */
.game-icon { width: 28px; height: 28px; border: 0; background: none; flex: none; display: block; overflow: hidden; }
.game-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.game-head .status { font-size: 12px; letter-spacing: 1px; color: #d8c8a0; line-height: 1.3;
  flex: none; max-width: 45%; text-align: right; }
.status.good { color: #1d6b34; font-weight: bold; }
.status.bad { color: var(--cinnabar); font-weight: bold; }
.story { display: none; }
#board { margin: 0 auto; }

/* 通用线索：正式版的虚金框 + 行内点分 */
.clue-panel { margin: 4px 0 2px; border: 1px dashed var(--gold); padding: 3px 8px;
  background: rgba(243,233,215,.06); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clue-panel h2 { font-size: 13px; letter-spacing: 1px; color: var(--gold); font-weight: 400; white-space: nowrap; margin-bottom: 1px; }
/* 通用规则：一条一行、紧凑、不带底色框。
   （底色 + 左竖线那种"卡片"太占地方，关卡页每一格高度都很紧；这里只留一个前置小点做行标。） */
.clue-list { display: flex; flex-direction: column; gap: 1px; align-items: stretch; }
.clue-list div { font-size: 13px; color: #d8cbb0; line-height: 1.45; }
.clue-list .global-clue { color: #e8a06a; padding-left: 14px; position: relative; background: none; border: 0; }
.clue-list .global-clue::before {
  content: "-";                       /* 每条前面的短横，做行引导 */
  position: absolute; left: 2px; top: 0;
  color: var(--gold); opacity: .9;
}
.clue-list b { color: var(--cinnabar); }

.legend { margin: 2px 0 0; font-size: 11.5px; color: #c4ae8c; text-align: center; line-height: 1.35;
  max-height: 34px; overflow: hidden; }   /* 最多两行；再长就省略，别把棋盘挤没 */
.legend b { color: var(--cinnabar); }
/* 手机上把这条常驻规矩收起来（同样的文案在「怎么玩」里，点标题旁的 ? 能看）：
   窄屏最缺的就是高度，它一排就吃掉 30px，大关的格子因此只剩十几 px。 */
@media (max-width: 700px) {
  .legend { display: none; }
}
.roster { margin-top: 3px; }
.roster h2 { font-size: 12px; letter-spacing: 2px; color: var(--gold); text-align: center; font-weight: 400;
  margin: 0 0 2px; display: flex; align-items: center; gap: 8px; }
.roster h2::before, .roster h2::after { content: ""; flex: 1; height: 1px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 4px, transparent 4px 8px); opacity: .55; }
/* 一行放几个由 app.js 按人数写死在 gridTemplateColumns 上（6 人铺满一行 / 7~16 人 8 个一排、最多两排）；
   这里只负责卡片的留白：边框 2px、内边距压到最小 —— 卡片本身别改小 */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 2px;
  justify-items: center; }
.char-token { position: relative; border: 2px solid var(--gold); background: rgba(243,233,215,.12);
  padding: 2px 1px; cursor: pointer; font-size: 13px; color: #f2ead8;
  border-radius: 4px; max-width: 74px; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 1px; transition: background .12s; }
.char-token:hover { background: rgba(243,233,215,.2); }
.char-token.active { border-color: var(--cinnabar); background: rgba(214,40,40,.25); box-shadow: 0 2px 6px rgba(214,40,40,.3); }
.char-token.placed, .char-token.disabled { opacity: .45; }
/* 已放置但被点开看线索：只加一圈浅边，外观仍是"已放置"的样子 */
.char-token.viewing { outline: 2px solid var(--gold-light); outline-offset: -2px; opacity: .8; }
.char-token .portrait { display: block; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  border: 1px solid var(--gold); flex: none; }
.char-token .portrait img { width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.5) translateY(-4%); transform-origin: center 25%; }
/* 卡上的标记小牌：和格子里草稿标记同色同字，一眼对得上 */
.char-token .cmark { display: inline-block; margin-top: 0; padding: 0 3px; font-size: 10px; line-height: 1.3;
  color: #fff; border: 1px solid rgba(0,0,0,.35); border-radius: 2px; }
.char-token .cname { line-height: 1.15; font-size: 12.5px; max-width: 100%; word-break: keep-all;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 名字长度的字号分档：3 个字必须完整显示（12×12 / 16×16 上嫌疑人卡只有 40~50px 宽），
   4 个字尽量显示，实在放不下才交给省略号。名字超过 3 个字建议改名（见 tools/check_char_names.js）。 */
.char-token.n3 .cname { font-size: 11.5px; letter-spacing: -.2px; }
.char-token.n4 .cname { font-size: 10.5px; letter-spacing: -.3px; }
/* 16 人（每排 8 个）卡片只有 40~50px 宽：内边距与字号再收一档，3 个字也放得下 */
.chars.dense .char-token { padding: 2px 0; }
.chars.dense .char-token .portrait { width: 30px; height: 30px; }
.chars.dense .char-token .cname { font-size: 12px; }
.chars.dense .char-token.n3 .cname { font-size: 11px; letter-spacing: -.3px; }
.chars.dense .char-token.n4 .cname { font-size: 10px; letter-spacing: -.4px; }
/* 人物详情：内容自适应（线索可折行、多条并列、持有物单独一行）。
   高度上限 96px（够放 2 条线索 + 持有物），真放不下时内部滚动；它变高时 refitBoard() 会把棋盘缩一点，
   保证整页仍是一屏 —— 之前写死 52px + nowrap，长线索和持有物直接被裁掉，是我做错了。 */
.char-detail {
  /* 固定高度：空着（提示语）和展开一张卡时高度必须一样 —— 否则棋盘会跟着跳，
     而且"按真实剩余空间把棋盘长满"的算法需要一个稳定的预留值。内容超出就内部滚动。 */
  margin: 4px 0 0; height: 62px; max-height: 96px; overflow-y: auto; overscroll-behavior: contain;
  display: none; align-items: flex-start; gap: 6px;
  border: 1px solid var(--gold); background: rgba(243,233,215,.08);
  padding: 4px 7px; font-size: 12px; color: #d8cbb0;
}
.char-detail.show { display: flex; }
/* 详情里的人物图：必须给尺寸（漏一次就按素材原图 143×160 渲染，把详情条撑爆 —— 已踩两次） */
.cd-portrait { flex: none; display: block; width: 40px; height: 40px; overflow: hidden; border: 1px solid var(--gold); }
.cd-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }
.cd-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.cd-name { font-size: 13px; color: var(--gold-light); line-height: 1.3; }
.cd-row { display: block; min-width: 0; }
.cd-clue, .cd-item { font-size: 12px; line-height: 1.4; color: #d8cbb0;
  white-space: normal; overflow-wrap: anywhere; }
.cd-clue-line + .cd-clue-line { margin-top: 1px; }
.cd-item { color: var(--gold-light); margin-top: 1px; }
.char-detail .cd-hint { font-size: 12px; color: #a89070; }

/* 底部操作条：正式版那条 fixed 金边横条，按钮换成四个 —— ×标记 · 橡皮擦 · 重置 · 提交 */
.actions {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: rgba(28,21,16,.95); border-top: 1px solid var(--gold);
  backdrop-filter: blur(6px);
}
button {
  font-family: inherit; font-size: 16px; letter-spacing: 3px;
  padding: 10px 26px; border: 2px solid var(--gold);
  background: transparent; color: var(--gold); transition: all .15s;
}
button:hover { background: var(--gold); color: #fff8e6; }
button.primary { background: var(--cinnabar); border-color: var(--cinnabar); color: #f5ecd8; }
button.primary:hover { background: #b83a24; }
.actions button { padding: 10px 2px; font-size: 14px; letter-spacing: 0; }
.actions .btn-off { opacity: .45; }
.actions .btn[aria-disabled="true"] { pointer-events: auto; }   /* 撤回按不动时给个提示，不彻底禁掉 */
.actions .btn.tool[aria-pressed="true"] { background: var(--gold); color: #2a2218; }
.px-icon { width: 16px; height: 16px; fill: currentColor; display: inline-block; vertical-align: -2px; }

/* ==========================================================================
   C. 结算卡 / 抽屉（正式版纸面金框）
   ========================================================================== */
.modal { position: fixed; inset: 0; background: rgba(20,14,8,.75); display: none;
  align-items: center; justify-content: center; z-index: 120; padding: 14px; }
.modal.show { display: flex; }
.modal-box { background: var(--paper); border: 1px solid var(--gold); padding: 28px 24px; text-align: center;
  max-width: 420px; width: 100%; max-height: 88vh; overflow-y: auto; color: var(--ink); }
.modal-box h2 { font-size: 22px; letter-spacing: 6px; margin-bottom: 10px; font-weight: 400; }
.modal-box h2.victory { color: #1d6b34; }
.modal-box h2.defeat { color: var(--cinnabar); }
.modal-box p { font-size: 14px; line-height: 1.8; color: #4a3d2c; margin-bottom: 6px; }
.result-sub { font-size: 13px; color: #6b5b3f; }
.killer-name { font-size: 22px; color: var(--cinnabar); letter-spacing: 2px; margin: 6px 0 10px; }
.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.result-cell { border: 1px solid var(--gold); padding: 8px; }
.result-key { font-size: 11px; color: #6b5b3f; }
.result-val { font-size: 18px; margin-top: 2px; }
.result-actions { display: grid; gap: 8px; margin-top: 10px; }
.result-actions button { width: 100%; border-color: var(--gold); color: var(--ink); }
.result-actions button.primary { background: var(--cinnabar); border-color: var(--cinnabar); color: var(--paper); }
.modal-box > button { margin-top: 18px; border-color: var(--gold); color: var(--ink); }
@media (min-width: 600px) { .result-actions { grid-template-columns: 1.4fr 1fr; } }

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20,14,8,.78);
  opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 82vh; overflow-y: auto;
  background: #221b13; border-top: 3px solid var(--gold); color: #e2d6bd;
  padding: 6px 16px calc(var(--safe-b) + 20px);
  translate: 0 102%; transition: translate .22s steps(4, end);
}
.sheet.on { translate: 0 0; }
.sheet-grip { width: 44px; height: 4px; background: var(--gold); margin: 8px auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head h2 { font-size: 20px; color: var(--gold-light); letter-spacing: 4px; font-weight: 400; }
.sheet-head .sheet-line { flex: 1; height: 2px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 10px); opacity: .5; }
.help-sec { margin-bottom: 14px; }
.help-sec h3 { font-size: 14px; color: var(--gold-light); letter-spacing: 2px; font-weight: 400; margin-bottom: 5px;
  display: flex; align-items: center; gap: 6px; }
.help-sec h3::before { content: ""; width: 6px; height: 6px; background: var(--gold); flex: none; }
.help-sec p { font-size: 14px; line-height: 1.75; color: #e2d6bd; margin: 0 0 6px; }
.help-sec b { color: var(--gold-light); }
.help-list { list-style: none; }
.help-list li { font-size: 14px; line-height: 1.75; color: #e2d6bd; padding-left: 16px; position: relative; }
.help-list li::before { content: "·"; position: absolute; left: 4px; color: var(--gold); }
.help-row { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 1.9; }
.help-row .hr-name { color: #f2ead8; min-width: 78px; }
.help-row .hr-bar { flex: 1; height: 8px; border: 1px solid var(--gold); background: rgba(0,0,0,.35); }
.help-row .hr-bar i { display: block; height: 100%; background: var(--gold); }
.help-row .hr-num { color: var(--gold-light); font-size: 13px; min-width: 52px; text-align: right; }
.sheet-foot { font-size: 12px; color: #9c8a6d; line-height: 1.7; border-top: 1px solid rgba(176,138,62,.4); padding-top: 8px; }
.sheet .btn { font-family: inherit; }

.ver { text-align: center; font-size: 10px; color: #6b5b3f; opacity: .7; padding: 8px 0 4px; letter-spacing: 1px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 80px); translate: -50% 10px;
  background: rgba(20,14,8,.96); color: var(--gold-light); border: 1px solid var(--gold);
  padding: 8px 14px; font-size: 12.5px; opacity: 0; pointer-events: none; z-index: 130;
  transition: opacity .2s, translate .2s; max-width: 86vw; text-align: center; }
.toast.on { opacity: 1; translate: -50% 0; }
#error-banner { position: fixed; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 76px); z-index: 140;
  display: none; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  background: #6d1b18; color: #ffe8d6; padding: 10px 12px; border: 2px solid #ffd166; font-size: 13px; }
#error-detail { display: none; width: 100%; font-size: 11px; opacity: .8; word-break: break-all; text-align: center; }
#update-banner { position: fixed; left: 10px; right: 10px; bottom: calc(var(--safe-b) + 72px); z-index: 125;
  display: none; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 12.5px;
  background: #241d15; color: var(--gold-light); padding: 10px 12px; border: 1px solid var(--gold); }

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

/* 宽屏窗口：原来整页被限宽 760px（手机时代的窄栏），16×16 棋盘只有 742px，
   900 宽的窗口里左右各空 79px（将近两格）。这里把**游戏页**的容器放宽，
   棋盘就能把窗口用起来；正文（规则/嫌疑人/详情）另外限宽，免得一行太长不好读。
   手机端（≤700px）本来就是满宽，不受影响。 */
@media (min-width: 701px) {
  #game-view.view { max-width: min(1400px, 96vw); }
  #game-view .frame { max-width: none; }
  #game-view .clue-panel,
  #game-view .legend,
  #game-view .char-detail { max-width: 760px; margin-left: auto; margin-right: auto; }
  #game-view .char-token { max-width: 96px; }
}

/* 关卡页左右不留边：棋盘按宽度铺满，任何内边距都会变成"左右空隙"。
   棋盘自己有 3px 深色边框 + 投影，视觉上不缺留白。 */
#game-view .frame { padding-left: 0; padding-right: 0; }
