/* math.css —— 抓口算妖怪：对局场景样式（MATH-4 §2.5 布局；math/CONTRACT.md §7）。
   题面组件（.mx-math）在 math-face.css、软键盘（.mx-keypad）在 math-keypad.css，这里 @import 进来，index.html 只需挂本文件。
   场景规则只作用于 .mx-scene--math 之下；飞进血条的小妖（.mx-mathp__minion）挂在 body；结算页的口算分支（.mx-result__math* / .mx-result__fight*）在文末。
   Boss 登场（.mx-mathp__monster.is-intro）/ 战果卡（.mx-mathp__verdict）/ 进度点分组（.mx-mathp__dotgroup）见各自小节。
   颜色 / 圆角 / 阴影 / 字体一律取 tokens.css 的变量；动效只动 transform / opacity / filter。 */

@import url('math-face.css');
@import url('math-keypad.css');

.mx-scene--math {
  font-family: var(--font-body);
  color: var(--ink);
}

/* ---------------------------------------------------------------- HUD：进度点 + 整局太阳 + Boss 面板 */

.mx-scene--math .mx-hud__streak { display: none; }
/* 左边只有返回键，别跟中间分空间：进度点 + 太阳 + Boss 面板三个药丸要排得下 */
.mx-scene--math .mx-hud__left { flex: 0 0 auto; }
.mx-scene--math .mx-hud__center { flex: 1 1 auto; gap: 8px; }

.mx-mathp__progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6);
}
.mx-mathp__dots { display: inline-flex; align-items: center; gap: 3px; }
.mx-mathp__dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ink-soft) 55%, transparent);
  background: transparent;
  transition: transform var(--dur-micro) var(--ease-bounce), background-color var(--dur-micro), border-color var(--dur-micro);
}
.mx-mathp__dot.is-hit { background: var(--ok); border-color: var(--ok); }
.mx-mathp__dot.is-weak { background: var(--warn); border-color: var(--warn); }
.mx-mathp__dot.is-miss { background: var(--bad); border-color: var(--bad); }
.mx-mathp__dot.is-demo { background: var(--sky-accent); border-color: var(--sky-accent); }
/* 巡山题：天蓝（不是绿 / 红），做错的空心描珊瑚边 */
.mx-mathp__dot.is-patrol { background: var(--sky-accent); border-color: var(--sky-accent); }
.mx-mathp__dot.is-patrol-miss { background: color-mix(in srgb, var(--sky-accent) 40%, transparent); border-color: var(--bad); }
/* 评分战斗的点按 Boss 分组：同一场连成一段药丸；当前场描珊瑚边，还没打的场虚线 */
.mx-mathp__dotgroup {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 3px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--coral) 30%, transparent);
  background: color-mix(in srgb, var(--coral) 9%, transparent);
}
.mx-mathp__dotgroup.is-live { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 16%, transparent); }
.mx-mathp__dotgroup.is-ahead { border-style: dashed; background: transparent; }
.mx-mathp__dot.is-current {
  border-color: var(--coral);
  background: color-mix(in srgb, var(--coral) 45%, transparent);
  animation: mx-breathe 1.8s var(--ease-out) infinite;
}
.mx-mathp__count { font-family: var(--font-display); font-size: 19px; line-height: 1; color: var(--ink); white-space: nowrap; }
.mx-mathp__count small { font-size: 14px; color: var(--ink-soft); }

/* 整局太阳：沿目标线从东到西；旁边是秒表 */
.mx-mathp__clockwrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6);
}
.mx-mathp__sun {
  position: relative;
  width: 92px;
  aspect-ratio: 100 / 16;
  pointer-events: none;
}
.mx-mathp__sun svg { width: 100%; height: 100%; overflow: visible; }
.mx-mathp__sun-track {
  fill: none;
  stroke: color-mix(in srgb, var(--wood) 45%, transparent);
  stroke-width: 1.4;
  stroke-dasharray: 2.4 2.6;
  stroke-linecap: round;
}
.mx-mathp__sun-trail { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; opacity: .85; }
.mx-mathp__sun-body { transition: opacity 600ms var(--ease-out); }
.mx-mathp__sun-core { fill: var(--gold-2); stroke: var(--gold); stroke-width: .9; }
.mx-mathp__sun-halo { fill: color-mix(in srgb, var(--gold-2) 45%, transparent); }
.mx-mathp__sun-rays { stroke: var(--gold); stroke-width: 1.1; stroke-linecap: round; transform-box: fill-box; transform-origin: center; }
.mx-mathp__sun.is-running .mx-mathp__sun-rays { animation: mx-mathp-sun-spin 14s linear infinite; }
@keyframes mx-mathp-sun-spin { to { transform: rotate(360deg); } }
.mx-mathp__sun.is-idle .mx-mathp__sun-body { opacity: .55; }
.mx-mathp__sun.is-expired .mx-mathp__sun-body { opacity: .35; }
.mx-mathp__sun.is-expired .mx-mathp__sun-trail { opacity: .4; }
.mx-mathp__clock { font-size: 18px; line-height: 1; color: var(--ink); min-width: 3.2em; text-align: right; }
.mx-mathp__sun.is-expired + .mx-mathp__clock { color: var(--ink-soft); }

