/* =========================================================
   数学打怪 · 样式
   ========================================================= */

* { box-sizing: border-box; }

:root {
  --bg: #FFF8EE;
  --card: #FFFFFF;
  --ink: #2B2140;
  --ink-2: #55496E;
  --muted: #857BA0;
  --line: #E9E1F4;
  --line-2: #D8CEE9;
  --green: #3DBE5B;
  --green-d: #2A9645;
  --red: #F0524B;
  --red-d: #C93A34;
  --yellow: #FFC531;
  --yellow-d: #D99E00;
  --blue: #3AA6F0;
  --blue-d: #1B7FC4;
  --radius: 22px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  /* 手机上下拉刷新会打断战斗，直接关掉 */
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

/* 触屏：去掉双击缩放延迟和长按菜单 */
.opt, .btn, .node, .icon-btn, .cont-card, .revenge-card,
.chap-head, .text-btn, .install-bar button {
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.app { -webkit-user-select: none; user-select: none; }
.fill-wrap input, .modal .m-rule, .fb-body, .rep-section {
  -webkit-user-select: text; user-select: text;
}

body {
  background-image: radial-gradient(rgba(43, 33, 64, .055) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}

button { font-family: inherit; }
button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(58, 166, 240, .55);
  outline-offset: 2px;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 22px 70px;
  user-select: none;
}

/* ---------------- HUD ---------------- */

.hud {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 2px 14px;
  background: linear-gradient(180deg, rgba(255, 248, 238, .97) 62%, rgba(255, 248, 238, 0));
  backdrop-filter: blur(6px);
}

.hud-id { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }

.avatar {
  width: 46px; height: 46px;
  border-radius: 15px;
  background: linear-gradient(160deg, #FFE7A8, #FFC531);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  display: grid; place-items: center;
  font-size: 23px;
  flex: 0 0 auto;
}

.hud-id-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hud-id-txt strong { font-size: 16px; letter-spacing: .2px; }
.hud-id-txt span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.hud-stats { display: flex; gap: 8px; }
.stat {
  display: flex; align-items: center; gap: 5px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 13px;
  padding: 6px 11px;
  font-size: 15px;
  box-shadow: 0 2px 0 var(--line);
}
.stat-ico { font-size: 14px; line-height: 1; }
.stat-ico.star { color: var(--yellow); }
.stat strong { font-variant-numeric: tabular-nums; }

.hud-btns { display: flex; gap: 8px; }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-size: 19px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink);
  transition: transform .06s, box-shadow .06s, background .12s;
}
.icon-btn:hover { background: #FBF7FF; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.icon-btn.off { opacity: .45; }

/* ---------------- 屏幕切换 ---------------- */

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .22s ease-out; }
#screenBattle.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 180px);
  min-height: calc(100dvh - 180px);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 地图 ---------------- */

.map-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}
.map-head h1 {
  margin: 0 0 4px;
  font-size: 38px;
  letter-spacing: -.5px;
  font-weight: 900;
}
.map-head p { margin: 0; color: var(--muted); font-size: 14px; }

.text-btn {
  border: 0; background: none; color: var(--ink-2);
  font-size: 14px; font-weight: 700; cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  padding: 6px;
}
.text-btn:hover { color: var(--ink); }

/* 继续闯关卡片 */
.cont-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 18px 22px;
  cursor: pointer;
  color: #fff;
  text-align: left;
  margin-bottom: 14px;
  overflow: hidden;
  transition: transform .08s, box-shadow .08s;
}
.cont-card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.cont-card::after {
  content: "";
  position: absolute;
  right: -40px; top: -60px;
  width: 190px; height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
}
.cont-card .cont-ico {
  width: 58px; height: 58px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .22);
  display: grid; place-items: center;
  font-size: 28px;
  flex: 0 0 auto;
}
.cont-txt { flex: 1; min-width: 0; }
.cont-txt small { display: block; font-size: 13px; opacity: .9; margin-bottom: 3px; }
.cont-txt strong { display: block; font-size: 22px; letter-spacing: .2px; }
.cont-arrow { font-size: 26px; font-weight: 900; }

