/* ==========================================================================
   小学英语闯关 · Web 端样式
   目标：平板/手机横竖屏都能用，按钮足够大，配色明快但不刺眼
   ========================================================================== */

:root {
  --bg1: #eef3ff;
  --bg2: #f8f0ff;
  --card: #ffffff;
  --primary: #5b7cfa;
  --primary-d: #4361e0;
  --primary-l: #eaefff;
  --ok: #2fbf71;
  --ok-l: #e4f8ed;
  --no: #ff8a3d;
  --no-l: #fff0e4;
  --gold: #ffc53d;
  --text: #1f2937;
  --muted: #7a8496;
  --line: #e6eaf3;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(46, 64, 120, .08);
  --shadow-s: 0 2px 10px rgba(46, 64, 120, .06);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

.view {
  display: none;
  min-height: 100vh;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 820px;
  margin: 0 auto;
}
.view.on {
  display: block;
  animation: fade .22s ease;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- 通用 ------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 124, 250, .32);
}
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost {
  background: var(--primary-l);
  color: var(--primary-d);
}
.btn-line {
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.muted { color: var(--muted); }

/* ------------------------------- 登录 ------------------------------- */

.login-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 60px);
  gap: 22px;
}
.brand { text-align: center; }
.brand .logo { font-size: 56px; line-height: 1; }
.brand h1 {
  margin: 12px 0 6px;
  font-size: 27px;
  letter-spacing: .5px;
}
.brand p { margin: 0; color: var(--muted); font-size: 14px; }

.login-card { padding: 22px; }
.login-card label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.login-card input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-size: 19px;
  font-family: inherit;
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  outline: none;
  transition: border-color .15s, background .15s;
}
.login-card input:focus {
  border-color: var(--primary);
  background: #fff;
}
.login-card .btn { margin-top: 16px; }

.profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.profiles:empty { display: none; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 10px;
  background: #f6f8ff;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background .15s, box-shadow .15s;
}
.profile-chip:hover { background: var(--primary-l); box-shadow: inset 0 0 0 1.5px var(--primary); }
.profile-chip .av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.tip {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ------------------------------- 顶栏 ------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h2 {
  margin: 0;
  font-size: 20px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 19px;
  background: #fff;
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.94); }

.stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  background: #fff8e4;
  color: #b47b00;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ------------------------------- 首页 ------------------------------- */

.home-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #5b7cfa 0%, #7b5bfa 100%);
  color: #fff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(91, 124, 250, .3);
}
.home-hero::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.home-hero .hi { font-size: 14px; opacity: .88; }
.home-hero .who {
  font-size: 25px;
  font-weight: 700;
  margin: 4px 0 14px;
}
.progress-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .28);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #fff;
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.home-hero .pmeta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-top: 8px;
  opacity: .92;
}

.sect-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 2px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.sect-title .line { flex: 1; height: 1px; background: var(--line); }

