/* 光阵 · 儿童化精致游戏视觉 */
:root {
  --ink: #3a2a1c;
  --ink-soft: #8a7358;
  --pink: #e8a84a;
  --pink-deep: #c07820;
  --yellow: #ffd570;
  --amber: #e8a84a;
  --cyan: #6fe0f0;
  --mint: #9ce8c4;
  --purple: #b79bff;
  /* 三块内容的统一横向基准：HUD / 棋盘 / 底部按钮条必须共用这两个值，
     否则窄屏和宽屏下会各走各的，看起来永远"没对齐"。
     改这里必须同步改 js/render.js 顶部的 GUTTER / SHELL_MAX。 */
  --gutter: 12px;
  --shell-max: 560px;
  /* HUD 里同一行所有控件共用的高度（关卡卡 / 三个 pill / 体力胶囊）。
     原来各自靠 padding 撑，差 2px 就会让整排看着不齐。 */
  --hud-h: 36px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性的兜底，必须带 !important。
   原因：UA 的 `[hidden] { display: none }` 只是元素级优先级，
   任何作者写的 `display: flex/grid` 都能把它顶掉 —— 元素标了 hidden 却照样占位。
   `.res-goal { display: flex }` 就是这么让"通关目标清单"在普通过关时露出来的
   （内容是初始占位 0/200，因为只有打通全部关卡才会填充）。
   放在这里一次兜住，以后新元素加 hidden 不会再漏。 */
[hidden] { display: none !important; }

/* 表单控件默认不继承字体，不显式声明的话按钮会掉回 Arial，和整体字形对不上 */
button, input, select, textarea { font-family: inherit; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #101624;
  color: var(--ink);
  /* 圆体优先：iOS/macOS 命中 Yuanti SC，Windows 命中幼圆，Android 退回思源/黑体。
     不内嵌字体文件是为了守住零依赖 —— 以后要统一字形再考虑约 100KB 的子集。 */
  font-family: "Yuanti SC", "Yuanti TC", "YouYuan", "Hiragino Sans GB",
    "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

#app {
  position: relative; display: flex; flex-direction: column;
  width: 100%; height: 100vh; height: 100dvh; overflow: hidden;
  background: #1a2744 url("../assets/scene/night-room.jpg") center top / cover no-repeat;
}

/* ---------- 夜灯房间：窗、灯笼、地板。都是静止形状，不做模糊和粒子 ---------- */
.bg { display: none; }
.scene-window {
  position: absolute; left: 12%; right: 12%; top: -8px; height: 46%;
  border-radius: 0 0 28px 28px;
  background:
    radial-gradient(70% 55% at 50% 18%, rgba(255, 196, 130, .28), transparent 70%),
    linear-gradient(180deg, #1c3158 0%, rgba(18, 28, 52, .2) 100%);
  box-shadow: inset 0 0 0 10px rgba(92, 62, 36, .45);
}
.scene-window::before, .scene-window::after {
  content: ''; position: absolute; background: rgba(92, 62, 36, .35);
}
.scene-window::before { left: 50%; top: 8%; bottom: 12%; width: 8px; margin-left: -4px; }
.scene-window::after { left: 10%; right: 10%; top: 42%; height: 8px; }
.lantern {
  position: absolute; top: 6px; width: 34px; height: 52px;
  border-radius: 16px 16px 14px 14px;
  background: linear-gradient(180deg, #ffe7b8 0%, #ffb15a 46%, #e07030 100%);
  box-shadow: 0 0 22px 6px rgba(255, 160, 60, .38);
}
.lantern::before {
  content: ''; position: absolute; left: 7px; right: 7px; top: -5px; height: 7px;
  border-radius: 3px; background: #c47830;
}
.lantern::after {
  content: ''; position: absolute; left: 50%; top: -18px; width: 2px; height: 16px;
  margin-left: -1px; background: rgba(196, 140, 70, .8);
}
.lantern-l { left: 4%; }
.lantern-r { right: 5%; top: 28px; height: 44px; }
.wood {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26%;
  background:
    linear-gradient(180deg, rgba(90, 58, 32, 0) 0%, rgba(74, 46, 28, .55) 18%, #4a2e1c 100%);
}

/* 只作用于背景层。弹窗里的 .stars 是评分星星，两者同名但完全无关，
   不加作用域的话星空的白点会被绝对定位到弹窗卡片上 */
.bg .stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 14% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 72% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 38% 42%, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 86% 48%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 26% 74%, #b7f0ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 86%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 78%, #ffd5e8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 8% 56%, #fff 50%, transparent 51%);
  opacity: .55;
}

.cloud { position: absolute; background: rgba(255,255,255,.10); border-radius: 100px; filter: blur(2px); }
.cloud::before, .cloud::after { content: ''; position: absolute; background: inherit; border-radius: 50%; }
.cloud-a { width: 110px; height: 26px; left: -20px; top: 30%; }
.cloud-a::before { width: 48px; height: 48px; left: 16px; top: -24px; }
.cloud-a::after { width: 34px; height: 34px; left: 56px; top: -16px; }
.cloud-b { width: 90px; height: 22px; right: -10px; top: 62%; }
.cloud-b::before { width: 40px; height: 40px; left: 12px; top: -20px; }
.cloud-b::after { width: 28px; height: 28px; left: 48px; top: -14px; }

.twinkle {
  position: absolute; font-size: 18px; color: var(--yellow);
  text-shadow: 0 0 12px rgba(255,213,112,.8);
  animation: float-twinkle 3.6s ease-in-out infinite;
}
.tw1 { left: 12%; top: 22%; animation-delay: .1s; }
.tw2 { right: 16%; top: 34%; font-size: 14px; color: var(--cyan); animation-delay: .8s; }
.tw3 { left: 22%; bottom: 26%; font-size: 13px; color: var(--pink); animation-delay: 1.5s; }
.tw4 { right: 24%; bottom: 18%; font-size: 20px; animation-delay: 2.2s; }

/* ---------- 顶部 HUD ---------- */
/* 两行：
     ① 招牌 + 四颗糖果按钮
     ② 关卡卡 + 目标灯 + 计时 + 机会
   一行塞不下（390px 上会被裁），拆开也让信息层级更清楚。

   排版只有一条硬规矩：**同一行里所有控件共用 --hud-h**。
   之前每个块各自 padding 撑高度，结果计时那一格比左右矮 2px，
   单独看没事，并排看就像没对齐 —— 这种"说不上哪不对但就是乱"的感觉多半来自这里。 */
.hud {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; gap: 8px;
  width: calc(100% - var(--gutter) * 2); max-width: var(--shell-max); margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 0 4px;
}
/* 入场动画挂在 #app.enter 上，而不是直接写死在元素上：
   写死在元素上只会播一次，切关时想让它再来一遍没有任何办法。
   见 js/game.js 的 replayEnter()。 */
#app.enter .hud { animation: hud-in .5s cubic-bezier(.2,1,.3,1) both; }
.hud-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: var(--hud-h);
}
.hud-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.hud-bottom { display: block; }
.hud-stats { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }

/* 招牌：不是按钮，就不许有按钮的形。
   老版本给了白描边 + 4px 厚底 + 按压位移，等于在骗玩家去点它。
   现在改成"发光字"：无底色、无边框、无投影，只有一层金色渐变和一圈柔光，
   形态上就说明它是一块牌子，不是控件。 */
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 30px; font-weight: 900; letter-spacing: .12em;
  padding: 0 2px; border: 0; background: none; box-shadow: none;
  background-image: linear-gradient(180deg, #fff8dc 0%, #ffd570 52%, #ffb083 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  /* 描边用 drop-shadow 而不是 text-shadow：文字已经是透明填充，
     text-shadow 会被裁在字形外面，看着像糊了一圈脏东西 */
  color: #ffd570; -webkit-text-fill-color: #ffd570;
}
.logo-star { font-size: 16px; color: #ffd570; -webkit-text-fill-color: #ffd570; }

.level-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  width: 100%; min-width: 0;
  min-height: 0; height: auto; padding: 14px 14px 12px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff1dc 0%, #f6d7b0 100%);
  border: 0;
  box-shadow: 0 6px 0 rgba(120, 72, 28, .28), 0 14px 24px rgba(40, 18, 6, .28);
}
#app.enter .level-card { animation: card-in .45s .06s cubic-bezier(.2,1.2,.35,1) both; }
.lc-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.lc-sep { color: #8a6844; font-weight: 900; font-size: 22px; }
.lc-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lc-chapter { font-size: 16px; font-weight: 800; color: #6a5340; flex: none; }
.level-no { font-size: 24px; color: #3a2a1c; font-weight: 900; white-space: nowrap; }
.level-no b {
  font-size: 24px; color: #3a2a1c; margin: 0 1px;
  font-variant-numeric: tabular-nums;
}
.level-name {
  font-size: 24px; color: #3a2a1c; font-weight: 900;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto; min-width: 0; padding-right: 2px;
}
/* 设计图的副标题是章节名。难度留在 DOM 里给脚本写，不再占一颗胶囊。 */
.difficulty { display: none; }

/* 信息卡右侧的小标签：单行文字，细金边，不再是一排独立的厚胶囊 */
.pill {
  display: flex; align-items: center; gap: 3px;
  height: 32px; padding: 0 10px;
  border-radius: 10px;
  background: rgba(255, 248, 236, .72);
  border: 1.5px solid rgba(196, 140, 70, .45);
  box-shadow: none;
}
#app.enter .pill { animation: card-in .45s cubic-bezier(.2,1.2,.35,1) both; }
.hud-stats .pill:nth-child(1) { animation-delay: .10s; }
.hud-stats .pill:nth-child(2) { animation-delay: .16s; }
.hud-stats .pill:nth-child(3) { animation-delay: .22s; }
/* 360~374 的窄屏：先让难度标签退场，再缩一轮 pill 的内边距。
   取舍标准是"哪个信息更贵"—— 关卡名是玩家自己的位置，难度只是描述这一关，
   所以被牺牲的是难度，不是名字。 */
@media (max-width: 374px) {
  .level-no, .level-name, .lc-sep { font-size: 15px; }
  .pill { padding: 0 6px; }
  .pill small { font-size: 9px; }
  .pill-time { padding: 0 6px; }
}
/* 340 以下连名字也放不下，整行让给关卡号 */
@media (max-width: 340px) {
  .level-name { display: none; }
}
.hud-actions .round-btn:nth-child(1) { animation-delay: .10s; }
.pill-ic {
  font-size: 13px; line-height: 1;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff;
}
.pill-goal .pill-ic { background: linear-gradient(135deg, var(--yellow), var(--amber)); }
.pill-tries .pill-ic { background: linear-gradient(135deg, var(--pink), var(--pink-deep)); }
.pill-body { display: flex; flex-direction: row; align-items: baseline; gap: 3px; line-height: 1; }
.pill small { font-size: 13px; color: #6a5340; font-weight: 800; }
.pill b {
  font-size: 13px; color: #3a2a1c; font-weight: 900; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill-time { padding: 0 6px; justify-content: center; }
.pill-time .pill-body { flex-direction: column; align-items: center; gap: 1px; }
.pill-time small { font-size: 8px; color: #8b6a4e; line-height: 1; }
.pill-time b { font-size: 12px; letter-spacing: .02em; }
.pill-time.run b { color: #2f7fb8; }
.pill-tries.low { animation: shake-soft 1.4s ease-in-out infinite; }
.pill-tries.low b { color: var(--pink-deep); }

/* 体力胶囊：比 pill 更小，因为它挤在右上角四颗按钮前面。
   带上限（28/30）而不是只给数字 —— 只给数字玩家不知道满是多少 */
.stam-pill {
  display: flex; align-items: center; gap: 1px;
  height: var(--hud-h); padding: 0 9px; border-radius: 12px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.85);
  background: linear-gradient(160deg, #fffdf7, #eef6ff);
  box-shadow: 0 3px 0 rgba(93,74,150,.5), 0 6px 12px rgba(0,0,0,.18);
  font: inherit; color: var(--ink);
}
.stam-pill[hidden] { display: none; }
.stam-pill b { font-size: 13px; font-weight: 900; font-variant-numeric: tabular-nums; color: #2f7fb8; }
.stam-pill small { font-size: 9px; font-weight: 700; color: #8ea9c4; }
.stam-pill.low b { color: var(--pink-deep); }
.stam-pill.low { animation: shake-soft 1.6s ease-in-out infinite; }
.stam-pill:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(93,74,150,.5); }

/* 右上四颗按钮：糖果质感。
   每颗一套配色（紫/蓝/金/粉），共用同一套形状：白描边、顶部内高光、
   3px 厚底、按下位移 2px —— 形状统一 + 颜色分工，既不像之前那样"一片素白"，
   也不会因为颜色乱而显得杂。 */
.round-btn {
  --btn-c1: #fffdf7; --btn-c2: #f3e6cf; --btn-edge: #e0c48a;
  width: 46px; height: 46px; border-radius: 16px;
  border: 2px solid #e7b56a;
  background:
    linear-gradient(180deg, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 46%),
    linear-gradient(160deg, var(--btn-c1), var(--btn-c2));
  color: #5a3a18;
  display: grid; place-items: center;
  box-shadow:
    0 3px 0 var(--btn-edge),
    0 6px 12px rgba(90,50,10,.18),
    inset 0 -2px 4px rgba(0,0,0,.10);
  /* backwards 而不是 both：动画结束后不能继续占用 transform，否则 :active 按压会失效 */
  transition: transform .12s ease, box-shadow .12s ease;
}
#btn-mode, #btn-sound, #btn-rules, #btn-share {
  --btn-c1: #fffdf7; --btn-c2: #f3e6cf; --btn-edge: #e0c48a;
}
/* B: 分享入口加强。原来 34px 纯出口箭头认不出是分享，换成「分享」两字；
   视觉尺寸仍是 34×34、与其他三颗保持同一套糖果形状，不动它们的位置。
   热区用伪元素向四周各扩 5px 到 44×44（指尖标准），320 窄屏下与左邻仍留 2px 空隙。 */
#btn-share { position: relative; }
#btn-share .share-word {
  font-size: 13px; font-weight: 800; line-height: 1; letter-spacing: .5px;
  color: #5a3a18;
}
#btn-share::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}
/* 静音时整颗按钮褪成灰紫：状态变化要让形状也说一遍，不能只靠图标 */
.round-btn.muted {
  --btn-c1: #cfc8de; --btn-c2: #a89fc0; --btn-edge: #867c9f;
}
.round-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--btn-edge), 0 3px 6px rgba(60,30,110,.24), inset 0 -2px 4px rgba(0,0,0,.12);
}
/* 图标：描边统一 2.1px、圆角线帽，四个按钮看起来才像一套。
   fill:none + currentColor 让图标跟着按钮的文字色走（静音时自然变灰）。 */
.round-btn svg {
  width: 24px; height: 24px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}
#btn-mode { color: #3e6b4e; }
#btn-sound, #btn-rules, #btn-share { color: #5c4632; }
/* 线宽 2.2 = 母题里的"主体"档。原来 2.1 + 一圈 drop-shadow 描边，
   在 17px 下反而让图标发糊；母题换成实心+描边分明的画法后，阴影可以撤了。 */
.round-btn .ic-sound-off { display: none; }

.round-btn.muted .ic-sound-on { display: none; }
.round-btn.muted .ic-sound-off { display: block; }
#app.enter .round-btn { animation: card-in .45s cubic-bezier(.2,1.2,.35,1) backwards; }

/* ---------- 棋盘舞台 ---------- */
.stage { position: relative; z-index: 1; flex: 1; min-height: 0; }
#board {
  display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer;
}
#app.enter #board { animation: board-in .7s ease-out both; }
#board[hidden] { display: none; }
#board:active { cursor: pointer; }

/* 操作提示只在开局亮一下，之后自动退场，不长期压在棋盘上 */
/* 复盘模式：顶部提示是"教你玩"的文案，通关后是噪音，让位给复盘工具条 */
.stage.replay .stage-tip { display: none; }
.stage-tip { display: none !important; }

/* 横屏且高度不足时挡一层：此时棋盘只剩百来像素，格子小到点不准，不如明确要求竖屏。
   但必须留出口 —— 平板横屏、方向锁定的设备如果被硬挡就彻底玩不了，所以给一个"就这样玩"。 */
.rotate-gate { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  .rotate-gate:not(.dismissed) {
    display: flex; align-items: center; justify-content: center;
    position: fixed; inset: 0; z-index: 80;
    padding: 20px;
    background: rgba(18,12,42,.88);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
}
.rotate-card {
  text-align: center; padding: 22px 26px; border-radius: 24px;
  background: linear-gradient(160deg, #fffdf7, #f3ecff);
  border: 3px solid #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: card-pop .3s cubic-bezier(.2,1.4,.4,1) both;
}
.rotate-card h3 { margin: 0 0 6px; font-size: 17px; font-weight: 900; color: var(--ink); }
.rotate-card p { margin: 0 0 16px; font-size: 12px; color: var(--ink-soft); }
.rotate-phone {
  width: 44px; height: 70px; margin: 0 auto 14px;
  border: 3px solid #b79bff; border-radius: 10px;
  position: relative;
  animation: rotate-hint 2.6s ease-in-out infinite;
}
.rotate-phone::after {
  content: ''; position: absolute; left: 50%; bottom: 5px;
  transform: translateX(-50%); width: 15px; height: 3px;
  border-radius: 2px; background: #b79bff;
}
@keyframes rotate-hint {
  0%, 22% { transform: rotate(90deg); }
  55%, 100% { transform: rotate(0deg); }
}

.restriction {
  position: absolute; left: 50%; top: 36px; transform: translateX(-50%);
  padding: 5px 13px; border-radius: 999px;
  font-size: 11px; font-weight: 900; color: #fff; white-space: nowrap;
  background: linear-gradient(135deg, #ff7fa8, #f26294);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 3px 0 #b83e6d, 0 6px 16px rgba(0,0,0,.25);
  pointer-events: none;
  animation: badge-pop .45s cubic-bezier(.2,1.4,.4,1);
}
.restriction[hidden] { display: none; }

.toast {
  position: absolute; left: 50%; top: 64px; transform: translate(-50%, -8px);
  padding: 7px 16px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--ink); background: rgba(255,253,247,.96);
  border: 2px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .22s, transform .22s;
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 底部操作台 ---------- */
.dock {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  width: calc(100% - var(--gutter) * 2); max-width: var(--shell-max);
  margin: 2px auto calc(env(safe-area-inset-bottom) + 12px);
  padding: 12px 12px 12px 18px; border-radius: 22px;
  background: linear-gradient(180deg, #fff1dc, #f6d7b0);
  border: 0;
  box-shadow: 0 5px 0 rgba(140,90,30,.28), 0 12px 26px rgba(0,0,0,.28), inset 0 2px 0 rgba(255,255,255,.9);
}
#app.enter .dock { animation: dock-in .55s .12s cubic-bezier(.2,1,.3,1) both; }
.dock-text { flex: 1; min-width: 0; }
.hint { font-size: 17px; font-weight: 900; color: #3a2a1c; }
.sub { display: none; }

.fire-btn {
  flex-shrink: 0; position: relative; overflow: hidden;
  border: 0; border-radius: 999px;
  min-width: 118px; padding: 14px 28px; font-size: 22px; font-weight: 900; letter-spacing: .08em;
  color: #fff;
  text-shadow: 0 1px 0 rgba(170, 70, 10, .35);
  background: linear-gradient(180deg, #ffe7a4 0%, #ffb01e 42%, #f06a12 100%);
  box-shadow: 0 4px 0 #c45a10, 0 8px 16px rgba(180, 70, 10, .28), inset 0 2px 0 rgba(255,255,255,.8), inset 0 -3px 0 rgba(160, 60, 8, .25);
  white-space: nowrap;
}
.fire-icon { display: inline-flex; width: 29px; height: 20px; flex: 0 0 29px; align-items: center; justify-content: center; }
.fire-icon img { display: block; width: 29px; height: 20px; object-fit: contain; }
.fire-btn::after { content: none; }
.fire-btn:disabled {
  color: #fff;
  background: linear-gradient(180deg, #ffe7a4 0%, #ffb01e 42%, #f06a12 100%);
  box-shadow: 0 4px 0 #c45a10, inset 0 2px 0 rgba(255,255,255,.8);
  opacity: 1;
}
.fire-btn:disabled::after { display: none; }
.fire-btn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 #d8762e; }

.dock.fail {
  background: linear-gradient(160deg, #fff0f4, #ffdce8);
  border-color: #fff; box-shadow: 0 5px 0 #c9597d, 0 12px 26px rgba(0,0,0,.3);
}
.dock.fail .hint { color: #c33f6c; }
.dock.fail .dock-icon { background: linear-gradient(135deg, #ff8fb8, #f26294); }

/* ---------- 弹层 ---------- */
.modal, .sheet {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 22px; background: rgba(24,12,52,.72);
}
.modal[hidden], .sheet[hidden] { display: none; }

.result-card {
  position: relative; width: min(100%, 340px);
  padding: 34px 22px 22px; border-radius: 30px; text-align: center;
  /* 每日挑战的结算里要塞一块榜单，矮屏上必须自己能滚，否则按钮会被顶出屏幕。
     滚动条必须藏掉：它一出现就占 8~15px，内容框中心右移，「过关！」就看着偏左了。 */
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none;
  background: linear-gradient(165deg, #fffdf5 0%, #fff4e2 55%, #ffe8f2 100%);
  border: 4px solid #fff;
  box-shadow: 0 8px 0 #a97fd8, 0 20px 44px rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.9);
  animation: card-pop .45s cubic-bezier(.2,1.3,.4,1);
}
.result-card::-webkit-scrollbar { display: none; }
.result-card::before {
  content: ''; position: absolute; inset: -12px; border-radius: 40px; z-index: -1; pointer-events: none;
  background: conic-gradient(from 0deg, #ffd570, #ff8fb8, #b79bff, #6fe0f0, #ffd570);
  opacity: .38; filter: blur(12px);
}

.ribbon {
  position: absolute; top: 16px; width: 46px; height: 60px;
  background: linear-gradient(135deg, #b79bff, #8e6fe0);
  border: 2px solid rgba(255,255,255,.8);
  box-shadow: 0 3px 8px rgba(0,0,0,.18);
}
.ribbon.left { left: -16px; transform: rotate(-18deg); clip-path: polygon(0 0,100% 0,100% 100%,50% 78%,0 100%); }
.ribbon.right { right: -16px; transform: rotate(18deg); clip-path: polygon(0 0,100% 0,100% 100%,50% 78%,0 100%); }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.confetti i { position: absolute; width: 8px; height: 8px; border-radius: 2px; animation: confetti-fall 2.6s ease-in-out infinite; }
.confetti i:nth-child(1) { left: 8%; top: -6px; background: var(--pink); animation-delay: 0s; transform: rotate(20deg); }
.confetti i:nth-child(2) { left: 24%; top: -10px; background: var(--yellow); animation-delay: .3s; }
.confetti i:nth-child(3) { left: 42%; top: -8px; background: var(--cyan); animation-delay: .6s; transform: rotate(40deg); }
.confetti i:nth-child(4) { left: 60%; top: -12px; background: var(--purple); animation-delay: .15s; }
.confetti i:nth-child(5) { left: 76%; top: -6px; background: var(--mint); animation-delay: .45s; transform: rotate(30deg); }
.confetti i:nth-child(6) { left: 90%; top: -10px; background: var(--amber); animation-delay: .75s; }
.confetti i:nth-child(7) { left: 33%; top: -14px; background: var(--pink-deep); animation-delay: .9s; }
.confetti i:nth-child(8) { left: 68%; top: -8px; background: var(--yellow); animation-delay: 1.1s; }

.medal {
  width: 92px; height: 92px; margin: 0 auto 6px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(from 0deg, #ffd570, #fff3c4, #ffb84d, #ffd570);
  border: 4px solid #fff;
  box-shadow: 0 5px 0 #d99b3f, 0 10px 22px rgba(0,0,0,.2), inset 0 2px 0 rgba(255,255,255,.8);
}
.result-mark {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  border: 3px solid rgba(255,255,255,.9);
  text-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.stars { display: flex; justify-content: center; gap: 4px; margin: 10px 0 4px; }
.stars[hidden] { display: none; }
/* 没拿到的那几颗：压成灰，不删掉。位置留着，玩家能看出"差一颗"还是"差两颗" */
/* 没点亮的星：从"实心"变"空心"。
   只改颜色的话，在奶油底上三颗看起来一样重 —— 用填充方式区分，
   和棋盘里"未点亮目标灯是空心槽"是同一套语言 */
.stars[data-stars="1"] span:nth-child(n+2) svg path,
.stars[data-stars="2"] span:nth-child(3) svg path {
  fill: none; stroke: currentColor; stroke-width: 1.9;
}
.stars[data-stars="1"] span:nth-child(n+2),
.stars[data-stars="2"] span:nth-child(3) { color: #d6c9e2; filter: none; }
.star-note { margin: 0 0 8px; font-size: 10.5px; font-weight: 700; color: #a08cc0; }
.star-note[hidden] { display: none; }
.stars span {
  display: block; width: 22px; height: 22px;
  color: var(--yellow); filter: drop-shadow(0 1.5px 0 #e8a63c);
  animation: star-pop .5s ease-out;
}
.stars span svg { width: 100%; height: 100%; display: block; fill: currentColor; }
.stars span:nth-child(1) { animation-delay: .15s; }
.stars span:nth-child(2) { animation-delay: .3s; }
.stars span:nth-child(3) { animation-delay: .45s; }

.result-card h2 {
  margin: 4px 0 6px; font-size: 27px; font-weight: 900; color: var(--ink);
  letter-spacing: .04em;
  text-shadow: 0 1px 0 rgba(255,255,255,.95), 0 3px 0 rgba(178,150,220,.35);
}
/* 以全角标点收尾的居中文字（"过关！""… 新纪录！"）要往右补半个标点。
   字形本身是左重的：27px 下"！"字宽 56px、墨宽只有 8px，右边空 40px，
   而 text-align:center 居中的是字框 —— 于是视觉上永远偏左。
   .34em 是拿 2 倍截图量出来的（墨迹中心 vs 字框中心），不是拍脑袋的数。
   用 em 而不是 px：标题 27px、副标题 12px，同一个比例各自成立。 */
.result-card .punct-tail { transform: translateX(.34em); }
.result-card p { margin: 0 0 18px; font-size: 12px; color: var(--ink-soft); }
.result-actions { display: flex; gap: 10px; }

.candy-btn {
  border: 2px solid rgba(255,255,255,.9); border-radius: 15px;
  padding: 11px 14px; font-size: 14px; font-weight: 900; cursor: pointer;
}
.ghost-btn {
  flex: 1; color: var(--ink);
  background: linear-gradient(135deg, #fff, #f6efe2);
  box-shadow: 0 4px 0 #d7c4a4, 0 6px 12px rgba(0,0,0,.12);
}
.primary-btn {
  flex: 1.3; color: #5a3208;
  background: linear-gradient(135deg, #ffe6a0, #f0b04a 60%, #e09030);
  box-shadow: 0 4px 0 #c07820, 0 8px 16px rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.55);
  text-shadow: none;
}
.candy-btn:active { transform: translateY(3px); }
.ghost-btn:active { box-shadow: 0 1px 0 #d7c4a4; }
.primary-btn:active { box-shadow: 0 1px 0 #c07820; }

.modal.fail .result-card { background: linear-gradient(165deg, #fffdf5, #ffe8ec); }
.modal.fail .result-card::before { background: conic-gradient(from 0deg, #ff8fb8, #ffc1d4, #b79bff, #ff8fb8); }
.modal.fail .result-mark { background: linear-gradient(135deg, #ff8fa8, #ff6f8d); }
.modal.fail .stars span { color: #e4d6ec; filter: none; }
.modal.fail .primary-btn { background: linear-gradient(135deg, #ffe6a0, #f0b04a 60%, #e09030); color: #5a3208; }

.sheet { align-items: flex-end; padding: 0; }
.sheet-card {
  position: relative; width: 100%; max-width: none;
  border-radius: 30px 30px 0 0; padding: 22px 22px calc(env(safe-area-inset-bottom) + 22px);
  background: linear-gradient(165deg, #fffdf5, #f6efe2);
  border: 4px solid #f0d7a4; border-bottom: none;
  box-shadow: 0 -8px 30px rgba(0,0,0,.3);
  animation: sheet-up .35s cubic-bezier(.2,1,.3,1);
}
.sheet-deco {
  text-align: center; color: var(--yellow); font-size: 16px; letter-spacing: .4em;
  /* 居中 + 字距 = 末尾多一格字距，整行被推左半格。text-indent 补回同样宽度，
     居中的视觉中心才真的落回中间（✦ ✧ ✦ 这种对称装饰最藏不住这个偏移） */
  text-indent: .4em;
}
.sheet-card h2 { margin: 6px 0 12px; text-align: center; font-size: 22px; font-weight: 900; color: var(--ink); }
.sheet-card ol { margin: 0 0 18px; padding-left: 22px; color: var(--ink-soft); font-size: 13px; line-height: 1.85; }
.sheet-card ol b { color: var(--ink); }
.wide { width: 100%; }

/* ---------- 模式选择 ---------- */
.mode-list { display: flex; flex-direction: column; gap: 10px; margin: 0 0 16px; }
.mode-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; cursor: pointer; text-align: left;
  border: 2px solid rgba(255,255,255,.95); border-radius: 18px;
  background: linear-gradient(135deg, #fff, #f6efe2);
  box-shadow: 0 4px 0 #d7c4a4, 0 8px 14px rgba(80,50,20,.1);
  transition: transform .12s ease;
}
.mode-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b6a2d6; }
.mode-ic {
  flex: none; width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 19px; color: #5a3208;
  background: linear-gradient(135deg, #ffe6a0, #e8a84a);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.55);
}
.mode-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mode-body b { font-size: 15px; font-weight: 900; color: var(--ink); }
.mode-body small { font-size: 11.5px; color: var(--ink-soft); }
.mode-btn:disabled { opacity: .55; filter: saturate(.5); }
.mode-btn:disabled .mode-ic { background: linear-gradient(135deg, #c9c3d8, #a49bb8); }
/* 当前正在玩的玩法：描金边，不用再靠记忆 */
.mode-btn.on { border-color: #ffc46b; box-shadow: 0 4px 0 #d99b3f, 0 8px 16px rgba(255,150,40,.28); }

/* 非主线模式不显示"第 N 关"，改用模式标签 */
.level-no.mode-tag {
  padding: 0 8px; border-radius: 999px; line-height: 16px;
  background: linear-gradient(135deg, #ffcf8a, #ff9f45);
  color: #4a2c07;
}

/* ---------- 选关 ---------- */

/* 关卡卡片现在是个按钮（点开选关）。button 的默认样式会带来自己的字体和行高，
   不清掉的话 HUD 上这一块会突然跟旁边的 pill 不一样高。 */
.level-card {
  font-family: inherit; color: inherit; text-align: left; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: transform .1s ease;
}
.level-card:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(140,90,30,.28); }
.level-open { flex: none; margin-left: auto; padding-left: 6px; font-size: 15px; line-height: 1; color: #b9a7d6; }
/* 430 以下先收掉箭头：它只是"可点"的暗示，卡片本身有按压反馈，
   但这 20px 正好是关卡名能不能完整显示出来的差别 —— 名字比箭头重要。
   （绝大多数手机都在 390~430，等于这个箭头只在平板和桌面上出现） */
@media (max-width: 430px) { .level-open { display: none; } }

.sheet-levels .sheet-card {
  display: flex; flex-direction: column;
  max-height: 92vh; overflow: hidden;
}
/* 弹层是 flex 列：标题栏和章节导航必须 flex:none，
   否则会被下面的滚动区挤扁，章节按钮只露出半截 */
.ls-bar {
  display: flex; flex: none; align-items: center; justify-content: space-between;
  gap: 10px; margin: 0 2px 8px;
}
.ls-progress { font-size: 11.5px; font-weight: 800; color: var(--ink-soft); }
.ls-legend { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--ink-soft); }
.ls-legend i { width: 9px; height: 9px; border-radius: 3px; margin-left: 4px; }
.ls-legend .lg-done { background: linear-gradient(135deg, #ffd570, #ffa93c); }
.ls-legend .lg-now { background: #fff; box-shadow: inset 0 0 0 2px #ff9f45; }
.ls-legend .lg-lock { background: #d8d2e6; }

.ls-chips {
  display: flex; flex: none; gap: 6px; padding: 2px 2px 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.ls-chips::-webkit-scrollbar { display: none; }
.ls-chip {
  flex: none; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgba(180,160,215,.5); background: #fff;
  font: inherit; font-size: 11px; font-weight: 800; color: var(--ink-soft);
}
.ls-chip:active { transform: translateY(1px); }

/* 200 个格子必须自己滚，不能让整个弹层长到屏幕外 */
/* min-height:0 是 flex 子项能滚动的必要条件，少了它网格会把卡片顶高再整体溢出 */
.ls-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px 2px 10px; -webkit-overflow-scrolling: touch;
}
.ls-chapter + .ls-chapter { margin-top: 12px; }
.ls-chapter-name {
  display: flex; align-items: center; gap: 6px; margin: 0 0 6px 2px;
  font-size: 11.5px; font-weight: 900; color: #8a6fbd; letter-spacing: .1em;
}
.ls-chapter-name em { font-style: normal; font-size: 10px; font-weight: 700; color: #b9a7d6; }
.ls-cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ls-cell {
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  min-height: 46px; padding: 6px 0;
  border: 2px solid rgba(255,255,255,.9); border-radius: 12px;
  background: #fff; box-shadow: 0 2px 0 rgba(160,140,200,.45);
  font: inherit; cursor: pointer; transition: transform .1s ease;
}
.ls-cell b { font-size: 14px; font-weight: 900; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.ls-cell small { font-size: 9px; font-weight: 700; line-height: 1; color: var(--ink-soft); }
.ls-cell.done { background: linear-gradient(160deg, #fff6dc, #ffd98f); box-shadow: 0 2px 0 #d99b3f; }
.ls-cell.done b { color: #8a5a12; }
.ls-cell.done small { color: #a8762c; }
.ls-cell.now { border-color: #ff9f45; box-shadow: 0 0 0 3px rgba(255,159,69,.35), 0 2px 0 #d99b3f; }
.ls-cell.now b { color: #e0662a; }
/* 已解锁但还没打过：底色偏紫一点点，和"当前关"的白底金圈区分开 */
.ls-cell.todo { background: #f8f4ff; border-color: rgba(180,160,215,.55); box-shadow: 0 2px 0 rgba(160,140,200,.3); }
.ls-cell.todo b { color: #6a5a8a; }
.ls-cell.locked { background: #e9e4f2; box-shadow: none; opacity: .7; cursor: not-allowed; }
.ls-cell.locked b { color: #a89cc2; }
.ls-cell.locked small { color: #b3a9c9; }
.ls-cell .ls-sweet { position: absolute; top: 1px; right: 3px; font-size: 8px; font-style: normal; color: #ff9f45; }
.ls-cell.done .ls-sweet { color: #e0662a; }
/* 没解锁的关不该拿一个高饱和的金星去勾人 */
.ls-cell.locked .ls-sweet { color: #c2b8d6; }
.ls-cell:active:not(.locked) { transform: translateY(2px); }

/* ---------- 每日榜 ---------- */
.res-rank {
  margin: 2px 0 14px; padding: 10px 12px; text-align: left;
  border-radius: 16px; background: rgba(255,255,255,.78);
  border: 1.5px solid rgba(180,160,215,.4);
}
.rr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.rr-head b { font-size: 13px; font-weight: 900; color: #e0662a; }
.rr-head small { font-size: 9.5px; color: var(--ink-soft); }
.rr-list {
  display: flex; flex-direction: column; gap: 3px;
  margin: 0; padding: 0; list-style: none;
  max-height: 128px; overflow-y: auto; overscroll-behavior: contain;
}
.rr-list li { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink); }
.rr-list .rr-no { flex: none; width: 16px; text-align: center; font-size: 10px; font-weight: 900; color: #b9a7d6; }
.rr-list em { flex: 1 1 auto; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-list b { font-size: 11px; font-variant-numeric: tabular-nums; }
.rr-list li.me { font-weight: 900; color: #e0662a; }
.rr-list li.me .rr-no { color: #e0662a; }

/* ---------- 通关后的目标清单 ---------- */
/* 200 关打完之后，结算页要回答的问题是"接下来干什么"，
   所以这里是四个还在动的数字，而不是一句祝贺。 */
.res-goal {
  margin: 2px 0 14px; padding: 10px 12px; text-align: left;
  border-radius: 16px; background: rgba(255,255,255,.78);
  border: 1.5px solid rgba(180,160,215,.4);
  display: flex; flex-direction: column; gap: 5px;
}
.goal-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.goal-row span { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.goal-row b { font-size: 12.5px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.goal-row b.hot { color: #e0662a; }
/* "为什么还没有星星"这类说明：不给解释的话，玩家会以为星数是坏的 */
.goal-note { font-size: 9.5px; line-height: 1.5; color: #a891c9; }

/* 刷星入口：一条具体到关号的文字链。它不该抢主按钮 ——
   通关那一刻玩家最可能想做的是"换个玩法"，刷星是之后的事 */
.goal-link {
  align-self: flex-start; margin-top: 2px; padding: 3px 9px;
  border: 1.5px solid rgba(255,159,69,.55); border-radius: 999px;
  background: rgba(255,236,208,.85); color: #b95f16;
  font: inherit; font-size: 10.5px; font-weight: 800; cursor: pointer;
}
.goal-link[hidden] { display: none; }
.goal-link:active { transform: translateY(1px); }
/* 持续更新：打完 200 关的玩家最想问"还有吗"。
   单独一条虚线分隔，别混进上面那堆数字里 */
.goal-update {
  margin-top: 7px; padding-top: 8px;
  font-size: 9.5px; line-height: 1.55; color: #8a76ad;
  border-top: 1px dashed rgba(180,160,215,.45);
}
.goal-update b { color: #e0662a; }

/* ---------- 主线总榜 ---------- */
.sheet-rank .sheet-card { display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }
.rk-bar { display: flex; flex: none; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.rk-me { font-size: 12px; font-weight: 900; color: #e0662a; }
.rk-legend { font-size: 9.5px; color: var(--ink-soft); }
/* min-height:0 才能让列表自己滚，而不是把卡片顶高 */
.rk-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 0 12px; padding: 0; list-style: none;
}
.rk-list li {
  display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink);
  padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.72);
}
.rk-list .rk-no { flex: none; width: 18px; text-align: center; font-size: 10px; font-weight: 900; color: #b9a7d6; }
.rk-list em { flex: 1 1 auto; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-list .rk-sub { flex: none; font-size: 9.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rk-list b { flex: none; font-size: 11px; font-variant-numeric: tabular-nums; }
/* 数字之间要留出呼吸：星数/关数/用时三个数字挤在一起会读成一坨。
   关数和用时各自独立成块，块间 10px —— 比 li 的 7px 行内间距再大一点，
   让"三个数字"和"名字"在视觉上分成两组 */
.rk-rel, .rk-time { flex: none; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink); }
.rk-rel { margin-left: 10px; font-weight: 900; }
.rk-time { margin-left: 8px; color: var(--ink-soft); }
li.me .rk-time { color: #e0662a; }
.rk-list li.me { font-weight: 900; color: #e0662a; background: rgba(255,214,160,.5); }
.rk-list li.me .rk-no, .rk-list li.me .rk-sub { color: #e0662a; }
.rk-list li.rk-tip { justify-content: center; font-size: 11px; color: var(--ink-soft); background: none; }
/* 前三名给点颜色：榜单上"我离前三还差多少"比绝对名次更有驱动力 */
.rk-list li.top1 .rk-no { color: #e0662a; }
.rk-list li.top2 .rk-no { color: #9a8ab8; }
.rk-list li.top3 .rk-no { color: #c08b4a; }

/* 切关时关号先弹一下：数字变了却没有反馈，玩家会怀疑是不是点错了 */
@keyframes lv-pop {
  0% { transform: scale(1.35); opacity: .25; }
  60% { transform: scale(.96); opacity: 1; }
  100% { transform: scale(1); }
}
#lv-num.pop { display: inline-block; animation: lv-pop .34s cubic-bezier(.2,1.3,.4,1); }

/* 系统开了"减少动态效果"就全部收掉：这不是可选项，前庭功能敏感的人会被这类动画劝退 */
@media (prefers-reduced-motion: reduce) {
  #app.enter .hud, #app.enter .dock, #app.enter .pill,
  #app.enter .level-card, #app.enter .round-btn, #app.enter #board,
  #lv-num.pop { animation: none !important; }
}

/* ---------- 动画 ---------- */
@keyframes twinkle-bg { from { opacity: .55; } to { opacity: .95; } }
@keyframes float-twinkle {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: .7; }
  50% { transform: translateY(-8px) rotate(18deg); opacity: 1; }
}
@keyframes shine { 0%, 55% { left: -60%; } 80%, 100% { left: 130%; } }
@keyframes shake-soft {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}
@keyframes badge-pop {
  from { opacity: 0; transform: translate(-50%, -10px) scale(.8); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes card-pop {
  from { opacity: 0; transform: translateY(24px) scale(.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes star-pop {
  from { transform: scale(0) rotate(-60deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes confetti-fall {
  0%, 100% { transform: translateY(0) rotate(0); opacity: .9; }
  50% { transform: translateY(18px) rotate(90deg); opacity: .5; }
}

/* 入场与待机微动：让画面"活着"，但不抢点击 */
@keyframes hud-in {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dock-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes board-in {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes logo-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
@keyframes star-twinkle {
  0%, 100% { opacity: .65; transform: scale(.86) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(18deg); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes tip-hint {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  10%, 68% { opacity: .75; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -5px); }
}
@keyframes tip-fade {
  0% { opacity: 0; }
  12%, 72% { opacity: .85; }
  100% { opacity: 0; }
}

/* 有指针的设备才做 hover 反馈，触屏不会出现粘滞态 */
@media (hover: hover) {
  .round-btn:hover { transform: translateY(-2px); }
  .candy-btn:hover { filter: brightness(1.04); }
  .fire-btn:not(:disabled):hover { filter: brightness(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (min-width: 520px) {
  /* 宽屏（iPad / 桌面）不再把整个应用限宽居中——那样两侧会漏出页面底色。
     背景铺满全屏，只把 HUD 和操作台限宽居中，棋盘按可用空间自由放大。 */
  #app { max-width: none; }
}

/* ---------- 切章过场 ---------- */
/* 章节符号只在这一次出现在 72px 的尺寸上。
   它不能进章节标题行 —— 15px 下"交叉光"读成关闭、"横光"读成折叠，
   那是给玩家错误的功能暗示。放在过场里，它只是"这一章开始了"的信号。 */
.ls-veil {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(30,24,58,.86), rgba(24,19,46,.96));
  border-radius: 0 0 30px 30px;
}
.ls-veil[hidden] { display: none; }
/* 显隐靠 hidden；淡入是一次性关键帧，**不用 fill 保留末态**。
   踩过的坑：先写 `opacity:0` 再靠 animation both 拉到 1，
   一旦动画没跑（减少动态效果、旧内核、被冻结的时间线），过场就永远不出现。
   现在基态就是"可见"，动画只负责第一下的淡入，跑不跑都不影响可用性。 */
.ls-veil.on { animation: veil-bg .18s ease-out; }
@keyframes veil-bg { from { opacity: 0; } }
.ls-veil-mark {
  width: 72px; height: 72px; color: var(--yellow);
  transform: scale(1);
  filter: drop-shadow(0 0 14px rgba(255,196,107,.55));
}
.ls-veil-mark svg { width: 100%; height: 100%; display: block; }
.ls-veil-name {
  font-size: 15px; font-weight: 900; letter-spacing: .22em;
  color: #fff6dd; text-shadow: 0 2px 0 rgba(120,70,20,.45);
}
/* 扩散环：符号"亮起来"的那一下，靠它把注意力从滚动上抢回来 */
.ls-veil-ring {
  position: absolute; width: 96px; height: 96px; margin-top: -26px;
  border-radius: 50%; border: 2px solid rgba(255,196,107,.75);
  opacity: 0;
}
@keyframes veil-mark {
  0%   { transform: scale(.55) rotate(-45deg); opacity: 0; }
  55%  { transform: scale(1.08) rotate(0deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0deg);     opacity: 1; }
}
@keyframes veil-ring {
  0%   { transform: scale(.35); opacity: .85; }
  100% { transform: scale(1.75); opacity: 0; }
}
.ls-veil.on .ls-veil-mark { animation: veil-mark .5s cubic-bezier(.2,1.2,.35,1); }
.ls-veil.on .ls-veil-ring { animation: veil-ring .62s ease-out; }

/* ---------- 加载态：光晶脉冲（替代"读榜单中…"那行死文字） ---------- */
/* 真等待才配得到动效。这个游戏没有全屏加载页 —— 105KB 的页面插一个加载画面
   等于在没有等待的地方造出等待。但"读全服成绩"确实要等，那就让等待有反馈。 */
.crystal-spin {
  display: inline-block; vertical-align: -2px;
  width: 9px; height: 9px; margin-right: 6px;
  background: currentColor; transform: rotate(45deg);
  animation: crystal-beat 1.1s ease-in-out infinite;
}
@keyframes crystal-beat {
  0%, 100% { transform: rotate(45deg) scale(.65); opacity: .45; }
  50%      { transform: rotate(45deg) scale(1); opacity: 1; }
}

/* ---------- 重玩已通关的关：舞台中央一次光晶脉冲 ---------- */
/* 只在"回顾"时出现，不拦点击、不占布局，700ms 后自己消失 */
.crystal-pulse {
  position: absolute; left: 50%; top: 50%; width: 1px; height: 1px;
  pointer-events: none; z-index: 2;
}
.crystal-pulse::before,
.crystal-pulse::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 96px; height: 96px; margin: -48px 0 0 -48px;
  border: 2px solid rgba(255,214,110,.85);
  transform: rotate(45deg) scale(.2);
  animation: crystal-burst .7s cubic-bezier(.2,.7,.3,1) both;
}
.crystal-pulse::after { animation-delay: .12s; border-color: rgba(255,240,200,.55); }
@keyframes crystal-burst {
  0%   { transform: rotate(45deg) scale(.2); opacity: 0; }
  25%  { opacity: .95; }
  100% { transform: rotate(45deg) scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ls-veil.on .ls-veil-mark, .ls-veil.on .ls-veil-ring,
  .crystal-spin, .crystal-pulse::before, .crystal-pulse::after { animation: none !important; }
}

/* ---------- 复盘模式工具条 ---------- */
/* 结算关掉之后，三个去处（下一关/重玩/榜单）并列在棋盘上方。
   用独立的条而不是复用 dock 按钮：dock 那两个的语义是"发射/重试"，
   复盘时改文案硬塞，玩家会怀疑自己点错。 */
.replay-bar {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  z-index: 4; display: flex; gap: 8px;
  padding: 7px 9px; border-radius: 999px;
  background: rgba(255,253,247,.96); border: 1.5px solid #e8c98a;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
  white-space: nowrap;
}
.replay-bar[hidden] { display: none; }
.rb-btn {
  border: 0; cursor: pointer; font: inherit;
  font-size: 12px; font-weight: 900; color: #5a3a18;
  padding: 6px 12px; border-radius: 999px;
  background: #fff;
}
.rb-btn:active { transform: translateY(1px); }
.rb-main { background: linear-gradient(135deg, #ffd570, #ff9255); color: #5a2c05; }
@media (max-width: 374px) { .rb-btn { font-size: 11px; padding: 5px 9px; } }

/* 收起手柄：全宽放在两个主按钮下面。
   为什么要专门一条：右上角的小 × 是"工具"，藏得深还带负面含义（拒绝奖励）；
   "收起 · 复盘棋盘"是动作，写得明明白白，玩家不用猜点了会发生什么 */
.result-fold {
  width: 100%; margin-top: 12px; padding: 11px 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid #e8c98a; border-radius: 15px;
  background: #fffdf7; color: #5a3a18;
  box-shadow: 0 3px 0 #e0c48a;
  font: inherit; font-size: 14px; font-weight: 900; cursor: pointer;
}
.result-fold svg {
  width: 13px; height: 13px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.result-fold:active { transform: translateY(1px); }
.result-fold:active svg { transform: translateY(1px); }

/* ---------- 实时星级（与小游戏同步的新功能，不动现有规则） ---------- */
/* 与 .stage-tip 同位（top:2px 居中），靠 hidden 切换显隐，互斥逻辑在 JS */
.stage-stars[hidden] { display: none !important; }
.stage-stars { display: flex !important; align-items: center; gap: 2px; flex: none; }
.stage-stars span {
  width: 18px; height: 18px; display: block; -webkit-mask: url("../assets/ui/v1/star-off.svg") center / contain no-repeat; mask: url("../assets/ui/v1/star-off.svg") center / contain no-repeat;
  background: linear-gradient(145deg,#eee9de,#a79c8b); filter: drop-shadow(0 1px 1px rgba(75,45,16,.35)); transition: filter .25s ease, transform .25s ease;
}
.stage-stars span.on {
  -webkit-mask-image: url("../assets/ui/v1/star-on.svg"); mask-image: url("../assets/ui/v1/star-on.svg");
  background: linear-gradient(145deg,#fff2a3 0%,#edb52d 54%,#a95c16 100%);
  filter: drop-shadow(0 0 3px rgba(255,205,91,.7));
  animation: star-live 2.6s ease-in-out infinite alternate;
}
.stage-stars span.on:nth-child(2) { animation-delay: .4s; }
.stage-stars span.on:nth-child(3) { animation-delay: .8s; }
@keyframes star-live {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

/* ---------- 章节徽章（章完成结算的大章标，≥48px 才有图形语义） ---------- */
.chapter-badge {
  width: 72px; height: 72px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: var(--amber);
  filter: drop-shadow(0 0 14px rgba(255,196,107,.45));
}
.chapter-badge svg { width: 100%; height: 100%; }

/* ---------- 连锁 banner（精致版即时夸赞） ---------- */
.combo-banner {
  position: absolute; left: 50%; top: 34%; z-index: 6;
  transform: translateX(-50%) scale(.5);
  padding: 9px 22px; border-radius: 999px;
  font-size: 26px; font-weight: 900; letter-spacing: .06em;
  white-space: nowrap; pointer-events: none; line-height: 1.1;
  color: #fff4c8; -webkit-text-fill-color: #fff4c8;
  background: linear-gradient(180deg, rgba(42, 24, 12, .92) 0%, rgba(22, 12, 8, .95) 100%);
  border: 2px solid rgba(255, 214, 120, .88);
  text-shadow: 0 2px 4px rgba(42, 16, 4, .95);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, .55),
    0 0 20px rgba(255, 196, 86, .35),
    inset 0 1px 0 rgba(255, 244, 210, .35);
  opacity: 0;
}
.combo-banner.play { animation: combo-pop 1.4s cubic-bezier(.22,1,.36,1) forwards; }
@keyframes combo-pop {
  0%   { opacity: 0; transform: translateX(-50%) scale(.5); }
  16%  { opacity: 1; transform: translateX(-50%) scale(1.08); }
  24%  { transform: translateX(-50%) scale(1); }
  72%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.22) translateY(-16px); }
}

/* ================= 收藏面板（主题 / 成就 / 图鉴） ================= */
/* 与小游戏的同名面板保持一致的视觉语言：奶白卡 + 暖金点缀 + 可滚动内容区 */

.collect-chips {
  display: flex; gap: 8px; margin: 10px 0 4px;
}
.collect-chip {
  flex: 1 1 0; min-width: 0; padding: 9px 4px; border-radius: 12px; border: 1.5px solid #fff;
  font-size: 12px; color: #5a3a18; background: #fff8e4; cursor: pointer;
  box-shadow: 0 3px 0 #e0c48a;
}
.collect-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 #e0c48a; }
.chip-theme, .chip-ach, .chip-codex { background: #fff8e4; box-shadow: 0 3px 0 #e0c48a; }

.collect-card {
  max-height: 88vh; display: flex; flex-direction: column;
  /* 关键：.sheet 是 flex 容器，卡片作为 flex 子项默认 min-width:auto，
     会被内容（tab 行 / 三列网格）按最小宽撑开 → 整卡超出屏幕右边缘。
     min-width:0 才允许它真正收缩到容器宽。 */
  min-width: 0; max-width: 100%; width: 100%;
  overflow: hidden;
}
.sheet-collect { background: radial-gradient(ellipse at 18% 62%, rgba(75,156,177,.22), transparent 38%), rgba(8,10,23,.76); }
.sheet-collect .collect-card {
  border-color: #9e91aa;
  background: linear-gradient(155deg,#fffdf8 0%,#f4f0ed 52%,#e5e3e9 100%);
  box-shadow: 0 16px 40px rgba(3,7,20,.48),inset 0 1px 0 #fff;
}
.sheet-collect .collect-card:before { border-color: rgba(255,255,255,.75); }
.sheet-collect[data-tab="theme"] .collect-card { border-top-color: #68bcc5; }
.sheet-collect[data-tab="ach"] .collect-card { border-top-color: #d77e9c; background: linear-gradient(155deg,#fffaf7,#f5edf2 58%,#ece6ef); }
.sheet-collect[data-tab="codex"] .collect-card { border-color: #536b95; background: linear-gradient(155deg,#253452,#182239 58%,#11182b); color: #f1edff; }
.sheet-collect[data-tab="codex"] .collect-card h2 { color: #f1edff; }
.sheet-collect[data-tab="codex"] .collect-card:before { border-color: rgba(194,219,255,.28); }
.sheet-collect #btn-close-collect { border-color:#d0c4d2; border-radius:14px; background:linear-gradient(180deg,#fff,#e7e1e9); box-shadow:0 3px 0 #bbb0c0,inset 0 1px #fff; }
.sheet-collect[data-tab="theme"] #btn-close-collect { border-color:#6bbcc1; background:linear-gradient(180deg,#d8fbf3,#6ec9c5); box-shadow:0 3px 0 #478e94,inset 0 1px #fff; color:#174d55; }
.sheet-collect[data-tab="ach"] #btn-close-collect { border-color:#d187a1; background:linear-gradient(180deg,#ffe9f1,#dc8ca8); box-shadow:0 3px 0 #a95375,inset 0 1px #fff; color:#623246; }
.sheet-collect[data-tab="codex"] #btn-close-collect { border-color:#6683aa; background:linear-gradient(180deg,#52738f,#294260); box-shadow:0 3px 0 #15243b,inset 0 1px rgba(255,255,255,.4); color:#f4f8ff; }
.collect-tabs { display: flex; gap: 8px; margin: 6px 0 12px; min-width: 0; }
.collect-tab {
  flex: 1 1 0; min-width: 0; padding: 8px 0; border-radius: 11px; border: 1.5px solid #e6d9f5;
  background: linear-gradient(180deg,#fff,#f1edf2); color: #777081; font-size: 13px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(96,77,110,.12),inset 0 1px #fff;
}
.collect-tab.on { background: linear-gradient(180deg,#d5fbf4,#75c9c8); border-color: #398f99; color: #174c59; font-weight: 800; box-shadow: 0 3px 0 #357983,inset 0 1px #fff; }
.sheet-collect[data-tab="ach"] .collect-tab.on { background: linear-gradient(180deg,#ffe2ee,#e89db8); border-color: #ba5b7f; color: #683149; box-shadow: 0 3px 0 #a24969,inset 0 1px #fff; }
.sheet-collect[data-tab="codex"] .collect-tab { background: linear-gradient(180deg,#344565,#222f49); border-color: #62789c; color: #b9c7df; box-shadow: 0 2px 0 #10182b,inset 0 1px rgba(255,255,255,.14); }
.sheet-collect[data-tab="codex"] .collect-tab.on { background: linear-gradient(180deg,#a8e5ec,#55aebd); border-color: #b9f6f2; color: #163d53; box-shadow: 0 3px 0 #367c90,inset 0 1px #fff; }
/* flex:1 1 0 在没有显式高度的容器里会分到 0 高（实测内容区空着）；
   改成 auto + 明确上限：内容能撑开，超出就滚。 */
.collect-body {
  flex: 1 1 auto; min-width: 0; max-height: 46vh;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 2px;
}
.collect-body::-webkit-scrollbar { width: 0; height: 0; }
.collect-pane { display: block; }

/* 主题色卡 */
.theme-item {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border-radius: 15px; margin-bottom: 9px; cursor: pointer;
  background: linear-gradient(135deg,#fff,#f5f1f3); border: 1.5px solid #cfd9df;
  box-shadow: 0 3px 0 rgba(85,107,128,.15),inset 0 1px #fff;
}
.theme-item.on { border-color: #54afb7; background: linear-gradient(135deg,#f9ffff,#e5f5f2); box-shadow: 0 3px 0 #57999b,inset 0 1px #fff; }
.theme-item.lock { opacity: .62; cursor: not-allowed; }
.theme-swatch {
  width: 46px; height: 46px; border-radius: 10px; flex: 0 0 46px;
  border: 1.5px solid rgba(0,0,0,.12); position: relative; overflow: hidden;
}
.theme-swatch i {
  position: absolute; left: 50%; top: 50%; width: 26%; height: 26%;
  transform: translate(-50%,-50%); border-radius: 50%;
}
.theme-swatch:after { content:""; position:absolute; left:53%; top:49%; width:37%; height:2px; border-radius:99px; background:linear-gradient(90deg,#fff,rgba(255,255,255,.06)); box-shadow:0 0 6px rgba(255,255,255,.75); }
.theme-meta b { display: block; font-size: 13px; color: #3a2a66; }
.theme-meta small { font-size: 11px; color: #8a76ad; }

/* 成就行 */
.ach-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 14px; margin-bottom: 8px; background: linear-gradient(135deg,#fff,#f7f2f8); border: 1.4px solid #e2d9e7;
  box-shadow: 0 3px 0 rgba(96,77,110,.1),inset 0 1px #fff;
}
.ach-row.done { background: linear-gradient(135deg,#fffaf2,#f5eadf); border-color: #e8c69f; }
.ach-emblem { width:34px; height:34px; flex:0 0 34px; filter:drop-shadow(0 2px 2px rgba(56,37,74,.18)); }
.ach-row[data-cat="speed"] { border-left:3px solid #8b70bd; }
.ach-row[data-cat="perfect"] { border-left:3px solid #c85f79; }
.ach-row[data-cat="explore"] { border-left:3px solid #4a9b80; }
.ach-name { font-size: 12.5px; color: #3a2a66; flex: 1; }
.ach-row.done .ach-name { color: #7a4a10; font-weight: 600; }
.ach-desc { font-size: 10px; color: #a08cc0; margin-top: 2px; }
.ach-prog { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ach-bar { width: 54px; height: 4px; border-radius: 2px; background: #e8dff5; overflow: hidden; }
.ach-bar i { display: block; height: 100%; background: #ffb45e; }
.ach-num { font-size: 9.5px; color: #a08cc0; }
.ach-tick { color: #38a97c; font-size: 15px; }

/* 图鉴网格 */
.codex-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.codex-item {
  position: relative; border-radius: 14px; padding: 8px 4px 6px; text-align: center;
  background: linear-gradient(155deg,#242f49,#192238); border: 1.2px solid #586987;
  box-shadow: 0 4px 0 #0d1424,inset 0 1px rgba(255,255,255,.14);
}
.codex-item.done {
  background: linear-gradient(155deg,#344b69,#1c2c46);
  border: 1.6px solid #77c9d1; box-shadow: 0 4px 0 #111b2f,inset 0 1px rgba(255,255,255,.22);
}
.codex-item canvas { display: block; margin: 0 auto; }
.codex-name { font-size: 10px; color: #aeb9ce; margin-top: 2px; }
.codex-item.done .codex-name { color: #eef9ff; font-weight: 700; }
.codex-sub { font-size: 8.5px; color: #858fa6; }
.codex-item.done .codex-sub { color: #8edce0; }

/* ================= 分享链路（v0.1） ================= */

/* 结算分享入口：纯文字胶囊，紧跟两颗主按钮、在收起手柄之上。
   不用右上角圆钮：压住彩带装饰，而且图标认不出是分享。 */
.result-share {
  width: 100%; margin-top: 10px; padding: 9px 0;
  border: 1.5px solid rgba(228,104,154,.5); border-radius: 13px;
  background: rgba(255,248,252,.7); color: #b84d7c;
  font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.result-share:active { transform: translateY(1px); }
.result-share[hidden] { display: none; }

/* 落地卡：同一套奶油渐变 + 白边 + 硬底影，不引入新美术风格 */
.ref-modal { padding: 22px calc(22px + env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left)); }
.ref-card {
  position: relative; width: min(100%, 330px);
  padding: 30px 20px 22px; border-radius: 26px; text-align: center;
  background: linear-gradient(165deg, #fffdf5 0%, #fff2e2 55%, #ffe8f2 100%);
  border: 4px solid #fff;
  box-shadow: 0 8px 0 #a97fd8, 0 16px 36px rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.9);
  animation: card-pop .45s cubic-bezier(.2,1.3,.4,1);
}
.ref-star {
  font-size: 30px; line-height: 1; color: #ffd570;
  text-shadow: 0 2px 8px rgba(255,196,107,.75);
  margin-bottom: 8px;
}
.ref-card h2 {
  margin: 0 0 10px; font-size: 20px; font-weight: 900; color: #3a2a66;
  text-shadow: 0 1px 0 rgba(255,255,255,.95);
}
.ref-score {
  margin: 0 0 18px; font-size: 14px; font-weight: 900; color: #b95f16;
}
.ref-actions { display: flex; gap: 10px; }
.ref-actions .candy-btn {
  flex: 1; height: 48px; min-height: 48px; padding: 0 10px;
  font-size: 15px; line-height: 1; box-sizing: border-box;
}
.ref-note { margin-top: 12px; font-size: 10.5px; color: #8a76ad; }
.ref-note[hidden] { display: none; }

@media (max-height: 640px) {
  .ref-card { padding: 20px 16px 16px; }
  .ref-star { font-size: 24px; margin-bottom: 4px; }
  .ref-card h2 { font-size: 18px; margin-bottom: 6px; }
  .ref-score { margin-bottom: 12px; }
}