/* 复仇战 */
.revenge-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 3px solid var(--red);
  border-radius: 22px;
  background: #FFF1F0;
  padding: 15px 20px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 14px;
  box-shadow: 0 5px 0 #F5C7C4;
  transition: transform .08s, box-shadow .08s;
}
.revenge-card:active { transform: translateY(4px); box-shadow: 0 1px 0 #F5C7C4; }
.revenge-card .rv-ico { font-size: 30px; }
.revenge-card .rv-txt { flex: 1; }
.revenge-card .rv-txt strong { display: block; font-size: 17px; color: var(--red-d); }
.revenge-card .rv-txt span { font-size: 13px; color: #9A6A66; }
.revenge-card .rv-go {
  background: var(--red); color: #fff;
  border-radius: 12px; padding: 8px 14px;
  font-weight: 800; font-size: 14px;
}

/* 章节 */
.chap { margin-top: 28px; }

.chap-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 18px;
  border-radius: 20px;
  border: 3px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  color: #fff;
}
.chap-head .ch-ico {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .24);
  display: grid; place-items: center;
  font-size: 21px; font-weight: 900;
  flex: 0 0 auto;
}
.chap-head .ch-txt { flex: 1; min-width: 0; }
.chap-head .ch-txt small { font-size: 12px; opacity: .86; display: block; letter-spacing: .4px; }
.chap-head .ch-txt strong { font-size: 19px; letter-spacing: .2px; }
.chap-head .ch-prog {
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, .22);
  padding: 7px 12px;
  border-radius: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chap.dark-head .chap-head { color: var(--ink); }

.path {
  position: relative;
  padding: 20px 0 6px;
}
.path::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: repeating-linear-gradient(180deg, var(--line-2) 0 9px, transparent 9px 19px);
  border-radius: 2px;
}