.action-list { display: grid; gap: 12px; }

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.action-card:active { transform: scale(.985); }
.action-card .ic {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px;
  flex-shrink: 0;
  background: var(--primary-l);
}
.action-card .ic.g { background: var(--ok-l); }
.action-card .ic.o { background: var(--no-l); }
.action-card .ic.y { background: #fff6e0; }
.action-card .body { flex: 1; min-width: 0; }
.action-card .t { display: block; font-size: 16px; font-weight: 700; }
.action-card .d { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.action-card .arrow { color: #c3cada; font-size: 20px; flex-shrink: 0; }

@media (min-width: 640px) {
  .action-list { grid-template-columns: 1fr 1fr; }
}

.badge-dot {
  display: inline-block;
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--no);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ------------------------------- 地图 ------------------------------- */

.map-head {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.map-head .big { font-size: 30px; }
.map-head .txt { flex: 1; }
.map-head .n { font-size: 16px; font-weight: 700; }
.map-head .s { font-size: 13px; color: var(--muted); margin-top: 3px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px;
}
.level-cell {
  position: relative;
  min-height: 76px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-s);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  transition: transform .12s;
}
.level-cell:active { transform: scale(.94); }
.level-cell .no {
  font-size: 21px;
  font-weight: 800;
  color: var(--primary-d);
  line-height: 1.05;
}
.level-cell .nm {
  font-size: 9px;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}
.level-cell .st {
  font-size: 10px;
  letter-spacing: -0.5px;
  color: var(--gold);
  line-height: 1;
}
.level-cell.locked {
  background: #f2f4f9;
  box-shadow: none;
}
.level-cell.locked .no { color: #c3cada; }
.level-cell.locked::after {
  content: "🔒";
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 10px;
  line-height: 1;
}
.level-cell.locked .st { display: none; }
.level-cell.passed { box-shadow: inset 0 0 0 2px #d0e9dd, var(--shadow-s); }
.level-cell.boss {
  background: linear-gradient(135deg, #fff4e0, #ffe7cc);
}
.level-cell.boss .no { color: #b47b00; }
.level-cell .st.empty-star { color: #ccd4e4; }

/* ------------------------------- 答题 ------------------------------- */

.play-view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  max-width: 820px;
  margin: 0 auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
}
.play-view.on { display: flex; }

.play-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.play-head .quit {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: #fff;
  display: grid; place-items: center;
  font-size: 17px;
  color: var(--muted);
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
}
.dots {
  flex: 1;
  display: flex;
  gap: 4px;
}
.dot {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #dfe5f2;
  transition: background .25s;
}
.dot.done { background: var(--ok); }
.dot.err { background: var(--no); }
.dot.now { background: var(--primary); }

.combo {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--no);
  min-width: 42px;
  text-align: right;
  transition: transform .15s;
}
.combo.pop { transform: scale(1.35); }

.q-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 8px 0;
}

.q-prompt {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

.q-big {
  text-align: center;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: .5px;
  line-height: 1.2;
  word-break: break-word;
  animation: pop .25s ease;
}
.q-big.cn { font-size: 34px; }
@keyframes pop {
  from { transform: scale(.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.ipa {
  text-align: center;
  font-size: 16px;
  color: var(--muted);
  margin-top: -12px;
}

.speaker {
  width: 118px; height: 118px;
  border-radius: 50%;
  margin: 0 auto;
  display: grid;
  place-items: center;
  font-size: 48px;
  background: linear-gradient(135deg, #5b7cfa, #7b5bfa);
  color: #fff;
  box-shadow: 0 10px 26px rgba(91, 124, 250, .34);
  transition: transform .12s;
}
.speaker:active { transform: scale(.93); }
.speaker.playing { animation: ring .7s ease infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 10px 26px rgba(91, 124, 250, .34); }
  50% { box-shadow: 0 10px 26px rgba(91, 124, 250, .34), 0 0 0 14px rgba(91, 124, 250, .12); }
}

.opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}
@media (max-width: 340px) {
  .opts { grid-template-columns: 1fr; }
}
.opt {
  min-height: 62px;
  padding: 11px 14px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-s), inset 0 0 0 2px transparent;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.opt:active { transform: scale(.975); }
.opt .k {
  width: 27px; height: 27px;
  border-radius: 9px;
  background: #f2f5fc;
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.opt .tx { flex: 1; min-width: 0; word-break: break-word; }
.opt.right {
  background: var(--ok-l);
  box-shadow: inset 0 0 0 2px var(--ok);
}
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong {
  background: var(--no-l);
  box-shadow: inset 0 0 0 2px var(--no);
  animation: shake .32s;
}
.opt.wrong .k { background: var(--no); color: #fff; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.opt[disabled] { pointer-events: none; }
.opts.dim .opt:not(.right):not(.wrong) { opacity: .45; }

/* 拼写 */
.spell-board {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 58px;
  align-items: center;
}
.slot {
  width: 40px; height: 52px;
  border-radius: 11px;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--line);
  display: grid; place-items: center;
  font-size: 24px;
  font-weight: 800;
  text-transform: lowercase;
}
.slot.filled {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--primary-l);
  color: var(--primary-d);
}
.slot.ok { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-l); color: #17864d; }
.slot.bad { box-shadow: inset 0 0 0 2px var(--no); background: var(--no-l); color: #b35a12; }

.letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 6px;
}
.letter {
  width: 54px; height: 54px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 22px;
  font-weight: 800;
  text-transform: lowercase;
  color: var(--primary-d);
  transition: transform .1s, opacity .15s;
}
.letter:active { transform: scale(.9); }
.letter.used { opacity: .25; pointer-events: none; }

.spell-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}
.spell-tools button {
  padding: 10px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* 答题结果条 */
.verdict {
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  min-height: 26px;
  color: var(--ok);
}
.verdict.bad { color: var(--no); }

/* ------------------------------- 结算 ------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 56, .45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
  backdrop-filter: blur(3px);
}
.sheet.on { display: flex; }
.sheet-body {
  width: 100%;
  max-width: 620px;
  background: #fff;
  border-radius: 26px 26px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: up .3s cubic-bezier(.2, .9, .25, 1);
}
/* 内容区独立滚动，按钮区固定在底部 —— 错题多的时候按钮不会被滚走 */
.sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px 20px 6px;
}
@keyframes up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.medal { text-align: center; }
.medal .big { font-size: 54px; line-height: 1; }
.medal .ttl {
  font-size: 22px;
  font-weight: 800;
  margin: 8px 0 2px;
}
.medal .sub { font-size: 14px; color: var(--muted); }

.star-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 6px;
  font-size: 40px;
  line-height: 1;
}
.star-row span {
  color: #e3e8f2;
  display: inline-block;
  animation: starIn .4s backwards;
}
.star-row span.on { color: var(--gold); }
.star-row span:nth-child(1) { animation-delay: .1s; }
.star-row span:nth-child(2) { animation-delay: .28s; }
.star-row span:nth-child(3) { animation-delay: .46s; }
@keyframes starIn {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(8deg); }
  to { transform: none; opacity: 1; }
}

.stat-row {
  display: flex;
  justify-content: space-around;
  padding: 16px 0;
  margin: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-row .it { text-align: center; }
.stat-row .v { font-size: 21px; font-weight: 800; }
.stat-row .l { font-size: 12px; color: var(--muted); margin-top: 3px; }

.wrong-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin: 16px 0 10px;
}
.wrong-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  background: #fbfcff;
  box-shadow: inset 0 0 0 1.5px var(--line);
  margin-bottom: 8px;
}
.wrong-item .w {
  font-size: 17px;
  font-weight: 700;
  color: var(--no);
}
.wrong-item .c { font-size: 13px; color: var(--muted); }
.wrong-item .spk {
  margin-left: auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-s);
  font-size: 15px;
  flex-shrink: 0;
}

.sheet-actions {
  display: grid;
  gap: 10px;
  flex-shrink: 0;
  background: #fff;
  padding: 12px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 矮屏（iPhone SE 这类 568~640 高度的机器）压缩垂直间距，否则四个选项会顶出屏幕 */
@media (max-height: 660px) {
  .play-view { padding-top: 10px; }
  .play-head { margin-bottom: 10px; }
  .q-stage { gap: 12px; padding: 0; }
  .q-prompt { font-size: 14px; }
  .q-big { font-size: 34px; }
  .q-big.cn { font-size: 26px; }
  .speaker { width: 86px; height: 86px; font-size: 34px; }
  .opts { gap: 9px; }
  .opt { min-height: 54px; padding: 9px 12px; font-size: 15px; }
  .slot { width: 36px; height: 46px; font-size: 21px; }
  .letter { width: 48px; height: 48px; font-size: 20px; }
}

/* ------------------------------- 选择册 ------------------------------- */

.book-list { display: grid; gap: 10px; }
.book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  text-align: left;
  width: 100%;
}
.book-item.cur { box-shadow: inset 0 0 0 2px var(--primary); }
.book-item .g {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--primary-l);
  color: var(--primary-d);
  display: grid; place-items: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.book-item .t { display: block; font-size: 15px; font-weight: 700; }
.book-item .s { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.book-item .ck { color: var(--primary); font-size: 18px; }

/* ------------------------------- 提示 ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 41, 55, .94);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 200;
  max-width: 80vw;
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty .e { font-size: 44px; }
.empty .t { margin-top: 10px; font-size: 15px; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  display: grid;
  place-items: center;
  min-height: 60vh;
  gap: 14px;
}
.loading-page .t { color: var(--muted); font-size: 14px; }

/* 桌面端放宽 */
@media (min-width: 700px) {
  .view { padding: 30px 24px 40px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .q-big { font-size: 50px; }
  .sheet-body { border-radius: 26px; margin-bottom: 24px; }
}

/* ==========================================================================
   数学练习
   和英语模块共用配色，但布局独立：题面占满中间、数字键盘固定贴底
   ========================================================================== */

/* ---------------------------- 首页入口 ---------------------------- */

.math-entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #6c8bff 0%, #9b7bff 100%);
  color: #fff;
  text-align: left;
  box-shadow: 0 8px 22px rgba(91, 124, 250, .28);
}
.math-entry:active { transform: scale(.985); }
.me-ico { font-size: 26px; line-height: 1; }
.me-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.me-txt b { font-size: 16px; font-weight: 700; }
.me-txt i { font-size: 12px; font-style: normal; opacity: .88; }
.me-go { font-size: 24px; opacity: .85; }

/* ---------------------------- 年级选择 ---------------------------- */

.m-grade-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.m-grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  background: #fff;
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-s);
}
.m-grade b { font-size: 14px; font-weight: 600; }
.m-grade i { font-size: 11px; font-style: normal; color: var(--muted); }
.m-grade.on { border-color: var(--primary); background: var(--primary-l); }
.m-grade.on b { color: var(--primary-d); }
.m-grade.on i { color: var(--primary); }

/* ---------------------------- 首页卡片 ---------------------------- */

.m-intro { text-align: center; padding: 22px 18px; margin-bottom: 16px; }
.mi-ico { font-size: 40px; line-height: 1; }
.m-intro h3 { margin: 10px 0 6px; font-size: 18px; }
.m-intro p { margin: 0; font-size: 13px; line-height: 1.75; color: var(--muted); }

.m-hero { padding: 18px; margin-bottom: 14px; }
.mh-top { display: flex; align-items: center; justify-content: space-between; }
.mh-t { font-size: 20px; font-weight: 700; }
.mh-s { font-size: 13px; color: var(--muted); margin-top: 4px; }
.mh-ring {
  text-align: right;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.mh-ring span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 2px;
}
.mh-ring i { font-size: 12px; font-style: normal; }
.m-bar {
  height: 8px;
  margin: 14px 0;
  border-radius: 99px;
  background: var(--primary-l);
  overflow: hidden;
}
.m-bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #5b7cfa, #8f7bff);
  transition: width .5s cubic-bezier(.2, .9, .25, 1);
}
.m-stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.m-stats div { display: flex; flex-direction: column; gap: 2px; }
.m-stats b { font-size: 19px; font-weight: 700; }
.m-stats span { font-size: 11px; color: var(--muted); }

.m-continue {
  height: 54px;
  font-size: 16px;
  margin-bottom: 14px;
  border-radius: 16px;
}

.m-alldone {
  text-align: center;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--ok-l);
  color: #1f9a5b;
  font-size: 15px;
  font-weight: 600;
}

