/* 猎人消消乐:念力对决 —— 界面样式(界面窗口)
 * 约定:所有按钮自绘;文字全用 clamp;棋盘边长 --board 不得超出屏幕。 */

:root {
  --ink: #2B2340;                          /* 文字/描边/数字:一律深紫黑 */
  --ink-dim: rgba(43, 35, 64, .68);
  --line: #2B2340;
  --lilac: #E4DCFB;  --lilac-2: #CFC4F7;
  --mint: #C9EFD9;
  --gold: #FFC94D;   --gold-hi: #FFF0B3;   --gold-lo: #F2A81D;
  --card: #fff;
  --shadow: rgba(43, 35, 64, .22);
  --danger: #D93A44;
  --radius: 18px;
  --pad: clamp(4px, 1.4vw, 8px);          /* 棋盘内边距 */
  --topbar-h: 48px;
  --stats-h: 66px;
  /* 棋盘边长:不超过 94vw / 560px / 剩余高度 */
  --board: min(94vw, 560px, calc(100vh - 178px));
}
@supports (height: 100dvh) {
  :root { --board: min(94vw, 560px, calc(100dvh - 178px)); }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--lilac);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Hiragino Sans GB", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none;
}
#app { position: relative; width: 100%; height: 100vh; height: 100dvh; }
[hidden] { display: none !important; }

/* ---------- 页面切换(背景用 assets/bg 的浅色 SVG) ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  overflow-x: hidden; overflow-y: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--lilac) url(assets/bg/game.svg) center / cover no-repeat;
}
#screen-home { background-image: url(assets/bg/home.svg); }
.screen.active { display: flex; animation: scr-in .32s ease both; }
@keyframes scr-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 通用卡片 / 按钮 ---------- */
.panel {
  background: rgba(255, 255, 255, .92);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--shadow), inset 0 3px 0 rgba(255, 255, 255, .9);
}

.btn {
  appearance: none; -webkit-appearance: none;
  border: 3px solid var(--line); outline: 0; margin: 0; cursor: pointer;
  font: inherit; font-weight: 900; letter-spacing: .04em; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 46px; padding: 0 1.2em;
  border-radius: 999px;
  font-size: clamp(15px, 4.4vw, 18px);
  position: relative;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn:focus-visible, .lv-cell:focus-visible { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--line); }
.btn:disabled { cursor: default; }
.btn .btn-ico { display: inline-flex; width: 1.3em; height: 1.3em; flex: none; }
.btn .btn-ico svg { width: 100%; height: 100%; display: block; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 55%, var(--gold-lo) 100%);
  box-shadow: 0 5px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .75);
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .6); }

.btn-secondary {
  background: linear-gradient(180deg, #F3EEFF 0%, var(--lilac-2) 100%);
  box-shadow: 0 5px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .8);
}
.btn-secondary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .6); }

