/* ============ 数独大冒险 ============ */
:root {
  --bg: #eaf2ff;
  --panel: #ffffff;
  --panel2: #f4f8ff;
  --line: #d4deef;
  --accent: #ff9337;
  --accent-dark: #e77a1d;
  --text: #33405e;
  --dim: #8a94ad;
  --red: #e85f5f;
  --green: #3cb96e;
  --blue: #4a7de8;
  --purple: #8f6ae0;
  --gold: #f0a92e;
  --cell: #ffffff;
  --cell-given: #eef2fb;
}

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

body {
  background: linear-gradient(180deg, #dcebff 0%, var(--bg) 40%, #f3f7ff 100%);
  color: var(--text);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  user-select: none;
}

#app { max-width: 1080px; margin: 0 auto; padding: 12px; }

.screen { display: none; padding-bottom: 40px; }
.screen.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

h2 { text-align: center; margin: 18px 0; color: var(--accent-dark); letter-spacing: 2px; }

button {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: #fff; border: 2px solid var(--line);
  border-radius: 12px; padding: 8px 14px; cursor: pointer;
  transition: all .15s;
  box-shadow: 0 2px 0 rgba(90, 110, 160, .12);
}
button:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary {
  background: linear-gradient(180deg, #ffa54f, var(--accent));
  border-color: var(--accent-dark); color: #fff; font-weight: bold;
  text-shadow: 0 1px 2px rgba(160, 80, 0, .3);
}
button.primary:hover { background: linear-gradient(180deg, #ffb066, #ff9d47); }

/* ---------- 主菜单 ---------- */
.menu-inner { text-align: center; padding-top: 10vh; }
.title {
  font-size: 56px; letter-spacing: 6px; color: var(--accent-dark);
  text-shadow: 0 3px 0 #ffd9ad, 0 6px 18px rgba(255, 147, 55, .3);
  margin-bottom: 10px;
}
.subtitle { color: var(--dim); letter-spacing: 6px; margin-bottom: 44px; }
.menu-btns { display: flex; flex-direction: column; gap: 14px; width: 280px; margin: 0 auto 24px; }
.menu-btns button { font-size: 19px; padding: 14px; letter-spacing: 2px; border-radius: 16px; }
#btn-continue.hidden { display: none; }
/* 次要入口一行小图标（issue #59）：图标 + 小字，竖排两层 */
.menu-icon-row { display: flex; gap: 18px; justify-content: center; margin: 0 auto 40px; }
.menu-icon-row button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 60px; padding: 8px 0 6px; border-radius: 16px;
}
.menu-icon-row .icon { font-size: 24px; line-height: 1; }
.menu-icon-row .icon-label { font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.start-tip { text-align: center; color: #7a819c; max-width: 560px; margin: 0 auto 18px; }
#menu-stats { display: flex; gap: 22px; justify-content: center; align-items: center; color: var(--dim); font-size: 14px; flex-wrap: wrap; }
#menu-stats b { color: var(--gold); }
/* 星星数是可点入口（直达训练营）：外观贴近相邻文字，仅加下划线暗示可点 */
.stat-link {
  background: none; border: none; box-shadow: none; padding: 0; border-radius: 6px;
  color: var(--dim); font-size: inherit; cursor: pointer;
  text-decoration: underline dotted var(--gold); text-underline-offset: 4px;
}
.stat-link:hover:not(:disabled) { color: var(--accent-dark); border-color: transparent; transform: none; }

/* ---------- 训练营 ---------- */
#talent-dao { text-align: center; font-size: 18px; margin-bottom: 20px; }
#talent-dao b { color: var(--gold); }
#talent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; max-width: 800px; margin: 0 auto; }
.talent-card { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 16px; text-align: center; }
.talent-card.maxed { border-color: var(--gold); box-shadow: 0 0 14px rgba(240, 169, 46, .18); }
.talent-emoji { font-size: 34px; margin-bottom: 6px; }
.talent-name { font-weight: bold; margin-bottom: 4px; }
.talent-lv { color: var(--gold); font-size: 13px; }
.talent-desc { color: var(--dim); font-size: 13px; margin-bottom: 10px; min-height: 36px; }
/* 返回键：左上角圆形图标，吸顶悬浮，滚动时一直可见（issue #57） */
.btn-back {
  position: sticky; top: 10px; z-index: 60;
  display: block; width: 44px; height: 44px; padding: 0;
  margin: 8px 0 0;
  border-radius: 50%; font-size: 22px; line-height: 1; font-weight: bold;
  color: var(--accent-dark);
}
/* 标题上提一行：返回键贴左缘、标题保持居中，两者同行互不重叠 */
.btn-back + h2 { margin-top: -40px; }
.btn-abandon { display: block; margin: 26px auto 0; color: var(--dim); font-size: 13px; box-shadow: none; }

/* ---------- 宝物图鉴 ---------- */
#gallery-progress { text-align: center; color: var(--dim); font-size: 15px; margin-bottom: 8px; }
#gallery-progress b { color: var(--gold); }
#gallery-groups { max-width: 800px; margin: 0 auto; }
.gallery-group h3 { color: var(--accent-dark); margin: 22px 0 10px; }
.gallery-count { font-size: 13px; color: var(--dim); font-weight: normal; margin-left: 8px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery-card { width: auto; background: var(--panel); border: 2px solid var(--line); }
/* 未解锁占位：内容置灰保持神秘，星级边框照常（稀有度一眼可辨） */
.gallery-locked { background: var(--panel2); }
.gallery-locked .relic-emoji { filter: grayscale(1); opacity: .55; }
.gallery-locked .relic-name { color: var(--dim); }
.gallery-locked .relic-desc { opacity: .7; }

/* ---------- 数独学堂（issue #33） ---------- */
.teach-tabs { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.teach-tabs button { color: var(--dim); background: var(--panel2); }
.teach-tabs button.active { color: #fff; background: var(--accent); }
.teach-progress { text-align: center; color: var(--dim); font-size: 14px; margin-bottom: 4px; }
.teach-progress b { color: var(--gold); }
.teach-group h3 { color: var(--accent-dark); margin: 22px 0 10px; }
.teach-card {
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin: 10px 0;
}
.teach-card h3 { color: var(--accent-dark); margin-bottom: 6px; }
.teach-card p { line-height: 1.9; }
/* 技巧卡是 <details>：summary 用 flex 会吃掉浏览器默认折叠三角，
   这里自绘一个常驻箭头当「可展开」信号（收起指右、展开翻下）+ 悬停/聚焦整卡高亮（issue #93） */
.teach-tech { transition: border-color .15s, box-shadow .15s; }
.teach-tech:hover, .teach-tech:focus-within {
  border-color: var(--accent); box-shadow: 0 2px 10px rgba(255, 147, 55, .18);
}
.teach-tech:hover > summary, .teach-tech:focus-within > summary { color: var(--accent-dark); }
.teach-tech summary {
  cursor: pointer; font-weight: bold;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  list-style: none;                 /* 去掉默认 ▶ marker，改用下面自绘箭头 */
}
.teach-tech summary::-webkit-details-marker { display: none; }   /* Safari/webkit */
.teach-tech summary::after {
  content: '›'; margin-left: 2px;
  color: var(--accent); font-size: 20px; font-weight: 900; line-height: 1;
  transition: transform .2s ease;
}
.teach-tech[open] summary::after { transform: rotate(90deg); }   /* 展开 → 箭头翻下 */
.teach-tech[open] summary { margin-bottom: 6px; }
.teach-stars { color: var(--gold); font-size: 13px; white-space: nowrap; }
.teach-name { color: var(--text); }
.teach-badge {
  margin-left: auto; font-size: 12px; font-weight: normal; color: var(--dim);
  background: var(--panel2); border-radius: 8px; padding: 2px 8px; white-space: nowrap;
}
.teach-badge.got { color: #1e7a45; background: #d9f4e3; }

/* ---------- 帮助 ---------- */
.help-body { max-width: 720px; margin: 0 auto; line-height: 1.9; font-size: 15px; user-select: text; }
.help-body h3 { color: var(--accent-dark); margin: 18px 0 6px; }
.help-body ul { padding-left: 22px; }
.help-body b { color: var(--accent-dark); }

/* ---------- 顶栏 ---------- */
.run-hud {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border: 2px solid var(--line);
  border-radius: 14px; padding: 10px 16px; margin-bottom: 10px; font-size: 15px;
}
.hud-item.hp { color: var(--red); }
.hud-item.stars { color: var(--gold); cursor: help; }
.hud-relic { font-size: 19px; cursor: help; margin-right: 2px; }
.hud-dim { color: var(--dim); font-size: 13px; }

/* ---------- 地图 ---------- */
.doors { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 34px 0; }
.door {
  width: 210px; padding: 26px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--panel);
  border: 2px solid var(--line); border-radius: 18px;
}
.door:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 22px rgba(90, 110, 160, .18); }
.door-emoji { font-size: 44px; }
.door-name { font-size: 20px; color: var(--accent-dark); letter-spacing: 3px; font-weight: bold; }
.door-desc { font-size: 13px; color: var(--dim); text-align: center; }
.door-boss { border-color: #f0b1b1; background: #fff5f5; }
.door-elite { border-color: #d5c2f2; background: #faf6ff; }
#map-inventory { text-align: center; color: var(--dim); font-size: 14px; }
.inv-label { display: inline; margin-right: 6px; }
.inv-item { margin: 0 8px; cursor: help; color: var(--text); }
.inv-tip { font-size: 12px; margin-top: 6px; }

/* ---------- 战斗顶部 ---------- */
.battle-wrap { position: relative; }
.battle-wrap.shake { animation: shake .35s; }
/* 🚪 退出并保存（issue #96）：右上角浮动小按钮，随时存好这盘棋回主菜单 */
.battle-exit {
  position: absolute; top: -2px; right: 0; z-index: 60;
  padding: 5px 12px; font-size: 13px; font-weight: bold; line-height: 1;
  border-radius: 999px; color: var(--accent-dark);
  background: var(--panel); border: 2px solid var(--line);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
}
.battle-exit:hover { background: #fff; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
.battle-top {
  display: flex; gap: 14px; justify-content: space-between; margin-bottom: 10px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px;
  padding-right: 84px; /* 右上角给「🚪 退出」浮动键留空档，别压住玩家血条（issue #96） */
}
.enemy-panel { display: flex; gap: 12px; align-items: center; flex: 1; }
#enemy-emoji { font-size: 44px; filter: drop-shadow(0 3px 6px rgba(232, 95, 95, .35)); }
.enemy-info { flex: 1; max-width: 400px; }
#enemy-name { font-weight: bold; color: var(--red); margin-bottom: 4px; }
#enemy-intent { font-size: 12px; color: var(--dim); margin-top: 4px; }
#enemy-intent b { color: var(--accent-dark); }
/* 认输后 HUD 领奖大钮（issue #120）：原位顶替大招充能条 + 意图行两行死 UI，
   高度与其相当 → 顶部 HUD 不长高、棋盘零位移，悬浮 mini 胜利条退役 */
#victory-claim-hud { display: none; }
.battle-wrap.won .bar.gauge, .battle-wrap.won #enemy-intent { display: none; }
.battle-wrap.won #victory-claim-hud {
  display: block; width: 100%; margin: 4px 0 0;
  padding: 7px 12px; font-size: 14px;
}

.bar { position: relative; height: 16px; background: #e6ebf5; border-radius: 8px; overflow: hidden; margin: 3px 0; }
.bar .fill { height: 100%; transition: width .3s; border-radius: 8px; }
.bar.hp .fill { background: linear-gradient(90deg, #e85f5f, #ff8f7a); }
/* 怪物认输后，气势条变成完美胜利线进度条：金色、从 0 涨向 150% 线（issue #37） */
.bar.hp .fill.over { background: linear-gradient(90deg, #f0a92e, #ffd76a); }
.bar.hp.player .fill { background: linear-gradient(90deg, #3cb96e, #6fd694); }
.bar.gauge { height: 12px; }
.bar.gauge .fill { background: linear-gradient(90deg, #f0a92e, #ffca5f); }
.bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #4a3a20; font-weight: bold; text-shadow: 0 1px 1px rgba(255,255,255,.5);
}
.bar.hp span { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }

.player-panel { display: flex; flex-direction: column; gap: 5px; min-width: 260px; }
.bar.player { height: 18px; }
#battle-stats { display: flex; gap: 14px; font-size: 14px; }
#battle-effects .fx { font-size: 12px; margin-right: 8px; padding: 2px 8px; border-radius: 10px; }
.fx.bad { background: #ffe4e4; color: #c94848; }
.fx.good { background: #e0f6e8; color: #2c9457; }
#battle-relics { font-size: 17px; }

/* ---------- 胜利选择条 ---------- */
#victory-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff9e8; border: 2px solid var(--gold); border-radius: 14px;
  padding: 10px 16px; margin-bottom: 10px;
  animation: fadein .3s ease;
}
#victory-bar.hidden { display: none; }
#victory-bar .victory-text { flex: 1; font-size: 14px; line-height: 1.6; }

/* ---------- 棋盘 ---------- */
.battle-main { display: flex; gap: 14px; align-items: flex-start; }
/* 宫与宫之间留缝露出深色底，宫界一眼可辨（issue #13）；格子按 3格+缝+3格+缝+3格 共 11 条轨道排布 */
#board {
  --cell-size: 54px;
  --box-gap: 5px;
  display: grid;
  grid-template-columns: repeat(3, var(--cell-size)) var(--box-gap) repeat(3, var(--cell-size)) var(--box-gap) repeat(3, var(--cell-size));
  grid-template-rows: repeat(3, var(--cell-size)) var(--box-gap) repeat(3, var(--cell-size)) var(--box-gap) repeat(3, var(--cell-size));
  background: #8fa3c8; border: 3px solid #8fa3c8; border-radius: 8px;
  width: fit-content;
  position: relative; /* 飘字/喝彩浮层的定位基准 */
  box-shadow: 0 6px 18px rgba(90, 110, 160, .15);
}
.board-loading { grid-column: 1 / -1; padding: 200px 160px; color: var(--accent-dark); font-size: 20px; background: var(--panel); }
.cell {
  position: relative; background: var(--cell); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e3e9f4;
}
.cell.given { background: var(--cell-given); }
/* 涂色工具（issue #75）：5 色低饱和底色；规则放在 same-num/selected/hl-* 之前，
 * 让选中、同数、提示等状态高亮照常盖过涂色 */
.cell.paint-1 { background: #ffc9c9; }
.cell.paint-2 { background: #ffe9a8; }
.cell.paint-3 { background: #b8ecc9; }
.cell.paint-4 { background: #bcd9ff; }
.cell.paint-5 { background: #e2ccff; }
.cell .val { font-size: 28px; font-weight: 700; color: var(--blue); }
.cell.given .val { color: #2d3752; font-weight: 800; }
.cell.error .val { color: var(--red); }
.cell.error { background: #ffe9e9; }

.cell.same-num { background: #fff0c8; }
.cell.same-num .val { text-shadow: 0 0 8px rgba(240, 169, 46, .5); }
.cell.same-cand {
  background: #f0e6ff;
  box-shadow: inset 0 0 0 2px rgba(143, 106, 224, .55), inset 0 0 12px rgba(143, 106, 224, .18);
}
.cell.same-cand .notes span { color: #6a55a8; }
.cell.selected { background: #dbe7ff !important; outline: 3px solid var(--blue); outline-offset: -3px; z-index: 2; }

/* 双值/三值标记（issue #75）：右下角小圆点，蓝=双值格、橙=三值格；
 * z-index 压过候选笔记（z1）与奖励水印（z0），不遮数字 */
.cell.bi-cell::after, .cell.tri-cell::after {
  content: ''; position: absolute; right: 3px; bottom: 3px;
  width: 7px; height: 7px; border-radius: 50%;
  z-index: 2; pointer-events: none;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
}
.cell.bi-cell::after { background: var(--blue); }
.cell.tri-cell::after { background: var(--gold); }

/* 画链模式：已点的起点格虚线描边等待第二点（issue #75） */
.cell.link-from { outline: 3px dashed var(--purple); outline-offset: -3px; z-index: 2; }

.cell.hl-cause { background: #dcf0ff !important; outline: 2px solid var(--blue); outline-offset: -2px; }
.cell.hl-place { background: #ddf5e6 !important; outline: 2px solid var(--green); outline-offset: -2px; }
.cell.hl-elim { background: #ffe8de !important; outline: 2px dashed var(--red); outline-offset: -2px; }
.cell.flash-error { animation: flasherr .4s 3; }
@keyframes flasherr { 50% { background: #ffb3b3; } }

.notes {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 2px;
  position: relative; z-index: 1;
}
/* 字号 = 基准 12px × 用户设置的倍率（⚙️ 设置界面，issue #31；基准 10→12 整体大一轮，issue #95），JS 在 :root 上写 --note-scale */
.notes span {
  font-size: calc(12px * var(--note-scale, 1)); color: #a6aec7; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; line-height: 1;
}
.notes span.note-hl { color: #fff; background: var(--purple); font-weight: bold; }
.notes span.note-cause { color: #fff; background: var(--blue); font-weight: bold; }
.notes span.note-bad { color: #fff; background: var(--red); text-decoration: line-through; }

/* 候选染色（issue #113）：单个候选数的圆点底色，色板与整格涂色同一套 5 色；
 * cd-auto-* 是画链自动染色（强链交替蓝/绿，冲突闪红），手动 cd-paint-* 永远优先 */
.notes span.cd-paint-1 { background: #ffc9c9; color: #a03636; border-radius: 50%; font-weight: bold; }
.notes span.cd-paint-2 { background: #ffe9a8; color: #8a6410; border-radius: 50%; font-weight: bold; }
.notes span.cd-paint-3 { background: #b8ecc9; color: #1e7a45; border-radius: 50%; font-weight: bold; }
.notes span.cd-paint-4 { background: #bcd9ff; color: #245d9e; border-radius: 50%; font-weight: bold; }
.notes span.cd-paint-5 { background: #e2ccff; color: #6a3fb0; border-radius: 50%; font-weight: bold; }
.notes span.cd-auto-b { background: #bcd9ff; color: #245d9e; border-radius: 50%; font-weight: bold; }
.notes span.cd-auto-g { background: #b8ecc9; color: #1e7a45; border-radius: 50%; font-weight: bold; }
.notes span.cd-auto-clash {
  background: var(--red); color: #fff; border-radius: 50%; font-weight: bold;
  animation: cd-clash .9s ease-in-out infinite;
}
@keyframes cd-clash { 50% { opacity: .35; } }
.notes span.cd-dim { opacity: .25; }

/* 奖励格图标：居中水印垫底，不遮挡任何候选笔记 */
.bonus {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; opacity: .32; z-index: 0; pointer-events: none;
}
/* 候选数统一托柔和白色光晕：纯色格底上几乎无感，叠在奖励格水印上能把图标"挤开"，
 * 数字可读且奖励格与普通格候选数外观一致（issue #27，替代 issue #16 的白底方案）；
 * 排除 note-hl/cause/bad——它们自带实色底 */
.notes span:not(.note-hl):not(.note-cause):not(.note-bad) {
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff;
}
.bonus.dimmed { opacity: .2; }

/* 冰冻格（issue #22）：整格冰蓝底 + 居中雪花水印，与封印/陷阱一眼可辨 */
.cell.frozen { background: #e3f4ff !important; box-shadow: inset 0 0 0 2px rgba(90, 170, 230, .6); }
.frozen-mark {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; opacity: .55; z-index: 0; pointer-events: none;
}
.cell.frozen .notes span:not(:empty):not(.note-hl):not(.note-cause):not(.note-bad) {
  background: rgba(255, 255, 255, .82);
}
/* 冰冻格 × 候选高亮（issue #74）：冰冻底色不能吞掉「高亮格子」模式的紫色——
 * 曾让玩家扫盘漏格拼出断鱼。紫底保证扫盘不漏，冰蓝内圈 + 雪花保住"还冻着"的信息 */
.cell.frozen.same-cand {
  background: #f0e6ff !important;
  box-shadow: inset 0 0 0 2px rgba(90, 170, 230, .75), inset 0 0 12px rgba(143, 106, 224, .18);
}

/* 单次得分飘字（issue #18）：挂 #board 浮层（left/top 由 JS 按格子定位），
 * 按得分档位分级，加分上飘、扣分下沉 */
.float-dmg {
  position: absolute; transform: translateX(-50%);
  font-weight: bold; font-size: 18px; color: var(--green); text-shadow: 0 1px 2px rgba(255,255,255,.8);
  animation: floatup .9s ease-out forwards; pointer-events: none; z-index: 5;
  white-space: nowrap; text-align: center;
}
.float-dmg.big { font-size: 21px; color: var(--accent-dark); }
.float-dmg.crit { color: #e8412c; font-size: 24px; animation: floatcrit 1.4s ease-out forwards; }
.float-dmg.neg { color: var(--red); animation: floatdown .9s ease-out forwards; }
.float-sub {
  font-size: 10px; font-weight: normal; color: var(--text); letter-spacing: 0;
  background: rgba(255, 255, 255, .9); border-radius: 8px; padding: 1px 7px; margin-top: 2px;
  box-shadow: 0 1px 4px rgba(90, 110, 160, .25);
}
@keyframes floatup { to { transform: translate(-50%, -30px); opacity: 0; } }
@keyframes floatdown { to { transform: translate(-50%, 26px); opacity: 0; } }
@keyframes floatcrit {
  0% { transform: translate(-50%, 0) scale(.6); }
  22% { transform: translate(-50%, -10px) scale(1.18); }
  40% { transform: translate(-50%, -14px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -44px) scale(1); opacity: 0; }
}

/* HUD 得分联动（issue #18）：🎯 数字跳动 + 旁侧 +N 微飘字 */
#stat-score.pulse { animation: statpulse .35s ease; }
#stat-score.pulse.neg { animation: statpulseneg .35s ease; }
@keyframes statpulse { 30% { transform: scale(1.22); color: var(--green); } }
@keyframes statpulseneg { 30% { transform: scale(1.22); color: var(--red); } }
#hud-float { position: relative; height: 0; pointer-events: none; }
.hud-pop {
  position: absolute; left: 58%; top: -20px;
  font-weight: bold; font-size: 15px; color: var(--green);
  animation: hudpop .9s ease-out forwards;
}
.hud-pop.neg { color: var(--red); animation: hudpopneg .9s ease-out forwards; }
@keyframes hudpop { to { transform: translateY(-15px); opacity: 0; } }
@keyframes hudpopneg { to { transform: translateY(13px); opacity: 0; } }

/* 怪物气势条：受击白闪 / 回气暗闪（issue #18） */
.bar .fill.hit { animation: barhit .45s ease; }
.bar .fill.regain { animation: barregain .5s ease; }
@keyframes barhit { 30% { filter: brightness(1.8); } }
@keyframes barregain { 30% { filter: brightness(.55) saturate(1.8); } }

/* 全屏喝彩：暴击 / 使出技巧（issue #18） */
.cheer {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%);
  z-index: 40; pointer-events: none; text-align: center; max-width: 92%;
  font-size: 34px; font-weight: 800; letter-spacing: 2px; color: var(--accent-dark);
  text-shadow: 0 2px 0 #fff, 0 0 18px rgba(255, 255, 255, .95), 0 6px 16px rgba(231, 122, 29, .35);
  animation: cheerpop 1.3s ease-out forwards;
}
@keyframes cheerpop {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
  32% { transform: translate(-50%, -50%) scale(1); }
  72% { opacity: 1; }
  100% { transform: translate(-50%, -66%) scale(1); opacity: 0; }
}

/* ---------- 侧栏 ---------- */
.side-panel { flex: 1; min-width: 230px; }
#digit-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.digit-btn {
  position: relative; height: 56px; font-size: 22px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.digit-btn .dcount { font-size: 10px; color: var(--dim); }
.digit-btn.active { border-color: var(--purple); color: var(--purple); }
.digit-btn.locked { background: #f0e6ff; border-color: var(--purple); box-shadow: 0 0 10px rgba(143, 106, 224, .35); }
.digit-btn.locked::after { content: '🔒'; position: absolute; top: 2px; right: 4px; font-size: 10px; }
.digit-btn.done { opacity: .35; }
.digit-btn.sealed { background: #ffe4e4; border-color: var(--red); }
.digit-btn.sealed::after { content: '⛓️'; position: absolute; top: 2px; right: 4px; font-size: 10px; }
.pad-tip { grid-column: span 3; font-size: 11px; color: var(--dim); text-align: center; margin-top: 2px; }

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.tool-grid button { font-size: 12px; padding: 6px 2px; }
.tool-grid button.on { border-color: var(--accent); color: var(--accent-dark); background: #fff3e4; }
.tool-grid button.tool-locked { opacity: .5; position: relative; }
.tool-grid button.tool-locked::after { content: '🔒'; position: absolute; top: 1px; right: 3px; font-size: 9px; }

/* ---------- 高级推理工具（issue #75） ---------- */
/* 链线绘制层：铺满棋盘、不挡点击；SVG 无 viewBox，坐标即 CSS 像素，与 cell offset 一一对应 */
#link-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 4; overflow: visible;
}
#link-layer line { stroke: var(--purple); stroke-width: 3; stroke-linecap: round; opacity: .8; }
#link-layer line.weak { stroke-dasharray: 6 7; }
/* 链端点：空心描边圆环套在候选数外围，数字露在圈中间（issue #87），不再用实心点盖住数字 */
#link-layer circle { fill: none; stroke: var(--purple); stroke-width: 2; opacity: .85; }
/* 链过滤（issue #88）：与当前数字无关的链淡成影子，保留位置感、防"线被删了"的错觉 */
#link-layer line.dimmed, #link-layer circle.dimmed { opacity: .15; }
/* 画链起点候选：同款圆环加粗提示"待连"（issue #85），替代原先整格描边 */
#link-layer circle.from { stroke-width: 2.5; opacity: 1; }

/* 画链候选选择弹窗（issue #85）：贴在被点格子旁，只列当前候选，触屏友好的大按钮 */
#link-pick {
  position: absolute; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 4px; max-width: 196px; padding: 6px;
  background: var(--panel); border: 2px solid var(--purple); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(51, 64, 94, .25);
  animation: fadein .15s ease;
}
.link-pick-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 8px;
  font-size: 17px; font-weight: 700; line-height: 1; color: var(--purple);
}
.link-pick-btn:hover { border-color: var(--purple); background: #f3edff; }
/* 涂色弹窗里的「■ 整格」按钮（issue #113）：老的整格上色入口 */
.link-pick-btn.pick-cell { color: var(--dim); font-size: 14px; }

/* 模式面板：调色盘 / 画链说明 / 双值三值图例 */
#adv-panel {
  margin-top: 8px; padding: 8px 10px;
  background: var(--panel2); border: 1px dashed var(--line); border-radius: 10px;
}
#adv-panel.hidden { display: none; }
.adv-tip { font-size: 12px; color: var(--dim); line-height: 1.7; }
.adv-tip b { color: var(--accent-dark); }
.adv-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-top: 7px; }
.paint-swatch {
  width: 30px; height: 30px; padding: 0; border-radius: 8px;
  font-size: 14px; line-height: 1;
}
.paint-swatch.swatch-1 { background: #ffc9c9; }
.paint-swatch.swatch-2 { background: #ffe9a8; }
.paint-swatch.swatch-3 { background: #b8ecc9; }
.paint-swatch.swatch-4 { background: #bcd9ff; }
.paint-swatch.swatch-5 { background: #e2ccff; }
.paint-swatch.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 158, 68, .4); }
.adv-clear { font-size: 12px; padding: 6px 10px; color: var(--dim); }
/* 双值/三值图例小圆点 */
.adv-tip .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 3px; vertical-align: 1px;
}
.adv-tip .dot-bi { background: var(--blue); }
.adv-tip .dot-tri { background: var(--gold); }

/* 工具区两页化（issue #88）：高级页里的过滤开关与返回键 */
#tool-link-filter { font-size: 12px; padding: 6px 10px; color: var(--dim); flex: 1; }
#tool-link-filter.on { border-color: var(--accent); color: var(--accent-dark); background: #fff3e4; }
#tool-link-filter.on::before { content: '✔ '; }
.adv-back { display: block; width: 100%; margin-top: 8px; font-size: 12px; padding: 6px 3px; color: var(--dim); }
#tools-adv.hidden, #tools-basic.hidden { display: none; }

.cons-label { margin: 12px 0 6px; color: var(--dim); font-size: 13px; }
#consumable-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.cons-btn { font-size: 16px; display: flex; align-items: center; gap: 4px; }
.cons-btn span { font-size: 12px; }

/* ---------- 提示面板 ---------- */
#hint-panel {
  margin-top: 12px; background: #fffdf4;
  border: 2px solid var(--gold); border-radius: 14px; padding: 12px 16px;
  box-shadow: 0 6px 20px rgba(90, 110, 160, .15);
}
#hint-panel.hidden { display: none; }
.hint-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint-title { flex: 1; font-weight: bold; color: var(--accent-dark); font-size: 16px; text-align: center; }
.hint-idx { color: var(--dim); font-size: 12px; margin-left: 6px; }
.stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.star-dim { color: #e3dcc8; }
.hint-nav { font-size: 12px; padding: 5px 10px; }
.hint-close { padding: 4px 9px; font-size: 12px; }
/* 展开到最大（issue #117）：桌面端面板在文档流里自然生长，按钮无用武之地，仅窄屏浮层显示 */
.hint-expand { display: none; padding: 4px 9px; font-size: 12px; }
.hint-body { margin: 10px 4px; line-height: 1.8; font-size: 14px; }
.hint-stage { color: var(--purple); font-size: 12px; margin-bottom: 4px; }
.hint-tip { color: var(--dim); font-size: 12px; margin-top: 6px; }
.hint-effect { margin-top: 6px; }
.fx-place { color: var(--green); }
.fx-elim { color: var(--red); }
.hint-actions { display: flex; gap: 10px; justify-content: center; }
.hint-lesson {
  margin-top: 10px; background: #f2f8ff; border: 1px dashed #b9cdec;
  border-radius: 10px; padding: 8px 12px; font-size: 13px;
}
.hint-lesson summary { cursor: pointer; color: var(--blue); font-weight: bold; }
.hint-lesson p { margin-top: 6px; color: var(--text); line-height: 1.8; }

/* 教学图例迷你棋盘 */
.lesson-fig { margin-top: 10px; }
.lesson-grid {
  display: grid; grid-template-columns: repeat(9, 30px); grid-template-rows: repeat(9, 30px);
  width: fit-content; border: 2px solid #a9b9d8; border-radius: 4px; background: #fff;
  margin: 0 auto;
}
.fcell {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #e6ebf4; font-size: 10px; color: #97a1bd; letter-spacing: 1px;
  overflow: hidden;
}
.fcell.bl { border-left: 2px solid #a9b9d8; }
.fcell.bt { border-top: 2px solid #a9b9d8; }
.fcell.br { border-right: 2px solid #a9b9d8; }
.fcell.bb { border-bottom: 2px solid #a9b9d8; }
.fcell b { font-size: 18px; font-weight: 800; color: #1f2940; letter-spacing: 0; }
.fcell s { color: var(--red); font-weight: bold; }
.fcell.fc-cause { background: #d9edff; }
.fcell.fc-green { background: #d9f4e3; }
.fcell.fc-green b, .fcell.fc-green { color: #1e7a45; font-weight: bold; }
.fcell.fc-elim { background: #ffe3de; }
/* 分步图例（issue #113）：每步小标题 + 单候选圆点（hl 字段，与候选染色同一套色） */
.fig-cap { font-size: 12px; color: var(--dim); margin: 10px 0 4px; text-align: center; }
.fcell .cdp {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5em; height: 1.5em; border-radius: 50%; font-style: normal; letter-spacing: 0;
}
.fcell .cdp.cd-paint-1 { background: #ffc9c9; color: #a03636; font-weight: bold; }
.fcell .cdp.cd-paint-2 { background: #ffe9a8; color: #8a6410; font-weight: bold; }
.fcell .cdp.cd-paint-3 { background: #b8ecc9; color: #1e7a45; font-weight: bold; }
.fcell .cdp.cd-paint-4 { background: #bcd9ff; color: #245d9e; font-weight: bold; }
.fcell .cdp.cd-paint-5 { background: #e2ccff; color: #6a3fb0; font-weight: bold; }
.lesson-legend {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  font-size: 11px; color: var(--dim); margin-top: 6px; flex-wrap: wrap;
}
.lesson-legend .lg {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid #c8d2e6; margin-right: -4px;
}
/* 图注色块与棋盘格同色（原选择器 .fcell.fc-* 罩不到图注的 .lg，色块一直是白的） */
.lesson-legend .lg.fc-cause { background: #d9edff; }
.lesson-legend .lg.fc-green { background: #d9f4e3; }
.lesson-legend .lg.fc-elim { background: #ffe3de; }
.lesson-legend s { color: var(--red); }

/* ---------- 通用面板（奖励/商店/事件/结算） ---------- */
.panel-box {
  max-width: 560px; margin: 30px auto; background: var(--panel);
  border: 2px solid var(--line); border-radius: 18px; padding: 26px 30px;
  box-shadow: 0 8px 24px rgba(90, 110, 160, .12);
}
.panel-box.center { text-align: center; margin-top: 12vh; }
.panel-box h2 { margin-top: 0; }
.panel-box .primary { display: block; margin: 22px auto 0; font-size: 16px; padding: 11px 26px; }
.reward-line { text-align: center; font-size: 16px; margin: 8px 0; }
.reward-sub { text-align: center; color: var(--dim); margin: 16px 0 10px; }
#reward-relics { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#reward-relics .reward-sub { width: 100%; }
.relic-card {
  position: relative; /* 「新」角标定位基准（issue #56） */
  width: 200px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px;
  border-radius: 14px;
}
.relic-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.relic-emoji { font-size: 34px; }
.relic-name { color: var(--accent-dark); font-weight: bold; }
.relic-desc { font-size: 12px; color: var(--dim); text-align: center; }
.relic-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 10px;
  background: #eef3fc; color: #5a6e9c; border: 1px solid var(--line);
}

.shop-group { margin-bottom: 14px; }
.shop-group-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: bold; color: var(--accent-dark); margin: 0 2px 8px;
}
.shop-group-count {
  font-size: 11px; font-weight: normal; padding: 1px 8px; border-radius: 10px;
  background: #eef3fc; color: #5a6e9c; border: 1px solid var(--line);
}
.shop-item {
  position: relative; /* 「新」角标定位基准（issue #56） */
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border: 2px solid var(--line); border-radius: 14px; margin-bottom: 10px; background: var(--panel2);
}
.shop-item.sold { opacity: .45; }
.shop-emoji { font-size: 30px; }
.shop-info { flex: 1; }
.shop-name { font-weight: bold; }
.shop-desc { font-size: 12px; color: var(--dim); }
.shop-buy { min-width: 76px; color: var(--accent-dark); font-weight: bold; }

.event-emoji { font-size: 52px; text-align: center; }
.event-text { line-height: 1.9; margin: 14px 0 22px; }
.event-options { display: flex; flex-direction: column; gap: 10px; }
.event-opt { padding: 12px; font-size: 15px; }
.event-opt:hover { border-color: var(--accent); }
.dao { color: var(--gold); font-size: 18px; }
.new-record { color: var(--accent-dark); animation: fadein .4s ease; }
#gameover-text p, #victory-text p { margin: 10px 0; line-height: 1.8; }

/* ---------- Tooltip（立即出现；移动端点击显示） ---------- */
#tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  max-width: 280px; padding: 7px 12px;
  white-space: pre-line; /* 宝物详情用 \n 分行（issue #51）：默认排版会把 \n 压成空格 */
  background: #3a4260; color: #fff; font-size: 13px; line-height: 1.6;
  border-radius: 10px; box-shadow: 0 4px 14px rgba(40, 55, 90, .3);
}
#tooltip.hidden { display: none; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none;
}
.toast {
  background: rgba(255, 255, 255, .97); border: 2px solid var(--line); border-radius: 20px;
  padding: 8px 20px; font-size: 14px; text-align: center; color: var(--text);
  animation: toastin .25s ease; box-shadow: 0 4px 16px rgba(90, 110, 160, .2);
}
.toast.good { border-color: #9ad8b2; color: #23824a; }
.toast.bad { border-color: #f0b1b1; color: #c94848; }
.toast.warn { border-color: #ecd28e; color: #a3781a; }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  body { overflow-x: hidden; }
  /* 棋盘格自适应：40px 封顶，窄屏按视口缩（34px = #app 左右 padding 24px + 棋盘边框 6px + 宫缝 2×2px）；
     小格子里 5px 宫缝占比过大，收窄为 2px */
  #board {
    --box-gap: 2px;
    --cell-size: min(40px, calc((100vw - 34px) / 9));
    margin: 0 auto;
  }
  .board-loading { padding: 200px 0; text-align: center; }
  .cell .val { font-size: 20px; }
  /* 小屏候选数加粗加深提可读性（issue #31）；字号随桌面端同走 12px × --note-scale（issue #95）；
     note-hl/cause/bad 与 same-cand 自带更高优先级颜色不受影响 */
  .notes span { font-weight: 700; color: #8a93b0; }
  /* 竖排时侧栏跟随容器宽度，而不是被数字键盘的内容宽度撑出屏幕 */
  .battle-main { flex-direction: column; align-items: stretch; }
  .side-panel { min-width: 0; }
  #digit-pad { grid-template-columns: repeat(9, 1fr); }
  .digit-btn { height: 44px; font-size: 17px; min-width: 0; padding-left: 0; padding-right: 0; }
  .pad-tip { grid-column: span 9; }
  .tool-grid button { min-width: 0; padding-left: 2px; padding-right: 2px; }
  .title { font-size: 38px; letter-spacing: 3px; }
  .battle-top { flex-direction: column; }
  .player-panel { min-width: 0; }
  .cheer { font-size: 25px; letter-spacing: 1px; }
  /* 胜利选择条上下排布：文字 basis-0 会被按钮挤成竖条（issue #30），
     改成文字独占首行、按钮 wrap 到下一行等宽平分 */
  #victory-bar .victory-text { flex-basis: 100%; }
  #victory-bar button { flex: 1; }
}

/* ============ 移动端战斗页：一屏化 + 定高防跳（issue #104） ============ */
/* 触屏点按去掉 iOS 双击缩放判定延迟；双击本身是「锁定数字」手势，误触缩放会造成"画面跑位"的观感 */
button, .cell { touch-action: manipulation; }
/* 出题占位居中铺满棋盘（棋盘行列轨道定宽高，出题完成零位移） */
.board-loading { grid-row: 1 / -1; padding: 0; display: flex; align-items: center; justify-content: center; }

@media (max-width: 860px) {
  /* 顶部 HUD 紧凑化：目标 ~150px 定高，任何状态变化不推挤棋盘 */
  #screen-battle.screen { padding-bottom: 8px; }
  .battle-top { gap: 2px; padding: 6px 10px; margin-bottom: 6px; }
  .enemy-panel { gap: 8px; padding-right: 70px; /* 给右上角🚪退出键让位 */ }
  #enemy-emoji { font-size: 24px; }
  #enemy-name { font-size: 13px; margin-bottom: 2px; }
  /* 意图固定一行，超长省略：文案 1⇄2 行换行是跳动源之一 */
  #enemy-intent { margin-top: 2px; height: 17px; line-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .player-panel { gap: 2px; }
  .bar { margin: 2px 0; }
  /* 统计行定高单行：分数位数增长不再引发换行跳动 */
  #battle-stats { font-size: 12px; gap: 8px; height: 18px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
  #battle-stats span { white-space: nowrap; }
  /* 状态徽章行常驻占位：封印/冰冻/洞察出现消失不再推挤棋盘 */
  #battle-effects { height: 20px; overflow: hidden; white-space: nowrap; }
  #battle-effects .fx { font-size: 11px; }
  #battle-relics { font-size: 15px; white-space: nowrap; overflow: hidden; }

  /* 棋盘宽高双约束：矮屏按视口高缩格子（下限 32px 保触控），385px = 棋盘外全部 UI 预算 */
  .battle-main { gap: 8px; }
  #board { --cell-size: min(40px, calc((100vw - 34px) / 9), max(32px, calc((100vh - 385px) / 9))); }
  @supports (height: 100dvh) {
    #board { --cell-size: min(40px, calc((100vw - 34px) / 9), max(32px, calc((100dvh - 385px) / 9))); }
  }
  /* 侧栏纵向收紧 */
  .tool-grid { margin-top: 6px; }
  .tool-grid button { padding-top: 5px; padding-bottom: 5px; }
  .cons-label { margin: 6px 0 4px; }
  .cons-btn { font-size: 14px; }

  /* 胜利条浮层化（最大跳动源）：认输瞬间 fixed 盖在顶部 HUD 上，棋盘零位移。
     只在「领奖 / 继续」二选一时短暂出现；选继续后收起，领奖钮进 HUD（issue #120） */
  #victory-bar {
    position: fixed; top: 6px; left: 6px; right: 6px; z-index: 70; margin: 0;
    box-shadow: 0 10px 30px rgba(40, 55, 90, .35);
  }
  #victory-bar .victory-text { font-size: 13px; }
  /* HUD 领奖钮定高 = 被顶替的充能条(16+4) + 意图行(17+2) 两行之和，定高 HUD 零跳动 */
  .battle-wrap.won #victory-claim-hud { height: 35px; margin: 2px 0; padding: 0 10px; font-size: 13px; }

  /* 提示面板底部浮层：弹出不推挤布局、不用滚到页面底部找；
     最大高度 = 棋盘下缘以下的空间（JS 写 --hint-max），提示再长也只在面板内滚动、不遮数盘 */
  #hint-panel {
    position: fixed; left: 6px; right: 6px; bottom: 6px; z-index: 65; margin: 0;
    max-height: var(--hint-max, 45vh); overflow-y: auto;
    box-shadow: 0 -8px 30px rgba(40, 55, 90, .35);
    transition: max-height .15s ease;
  }
  /* 展开到最大（issue #117）：底部锚定向上长满全屏（留 6px 边距），z 仍在胜利条（70）之下。
     展开会盖住棋盘高亮，玩家点 🗕 一键收起回看——换实现极简、零位移 */
  #hint-panel.expanded { max-height: calc(100vh - 12px); }
  .hint-expand { display: inline-block; }
}

/* ============ 宝物袋 / 星级稀有度 / 替换面板（issue #9） ============ */
/* 星级边框：普通灰 / 稀有蓝 / 传说金 */
.relic-card.tier-1, .relic-slot.tier-1, .shop-item.tier-1 { border-color: #b9c2cc; }
.relic-card.tier-2, .relic-slot.tier-2, .shop-item.tier-2 { border-color: var(--blue); }
.relic-card.tier-3, .relic-slot.tier-3, .shop-item.tier-3 {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(240, 169, 46, .5);
}
.relic-tier { font-size: 11px; color: var(--gold); letter-spacing: -1px; }

/* 成长宝物层数角标 */
.stacks {
  position: absolute; top: -6px; right: -7px;
  font-size: 10px; font-style: normal; font-weight: bold; line-height: 1;
  background: var(--green); color: #fff; border-radius: 8px; padding: 2px 4px;
  pointer-events: none;
}
.hud-relic { position: relative; display: inline-block; }
.hud-relic .stacks { top: -4px; right: -6px; }

/* 未收集宝物「新」角标（issue #56）：图鉴里还没点亮的宝物，
   出现在奖励卡 / 商店货架 / 袋满替换面板时提醒「这件还没集到过」 */
.new-badge {
  position: absolute; top: -9px; right: -9px;
  font-size: 11px; font-style: normal; font-weight: bold; line-height: 1;
  background: var(--accent); color: #fff; border-radius: 9px; padding: 3px 6px;
  box-shadow: 0 2px 6px rgba(231, 122, 29, .35);
  pointer-events: none;
  animation: new-badge-breathe 1.6s ease-in-out infinite;
}
.shop-item .new-badge { right: auto; left: -9px; } /* 商店条目右侧是价格按钮，角标改贴左上角 */
.new-badge.inline { position: static; display: inline-block; vertical-align: 2px; animation: none; }
@keyframes new-badge-breathe { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .new-badge { animation: none; } }
.hud-relic.leader::before {
  content: '👑'; position: absolute; top: -9px; left: -4px; font-size: 10px;
}

/* 地图页宝物袋：8 槽，空槽虚线；选中可 ◀▶ 调序 */
.relic-bag {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: center;
  margin: 8px 0 4px;
}
.relic-slot {
  position: relative; width: 46px; height: 46px; font-size: 23px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.relic-slot.empty { border-style: dashed; background: transparent; opacity: .45; cursor: default; }
.relic-slot.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.relic-slot .leader-mark {
  position: absolute; top: -8px; left: -6px; font-size: 10px; font-style: normal; font-weight: bold;
  background: var(--gold); color: #fff; border-radius: 8px; padding: 1px 4px;
}
.bag-move { display: inline-flex; gap: 6px; margin-left: 8px; }
.bag-move button { font-size: 13px; padding: 6px 10px; border-radius: 10px; }
.bag-move button:disabled { opacity: .4; cursor: default; }

/* 袋满替换面板 */
#relic-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(40, 52, 84, .55);
  display: flex; align-items: center; justify-content: center;
}
#relic-modal.hidden { display: none; }
#relic-modal .modal-card {
  background: var(--panel); border-radius: 18px; padding: 22px;
  width: min(600px, 94vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(30, 40, 70, .35);
}
#relic-modal h3 { color: var(--accent-dark); margin-bottom: 10px; text-align: center; }
#relic-modal p { margin: 6px 0; }
#relic-modal .modal-sub { color: var(--dim); font-size: 13px; }
#relic-modal .tier-t1 { color: var(--text); }
#relic-modal .tier-t2 { color: var(--blue); }
#relic-modal .tier-t3 { color: var(--gold); }
.replace-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0; }
.replace-list .relic-card { width: 160px; padding: 12px; }
.replace-list .relic-emoji { position: relative; }
#replace-cancel { display: block; margin: 6px auto 0; padding: 9px 20px; }

/* ============ 商店刷新 / 拖拽调序 / 已有宝物条（issue #19） ============ */
/* 触屏上按住宝物拖动时不触发页面滚动 */
.relic-slot { touch-action: none; }
/* iOS 长按会呼出文本选择放大镜，劫持拖动/点按（issue #34） */
.relic-slot, .hud-relic {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.relic-slot.drag-src, .hud-relic.drag-src { opacity: .35; }
.relic-slot.drop-target, .hud-relic.drop-target {
  outline: 3px dashed var(--accent); outline-offset: 1px;
  background: #fff3e4; transform: scale(1.08);
}

/* 战斗内拖拽调序（issue #63）：HUD 宝物触点加大到 ~28px 方便手指拖动；
 * 👑队长位（.leader）战斗中锁定，保持"看说明"的手势提示 */
#battle-relics .hud-relic {
  padding: 4px 5px; margin-right: 0;
  border-radius: 8px; cursor: grab; touch-action: none;
}
#battle-relics .hud-relic.leader { cursor: help; }
#battle-relics .hud-relic.drop-target { transform: scale(1.12); }
/* 跟随指针的拖影 */
.relic-ghost {
  position: fixed; z-index: 90; font-size: 30px; pointer-events: none;
  transform: translate(-50%, -70%);
  filter: drop-shadow(0 4px 8px rgba(90, 110, 160, .45));
}

/* 商店 / 战利品页的「已有宝物」条 */
#shop-bag, #reward-bag { text-align: center; color: var(--dim); font-size: 14px; margin-top: 16px; }
.bag-detail {
  max-width: 430px; margin: 8px auto 0; padding: 8px 14px;
  background: var(--panel2); border: 1px dashed var(--line); border-radius: 10px;
  font-size: 13px; line-height: 1.6; color: var(--text); text-align: left;
  animation: fadein .2s ease;
}
/* 详情框分行（issue #38）：标题 / 描述 / 附加信息各占一行 */
.bag-detail-title { font-weight: bold; }
.bag-detail-desc { margin-top: 2px; }
.bag-detail-extra { margin-top: 2px; color: var(--dim); font-size: 12px; }

/* 商店底部按钮行：🔄 换一批 + 离开 */
.shop-actions { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.shop-actions .primary { margin: 0; }
#shop-reroll { color: var(--accent-dark); font-weight: bold; }

/* 图鉴卡片是纯展示：取消可点击式的悬停反馈，星级描边保持不变
 *（放在 .relic-card:hover 与星级边框规则之后，靠 cascade 覆盖） */
.gallery-card:hover { transform: none; border-color: #b9c2cc; }
.gallery-card.tier-2:hover { border-color: var(--blue); }
.gallery-card.tier-3:hover { border-color: var(--gold); }

/* ============ ⚙️ 设置界面（issue #31） ============ */
.settings-body { max-width: 520px; margin: 0 auto; text-align: left; }
.setting-group {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px;
}
.setting-label { font-weight: bold; margin-bottom: 10px; }
.opt-row { display: flex; gap: 10px; flex-wrap: wrap; }
.opt-btn.on {
  border-color: var(--accent); background: #fff3e2; color: var(--accent-dark);
  font-weight: bold; box-shadow: 0 0 0 2px rgba(255, 158, 68, .25);
}
.setting-tip { color: var(--dim); font-size: 12px; margin: 10px 0 0; line-height: 1.6; }
/* 实时预览：一宫 3×3 迷你棋盘，复用真实 .cell/.notes 样式，改字号/高亮立刻生效 */
.preview-board {
  --pv-cell: 54px;
  display: grid;
  grid-template-columns: repeat(3, var(--pv-cell));
  grid-auto-rows: var(--pv-cell);
  gap: 1px; width: fit-content; margin: 4px auto 0;
  background: #8fa3c8; border: 3px solid #8fa3c8; border-radius: 8px;
}
.preview-board .cell { cursor: default; }
@media (max-width: 860px) {
  /* 与窄屏真实棋盘同尺寸，预览效果所见即所得 */
  .preview-board { --pv-cell: min(40px, calc((100vw - 34px) / 9)); }
}

/* ============ 对局内候选数样式浮层（issue #95） ============ */
/* 半透明遮罩 + 居中卡片浮在战斗界面上；改字号 / 高亮立刻作用到身后真实棋盘 */
#battle-settings { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
#battle-settings.hidden { display: none; }
.bset-backdrop { position: absolute; inset: 0; background: rgba(51, 64, 94, .38); animation: fadein .15s ease; }
.bset-card {
  position: relative; z-index: 1; width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg); border: 2px solid var(--purple); border-radius: 16px;
  padding: 18px 18px 16px; box-shadow: 0 12px 32px rgba(51, 64, 94, .3);
  animation: fadein .18s ease; text-align: left;
}
.bset-card h3 { margin: 0 0 14px; text-align: center; }
.bset-card .setting-group { margin-bottom: 12px; }
.bset-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0;
  border-radius: 50%; font-size: 15px; line-height: 1; color: var(--dim);
}
.bset-close:hover { border-color: var(--purple); color: var(--purple); }

/* 💾 存档搬家弹层（issue #124）：导出/导入共用一张卡，样式对齐对局内设置浮层 */
#save-move { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
#save-move.hidden { display: none; }
.smove-backdrop { position: absolute; inset: 0; background: rgba(51, 64, 94, .38); animation: fadein .15s ease; }
.smove-card {
  position: relative; z-index: 1; width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg); border: 2px solid var(--purple); border-radius: 16px;
  padding: 18px 18px 16px; box-shadow: 0 12px 32px rgba(51, 64, 94, .3);
  animation: fadein .18s ease; text-align: left;
}
.smove-card h3 { margin: 0 0 10px; text-align: center; }
.smove-card .setting-tip { margin: 0 0 10px; }
.smove-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; padding: 0;
  border-radius: 50%; font-size: 15px; line-height: 1; color: var(--dim);
}
.smove-close:hover { border-color: var(--purple); color: var(--purple); }
#smove-text {
  display: block; width: 100%; height: 130px; box-sizing: border-box; resize: vertical;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5;
  word-break: break-all;
}
#smove-text:focus { outline: none; border-color: var(--purple); }
.smove-msg { min-height: 20px; margin: 8px 0 4px; font-size: 13px; color: var(--dim); }
.smove-msg.ok { color: var(--green); }
.smove-msg.warn { color: var(--red); }
#smove-ok { display: block; width: 100%; }