/* Boss 面板：心 / 肚皮字 / 血条 / 灰盾 / 「还差 N 只」 */
.mx-mathp__boss {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--coral) 10%, rgba(255, 255, 255, .55));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6);
  white-space: nowrap;
  flex: 0 0 auto;
}
.mx-mathp__clockwrap { flex: 0 0 auto; }
.mx-mathp__boss.is-enter { animation: mx-mathp-boss-in 640ms var(--ease-bounce) both; }
@keyframes mx-mathp-boss-in {
  0%   { transform: translateY(-10px) scale(.8); opacity: 0; }
  55%  { transform: translateY(2px) scale(1.14); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
/* 「Boss 2/4」：本局第几场 / 共几场 */
.mx-mathp__boss-idx {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.2;
}
.mx-mathp__boss-idx .mx-num { font-size: 15px; }
.mx-mathp__boss.is-bump { animation: mx-mathp-boss-bump 420ms var(--ease-bounce) both; }
@keyframes mx-mathp-boss-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.mx-mathp__hearts { display: inline-flex; gap: 1px; }
.mx-mathp__heart { display: inline-flex; width: 16px; height: 16px; color: var(--coral); }
.mx-mathp__heart svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
.mx-mathp__heart.is-empty { color: color-mix(in srgb, var(--ink-soft) 40%, transparent); }
.mx-mathp__boss-glyph {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--paper);
  border: 1px solid var(--card-stroke);
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
}
.mx-mathp__hp { display: inline-flex; gap: 3px; }
.mx-mathp__hp-cell {
  width: 12px;
  height: 18px;
  border-radius: 4px;
  background: var(--coral);
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--coral), var(--ink) 25%);
  transition: background-color 240ms var(--ease-out), transform 240ms var(--ease-bounce);
}
.mx-mathp__hp-cell.is-hit {
  background: color-mix(in srgb, var(--ink-soft) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-soft) 35%, transparent);
  transform: scaleY(.7);
}
.mx-mathp__shield { display: inline-flex; gap: 3px; }
.mx-mathp__shield-cell {
  width: 12px;
  height: 18px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink-soft) 45%, var(--paper));
  border: 1.5px dashed color-mix(in srgb, var(--ink-soft) 70%, transparent);
  animation: mx-mathp-shield-in 320ms var(--ease-bounce) both;
}
@keyframes mx-mathp-shield-in {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.mx-mathp__shield-cell.is-break { animation: mx-mathp-shield-break 360ms ease-in both; }
@keyframes mx-mathp-shield-break {
  0%   { transform: scale(1) rotate(0); opacity: 1; }
  40%  { transform: scale(1.25) rotate(-10deg); opacity: 1; }
  100% { transform: scale(.2) rotate(25deg) translateY(10px); opacity: 0; }
}
.mx-mathp__need { font-family: var(--font-display); font-size: 16px; color: var(--coral-text); }

/* ---------------------------------------------------------------- 主体骨架 */

.mx-mathp__body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px clamp(16px, 3vw, 40px) 12px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- 题卡 + 旁边的小妖 */

.mx-mathp__top {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.mx-mathp__card {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 128px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px 22px 26px;
  border-radius: var(--radius-lg);
  transition: opacity 240ms var(--ease-in);
}
.mx-mathp__card.is-entering { animation: mx-mathp-card-in var(--dur-card) var(--ease-out) both; }
.mx-mathp__card.is-out { opacity: .35; }
@keyframes mx-mathp-card-in {
  from { transform: translateY(-22px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
/* 巡山题：卡片底色偏灰，角标「巡山」 */
.mx-mathp__card.is-patrol { background-color: color-mix(in srgb, var(--paper-2) 80%, transparent); }
.mx-mathp__tag {
  position: absolute;
  left: 14px;
  top: -12px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--sky-accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.2;
  box-shadow: var(--shadow-soft);
}
.mx-mathp__card.is-patrol .mx-mathp__tag { background: var(--ink-soft); }
.mx-mathp__card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mx-mathp__face { width: 100%; text-align: center; overflow: hidden; line-height: 1.2; }
.mx-mathp__face .mx-math { justify-content: center; max-width: 100%; }
.mx-mathp__hint {
  font-family: var(--font-kai);
  font-size: 20px;
  line-height: 1.4;
  color: var(--ink-soft);
  text-align: center;
}
.mx-mathp__answer {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--bad-text);
  opacity: .75;
}
.mx-mathp__speak { flex: 0 0 auto; color: var(--sky-accent); }

/* 每题超时线：题卡底边一根从满到空的线（3/4 处变珊瑚，走完变灰） */
.mx-mathp__timer {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 9px;
  height: 5px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--wood) 22%, transparent);
  overflow: hidden;
  opacity: 0;
  transition: opacity 200ms;
}
.mx-mathp__timer.is-running, .mx-mathp__timer.is-expired { opacity: 1; }
.mx-mathp__timer-bar {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: var(--gold);
  transform-origin: 0 50%;
  transform: scaleX(1);
}
.mx-mathp__timer.is-warn .mx-mathp__timer-bar { background: var(--coral); }
.mx-mathp__timer.is-expired .mx-mathp__timer-bar { background: color-mix(in srgb, var(--ink-soft) 40%, transparent); transform: scaleX(1); }

/* 反馈浮标：「捉住一只小妖！」/「差一点！是 12」压在题卡下边缘 */
.mx-mathp__caption {
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translate(-50%, 8px);
  max-width: 96%;
  padding: 8px 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 1px solid var(--card-stroke);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 260ms var(--ease-out);
  z-index: 2;
}
.mx-mathp__caption b { font-family: var(--font-math); font-weight: 600; font-size: 26px; }
.mx-mathp__caption small { display: block; font-size: 15px; color: var(--ink-soft); }
.mx-mathp__caption.is-on { opacity: 1; transform: translate(-50%, 50%); }
.mx-mathp__caption.is-ok {
  color: var(--ok-text);
  background: color-mix(in srgb, var(--ok) 14%, var(--paper));
  border-color: color-mix(in srgb, var(--ok) 40%, var(--card-stroke));
}
.mx-mathp__caption.is-bad { color: var(--bad-text); }
.mx-mathp__caption.is-bad b { color: var(--ok-text); }

/* 小妖：站在题卡右侧；出场弹一下，关笼时被网住，逃跑时滑出画面；巡山题是灰色影子 */
.mx-mathp__monster {
  flex: 0 0 auto;
  position: relative;
  width: 104px;
  height: 104px;
  margin-bottom: -4px;
  transition: opacity 200ms var(--ease-out), filter 200ms;
}
.mx-mathp__monster-el { display: block; filter: drop-shadow(0 6px 10px rgba(60, 50, 30, .18)); }
.mx-mathp__monster.is-patrol { filter: grayscale(1); opacity: .55; }
.mx-mathp__monster.is-arrive { animation: mx-mathp-monster-in 420ms var(--ease-bounce) both; }
@keyframes mx-mathp-monster-in {
  from { transform: translateY(14px) scale(.6); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
/* Boss 登场：从右侧跳过来，放大 1.3× 停一下再落定；肚皮字同时亮出 */
.mx-mathp__monster.is-intro { animation: mx-mathp-monster-intro 900ms var(--ease-out) both; z-index: 3; }
@keyframes mx-mathp-monster-intro {
  0%   { transform: translate(160px, 10px) scale(.5) rotate(8deg); opacity: 0; }
  30%  { transform: translate(-8px, -14px) scale(1.3) rotate(-4deg); opacity: 1; }
  62%  { transform: translate(-4px, -10px) scale(1.3) rotate(0); opacity: 1; }
  82%  { transform: translate(0, 4px) scale(.94); }
  100% { transform: translate(0, 0) scale(1); opacity: 1; }
}
.mx-mathp__monster.is-intro .mx-monster__glyph { animation: mx-mathp-glyph-flash 900ms var(--ease-out) both; transform-box: fill-box; transform-origin: center; }
.mx-mathp__monster.is-intro .mx-monster__belly { animation: mx-mathp-belly-flash 900ms var(--ease-out) both; }
@keyframes mx-mathp-glyph-flash {
  0%, 30% { opacity: 0; transform: scale(.4); }
  55%  { opacity: 1; transform: scale(1.35); }
  75%  { transform: scale(1); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes mx-mathp-belly-flash {
  0%, 30% { opacity: .82; }
  55%  { opacity: 1; fill: var(--gold-2); }
  100% { opacity: .82; }
}
.mx-mathp__monster.is-gone { opacity: 0; animation: none; }
.mx-mathp__monster.is-caught { animation: mx-mathp-monster-caught 520ms var(--ease-bounce) both; }
@keyframes mx-mathp-monster-caught {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18) rotate(-4deg); }
  100% { transform: scale(1); }
}
.mx-mathp__monster.is-escape { animation: mx-mathp-monster-escape 520ms ease-in both; }
@keyframes mx-mathp-monster-escape {
  0%   { transform: translateX(0) rotate(0); opacity: 1; }
  25%  { transform: translateX(-10px) rotate(-8deg); opacity: 1; }
  100% { transform: translateX(160px) rotate(14deg); opacity: 0; }
}
/* 飞进血条的小妖（挂在 body，Web Animations 驱动） */
.mx-mathp__minion {
  position: fixed;
  z-index: var(--z-fx);
  width: 40px;
  height: 40px;
  transform-origin: 50% 50%;
  pointer-events: none;
  line-height: 0;
}

/* 浮字（fx 不可用 / 减少动态时的 DOM 版本；fx 版本从这里读颜色） */
.mx-mathp__float {
  position: absolute;
  left: 50%;
  top: 40%;
  translate: -50% 0;
  font-family: var(--font-display);
  font-size: 34px;
  color: color-mix(in srgb, var(--gold), var(--ink) 35%);
  text-shadow: 0 1px 0 var(--paper), 0 2px 8px rgba(60, 50, 30, .2);
  pointer-events: none;
  animation: mx-float-up 1100ms var(--ease-out) both;
  z-index: 3;
}
.mx-mathp__float--sun {
  color: color-mix(in srgb, var(--warn), var(--ink) 30%);
  font-size: 24px;
  top: calc(40% + 34px + var(--mx-float-row, 0) * 28px);
}

/* ---------------------------------------------------------------- 操作行 + 三栏主区（连击 | 键盘 | 手掌落区） */

.mx-mathp__main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  grid-template-areas: "combo center spacer";
  align-items: stretch;
  column-gap: clamp(12px, 2.5vw, 36px);
}
.mx-mathp__center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  justify-self: center;
  min-height: 0;
  gap: 10px;
}
/* 题卡与键盘之间的空地：浮字 / 连击大字的舞台（DOM 版浮字挂在这里） */
.mx-mathp__stage { position: relative; flex: 1 1 auto; align-self: stretch; min-height: 0; pointer-events: none; }
.mx-mathp__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.mx-mathp__actions .mx-btn { padding-left: 14px; padding-right: 14px; }
.mx-mathp__giveup { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); min-width: 88px; }
.mx-mathp__spacer { grid-area: spacer; }
/* 键盘里的确认键 / 数字块：贴底居中，由 math-keypad.css 定尺寸 */
.mx-mathp__keypad { margin-bottom: 2px; }

/* 连击栏 */
.mx-mathp__combo {
  grid-area: combo;
  justify-self: end;
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 132px;
  padding: 14px 12px 10px;
  border-radius: var(--radius);
}
.mx-mathp__combo-label { font-family: var(--font-display); font-size: 18px; color: var(--ink-soft); line-height: 1; }
.mx-mathp__combo-num {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.1;
  color: var(--ink);
  transition: transform var(--dur-micro) var(--ease-bounce), color var(--dur-micro);
}
.mx-mathp__combo.is-hot .mx-mathp__combo-num { color: var(--coral-num); }
.mx-mathp__combo-num.is-pop { animation: mx-pop 320ms var(--ease-bounce) both; }
.mx-mathp__gauge {
  position: relative;
  width: 34px;
  height: 130px;
  margin: 6px 0 4px;
  border-radius: 17px;
  background: color-mix(in srgb, var(--paper-2), var(--wood-dark) 10%);
  box-shadow: inset 0 2px 6px rgba(60, 50, 30, .18), inset 0 0 0 2px rgba(255, 255, 255, .5);
  overflow: hidden;
}
.mx-mathp__gauge-ink {
  position: absolute;
  inset: 0;
  border-radius: 17px;
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  transform-origin: 50% 100%;
  transform: scaleY(0);
  transition: transform 500ms var(--ease-out);
}
.mx-mathp__combo.is-hot .mx-mathp__gauge-ink { background: linear-gradient(180deg, var(--coral), var(--ink) 85%); }
.mx-mathp__combo.is-dropping .mx-mathp__gauge-ink { transition-duration: 1200ms; transition-timing-function: ease-in-out; }
.mx-mathp__gauge-tick {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 0;
  border-top: 2px dotted rgba(255, 255, 255, .7);
  mix-blend-mode: multiply;
  opacity: .6;
}
.mx-mathp__combo-fire {
  width: 30px;
  height: 30px;
  color: var(--ink-soft);
  opacity: .35;
  transition: opacity var(--dur-micro), transform var(--dur-micro) var(--ease-bounce), color var(--dur-micro);
}
.mx-mathp__combo-fire svg { width: 100%; height: 100%; }
.mx-mathp__combo.is-hot .mx-mathp__combo-fire {
  opacity: 1;
  color: var(--coral);
  animation: mx-mathp-flicker 1.1s ease-in-out infinite alternate;
}
@keyframes mx-mathp-flicker {
  from { transform: scale(1) rotate(-3deg); }
  to   { transform: scale(1.12) rotate(3deg); }
}
.mx-mathp__mascot-anchor { width: 120px; height: 144px; margin-top: 10px; pointer-events: none; }

/* ---------------------------------------------------------------- 讲解卡 / 示范卡：盖在题卡与键盘上 */

.mx-mathp__explain {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--paper) 30%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 240ms var(--ease-out);
}
.mx-mathp__explain.is-on { opacity: 1; }
.mx-mathp__explain-card {
  width: min(94%, 640px);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 26px 18px;
  cursor: pointer;
  animation: mx-mathp-card-in var(--dur-card) var(--ease-out) both;
}
.mx-mathp__explain-title { font-family: var(--font-display); font-size: 24px; color: var(--ink); }
.mx-mathp__explain.is-demo .mx-mathp__explain-title { color: var(--sky-accent); }
.mx-mathp__explain-face { display: flex; justify-content: center; max-width: 100%; overflow: hidden; }
.mx-mathp__explain-steps {
  width: 100%;
  margin: 0;
  padding: 0 0 0 1.6em;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-kai);
  font-size: 21px;
  line-height: 1.45;
  color: var(--ink);
}
.mx-mathp__step {
  padding: 4px 10px;
  border-radius: 10px;
  opacity: .28;
  transition: opacity 260ms var(--ease-out), background-color 260ms;
}
.mx-mathp__step.is-on { opacity: 1; }
.mx-mathp__step.is-last { background: color-mix(in srgb, var(--gold-2) 30%, transparent); }   /* 最新亮起的那一行 */
.mx-mathp__explain-btn { margin-top: 4px; }