.btn-ghost {
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.btn-ghost:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn-ghost[aria-pressed="false"] { background: #ECE8F6; color: var(--ink-dim); }

.btn .btn-ico img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; pointer-events: none; }
/* 图标按钮:美术 SVG 自带暖黄圆角底 + 描边,按钮本身不再画底 */
.btn-icon {
  width: 48px; min-width: 48px; height: 48px; padding: 0; border: 0; border-radius: 14px;
  background: none; box-shadow: none;
  filter: drop-shadow(0 3px 0 rgba(43, 35, 64, .28));
}
.btn-icon .btn-ico { width: 100%; height: 100%; }
.btn-icon:active { transform: translateY(2px); filter: drop-shadow(0 1px 0 rgba(43, 35, 64, .28)); }
.btn-ghost .btn-ico { width: 1.7em; height: 1.7em; margin-left: -.5em; }

.btn-xl { min-height: clamp(54px, 9vh, 64px); padding: 0 2em; font-size: clamp(19px, 5.6vw, 24px); width: min(100%, 340px); }
.btn-sm { min-height: 42px; font-size: clamp(13px, 3.8vw, 15px); padding: 0 1em; }

/* ================= 首页 ================= */
#screen-home { justify-content: center; }
.home-inner {
  width: min(100%, 460px); margin: auto;
  padding: clamp(10px, 3vh, 28px) 16px clamp(14px, 3vh, 28px);
  display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.4vh, 22px);
}
.logo-wrap { text-align: center; position: relative; }
.logo-img { display: block; width: min(80vw, 340px); height: auto; margin: 0 auto; }
.logo {                                     /* 仅在 logo.svg 加载失败时显示 */
  margin: 0; line-height: 1.05; font-weight: 900; letter-spacing: .06em;
  font-size: clamp(36px, 11vw, 60px); color: var(--gold);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
}
.logo-sub { margin: 6px 0 0; font-weight: 900; letter-spacing: .5em; padding-left: .5em; font-size: clamp(14px, 4.2vw, 20px); color: var(--ink); }
.lv-panel { width: 100%; padding: clamp(10px, 2.2vh, 16px) clamp(10px, 3vw, 16px) clamp(12px, 2.4vh, 18px); }
.panel-title { margin: 0 0 10px; text-align: center; font-size: clamp(14px, 4vw, 17px); letter-spacing: .3em; padding-left: .3em; color: var(--ink); font-weight: 900; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: clamp(6px, 1.8vw, 10px); }
.lv-cell {
  appearance: none; -webkit-appearance: none; border: 3px solid var(--line); outline: 0; font: inherit; color: var(--ink); cursor: pointer;
  aspect-ratio: 1 / 1.08; min-width: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 14px;
  background: linear-gradient(180deg, #F3EEFF 0%, var(--lilac-2) 100%);
  box-shadow: 0 4px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .8);
  transition: transform .08s;
  touch-action: manipulation;
}
.lv-cell:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .6); }
.lv-cell .no { font-weight: 900; font-size: clamp(18px, 5.4vw, 26px); line-height: 1; }
.lv-cell .stars { display: flex; gap: 1px; height: clamp(9px, 2.6vw, 13px); }
.lv-cell .stars img { width: clamp(10px, 2.9vw, 14px); height: 100%; display: block; }
.lv-cell.cleared { background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 100%); }
.lv-cell.current { animation: cur-pulse 1.4s ease-in-out infinite; }
@keyframes cur-pulse { 0%, 100% { box-shadow: 0 4px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .8), 0 0 0 0 rgba(43, 35, 64, 0); }
  50% { box-shadow: 0 4px 0 var(--line), inset 0 2px 0 rgba(255, 255, 255, .8), 0 0 0 5px rgba(255, 201, 77, .9); } }