.node-row {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.node-row:nth-child(odd) { margin-left: 96px; }
.node-row:nth-child(even) { margin-right: 96px; }

.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.node {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 26px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.node:hover:not(.locked) { transform: translateY(-2px); }
.node:active:not(.locked) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.node.cleared { color: #fff; }
.node.locked {
  background: #F0EBF7;
  border-color: #CDBEE0;
  box-shadow: 0 4px 0 #CDBEE0;
  color: #A99BC2;
  cursor: not-allowed;
  font-size: 22px;
}
.node.boss { width: 84px; height: 84px; font-size: 31px; }
.node.current::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 3px solid var(--yellow);
  animation: ring 1.6s ease-out infinite;
}
.node.current { background: var(--yellow); color: var(--ink); box-shadow: 0 4px 0 var(--yellow-d); }

@keyframes ring {
  0% { transform: scale(.94); opacity: .9; }
  70% { transform: scale(1.14); opacity: 0; }
  100% { transform: scale(1.14); opacity: 0; }
}

.node-stars { font-size: 12px; letter-spacing: 1px; color: var(--line-2); height: 14px; }
.node-stars .on { color: var(--yellow); text-shadow: 0 1px 0 rgba(43, 33, 64, .18); }

.node-label {
  font-size: 11.5px;
  color: var(--muted);
  max-width: 112px;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-label.boss-label { color: var(--ink-2); font-weight: 800; }

.map-foot {
  margin-top: 34px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
.map-foot p { margin: 2px 0; }

/* ---------------- 战斗 ---------------- */

.b-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0 12px;
}
.b-title { flex: 1; font-size: 17px; font-weight: 800; text-align: center; }
.hearts { display: flex; gap: 4px; font-size: 22px; line-height: 1; min-width: 82px; justify-content: flex-end; }
.heart { color: var(--red); transition: .25s; }
.heart.lost { color: #D9D2E6; transform: scale(.85); }

.b-body {
  display: grid;
  grid-template-columns: .88fr 1.12fr;
  gap: 18px;
  align-items: stretch;
}
/* 防止填空输入框的固有宽度把网格列撑出屏幕 */
.b-body > * { min-width: 0; }

.stage {
  position: relative;
  border-radius: 26px;
  border: 3px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink);
  background: linear-gradient(180deg, var(--st1, #E3F4FF) 0%, var(--st2, #B9E4FF) 100%);
  padding: 15px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background .3s;
}
.stage::before {
  content: "";
  position: absolute;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .38);
  top: -50px; right: -35px;
}
.stage::after {
  content: "";
  position: absolute;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  bottom: 40px; left: -25px;
}
.stage.shake { animation: stageShake .4s ease; }

@keyframes stageShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  35% { transform: translateX(6px); }
  55% { transform: translateX(-4px); }
  75% { transform: translateX(2px); }
}

.hp-wrap {
  position: relative;
  z-index: 2;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 15px;
  padding: 8px 11px 10px;
  box-shadow: 0 3px 0 rgba(43, 33, 64, .18);
}
.hp-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--ink);
}
.hp-label span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: 12px; }
.hp { height: 13px; background: #EDE7F6; border-radius: 99px; overflow: hidden; }
.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FF8A5B, #F0524B);
  transition: width .45s cubic-bezier(.2, .9, .3, 1);
}
.hp-fill.low { background: linear-gradient(90deg, #FFB03A, #F0524B); animation: lowPulse 1s infinite; }
@keyframes lowPulse { 50% { filter: brightness(1.25); } }

.monster-slot {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 6px 0;
  min-height: 230px;
}
.monster-wrap {
  width: min(86%, 300px);
  animation: bob 2.8s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.monster-wrap.boss { width: min(92%, 330px); }
.monster-wrap.hurt { animation: hurt .45s ease; }
.monster-wrap.attack { animation: lunge .5s ease; }
.monster-wrap.dead { animation: die .9s ease forwards; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50% { transform: translateY(-10px) rotate(1.2deg); }
}
@keyframes hurt {
  0% { transform: translateX(0); filter: none; }
  15% { transform: translateX(18px) rotate(7deg); filter: brightness(2.4) saturate(.4); }
  35% { transform: translateX(-10px) rotate(-4deg); filter: brightness(2); }
  60% { transform: translateX(6px); filter: none; }
  100% { transform: translateX(0); }
}
@keyframes lunge {
  0% { transform: scale(1) translateY(0); }
  30% { transform: scale(1.16) translateY(-6px); }
  55% { transform: scale(1.06) translateY(2px); }
  100% { transform: scale(1); }
}
@keyframes die {
  to { transform: rotate(14deg) translateY(24px) scale(.9); opacity: 0; }
}

.monster { width: 100%; height: auto; display: block; }
.monster .eyes { animation: blink 5.5s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95%, 97% { transform: scaleY(.08); }
}

.combo {
  position: absolute;
  left: 14px; bottom: 14px;
  z-index: 3;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  opacity: 0;
  transform: translateY(6px) scale(.9);
  transition: .18s;
  pointer-events: none;
}
.combo.show { opacity: 1; transform: none; }
.combo.crit { background: #FF7A3D; color: #fff; }

.dmg-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.dmg {
  position: absolute;
  font-size: 36px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 4px 0 var(--ink);
  animation: dmgUp .95s cubic-bezier(.2, .8, .3, 1) forwards;
  white-space: nowrap;
}
.dmg.crit { color: var(--yellow); font-size: 44px; }
@keyframes dmgUp {
  0% { transform: translate(-50%, 0) scale(.6) rotate(-8deg); opacity: 0; }
  20% { transform: translate(-50%, -14px) scale(1.15) rotate(-4deg); opacity: 1; }
  60% { transform: translate(-50%, -52px) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -92px) scale(.92); opacity: 0; }
}

.panel {
  background: var(--card);
  border: 2px solid var(--line-2);
  border-radius: 26px;
  box-shadow: 0 6px 0 var(--line), 0 14px 34px rgba(43, 33, 64, .06);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  background: var(--line);
  color: var(--ink-2);
}
.q-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; }

.q-prompt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(22px, 2.35vw, 29px);
  font-weight: 800;
  line-height: 1.55;
  padding: 18px 6px 20px;
  min-height: 92px;
  letter-spacing: .2px;
}

.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.opts.three { grid-template-columns: repeat(3, 1fr); }
.opts.long { grid-template-columns: 1fr; }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 11px 15px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s, transform .06s, box-shadow .06s;
  font-variant-numeric: tabular-nums;
}
.opt:hover:not(:disabled) { border-color: #C9BEE4; background: #FCFAFF; }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: 0 0 25px;
  height: 25px;
  border-radius: 8px;
  background: #F3EFFA;
  color: var(--muted);
  font-size: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.opt.correct { background: #E9FBEF; border-color: var(--green); box-shadow: 0 3px 0 var(--green-d); }
.opt.correct .key { background: var(--green); color: #fff; }
.opt.wrong { background: #FFECEB; border-color: var(--red); box-shadow: 0 3px 0 var(--red-d); animation: shake .36s; }
.opt.wrong .key { background: var(--red); color: #fff; }
.opt.faded { opacity: .5; }
.opts.sym .opt { justify-content: center; font-size: 30px; padding: 8px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

.opts.long .opt { font-size: 17px; font-weight: 700; line-height: 1.35; min-height: 58px; }

.fill-wrap { display: none; gap: 10px; align-items: stretch; }
.fill-wrap.show { display: flex; }
.fill-wrap input {
  flex: 1;
  min-width: 0;
  min-height: 62px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #FCFAFF;
  font-size: 28px;
  font-weight: 800;
  padding: 8px 16px;
  text-align: center;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}
.fill-wrap input:focus { border-color: var(--blue); background: #fff; }
.fill-wrap input:disabled { opacity: .7; }
.fill-wrap input.correct { border-color: var(--green); background: #E9FBEF; color: var(--green-d); opacity: 1; }
.fill-wrap input.wrong { border-color: var(--red); background: #FFECEB; color: var(--red-d); opacity: 1; animation: shake .36s; }
.fill-wrap .btn { flex: 0 0 auto; }

.btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 22px;
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--btn-sh, var(--line-2));
  transition: transform .06s, box-shadow .06s, filter .12s;
  white-space: nowrap;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--btn-sh, var(--line-2)); }
.btn-primary { background: var(--green); color: #fff; --btn-sh: var(--green-d); }
.btn-primary:hover { filter: brightness(1.04); }
.btn-blue { background: var(--blue); color: #fff; --btn-sh: var(--blue-d); }
.btn-ghost { background: #fff; border: 2px solid var(--line); --btn-sh: var(--line); }
.btn-danger { background: #fff; color: var(--red-d); border: 2px solid #FFC9C6; --btn-sh: #F5C7C4; }
.btn-lg { font-size: 19px; padding: 17px 28px; border-radius: 18px; }
.btn-sm { font-size: 14px; padding: 9px 15px; border-radius: 12px; }

.fb { display: none; margin-top: 13px; border-radius: 18px; padding: 14px 16px; }
.fb.show { display: block; animation: slideUp .22s ease-out; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.fb.ok { background: #E9FBEF; border: 2px solid #BFEBCE; }
.fb.bad { background: #FFECEB; border: 2px solid #FFC9C6; }
.fb-head { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 900; margin-bottom: 6px; }
.fb.ok .fb-head { color: var(--green-d); }
.fb.bad .fb-head { color: var(--red-d); }
.fb-body { font-size: 15px; line-height: 1.75; color: #463B5C; white-space: pre-line; }
.fb-body b { color: var(--ink); }
.fb-ans { font-size: 14px; color: var(--ink-2); margin: 0 0 6px; }
.fb-ans b { color: var(--ink); font-weight: 800; }
.fb-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ---------------- 结算 ---------------- */

#screenResult { padding-top: 18px; }
.result-card {
  position: relative;
  overflow: hidden;
  width: min(680px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 30px 32px 26px;
  text-align: center;
}
.result-monster { width: 150px; margin: 0 auto 4px; }
.result-title { font-size: 30px; font-weight: 900; margin: 4px 0 2px; letter-spacing: .2px; }
.result-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.stars-row { display: flex; justify-content: center; gap: 12px; margin: 6px 0 18px; }
.big-star {
  font-size: 54px;
  line-height: 1;
  color: #E7E0F2;
  transform: scale(.8);
  animation: starPop .5s cubic-bezier(.2, 1.5, .4, 1) forwards;
}
.big-star.on { color: var(--yellow); text-shadow: 0 4px 0 var(--yellow-d); }
.big-star:nth-child(2) { animation-delay: .12s; }
.big-star:nth-child(3) { animation-delay: .24s; }
@keyframes starPop {
  0% { transform: scale(.4) rotate(-20deg); opacity: 0; }
  70% { transform: scale(1.14) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.rs {
  background: #FBF8FF;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 8px;
}
.rs strong { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.rs span { font-size: 12px; color: var(--muted); }

.missed-box {
  text-align: left;
  border-top: 2px dashed var(--line);
  padding-top: 16px;
  margin-top: 6px;
}
.missed-title { font-size: 14px; font-weight: 900; color: var(--ink-2); margin-bottom: 10px; }
.missed-item {
  background: #FFF7F6;
  border: 2px solid #FFE1DF;
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 9px;
  font-size: 14px;
  line-height: 1.65;
}
.missed-item .mi-q { font-weight: 800; color: var(--ink); }
.missed-item .mi-a { color: var(--green-d); font-weight: 800; }
.missed-item .mi-you { color: var(--red-d); }
.missed-item .mi-ex { color: var(--ink-2); margin-top: 4px; font-size: 13px; white-space: pre-line; }

.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.confetti {
  position: fixed;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  z-index: 100;
  pointer-events: none;
  animation: confettiFall 2.6s cubic-bezier(.2, .7, .35, 1) forwards;
}
@keyframes confettiFall {
  0% { transform: translate3d(0, -20px, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); opacity: .85; }
}

/* ---------------- 家长报告 ---------------- */

.r-top { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
.r-top h2 { flex: 1; margin: 0; text-align: center; font-size: 21px; letter-spacing: .4px; }
.r-top-sp { width: 44px; }

.rep-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.rep-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 3px 0 var(--line);
}
.rep-card span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rep-card strong { font-size: 23px; font-variant-numeric: tabular-nums; }

.rep-section { margin-top: 22px; }
.rep-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: .3px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rep-section h3::before {
  content: "";
  width: 5px; height: 16px;
  border-radius: 3px;
  background: var(--blue);
}

.week-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 130px;
  padding: 12px 14px 8px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
}
.wc-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.wc-bar { width: 100%; max-width: 38px; border-radius: 8px 8px 4px 4px; background: var(--line); min-height: 4px; transition: height .3s; }
.wc-bar.has { background: linear-gradient(180deg, #7FD1FF, var(--blue)); }
.wc-lbl { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.wc-num { font-size: 10.5px; color: var(--ink-2); font-weight: 800; font-variant-numeric: tabular-nums; }

.tip-box {
  background: #F2F8FF;
  border: 2px solid #CFE6FA;
  border-radius: 16px;
  padding: 13px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: #2C5578;
}
.tip-box b { color: #14456E; }

.unit-block {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 12px;
}
.unit-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}
.unit-block-head span { opacity: .85; font-weight: 700; }
.kp-row {
  display: grid;
  grid-template-columns: 1fr 92px 58px;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border-top: 1px solid #F3EEFA;
  font-size: 13.5px;
}
.kp-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-bar { height: 8px; border-radius: 99px; background: #F1ECF8; overflow: hidden; }
.kp-bar i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.kp-bar i.warn { background: #F5A623; }
.kp-bar i.bad { background: var(--red); }
.kp-bar i.none { background: var(--line-2); }
.kp-chip {
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  padding: 3px 0;
  border-radius: 8px;
  white-space: nowrap;
}
.chip-none { background: #F3EFF9; color: var(--muted); }
.chip-bad { background: #FFECEB; color: var(--red-d); }
.chip-warn { background: #FFF4E0; color: #A86B00; }
.chip-ok { background: #E9FBEF; color: var(--green-d); }

.wrong-book { display: flex; flex-direction: column; gap: 9px; }
.wb-item {
  background: #fff;
  border: 2px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.6;
}
.wb-item .wb-q { font-weight: 800; }
.wb-item .wb-a { color: var(--green-d); font-weight: 800; }
.wb-item .wb-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

.empty-note {
  color: var(--muted);
  font-size: 13px;
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 17px;
  text-align: center;
}

.danger-zone { margin: 30px 0 10px; text-align: center; }
.danger-zone .text-btn { color: #B29FBE; font-size: 12px; }

/* ---------------- 弹窗 / 提示 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(35, 26, 52, .5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 10px 0 var(--ink), 0 30px 70px rgba(35, 26, 52, .35);
  padding: 26px 26px 24px;
  text-align: center;
  animation: modalPop .24s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes modalPop {
  from { transform: scale(.92) translateY(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal .m-monster { width: 170px; margin: 0 auto 2px; }
.modal h2 { margin: 2px 0 4px; font-size: 25px; }
.modal .m-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.modal .m-kps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 16px; }
.modal .m-kp {
  background: #F4F0FB;
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 700;
}
.modal .m-rule {
  background: #FBF8FF;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
  text-align: left;
  margin-bottom: 18px;
}
.modal .m-rule b { color: var(--ink); }
.modal .m-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal .m-tip {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  text-align: left;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 90;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 分数 ---------------- */

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 .14em;
  line-height: 1.02;
  font-size: .92em;
  position: relative;
  top: -.02em;
}
.frac i {
  font-style: normal;
  padding: 0 .2em 2px;
  border-bottom: 2px solid currentColor;
}
.frac b {
  font-weight: 800;
  padding: 2px .2em 0;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .b-body { grid-template-columns: 1fr; }
  .stage { min-height: 300px; }
  .monster-slot { min-height: 180px; }
  .monster-wrap { width: min(62%, 220px); }
  .monster-wrap.boss { width: min(68%, 240px); }
  .panel { min-height: auto; }
  .q-prompt { padding: 14px 4px 16px; }
  .app { padding: 0 16px 60px; }
  .rep-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .map-head h1 { font-size: 30px; }
  .node-row:nth-child(odd) { margin-left: 48px; }
  .node-row:nth-child(even) { margin-right: 48px; }
  .hud-stats .stat { padding: 5px 8px; font-size: 13px; }
  .hud-id-txt span { display: none; }
  .opts { grid-template-columns: 1fr; }
  .opts.three { grid-template-columns: repeat(3, 1fr); }
  .result-card { padding: 24px 18px 20px; }
  .result-title { font-size: 25px; }
  .big-star { font-size: 44px; }
  .result-stats { gap: 6px; }
  .rs strong { font-size: 20px; }
  .kp-row { grid-template-columns: 1fr 60px 52px; gap: 8px; }

  /* 竖屏手机：战斗页压缩舞台，让题目和选项尽量一屏可见 */
  #screenBattle.active { justify-content: flex-start; min-height: 0; }
  .b-top { padding: 0 0 10px; }
  .b-title { font-size: 14px; line-height: 1.35; }
  .hearts { font-size: 19px; min-width: 68px; }
  .stage { min-height: 190px; padding: 10px; border-radius: 20px; }
  .stage::before { width: 100px; height: 100px; top: -34px; right: -24px; }
  .stage::after { width: 56px; height: 56px; bottom: 26px; left: -18px; }
  .hp-wrap { padding: 6px 9px 8px; border-radius: 12px; }
  .hp-label { font-size: 12px; margin-bottom: 4px; }
  .hp { height: 10px; }
  .monster-slot { min-height: 116px; }
  .monster-wrap { width: min(44%, 150px); }
  .monster-wrap.boss { width: min(52%, 170px); }
  .combo { left: 10px; bottom: 10px; font-size: 12px; padding: 4px 9px; }
  .dmg { font-size: 30px; }
  .dmg.crit { font-size: 36px; }
  .panel { padding: 14px 14px 16px; border-radius: 20px; }
  .q-prompt { min-height: 60px; font-size: 20px; padding: 10px 2px 12px; line-height: 1.5; }
  .opt { min-height: 54px; font-size: 19px; padding: 9px 13px; border-radius: 14px; }
  .opts.sym .opt { font-size: 26px; }
  .opts.long .opt { font-size: 15px; min-height: 50px; }
  .fill-wrap input { min-height: 54px; font-size: 24px; }
  .fb { padding: 12px 13px; border-radius: 15px; }
  .fb-head { font-size: 16px; }
  .fb-body { font-size: 14px; line-height: 1.7; }
  .fb-actions { margin-top: 10px; }
  .fb-actions .btn { width: 100%; }
  .result-actions .btn { flex: 1 1 46%; }
  .cont-card { padding: 14px 16px; gap: 12px; }
  .cont-card .cont-ico { width: 48px; height: 48px; font-size: 24px; border-radius: 15px; }
  .cont-txt strong { font-size: 18px; }
  .cont-arrow { font-size: 22px; }
  .revenge-card { padding: 12px 14px; gap: 10px; }
  .chap-head { padding: 12px 14px; gap: 10px; }
  .chap-head .ch-ico { width: 36px; height: 36px; font-size: 18px; }
  .chap-head .ch-txt strong { font-size: 16px; }
  .chap-head .ch-prog { font-size: 12px; padding: 6px 9px; }
  .node-label { max-width: 96px; font-size: 11px; }
  .modal { padding: 20px 16px 18px; border-radius: 22px; }
  .modal .m-monster { width: 130px; }
  .modal h2 { font-size: 21px; }
  .modal .m-actions .btn { flex: 1 1 46%; }
  .week-chart { height: 118px; padding: 10px 10px 6px; gap: 6px; }
}

/* 窄屏手机：HUD 与知识点表格收紧 */
@media (max-width: 480px) {
  .hud { gap: 8px; padding: 10px 0 12px; }
  .avatar { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  .hud-id { gap: 8px; }
  .hud-id-txt strong { font-size: 14px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud-stats { gap: 6px; }
  .hud-stats .stat { padding: 4px 7px; font-size: 12px; border-radius: 11px; }
  .hud-btns { gap: 6px; }
  .icon-btn { width: 38px; height: 38px; font-size: 17px; border-radius: 12px; }
  .map-head { padding: 6px 0 14px; }
  .map-head h1 { font-size: 26px; }
  /* 小屏手机战斗页再压一档，让 4 个选项尽量进一屏 */
  .stage { min-height: 168px; }
  .monster-slot { min-height: 96px; }
  .monster-wrap { width: min(40%, 132px); }
  .monster-wrap.boss { width: min(48%, 150px); }
  .q-prompt { min-height: 48px; font-size: 19px; padding: 8px 2px 10px; }
  .opt { min-height: 50px; font-size: 18px; }
  .opts { gap: 9px; }
  /* 知识点一行放不下，改成两行：名称一行，进度条 + 标签一行 */
  .kp-row {
    grid-template-columns: 1fr 92px;
    grid-template-areas: "name name" "bar chip";
    gap: 6px 8px;
    padding: 9px 13px;
  }
  .kp-name { grid-area: name; white-space: normal; line-height: 1.4; }
  .kp-bar { grid-area: bar; }
  .kp-chip { grid-area: chip; font-size: 10.5px; }
}

/* 刘海屏 / 全面屏安全区 */
@supports (padding: env(safe-area-inset-bottom)) {
  .app { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .hud { padding-top: calc(12px + env(safe-area-inset-top)); }
  .toast { bottom: calc(34px + env(safe-area-inset-bottom)); }
  .modal-mask { padding-bottom: env(safe-area-inset-bottom); }
  .install-bar { bottom: calc(12px + env(safe-area-inset-bottom)); }
  body.has-install-bar .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
body.has-install-bar .toast { bottom: 96px; }

/* 安装到主屏幕引导条 */
.install-bar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: 12px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 8px 26px rgba(35, 26, 52, .35);
  animation: slideUp .24s ease-out;
}
.install-bar img { width: 36px; height: 36px; border-radius: 9px; flex: 0 0 auto; }
.install-bar .ib-txt { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.5; }
.install-bar .ib-txt b { display: block; font-size: 13.5px; }
.install-bar .ib-btn {
  border: 0;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
  border-radius: 11px;
  padding: 9px 14px;
  cursor: pointer;
  flex: 0 0 auto;
}
.install-bar .ib-x {
  border: 0; background: none; color: rgba(255, 255, 255, .6);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 6px;
  flex: 0 0 auto;
}

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