/* ---------------------------------------------------------------- 战果卡：一场打完，居中盖在题卡与键盘上 */

.mx-mathp__verdict {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--paper) 30%, transparent);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
  cursor: pointer;
}
.mx-mathp__verdict.is-on { opacity: 1; }
.mx-mathp__verdict-card {
  position: relative;
  width: min(94%, 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 28px 14px;
  text-align: center;
  border: 3px solid color-mix(in srgb, var(--ok) 45%, var(--card-stroke));
  animation: mx-mathp-verdict-in 520ms var(--ease-bounce) both;
}
@keyframes mx-mathp-verdict-in {
  from { transform: translateY(18px) scale(.86); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.mx-mathp__verdict-card.is-struggled { border-color: color-mix(in srgb, var(--warn) 60%, var(--card-stroke)); }
.mx-mathp__verdict-card.is-escaped { border-color: color-mix(in srgb, var(--bad) 55%, var(--card-stroke)); }
.mx-mathp__verdict-card.is-tamed { border-color: color-mix(in srgb, var(--wisteria) 65%, var(--card-stroke)); background: color-mix(in srgb, var(--wisteria) 8%, var(--paper)); }
.mx-mathp__verdict-kicker { font-family: var(--font-display); font-size: 16px; color: var(--ink-soft); }
.mx-mathp__verdict-monster { display: block; margin: 2px 0 -4px; filter: drop-shadow(0 8px 12px rgba(60, 50, 30, .2)); }
.mx-mathp__verdict-card.is-caged .mx-mathp__verdict-monster,
.mx-mathp__verdict-card.is-struggled .mx-mathp__verdict-monster { animation: mx-mathp-monster-caught 620ms var(--ease-bounce) 260ms both; }
.mx-mathp__verdict-card.is-escaped .mx-mathp__verdict-monster { animation: mx-mathp-verdict-flee 900ms ease-in-out 300ms infinite alternate; }
@keyframes mx-mathp-verdict-flee {
  from { transform: translateX(-6px) rotate(-5deg); }
  to   { transform: translateX(10px) rotate(6deg); }
}
.mx-mathp__verdict-title {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.2;
  color: var(--ok-text);
}
.mx-mathp__verdict-card.is-struggled .mx-mathp__verdict-title { color: color-mix(in srgb, var(--warn), var(--ink) 35%); }
.mx-mathp__verdict-card.is-escaped .mx-mathp__verdict-title { color: var(--bad-text); }
.mx-mathp__verdict-card.is-tamed .mx-mathp__verdict-title { color: var(--wisteria-text); }
.mx-mathp__verdict-sub { font-family: var(--font-kai); font-size: 19px; color: var(--ink-soft); }
.mx-mathp__verdict-heartline { display: inline-flex; align-items: center; gap: 10px; margin-top: 4px; }
.mx-mathp__verdict-hearts { display: inline-flex; gap: 4px; }
.mx-mathp__verdict-hearts .mx-mathp__heart { width: 30px; height: 30px; filter: drop-shadow(0 2px 0 rgba(60, 50, 30, .15)); }
.mx-mathp__verdict-hearts .mx-mathp__heart.is-drop { animation: mx-mathp-heart-drop 560ms ease-in both; }
@keyframes mx-mathp-heart-drop {
  0%   { transform: scale(1); opacity: 1; }
  25%  { transform: scale(1.35) rotate(-8deg); opacity: 1; }
  100% { transform: translateY(26px) scale(.5) rotate(20deg); opacity: 0; }
}
.mx-mathp__verdict-heartnote { font-size: 15px; color: var(--ink-soft); }
.mx-mathp__verdict-coins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  padding: 4px 14px 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold-2) 55%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
  font-family: var(--font-display);
  font-size: 22px;
  color: color-mix(in srgb, var(--gold), var(--ink) 40%);
}
.mx-mathp__verdict-coin { display: inline-flex; width: 22px; height: 22px; color: color-mix(in srgb, var(--gold), var(--wood-dark) 30%); }
.mx-mathp__verdict-coin svg { width: 100%; height: 100%; }
.mx-mathp__verdict-tip { margin-top: 4px; font-size: 13px; color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }

/* ---------------------------------------------------------------- 减少动态 */

.mx-scene--math.is-reduced .mx-mathp__dot.is-current,
.mx-scene--math.is-reduced .mx-mathp__sun-rays,
.mx-scene--math.is-reduced .mx-mathp__combo-fire,
.mx-scene--math.is-reduced .mx-mathp__monster.is-arrive,
.mx-scene--math.is-reduced .mx-mathp__monster.is-intro,
.mx-scene--math.is-reduced .mx-mathp__monster.is-intro .mx-monster__glyph,
.mx-scene--math.is-reduced .mx-mathp__monster.is-intro .mx-monster__belly,
.mx-scene--math.is-reduced .mx-mathp__verdict-card,
.mx-scene--math.is-reduced .mx-mathp__verdict-monster,
.mx-scene--math.is-reduced .mx-mathp__verdict-hearts .mx-mathp__heart,
.mx-scene--math.is-reduced .mx-mathp__monster.is-caught,
.mx-scene--math.is-reduced .mx-mathp__boss.is-enter,
.mx-scene--math.is-reduced .mx-mathp__boss.is-bump,
.mx-scene--math.is-reduced .mx-mathp__shield-cell,
.mx-scene--math.is-reduced .mx-mathp__card.is-entering,
.mx-scene--math.is-reduced .mx-mathp__explain-card { animation: none !important; }
.mx-scene--math.is-reduced .mx-mathp__monster.is-escape { animation: none !important; opacity: 0; }
.mx-scene--math.is-reduced .mx-mathp__step,
.mx-scene--math.is-reduced .mx-mathp__explain,
.mx-scene--math.is-reduced .mx-mathp__verdict,
.mx-scene--math.is-reduced .mx-mathp__caption { transition: none; }

/* ---------------------------------------------------------------- 竖屏 / 窄屏：堆叠 */

/* 不够宽（iPad 横放 1180 以下）：HUD 先收掉「还差 N 只」——血条格子本身已经说明，Boss N/M 更要紧 */
@media (max-width: 1280px) {
  .mx-mathp__need { display: none; }
}

@media (max-width: 900px) {
  .mx-mathp__dots { display: none; }
  .mx-mathp__sun { width: 84px; }
  .mx-mathp__boss-idx { padding: 2px 6px; font-size: 13px; }
  .mx-mathp__verdict-card { padding: 12px 18px 10px; }
  .mx-mathp__verdict-title { font-size: 28px; }
  .mx-mathp__verdict-monster { width: 96px !important; height: 96px !important; }
  .mx-mathp__verdict-monster svg { width: 100%; height: 100%; }
  .mx-mathp__top { gap: 10px; }
  .mx-mathp__monster { width: 84px; height: 84px; }
  .mx-mathp__card { min-height: 108px; padding: 14px 16px 18px 20px; }
  .mx-mathp__main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "center"
      "combo";
    row-gap: 12px;
    justify-items: center;
  }
  .mx-mathp__combo { justify-self: center; flex-direction: row; align-items: center; width: auto; gap: 10px; padding: 8px 14px; }
  .mx-mathp__combo-label { order: 1; }
  .mx-mathp__combo-num { order: 2; margin-right: 6px; }
  .mx-mathp__gauge { order: 3; height: 64px; margin: 0; }
  .mx-mathp__combo-fire { order: 4; }
  .mx-mathp__mascot-anchor { display: none; }
  .mx-mathp__spacer { display: none; }
  .mx-mathp__caption { font-size: 19px; }
}