.m-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mq {
  position: relative;
  height: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 14px;
}
.mq:active { transform: scale(.97); }
.mq .i { font-size: 24px; line-height: 1; }
.mq .badge {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--no);
  color: #fff;
  font-size: 11px;
  font-style: normal;
}

.sec-h { margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------------------------- 关卡地图 ---------------------------- */

.m-map-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}
.m-map-top b { font-size: 16px; color: var(--text); }

.m-sec { margin-bottom: 20px; }
.m-sec-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.m-sec-h b { font-size: 15px; font-weight: 600; }
.m-sec-h span { font-size: 12px; color: var(--muted); }

.mlv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mlv {
  height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-s);
}
.mlv .n { font-size: 20px; font-weight: 700; }
.mlv .st { display: flex; gap: 2px; font-size: 11px; color: #dfe4ee; line-height: 1; }
.mlv .st i { font-style: normal; }
.mlv .st i.on { color: var(--gold); }
.mlv.pass { background: #f4fcf7; border-color: #cceedd; }
.mlv.open { border-color: var(--primary); box-shadow: 0 4px 14px rgba(91, 124, 250, .2); }
.mlv.lock { opacity: .36; }
.mlv.lock .n { font-size: 15px; }
.mlv:active:not([disabled]) { transform: scale(.96); }

/* ---------------------------- 答题页 ---------------------------- */

.view.mplay.on {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.math-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.m-qbox {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  /* 内容整体略偏下，靠近键盘，视线和手指的距离更短 */
  padding: 6vh 2px 4px;
}
.m-qhead { text-align: center; font-size: 13px; color: var(--muted); }
.m-qtext {
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 1px;
  word-break: break-word;
}
/* 应用题字数多，字号收小、左对齐才好读 */
.m-qtext.word {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.85;
  letter-spacing: 0;
  text-align: left;
}
.qmark {
  color: var(--primary);
  border-bottom: 4px solid var(--primary);
  padding: 0 5px 1px;
}

.m-answer {
  position: relative;
  min-height: 84px;
  margin-top: 6px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: 36px;
  font-weight: 700;
}
.m-answer .ph { font-size: 18px; font-weight: 500; color: #c3cada; }
.m-answer .u { font-size: 20px; font-weight: 600; color: var(--muted); }
.m-answer .mark {
  position: absolute;
  right: 16px;
  font-size: 26px;
  color: var(--ok);
}
.m-answer.right { border-style: solid; border-color: var(--ok); background: var(--ok-l); }
.m-answer.right .v { color: var(--ok); }
.m-answer.wrong {
  flex-direction: column;
  gap: 2px;
  border-style: solid;
  border-color: var(--no);
  background: var(--no-l);
}
.m-answer.wrong .v {
  font-size: 26px;
  color: var(--no);
  text-decoration: line-through;
}
.m-answer .right-ans { font-size: 13px; font-weight: 500; color: var(--muted); }
.m-answer .right-ans b { font-size: 19px; color: var(--ok); }

.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--no); }

/* 数字键盘 */
.kb {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
}
.kb .k {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.kb .k:active { transform: scale(.96); background: var(--primary-l); }
.kb .k.aux { background: #eef1f8; color: var(--muted); font-size: 20px; }
.kb .k.off { opacity: .32; pointer-events: none; }
.kb .k.wide {
  grid-column: span 2;
  background: linear-gradient(135deg, #5b7cfa, #7f6bff);
  color: #fff;
  font-size: 17px;
}
.kb .k.wide:active { background: var(--primary-d); }
.kb.wait { opacity: .5; pointer-events: none; }

/* ---------------------------- 结算 ---------------------------- */

.m-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 6px; }
.m-stars i { font-style: normal; font-size: 40px; line-height: 1; color: #e3e8f2; }
.m-stars i.on { color: var(--gold); }
.record {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 99px;
  background: #fff7e0;
  color: #b8860b;
  font-size: 12px;
}

.m-wronglist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.mwl { padding: 10px 12px; border-radius: 12px; background: #f7f9ff; }
.mwl .q { font-size: 14px; line-height: 1.65; }
.mwl .a { margin-top: 4px; font-size: 12px; color: var(--muted); }
.mwl .a .ok { color: var(--ok); }
.mwl .a .no { color: var(--no); }

.m-allright { padding: 14px; text-align: center; font-size: 15px; color: var(--ok); }

/* ---------------------------- 解题思路（应用题答错时） ---------------------------- */

/* 答错后让键盘退场，把屏幕让给解析 —— 一块屏塞两件不相干的事最难看 */
.math-stage.explaining { justify-content: center; }
.math-stage.explaining .kb { display: none; }
/* 题面不再撑满，跟解析卡片贴在一起当一组居中，上面就不会空出一大块 */
.math-stage.explaining .m-qbox {
  flex: 0 0 auto;
  padding: 0 2px 16px;
}

.m-explain {
  flex: 0 0 auto;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 15px 17px 17px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: pop .22s ease-out;
}
.m-explain[hidden] { display: none; }
.me-head { margin-bottom: 7px; }
.me-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--primary-l);
  color: var(--primary-d);
  font-size: 12px;
  font-weight: 600;
}
.me-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  /* 六年级的长解析允许自己滚，别把按钮顶出屏幕 */
  max-height: 32vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.me-ok { margin-top: 13px; height: 48px; font-size: 16px; }

/* 错题本里的解析 */
.mw-exp {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f2f6ff;
  font-size: 13px;
  line-height: 1.8;
  color: #4a5468;
}
.mw-exp .lbl { font-weight: 600; color: var(--primary-d); }

/* 结算页错题回顾里的解析 */
.mwl .e {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #dfe5f2;
  font-size: 12px;
  line-height: 1.75;
  color: #5a6478;
}

/* ---------------------------- 错题本 ---------------------------- */

.mw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.mw-list { display: flex; flex-direction: column; gap: 10px; }
.mw-item { padding: 14px; border-radius: 16px; background: #fff; box-shadow: var(--shadow-s); }
.mw-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}
.mw-top .mw-times { color: var(--no); }
.mw-q { font-size: 15px; line-height: 1.7; margin-bottom: 6px; }
.mw-a { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.mw-a b { font-size: 16px; color: var(--ok); }
.mw-item.mastered { opacity: .6; }
.btn-mini { padding: 6px 14px; font-size: 12px; border-radius: 10px; }
.mw-item .btn-mini {
  display: inline-flex;
  width: auto;
  height: 34px;
  padding: 0 16px;
  align-items: center;
}

/* ---------------------------- 小屏适配 ---------------------------- */

@media (max-height: 680px) {
  .m-qtext { font-size: 30px; }
  .m-qtext.word { font-size: 17px; line-height: 1.75; }
  .m-answer { min-height: 64px; font-size: 30px; }
  .kb .k { height: 46px; font-size: 19px; }
  .kb { gap: 6px; }
  .m-qbox { gap: 5px; }
}

@media (min-width: 640px) {
  .m-grade-row { grid-template-columns: repeat(6, 1fr); }
  .mlv-grid { grid-template-columns: repeat(5, 1fr); }

  /* 宽屏上别把键盘拉成一排又宽又扁的横条，收窄居中才像个数码键盘 */
  .kb {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
  }
  .kb .k { height: 64px; font-size: 24px; }

  .m-qbox {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
  }
  #v-math-play .play-head {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
  }
  .m-explain {
    width: 100%;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
  }
  .me-body { max-height: 40vh; }
}

/* ==========================================================================
 * 语文练习
 * 外壳（顶栏、地图、错题本）全部复用数学模块那套 class，
 * 这里只补答题页的两种作答界面：四选一、汉字托盘。
 * ========================================================================== */

.cn-entry {
  background: linear-gradient(135deg, #ff8a7a 0%, #ffb457 100%);
  box-shadow: 0 8px 22px rgba(255, 138, 106, .28);
}

.cnplay .math-stage {
  justify-content: center;
}

/* 题面和选项当成一整块居中：题目和选项之间不留空档，
   上下多余的空白均分，屏幕上任何一处都不至于空出一大截 */
.cn-qbox {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 20px;
}

.cn-qtext {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.cn-qtext.long {
  font-size: 19px;
  line-height: 1.7;
}

.cn-hint {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.cn-hint:empty { display: none; }

/* 托盘拼字时，上面这条就是「已经拼出来的答案」 */
.cn-slots {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 2px;
}
.cn-slots[hidden] { display: none; }
.cn-slots .ph {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  color: #c3cad8;
}
.cn-slots.right { color: var(--ok); }
.cn-slots.wrong {
  color: var(--no);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* 四选一 */
.cn-opts {
  flex: 0 0 auto;
  display: grid;
  gap: 9px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.cn-opts[hidden] { display: none; }

.cn-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 11px 15px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-s);
  text-align: left;
}
.cn-opt:active { transform: scale(.99); }
.cn-opt .k {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-l);
  color: var(--primary-d);
  font-size: 13px;
  font-weight: 700;
}
.cn-opt .t {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.cn-opts.short .cn-opt .t {
  font-size: 20px;
  letter-spacing: .5px;
}
.cn-opt.right {
  background: var(--ok-l);
  box-shadow: inset 0 0 0 1.5px var(--ok);
}
.cn-opt.right .k { background: var(--ok); color: #fff; }
.cn-opt.wrong {
  background: var(--no-l);
  box-shadow: inset 0 0 0 1.5px var(--no);
}
.cn-opt.wrong .k { background: var(--no); color: #fff; }
/* 判过之后不要变灰，否则看不出对错 */
.cn-opt:disabled { opacity: 1; }

/* 汉字托盘 */
.cn-tray {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.cn-tray[hidden] { display: none; }

.cn-tile {
  height: 56px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.cn-tile:active { transform: scale(.96); }
.cn-tile.used {
  background: #eef1f7;
  box-shadow: none;
  color: #c3cad8;
}
.cn-tile:disabled { opacity: 1; }
.cn-tile.used:disabled { opacity: .55; }

.cn-tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.9fr;
  gap: 9px;
  padding: 9px 0 calc(12px + env(safe-area-inset-bottom));
}
.cn-tools[hidden] { display: none; }

.cn-tool {
  height: 50px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.cn-tool.ok {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 124, 250, .3);
}
.cn-tool:disabled { opacity: .4; box-shadow: none; }

/* 答错后：托盘整个让位给解析卡片；
   四选一则保留选项 —— 孩子得看得见自己刚点的是哪个、对的又是哪个 */
.math-stage.explaining.form-pick .cn-tray,
.math-stage.explaining.form-pick .cn-tools {
  display: none;
}
.math-stage.explaining .cn-qbox { padding: 0 0 12px; }
.math-stage.explaining .cn-qtext { font-size: 19px; }
.math-stage.explaining.form-choice .cn-opt {
  min-height: 46px;
  padding: 8px 14px;
}
.math-stage.explaining.form-choice .cn-opt .t { font-size: 15px; }
.math-stage.explaining.form-choice .cn-opts.short .cn-opt .t { font-size: 17px; }

.cn-explain {
  flex: 0 0 auto;
  margin-bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 15px 17px 17px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: pop .22s ease-out;
}
.cn-explain[hidden] { display: none; }

.ce-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.ce-tag {
  padding: 3px 10px;
  border-radius: 9px;
  background: var(--ok-l);
  color: var(--ok);
  font-size: 12px;
  font-weight: 600;
}
.ce-ans {
  font-size: 20px;
  font-weight: 700;
  color: var(--ok);
}
.ce-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}
.ce-ok {
  width: 100%;
  margin-top: 14px;
  height: 48px;
}

/* 宽屏：别让选项和托盘铺满整行 */
@media (min-width: 640px) {
  .cn-qbox,
  .cn-opts,
  .cn-tray,
  .cn-tools,
  .cn-explain {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
  }
  .cn-tray { grid-template-columns: repeat(6, 1fr); }
}