.lv-cell:disabled { background: #E4E0F3; box-shadow: 0 4px 0 rgba(43, 35, 64, .45); border-color: rgba(43, 35, 64, .5); cursor: default; color: rgba(43, 35, 64, .55); }
.lv-cell .lock { width: clamp(22px, 6.4vw, 30px); height: clamp(22px, 6.4vw, 30px); display: block; }
.lv-cell .lock img { width: 100%; height: 100%; display: block; }
.toggles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ================= 游戏页 ================= */
#screen-game { justify-content: center; overflow: hidden; }
.game-inner {
  position: relative;
  width: 100%; max-width: 600px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 8px 0;
}
.topbar {
  width: var(--board); height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.lv-title { text-align: center; min-width: 0; flex: 1; }
.lv-no { font-weight: 900; font-size: clamp(17px, 5vw, 23px); line-height: 1.1; color: var(--ink); }
.lv-name { font-size: clamp(11px, 3.2vw, 14px); color: var(--ink-dim); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.stats {
  width: var(--board); height: var(--stats-h);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: center; gap: 8px; padding: 0 clamp(8px, 2.6vw, 14px);
}
.stat { text-align: left; min-width: 0; }
.stat-r { text-align: right; }
.stat-mid { text-align: center; }
.stat-k { font-size: clamp(11px, 3.2vw, 13px); color: var(--ink-dim); font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.stat-k b { color: var(--ink); font-weight: 900; }
.stat-v { font-size: clamp(22px, 6.8vw, 32px); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.stat-v.bump { animation: bump .28s ease; }
.stat-v.low { color: var(--danger); animation: low-pulse 1s ease-in-out infinite; }
@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes low-pulse { 50% { transform: scale(1.1); } }
.bar-wrap { position: relative; margin-top: 6px; }
.bar { height: clamp(12px, 3.2vw, 16px); border-radius: 999px; background: #fff; border: 2.5px solid var(--line); overflow: hidden; position: relative; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #8EDDB0, var(--gold)); transition: width .35s ease; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6); }
.bmark {
  position: absolute; top: 50%; width: clamp(17px, 5vw, 22px); height: clamp(17px, 5vw, 22px);
  transform: translate(-85%, -50%); z-index: 2; pointer-events: none; opacity: .95;
  filter: drop-shadow(0 1px 0 rgba(43, 35, 64, .35));
}
#mark2 { transform: translate(-50%, -50%); }
.bmark img { width: 100%; height: 100%; display: block; }
.bmark.pending { opacity: .6; }
.bmark.pending img { filter: saturate(.25) brightness(1.05); }
.bmark.on img { filter: none; }
.bmark.pop { animation: mark-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes mark-pop { 0% { transform: translate(-50%, -50%) scale(.4); } 60% { transform: translate(-50%, -50%) scale(1.5); } 100% { transform: translate(-50%, -50%) scale(1); } }
#mark3.pop { animation-name: mark-pop3; }
@keyframes mark-pop3 { 0% { transform: translate(-85%, -50%) scale(.4); } 60% { transform: translate(-85%, -50%) scale(1.5); } 100% { transform: translate(-85%, -50%) scale(1); } }
.bar.done .bar-fill { background: linear-gradient(90deg, var(--gold-hi), var(--gold-lo)); }

/* ---------- 关卡目标栏(2.0) ---------- */
#screen-game.has-goals { --board: min(94vw, 560px, calc(100vh - 232px)); }
@supports (height: 100dvh) { #screen-game.has-goals { --board: min(94vw, 560px, calc(100dvh - 232px)); } }
.goals {
  width: var(--board); min-height: 44px;
  display: flex; flex-wrap: nowrap; gap: 6px; justify-content: center; align-items: stretch;
}
.goal-settle { flex: none; min-height: 44px; padding: 0 1em; font-size: clamp(14px, 4vw, 16px); animation: settle-in .3s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes settle-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.goal {
  --p: 0%;
  position: relative; flex: 1 1 auto; min-width: 0; max-width: 50%;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 5px; min-height: 44px;
  background: rgba(255, 255, 255, .92);
  border: 2.5px solid var(--line); border-radius: 14px;
  box-shadow: 0 3px 0 var(--shadow), inset 0 3px 0 rgba(255, 255, 255, .9);
  overflow: hidden;
}
.goal::after {                                    /* 底部细进度条 */
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p);
  background: linear-gradient(90deg, #8EDDB0, var(--gold)); transition: width .35s ease;
}
.goal .gi { position: relative; flex: none; width: clamp(26px, 8vw, 34px); height: clamp(26px, 8vw, 34px); display: block; }
.goal .gi .char { border-width: 2px; box-shadow: 0 2px 0 rgba(43, 35, 64, .25); }
.goal .gi .char-letter { font-size: clamp(11px, 3.4vw, 15px); }
.goal .gi > svg, .goal .gi > img { width: 100%; height: 100%; display: block; }
.goal .gi-txt {
  display: flex; align-items: center; justify-content: center; border-radius: 22%; border: 2px solid var(--line);
  font-weight: 900; font-size: clamp(12px, 3.6vw, 15px); color: var(--ink);
  background: linear-gradient(145deg, var(--gold-hi), var(--gold));
}
.goal .gt { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.goal .gl { font-size: clamp(10px, 2.9vw, 12px); font-weight: 800; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal .gn { font-size: clamp(13px, 4vw, 17px); font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal .gok {
  display: none; position: absolute; right: 4px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  align-items: center; justify-content: center; font-size: 12px; font-weight: 900; line-height: 1;
  color: var(--ink); background: #8EDDB0; border: 2px solid var(--line);
}
.goal.done { background: #EAF9F0; }
.goal.done .gok { display: flex; }
.goal.bump { animation: goal-bump .3s ease; }
@keyframes goal-bump { 40% { transform: scale(1.06); } }
.goals.many { gap: 4px; }
.goals.many .goal { padding: 4px 4px 4px 4px; gap: 4px; }
.goals.many .gi { width: clamp(22px, 6.4vw, 28px); height: clamp(22px, 6.4vw, 28px); }
.goals.many .gl { display: none; }
.goals.many .gn { font-size: clamp(12px, 3.5vw, 15px); }
.goals.many .gok { right: 2px; top: 2px; width: 15px; height: 15px; font-size: 10px; }

/* ---------- 特殊棋子 / 障碍(降级:CSS 徽标 + 文字角标;素材到了自动换 SVG) ---------- */
.char .sp, .char .ob, .char .hp, .char .cell-glyph, .char .crate-mark { pointer-events: none; }
.sp {
  position: absolute; right: -6%; bottom: -6%; width: 46%; height: 46%; z-index: 2;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  font-weight: 900; line-height: 1; color: var(--ink);
  font-size: calc(var(--board) / 8 * .3);
  background: radial-gradient(circle at 35% 30%, #fff 0, #FFF0B3 45%, #FFC94D 100%);
  border: 2px solid var(--ink); box-shadow: 0 2px 0 rgba(43, 35, 64, .3);
  animation: sp-pulse 1.1s ease-in-out infinite;
}
.sp.has-img { background: none; border: 0; box-shadow: none; border-radius: 0; }
.sp img { width: 100%; height: 100%; display: block; }
.sp-blast { background: radial-gradient(circle at 35% 30%, #fff 0, #FFD0B0 45%, #FF8A4D 100%); }
@keyframes sp-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.piece.is-special .char { box-shadow: 0 0 0 2px #fff, 0 0 10px 2px var(--glow, #fff), inset 0 3px 0 rgba(255, 255, 255, .55), inset 0 -4px 0 rgba(43, 35, 64, .18); }
.piece .char { overflow: visible; }                 /* 让徽标能探出底板一点;img 被底板圆角裁切由下面的 clip 保证 */
.piece .char > img { clip-path: inset(0 round 18%); }

.char.cell-core { background: radial-gradient(circle at 50% 45%, #fff 0, #E2C4FA 38%, #9B4DDB 80%); }
.cell-core .cell-glyph { font-size: calc(var(--board) / 8 * .56); color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; animation: sp-pulse 1.3s ease-in-out infinite; }
.char.cell-gem { background: radial-gradient(circle at 35% 28%, #fff 0, #BFE8FA 35%, #2FA8DB 100%); }
.cell-gem .cell-glyph { font-size: calc(var(--board) / 8 * .5); color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.char.cell-core.has-img, .char.cell-gem.has-img, .char.crate.has-img { background: none; border-color: transparent; box-shadow: none; }
.char.has-img > img { position: absolute; inset: 0; left: 0; bottom: auto; width: 100%; height: 100%; transform: none; clip-path: none; }

.char.crate { background: linear-gradient(145deg, #E8C9A0, #B98250); }
.char.crate-1 { background: linear-gradient(145deg, #F0D9B8, #CFA06A); }
.char.crate-3 { background: linear-gradient(145deg, #D9B07C, #9A6A3C); }
.crate-mark { font-size: calc(var(--board) / 8 * .46); font-weight: 900; color: var(--ink); opacity: .75; }
.crate .hp {                                         /* 素材不含层数:角标探出右下角外沿,不压钢带/护角(32px、48px 下对比后定的) */
  position: absolute; right: -9%; bottom: -9%; z-index: 4; min-width: 32%; height: 32%; padding: 0 4%;
  display: flex; align-items: center; justify-content: center; border-radius: 999px;
  font-size: calc(var(--board) / 8 * .26); font-weight: 900; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); line-height: 1;
}
.ob { position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none; }
.ob-chain { background: repeating-linear-gradient(135deg, rgba(120, 130, 150, .55) 0 5px, rgba(230, 232, 238, .35) 5px 10px); box-shadow: inset 0 0 0 2px rgba(43, 35, 64, .65); }
.ob-barrier { background: radial-gradient(circle, rgba(226, 196, 250, .25) 30%, rgba(155, 77, 219, .55) 100%); box-shadow: inset 0 0 0 2px #9B4DDB, 0 0 8px 2px rgba(155, 77, 219, .5); animation: sp-pulse 1.6s ease-in-out infinite; }
.ob.has-img { background: none; box-shadow: none; animation: none; }
.ob > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.obhp {
  position: absolute; left: 3%; top: 3%; min-width: 30%; height: 30%; padding: 0 4%;
  display: flex; align-items: center; justify-content: center; border-radius: 999px;
  font-size: calc(var(--board) / 8 * .22); font-weight: 900; color: var(--ink); line-height: 1;
  background: #fff; border: 2px solid var(--ink);
}

/* ---------- 棋盘 ---------- */
.board-frame {
  position: relative;
  width: var(--board); height: var(--board);
  border-radius: clamp(14px, 3.4vw, 22px);
  background: rgba(255, 255, 255, .86);
  border: 3px solid var(--line);
  box-shadow: 0 5px 0 var(--shadow), inset 0 3px 0 rgba(255, 255, 255, .9);
  flex: none;
}
.board {
  position: absolute; inset: var(--pad);
  display: grid; grid-template-columns: repeat(8, 1fr); grid-auto-rows: auto;
}
.slot { aspect-ratio: 1; }
.slot::before { content: ""; display: block; width: 94%; height: 94%; margin: 3%; border-radius: 22%; background: rgba(43, 35, 64, .14); }
.slot.alt::before { background: rgba(43, 35, 64, .07); }

.pieces {
  position: absolute; inset: var(--pad); clip-path: inset(0 -10px -10px -10px);
  touch-action: none; cursor: pointer;
}
.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  padding: .55%; will-change: transform;
}
.pface { width: 100%; height: 100%; border-radius: 24%; position: relative; }
.piece.sel { z-index: 3; }
.piece.sel .pface { animation: breathe .9s ease-in-out infinite; outline: 3px solid var(--ink); outline-offset: 1px; box-shadow: 0 0 14px 4px var(--glow, #fff); }
@keyframes breathe { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.08); } }
.piece.hint .pface { animation: hint-wig .8s ease-in-out infinite; }
@keyframes hint-wig { 0%, 100% { transform: scale(1); filter: none; } 50% { transform: scale(1.1); filter: brightness(1.3); } }

/* 角色底板:STYLE.md §2。--col=config.color、--glow=config.glow;img 贴底略放大,肩部被底板裁掉 */
.char {
  position: absolute; inset: 0; border-radius: 22%; overflow: hidden;
  border: clamp(2px, calc(var(--board) / 8 * .06), 3px) solid #2B2340;   /* 小格 2px,大格 3px */
  background:
    radial-gradient(circle at 30% 22%, var(--glow, #fff) 0, transparent 60%),
    linear-gradient(145deg, var(--glow, #fff) 0%, var(--col, #888) 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .55),
    inset 0 -4px 0 rgba(43, 35, 64, .18),
    0 3px 0 rgba(43, 35, 64, .25);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.char-letter {
  font-weight: 900; color: #fff; line-height: 1;
  font-size: calc(var(--board) / 8 * .44);
  text-shadow: 0 2px 0 #2B2340, 0 0 6px rgba(43, 35, 64, .35);
}
.char img {
  position: absolute; left: 50%; bottom: -4%; width: 106%; transform: translateX(-50%);
  display: block; pointer-events: none; -webkit-user-drag: none;
}

.fx-layer { position: absolute; inset: var(--pad); pointer-events: none; z-index: 5; overflow: visible; }
.fx-float {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font-weight: 900; color: var(--ink);
  -webkit-text-stroke: 4px #fff; paint-order: stroke fill;
  font-size: clamp(14px, 4vw, 20px); animation: fx-float 0.8s ease-out forwards;
}
.fx-float.big { font-size: clamp(20px, 6vw, 32px); color: #C4540A; animation-duration: 1s; }
@keyframes fx-float { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }

.toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.8); z-index: 8;
  padding: .5em 1.2em; border-radius: 999px; pointer-events: none; opacity: 0; white-space: nowrap;
  background: #fff; border: 3px solid var(--line); box-shadow: 0 3px 0 var(--line);
  font-weight: 900; font-size: clamp(16px, 5vw, 22px); color: var(--ink);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- 教学提示条 ---------- */
.intro {
  appearance: none; -webkit-appearance: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  position: absolute; left: 50%; top: 56px; margin-left: calc(min(92vw, 520px) / -2); z-index: 12;
  width: min(92vw, 520px); display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px 8px 8px;
  background: #FFF0B3; border: 3px solid var(--line); border-radius: 14px; box-shadow: 0 4px 0 var(--shadow);
  font-size: clamp(12px, 3.5vw, 14px); font-weight: 700; line-height: 1.4;
  animation: intro-in .25s ease both;
}
@keyframes intro-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.intro-tag { flex: none; padding: 1px 8px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 900; font-size: .9em; }
.intro-text { flex: 1; min-width: 0; }
.intro-x { flex: none; opacity: .5; font-weight: 900; }

/* ---------- 暂停遮罩 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;                 /* 铺满视口:桌面端点两侧空白也算「点遮罩」 */
  display: flex; align-items: center; justify-content: center;
  background: rgba(43, 35, 64, .38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: scr-in .2s ease both;
}
.modal {
  width: min(86vw, 320px); padding: clamp(16px, 3vh, 26px) 20px;
  display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  background: linear-gradient(180deg, #fff, var(--lilac));
}
.modal-title { margin: 0 0 2px; text-align: center; font-size: clamp(22px, 6.4vw, 30px); letter-spacing: .3em; padding-left: .3em; color: var(--ink); }

.settle-title { letter-spacing: .15em; font-size: clamp(20px, 5.8vw, 26px); }
.settle-msg { margin: 0; text-align: center; line-height: 1.6; font-weight: 700; font-size: clamp(13px, 3.8vw, 15px); color: var(--ink); }
.settle-msg b { font-weight: 900; font-variant-numeric: tabular-nums; }

/* ================= 结算页 ================= */
#screen-result { justify-content: center; align-items: center; }
.result-inner { width: min(100%, 460px); margin: auto; padding: 16px; position: relative; }
.result-card { padding: clamp(18px, 4vh, 32px) clamp(14px, 4vw, 26px); text-align: center; display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.8vh, 14px); }
.result-title { margin: 0; font-size: clamp(34px, 10vw, 52px); font-weight: 900; letter-spacing: .15em; padding-left: .15em; line-height: 1.1; color: var(--ink); }
.result-card.win .result-title { color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.result-level { font-size: clamp(13px, 3.8vw, 16px); color: var(--ink-dim); font-weight: 700; letter-spacing: .1em; }
.result-stars { display: flex; gap: clamp(6px, 2vw, 12px); justify-content: center; align-items: flex-end; min-height: clamp(52px, 15vw, 84px); }
.result-stars .rstar { width: clamp(46px, 14vw, 78px); height: clamp(46px, 14vw, 78px); opacity: 0; transform: scale(0) rotate(-40deg); }
.result-stars .rstar:nth-child(2) { margin-bottom: clamp(8px, 2.4vw, 16px); }
.result-stars .rstar.off { opacity: 1; transform: none; }
.result-stars .rstar.on { animation: star-pop .55s cubic-bezier(.2, 1.5, .4, 1) forwards; animation-delay: var(--d, 0s); }
@keyframes star-pop { 0% { opacity: 0; transform: scale(0) rotate(-40deg); } 70% { opacity: 1; transform: scale(1.25) rotate(8deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.rs-k { font-size: clamp(12px, 3.4vw, 14px); color: var(--ink-dim); font-weight: 800; letter-spacing: .3em; padding-left: .3em; }
.rs-v { font-size: clamp(40px, 12vw, 60px); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--ink); }
.result-sub { font-size: clamp(13px, 3.8vw, 16px); color: var(--ink-dim); font-weight: 700; min-height: 1.4em; line-height: 1.5; }
.result-sub .newbest { color: #C4540A; font-weight: 900; }
.result-todo { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.result-todo:empty { display: none; }
.todo-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 12px; background: #fff; border: 2.5px solid var(--line); font-weight: 800; font-size: clamp(12px, 3.6vw, 15px); }
.todo-row.ok { background: #EAF9F0; }
.todo-row .tn { font-variant-numeric: tabular-nums; }
.result-btns { display: flex; flex-direction: column; gap: 12px; width: min(100%, 280px); margin-top: 4px; }

/* ---------- 小屏 / 矮屏 ---------- */
@media (max-height: 600px) {
  :root { --topbar-h: 40px; --stats-h: 56px; --board: min(94vw, 560px, calc(100vh - 150px)); }
  .game-inner { gap: 6px; padding: 4px 0; }
  .btn-icon { width: 42px; min-width: 42px; height: 42px; }
  #screen-game.has-goals { --board: min(94vw, 560px, calc(100vh - 198px)); }
  .goal { min-height: 38px; }
}
@media (max-width: 340px) { .btn { padding: 0 .9em; } }

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