/* ================================================================ 结算页的口算分支（result.js summary.subject === 'math'） */

/* 用时行：「用时 6 分 40 秒 · 比上次快 45 秒」 */
.mx-result__time { color: var(--ink-soft); }
.mx-result__time b { font-family: var(--font-display); font-weight: 400; color: var(--ink); }
.mx-result__time .is-faster { color: var(--ok-text); }
.mx-result__time .is-slower { color: var(--coral-text); }

/* 逃跑的 Boss：妖怪 + 肚皮字，点一下展开错题与解法卡 */
.mx-result__mathboss .mx-result__wrongglyph { font-size: 22px; min-width: 54px; padding: 0 6px; width: auto; }
.mx-result__mathboss.is-open { background: color-mix(in srgb, var(--sky-accent) 16%, var(--paper)); }
.mx-result__mathdetail {
  width: 100%;
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper-2) 80%, transparent);
  border: 1px solid var(--card-stroke);
  text-align: left;
}
.mx-result__mathdetail.is-on { display: flex; }
.mx-result__mathdetail-title { font-family: var(--font-display); font-size: 18px; color: var(--ink); }
.mx-result__mathitem { display: flex; flex-direction: column; gap: 4px; }
.mx-result__mathitem .mx-math { font-size: 28px; }
.mx-result__mathitem-ans { font-size: 15px; color: var(--ink-soft); }
.mx-result__mathitem-ans b { font-family: var(--font-math); font-weight: 600; color: var(--bad-text); }
.mx-result__mathitem-ans i { font-style: normal; font-family: var(--font-math); font-weight: 600; color: var(--ok-text); }
.mx-result__mathsteps {
  margin: 2px 0 0;
  padding-left: 1.5em;
  font-family: var(--font-kai);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
}
.mx-result__mathsteps li { padding: 1px 0; }

