:root {
  --bg: #f4f6fb;
  --card: #fff;
  --ink: #1f2937;
  --mute: #6b7280;
  --line: #e5e7eb;
  --main: #4c6ef5;
  --ok: #2f9e44;
  --okbg: #ebfbee;
  --bad: #e03131;
  --badbg: #fff5f5;
  --c: var(--main);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px; line-height: 1.6;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 600px; margin: 0 auto; min-height: 100vh; padding-bottom: 120px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.loading { text-align: center; padding: 40vh 0; color: var(--mute); }
.sm { font-size: 13px; color: var(--mute); }
small { color: var(--mute); }

/* 进度条 */
.meter { height: 10px; background: #e9ecef; border-radius: 99px; overflow: hidden; flex: 1; }
.meter i { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .4s; }
.meter.light { background: rgba(255,255,255,.3); margin: 8px 0 4px; }
.meter.light i { background: #ffd43b; }

/* 顶栏 */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(244,246,251,.95); backdrop-filter: blur(8px); }
.bar h1 { flex: 1; margin: 0; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .back { font-size: 32px; line-height: 1; width: 36px; }
.bar .pts { font-weight: 700; font-size: 14px; color: #e67700; min-width: 36px; text-align: right; }

/* 首页 */
.hero { margin: 12px; padding: 22px 20px 18px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, #4c6ef5, #7950f2); box-shadow: 0 8px 24px rgba(76,110,245,.3); }
.hero .lv { font-size: 14px; opacity: .9; }
.hero .big { font-size: 40px; font-weight: 800; line-height: 1.2; }
.hero .sm { color: rgba(255,255,255,.85); }
.hero h2 { margin: 14px 0 0; font-size: 18px; }
.tip { margin: 0 12px 12px; padding: 14px 16px; background: #fff9db; border-radius: var(--radius); font-size: 14px; }
.tip p { margin: 6px 0; }
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 12px; }
.subj { display: flex; flex-direction: column; gap: 4px; padding: 18px 16px; background: var(--card); border-radius: var(--radius); border-bottom: 5px solid var(--c); box-shadow: 0 2px 8px rgba(0,0,0,.05); transition: transform .15s; }
.subj:active, .tile:active, .node:active .dot { transform: scale(.96); }
.subj .ico { font-size: 34px; }
.subj .nm { font-size: 18px; font-weight: 700; }
.subj .pg { font-size: 13px; color: var(--mute); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px; }
.tile { position: relative; display: flex; flex-direction: column; padding: 14px; background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(0,0,0,.05); transition: transform .15s; }
.tile span { font-size: 28px; }
.tile small { font-size: 12px; }
.tile em { position: absolute; top: 10px; right: 10px; font-style: normal; font-size: 11px; background: #ffe8cc; color: #d9480f; padding: 1px 8px; border-radius: 99px; }
.foot { text-align: center; padding: 16px; font-size: 12px; color: var(--mute); }
.link { background: none; border: 0; color: var(--main); padding: 6px 10px; font-size: 14px; }
.link.center { display: block; margin: 12px auto 0; }

/* 闯关地图 */
.map { padding: 0 16px; }
.unit h3 { margin: 18px 0 4px; font-size: 18px; }
.unit h3 small { display: block; font-size: 13px; font-weight: 400; }
.path { display: flex; flex-direction: column; gap: 6px; padding: 10px 0 20px; }
.node { display: flex; flex-direction: column; align-items: center; width: 46%; text-align: center; }
.node.p0 { margin-left: 0; }
.node.p1 { margin-left: 27%; }
.node.p2 { margin-left: 54%; }
.node .dot { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; font-size: 26px; font-weight: 800; color: #fff; background: var(--c); box-shadow: 0 6px 0 rgba(0,0,0,.18); transition: transform .15s; }
.node.done .dot { box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 0 0 5px #ffd43b; }
.node.locked .dot { background: #ced4da; font-size: 24px; }
.node .st { color: #fab005; font-size: 18px; letter-spacing: 2px; margin-top: 8px; }
.node.locked .st { color: #ced4da; }
.node .tt { font-size: 14px; line-height: 1.35; }
.node.locked .tt { color: var(--mute); }
.more { text-align: center; color: var(--mute); font-size: 13px; }

/* 知识卡片 */
.cardwrap { padding: 4px 16px; }
.kcard { background: var(--card); border-radius: 20px; padding: 20px 18px; border-top: 6px solid var(--c); box-shadow: 0 4px 16px rgba(0,0,0,.06); min-height: 50vh; animation: pop .25s; }
.kno { font-size: 12px; color: var(--c); font-weight: 700; }
.kcard h2 { margin: 4px 0 10px; font-size: 20px; }
.kcard ul { margin: 0; padding-left: 20px; }
.kcard li { margin: 8px 0; }
.kcard b { color: var(--c); background: linear-gradient(transparent 60%, rgba(255,212,59,.45) 60%); }
.dots { display: flex; justify-content: center; gap: 6px; margin: 14px 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #ced4da; }
.dots i.on { background: var(--c); width: 20px; border-radius: 99px; }
.nav { display: flex; gap: 10px; }
.nav .btn { flex: 1; }

/* 按钮 */
.btn { display: block; width: 100%; padding: 14px; border: 0; border-radius: 14px; background: var(--bc, var(--main)); color: #fff; font-size: 17px; font-weight: 700; text-align: center; box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .1s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn:disabled { background: #ced4da; box-shadow: none; cursor: default; }
.btn.go { background: var(--ok); }
.btn.warn { background: var(--bad); }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 0 0 2px var(--line) inset, 0 4px 0 var(--line); }

/* 答题 */
.qbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg); }
.qbar .x { border: 0; background: none; font-size: 30px; line-height: 1; color: var(--mute); padding: 0 4px; }
.qbar .meter i { background: var(--ok); }
.combo { font-weight: 800; color: #f76707; animation: pop .3s; }
.cnt { font-size: 14px; color: var(--mute); }
.timer { font-weight: 800; color: var(--main); min-width: 56px; text-align: right; }
.timer.hurry { color: var(--bad); animation: shake .5s infinite; }
.qwrap { padding: 4px 16px 300px; } /* 留出底部反馈面板的高度，长题目可以滚动看全 */
.qtag { display: inline-block; font-size: 13px; color: var(--c); font-weight: 700; background: #fff; padding: 2px 12px; border-radius: 99px; }
.qtag small { font-weight: 400; }
.qtext { font-size: 20px; line-height: 1.55; margin: 12px 0 18px; }
.blank { display: inline-block; width: 4em; border-bottom: 2px solid var(--ink); margin: 0 4px; }
.opts, .judge { display: flex; flex-direction: column; gap: 10px; }
.judge { flex-direction: row; }
.judge .opt { justify-content: center; font-size: 20px; padding: 22px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; background: #fff; border: 2px solid var(--line); border-radius: 14px; font-size: 17px; box-shadow: 0 3px 0 var(--line); }
.opt .key { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); font-size: 14px; font-weight: 700; color: var(--mute); }
.opt.sel { border-color: var(--main); background: #edf2ff; box-shadow: 0 3px 0 #bac8ff; }
.opt.sel .key { border-color: var(--main); color: var(--main); }
.opt.right, .chip.right, .mt.right, .fill.right { border-color: var(--ok) !important; background: var(--okbg) !important; }
.opt.wrong, .chip.wrong, .mt.wrong, .fill.wrong { border-color: var(--bad) !important; background: var(--badbg) !important; }
.opt.right { animation: pop .3s; }
.opt.wrong { animation: shake .35s; }
.opt.dim { opacity: .5; }
.opt:disabled { color: var(--ink); }
.fill { width: 100%; font-size: 18px; padding: 14px; border: 2px solid var(--line); border-radius: 14px; outline: none; background: #fff; }
.fill:focus { border-color: var(--main); }
.hint { font-size: 13px; color: var(--mute); margin: -8px 0 12px; }
.slots { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #fff; border-radius: 14px; border: 2px dashed var(--line); min-height: 60px; }
.slot.empty { padding: 10px; border-radius: 10px; background: #f1f3f5; color: #adb5bd; font-weight: 700; text-align: center; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { padding: 10px 14px; background: #fff; border: 2px solid var(--line); border-radius: 12px; font-size: 16px; box-shadow: 0 3px 0 var(--line); text-align: left; }
.slots .chip { display: flex; gap: 10px; align-items: center; width: 100%; border-color: #bac8ff; background: #edf2ff; }
.chip em { font-style: normal; font-weight: 800; color: var(--main); }
.chip:disabled { color: var(--ink); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.mt { min-height: 56px; padding: 10px; background: #fff; border: 2px solid var(--line); border-radius: 12px; font-size: 15px; line-height: 1.4; box-shadow: 0 3px 0 var(--line); }
.mt.active { border-color: var(--main); box-shadow: 0 0 0 3px #bac8ff; }
.mt[data-paired] { border-color: var(--pc); border-width: 3px; background: #f8f9fa; background: color-mix(in srgb, var(--pc) 12%, #fff); }
.mt:disabled { color: var(--ink); }
.foot-btn, .fb { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; max-width: 600px; margin: 0 auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.foot-btn { background: linear-gradient(transparent, var(--bg) 30%); }
.fb { border-radius: 20px 20px 0 0; animation: up .25s; max-height: 60vh; overflow: auto; }
.fb.ok { background: var(--okbg); color: #2b8a3e; }
.fb.bad { background: var(--badbg); color: #c92a2a; }
.fb b { font-size: 19px; }
.fb p { margin: 6px 0; color: var(--ink); }
.fb .ex { font-size: 14px; color: #495057; }
.fb .btn { margin-top: 10px; }

/* 结果、介绍页 */
.result, .intro { padding: 8px 16px; text-align: center; }
.intro p { text-align: left; }
.emoji { font-size: 64px; animation: pop .4s; }
.stars.big3 span { font-size: 60px; color: #dee2e6; display: inline-block; margin: 0 4px; }
.stars.big3 span.on { color: #fab005; animation: starin .5s both; }
.score { font-size: 72px; font-weight: 800; color: var(--main); animation: pop .4s; }
.score small { font-size: 22px; }
.stats { display: flex; justify-content: center; gap: 10px; margin: 16px 0; }
.stats div { flex: 1; background: #fff; border-radius: 14px; padding: 10px; }
.stats b { display: block; font-size: 22px; }
.newbadge { background: #fff9db; border-radius: 14px; padding: 10px; margin-bottom: 14px; }
.newbadge p { margin: 0 0 6px; font-weight: 700; }
.newbadge span { display: inline-flex; align-items: center; gap: 4px; margin: 4px; padding: 4px 10px; background: #fff; border-radius: 99px; animation: pop .5s; }
.newbadge i { font-style: normal; font-size: 20px; }
.acts { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.review { text-align: left; margin-top: 20px; }
.rv { background: #fff; border-radius: 12px; padding: 12px; margin: 8px 0; border-left: 5px solid var(--ok); }
.rv.bad { border-left-color: var(--bad); }
.rq { margin-bottom: 4px; }
.ra { font-size: 14px; color: #495057; }
.re { font-size: 13px; color: var(--mute); margin-top: 4px; }

/* 错题本 */
.wlist { padding: 0 16px; }
.wlist h3 { margin: 16px 0 8px; }
.wq { background: #fff; border-radius: 12px; padding: 12px; margin: 8px 0; }
.wq summary { cursor: pointer; }
.wq summary small { display: block; }
.wq p { margin: 6px 0 0; color: var(--ok); }
.wq .ex { color: var(--mute); font-size: 14px; }

/* 徽章 */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 8px 16px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 6px; background: #fff; border-radius: 14px; opacity: .55; filter: grayscale(1); }
.badge.got { opacity: 1; filter: none; box-shadow: 0 0 0 2px #ffd43b; }
.badge i { font-style: normal; font-size: 34px; }
.badge b { font-size: 14px; }
.badge small { font-size: 11px; line-height: 1.4; }
.badge em { font-style: normal; font-size: 10px; color: #e67700; }

/* 提示、彩带 */
#toast { position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px); background: rgba(33,37,41,.92); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

@keyframes pop { 0% { transform: scale(.85); opacity: .4; } 60% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes starin { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes fall { to { top: 110vh; transform: translateX(60px) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 700px) { .badges { grid-template-columns: repeat(4, 1fr); } }