/* 本局 Boss：每个打过的 Boss 一张小卡横排（序号 + 妖怪 + 肚皮字 / 名字 / 结果 / 心 before→after），点开看这场的题 */
.mx-result__fightblock { margin-top: 4px; }
.mx-result__fights-title { margin: 6px 0 6px; display: flex; justify-content: center; align-items: baseline; gap: 10px; }
.mx-result__fights-title small { font-family: var(--font-body); font-size: 13px; color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }
.mx-result__fights {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.mx-result__fight {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 6px;
  border-radius: 14px;
  background: var(--paper-2);
  border: 2px solid var(--card-stroke);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--paper-2), var(--wood-dark) 24%), var(--shadow-soft);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(.92);
  transition: transform 100ms var(--ease-out), box-shadow 100ms, background-color 160ms, border-color 160ms;
}
.mx-result__fight.is-on { animation: mx-result-fight-in 420ms var(--ease-bounce) both; }
@keyframes mx-result-fight-in {
  from { opacity: 0; transform: translateY(8px) scale(.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.mx-result__fight:active { transform: scale(.96) !important; }
.mx-result__fight.is-caged { border-color: color-mix(in srgb, var(--ok) 45%, var(--card-stroke)); }
.mx-result__fight.is-struggled { border-color: color-mix(in srgb, var(--warn) 60%, var(--card-stroke)); }
.mx-result__fight.is-escaped { border-color: color-mix(in srgb, var(--bad) 50%, var(--card-stroke)); }
.mx-result__fight.is-tamed { border-color: color-mix(in srgb, var(--wisteria) 60%, var(--card-stroke)); background: color-mix(in srgb, var(--wisteria) 10%, var(--paper)); }
.mx-result__fight.is-open { background: color-mix(in srgb, var(--sky-accent) 16%, var(--paper)); border-color: var(--sky-accent); }
.mx-result__fight-n {
  position: absolute;
  left: -7px;
  top: -9px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.mx-result__fight-monster { display: block; flex: 0 0 auto; }
.mx-result__fight-body { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px; align-items: center; }
.mx-result__fight-glyph { font-size: 22px; line-height: 1; color: var(--ink); }
.mx-result__fight-name { font-size: 13px; color: var(--ink-soft); white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.mx-result__fight-outcome {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px 1px 5px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.3;
  color: var(--ok-text);
  background: color-mix(in srgb, var(--ok) 16%, var(--paper));
  white-space: nowrap;
  justify-self: start;
}
.mx-result__fight-icon { display: inline-flex; width: 14px; height: 14px; }
.mx-result__fight-icon svg { width: 100%; height: 100%; }
.mx-result__fight.is-struggled .mx-result__fight-outcome, .mx-result__fight-outcome.is-struggled { color: color-mix(in srgb, var(--warn), var(--ink) 40%); background: color-mix(in srgb, var(--warn) 22%, var(--paper)); }
.mx-result__fight.is-escaped .mx-result__fight-outcome, .mx-result__fight-outcome.is-escaped { color: var(--bad-text); background: color-mix(in srgb, var(--bad) 14%, var(--paper)); }
.mx-result__fight.is-tamed .mx-result__fight-outcome, .mx-result__fight-outcome.is-tamed { color: var(--wisteria-text); background: color-mix(in srgb, var(--wisteria) 20%, var(--paper)); }
.mx-result__fight-heartline { display: inline-flex; align-items: center; gap: 3px; }
.mx-result__fight-hearts { display: inline-flex; gap: 1px; }
.mx-result__fight-heart { display: inline-flex; width: 15px; height: 15px; color: var(--coral); }
.mx-result__fight-heart svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
.mx-result__fight-heart.is-empty { color: color-mix(in srgb, var(--ink-soft) 35%, transparent); }
.mx-result__fight-arrow { font-size: 12px; color: var(--ink-soft); margin: 0 1px; }

/* 展开的这场题目列表 */
.mx-result__fightdetail {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper-2) 80%, transparent);
  border: 1px solid var(--card-stroke);
  text-align: left;
}
.mx-result__fightdetail.is-on { display: flex; }
.mx-result__fightdetail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.mx-result__fightdetail-title { font-family: var(--font-display); font-size: 18px; color: var(--ink); }
.mx-result__fightdetail-sum { font-size: 14px; color: var(--ink-soft); }
.mx-result__fightitems { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.mx-result__fightitem {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto 64px;
  align-items: center;
  column-gap: 10px;
  padding: 3px 8px;
  border-radius: 10px;
}
.mx-result__fightitem.is-miss { background: color-mix(in srgb, var(--bad) 8%, transparent); }
.mx-result__fightitem.is-demo { opacity: .7; }
.mx-result__fightitem-n { font-size: 14px; color: var(--ink-soft); text-align: right; }
.mx-result__fightitem-face { min-width: 0; overflow: hidden; }
.mx-result__fightitem-face .mx-math { font-size: 24px; }
.mx-result__fightitem-tags { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.mx-result__fightitem-kind { font-family: var(--font-display); font-size: 15px; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.mx-result__fightitem-kind.is-hit { color: var(--ok-text); background: color-mix(in srgb, var(--ok) 16%, var(--paper)); }
.mx-result__fightitem-kind.is-weak { color: color-mix(in srgb, var(--warn), var(--ink) 40%); background: color-mix(in srgb, var(--warn) 22%, var(--paper)); }
.mx-result__fightitem-kind.is-miss { color: var(--bad-text); background: color-mix(in srgb, var(--bad) 14%, var(--paper)); }
.mx-result__fightitem-kind.is-demo { color: var(--sky-accent); background: color-mix(in srgb, var(--sky-accent) 14%, var(--paper)); }
.mx-result__fightitem-tag { font-size: 13px; color: var(--ink-soft); }
.mx-result__fightitem-wrote { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.mx-result__fightitem-wrote b { font-family: var(--font-math); font-weight: 600; color: var(--bad-text); }
.mx-result__fightitem-secs { font-size: 15px; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.mx-scene--result.is-instant .mx-result__fight { animation: none !important; opacity: 1; transform: none; }
@media (max-width: 720px) {
  .mx-result__fightitem { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .mx-result__fightitem-secs { display: none; }
}
