/* ============================================================
   五年级学习闯关乐园 · 贴纸绘本风 v4
   方向：暖色绘本贴纸风游戏机 —— 奶油纸底、墨色描边贴纸卡片、
   硬投影、一颗珊瑚橘主色（=动作）；学科彩色只作学科身份。
   展示字体：ZCOOL KuaiLe（CJK）/ Baloo 2（数字与拉丁）
   ============================================================ */

:root {
  /* 中性色：从同一暖色调派生 */
  --paper: #faf6ee;
  --paper-2: #f2ecdd;
  --surface: #fffdf7;
  --ink: #35322c;
  --ink-2: #77715f;
  --line: #e6dfcf;

  /* 强调色：只给"动作"和"现在进行的事" */
  --accent: #e85a35;
  --accent-soft: #ffe9e0;
  --gold: #f0a51e;      /* 只用于金币与星星 */
  --good: #3f9e6e;      /* 只用于"正确/完成" */
  --good-soft: #e3f3ea;
  --bad: #d9534f;       /* 只用于"错误" */
  --bad-soft: #fde9e7;

  /* 学科身份色：只出现在学科相关元素上 */
  --c-math: #e05a80;   --c-math-bg: #fce4ec;
  --c-chinese: #d97e14; --c-chinese-bg: #fcefd7;
  --c-english: #2f7fd0; --c-english-bg: #e2eefb;
  --c-science: #2f8f62; --c-science-bg: #e0f2e8;
  --c-df: #7c58c7;      --c-df-bg: #ebe4fa;

  /* 唯一圆角与唯一阴影配方 */
  --radius: 16px;
  --bw: 2px;
  --line-ink: rgb(53 50 44 / .85);
  --shadow-sticker: 0 4px 0 rgb(53 50 44 / .13);
  --shadow-sticker-lg: 0 5px 0 rgb(53 50 44 / .13), 0 14px 28px rgb(53 50 44 / .08);
  --shadow-modal: 0 8px 0 rgb(53 50 44 / .12), 0 28px 60px rgb(53 50 44 / .22);

  /* 字体 */
  --font-display: 'ZCOOL KuaiLe', 'Yuanti SC', 'STYuanti', 'PingFang SC', sans-serif;
  --font-num: 'Baloo 2', 'ZCOOL KuaiLe', 'PingFang SC', sans-serif;
  --font-body: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;

  /* 间距（只用这些值） */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px; --s12: 48px;

  /* 字号（1.25 比例，跳跃要果断） */
  --text-xs: .75rem; --text-sm: .875rem; --text-base: 1rem;
  --text-lg: 1.25rem; --text-xl: 1.563rem; --text-2xl: 1.953rem; --text-3xl: 2.441rem;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.7;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.num { font-family: var(--font-num); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- 粒子星光（唯一的环境动效，暖色调） ---------- */
#particles-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ---------- 顶栏：实底 + 发丝线 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: .04em;
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.logo b { color: var(--accent); font-weight: 400; }
.top-stats { display: flex; align-items: center; gap: var(--s2); }
.stat {
  font-family: var(--font-num);
  font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums;
  padding: 3px var(--s3); border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--line-ink);
  box-shadow: 0 2px 0 rgb(53 50 44 / .12);
  white-space: nowrap;
}
.chip-gold { color: #9a6a10; background: #fdf3dd; }
.chip-fire { color: #b3402c; background: #fdeae4; }
.stat.bump { animation: bump .45s cubic-bezier(.2, 2.2, .4, 1); }
@keyframes bump { 40% { transform: scale(1.25); } }
.icon-btn {
  border: var(--bw) solid var(--line-ink); background: var(--surface); font-size: 18px;
  width: 40px; height: 40px; border-radius: 12px;
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
  transition: transform .18s cubic-bezier(.2, 0, 0, 1), box-shadow .18s;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 rgb(53 50 44 / .13); }
.back-btn {
  display: none;
  border: var(--bw) solid var(--line-ink); background: var(--surface); color: var(--ink);
  font-size: 20px; font-weight: 800;
  width: 40px; height: 40px; border-radius: 12px;
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
}
body.screen-sub #btn-back { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- 通用 ---------- */
main { max-width: 780px; margin: 0 auto; padding: var(--s6) var(--s4) 64px; }
.screen { display: none; }
.screen.active { display: block; animation: pop-in .3s cubic-bezier(.2, 0, 0, 1); }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 贴纸按钮：实色 + 墨描边 + 硬投影，按压有物理感 */
.btn {
  border: var(--bw) solid var(--line-ink);
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 400; font-size: 19px; letter-spacing: .05em; color: #fff;
  padding: 11px var(--s6) 13px;
  background: var(--accent);
  box-shadow: 0 4px 0 rgb(53 50 44 / .85);
  transition: transform .16s cubic-bezier(.2, 0, 0, 1), box-shadow .16s;
  text-shadow: 0 1px 0 rgb(0 0 0 / .15);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgb(53 50 44 / .85); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgb(53 50 44 / .85); }
.btn.small { font-size: 15px; padding: 7px var(--s4); border-radius: 11px; }
.btn.gray { background: #b6ae9c; }
.btn.gold { background: var(--gold); color: var(--ink); text-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--ink); }

.card {
  background: var(--surface);
  border: var(--bw) solid var(--line-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sticker);
  padding: var(--s6);
}

/* ---------- 首页 ---------- */
.home-head { margin: var(--s4) 0 var(--s6); }
.home-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-3xl);
  line-height: 1.2;
  letter-spacing: .05em;
  margin: 0;
  text-wrap: balance;
}
.home-title em { font-style: normal; color: var(--accent); }
.home-sub { color: var(--ink-2); margin: var(--s1) 0 0; font-size: var(--text-sm); }

/* 继续闯关主卡：唯一的视觉焦点 */
.continue-card {
  display: flex; align-items: center; gap: var(--s4);
  background: var(--surface);
  border: var(--bw) solid var(--line-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sticker-lg);
  padding: var(--s4) var(--s6);
  margin-bottom: var(--s6);
  border-left-width: 8px;
  text-align: left; width: 100%;
  transition: transform .18s cubic-bezier(.2, 0, 0, 1), box-shadow .18s;
}
.continue-card:hover { transform: translateY(-2px); }
.continue-card .cc-icon {
  flex: none; width: 64px; height: 64px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; border: var(--bw) solid var(--line-ink);
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
}
.continue-card .cc-body { flex: 1; min-width: 0; }
.continue-card .cc-eyebrow {
  font-size: var(--text-xs); letter-spacing: .14em; color: var(--accent);
  font-weight: 700; margin: 0 0 2px;
}
.continue-card .cc-title {
  font-family: var(--font-display);
  font-size: var(--text-xl); line-height: 1.3; margin: 0; text-wrap: balance;
}
.continue-card .cc-progress { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); }
.continue-card .cc-track {
  flex: 1; height: 10px; border-radius: 999px;
  background: var(--paper-2); border: 1.5px solid var(--line-ink);
  overflow: hidden;
}
.continue-card .cc-track i { display: block; height: 100%; background: var(--accent); }
.continue-card .cc-count { font-family: var(--font-num); font-size: var(--text-sm); font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.continue-card .cc-play {
  flex: none; width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff;
  border: var(--bw) solid var(--line-ink);
  box-shadow: 0 4px 0 rgb(53 50 44 / .85);
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  transition: transform .16s, box-shadow .16s;
}
.continue-card:hover .cc-play { transform: translateY(-2px); box-shadow: 0 6px 0 rgb(53 50 44 / .85); }

/* 学科贴纸墙 */
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.subject-card {
  position: relative; border: var(--bw) solid var(--line-ink); text-align: left;
  border-radius: var(--radius); padding: var(--s4);
  background: var(--surface);
  box-shadow: var(--shadow-sticker);
  transition: transform .18s cubic-bezier(.2, 0, 0, 1), box-shadow .18s;
  overflow: hidden;
  display: flex; flex-direction: column; gap: var(--s2);
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sticker-lg); }
.subject-card.span2 { grid-column: span 2; flex-direction: row; align-items: center; }
.subject-card .s-icon {
  width: 52px; height: 52px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; border: var(--bw) solid var(--line-ink);
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
}
.subject-card.span2 .s-icon { width: 64px; height: 64px; font-size: 33px; }
.subject-card .s-main { flex: 1; min-width: 0; }
.subject-card .s-name { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.3; letter-spacing: .04em; }
.subject-card.span2 .s-name { font-size: var(--text-xl); }
.subject-card .s-tag { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; }
.subject-card .s-progress {
  font-family: var(--font-num); font-size: var(--text-sm); font-weight: 800;
  color: var(--ink-2); margin-top: var(--s2);
}
.subject-card .s-progress b { color: var(--ink); }
.subject-card .s-go {
  position: absolute; top: 10px; right: 12px;
  font-family: var(--font-num); font-size: var(--text-sm); font-weight: 800; color: var(--ink-2);
}
/* 学科身份色：只染色图标圆片与名称 */
.subject-card.t-math .s-icon { background: var(--c-math-bg); }
.subject-card.t-math .s-name { color: var(--c-math); }
.subject-card.t-chinese .s-icon { background: var(--c-chinese-bg); }
.subject-card.t-chinese .s-name { color: var(--c-chinese); }
.subject-card.t-english .s-icon { background: var(--c-english-bg); }
.subject-card.t-english .s-name { color: var(--c-english); }
.subject-card.t-science .s-icon { background: var(--c-science-bg); }
.subject-card.t-science .s-name { color: var(--c-science); }
.subject-card.t-df .s-icon { background: var(--c-df-bg); }
.subject-card.t-df .s-name { color: var(--c-df); }

/* 状态行：安静的数字条 */
.stat-row {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6);
  margin-top: var(--s6); padding: var(--s3) var(--s4);
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface);
  font-size: var(--text-sm); color: var(--ink-2);
  justify-content: center;
}
.stat-row b { font-family: var(--font-num); color: var(--ink); }

/* ---------- 地图 ---------- */
.map-header { display: flex; align-items: center; gap: var(--s4); margin: var(--s2) 0 var(--s6); }
.map-header .m-icon {
  flex: none; width: 64px; height: 64px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; background: var(--surface);
  border: var(--bw) solid var(--line-ink); box-shadow: 0 4px 0 rgb(53 50 44 / .13);
}
.map-header .m-title { font-family: var(--font-display); font-size: var(--text-2xl); line-height: 1.25; margin: 0; letter-spacing: .04em; }
.map-header .m-sub { color: var(--ink-2); font-size: var(--text-sm); margin-top: 2px; }

.map-path { position: relative; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) 0; }
.map-path::before {
  content: ''; position: absolute; left: 50%; top: var(--s3); bottom: var(--s3);
  border-left: 2px dashed var(--line); transform: translateX(-50%);
}
.map-node {
  display: flex; align-items: center; gap: var(--s3);
  border: none; background: transparent; text-align: left;
  padding: var(--s2) var(--s3); border-radius: 18px;
  width: 88%;
}
.map-node:nth-child(odd)  { align-self: flex-start; }
.map-node:nth-child(even) { align-self: flex-end; flex-direction: row-reverse; text-align: right; }
.map-node .node-circle {
  flex: none; position: relative;
  width: 62px; height: 62px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-size: 24px; font-weight: 800; color: var(--ink);
  background: var(--surface);
  border: var(--bw) solid var(--line-ink);
  box-shadow: 0 4px 0 rgb(53 50 44 / .13);
}
.map-node.current .node-circle { background: var(--accent); color: #fff; }
.map-node.current .node-circle { animation: glow-ring 1.8s ease-in-out infinite; }
@keyframes glow-ring {
  0%, 100% { box-shadow: 0 4px 0 rgb(53 50 44 / .13), 0 0 0 0 rgb(232 90 53 / .4); }
  50% { box-shadow: 0 4px 0 rgb(53 50 44 / .13), 0 0 0 12px rgb(232 90 53 / 0); }
}
.map-node.done .node-circle { background: var(--good-soft); }
.map-node.done .node-circle::after { content: '✓'; position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; border: 1.5px solid var(--line-ink); }
.map-node.locked .node-circle { background: var(--paper-2); color: var(--ink-2); border-style: dashed; box-shadow: none; }
.map-node .node-label { flex: 1; }
.map-node .node-bubble {
  background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: 14px;
  padding: var(--s2) var(--s3); box-shadow: 0 3px 0 rgb(53 50 44 / .12);
}
.map-node.locked .node-bubble { border-style: dashed; box-shadow: none; background: transparent; border-color: var(--line); }
.map-node .node-title { font-weight: 700; font-size: 15px; }
.map-node .node-sub { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; }
.map-node.locked .node-title { color: var(--ink-2); font-weight: 500; }
.map-node .node-stars { font-family: var(--font-num); font-size: var(--text-xs); margin-top: 3px; color: var(--gold); letter-spacing: 2px; }
.map-node .node-flag { font-size: 22px; }

/* ---------- 单元 ---------- */
.unit-header { margin: var(--s2) 0 var(--s6); }
.unit-header .u-title { font-family: var(--font-display); font-size: var(--text-2xl); margin: 0; line-height: 1.3; letter-spacing: .04em; text-wrap: balance; }
.unit-header .u-sub { color: var(--ink-2); font-size: var(--text-sm); margin-top: var(--s1); }
.level-list { display: flex; flex-direction: column; gap: var(--s3); }
.level-row {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-sticker);
  padding: var(--s3) var(--s4); border-radius: var(--radius); border: var(--bw) solid var(--line-ink); width: 100%;
  transition: transform .16s cubic-bezier(.2, 0, 0, 1), box-shadow .16s;
}
.level-row:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-sticker-lg); }
.level-row .lv-icon {
  flex: none; width: 50px; height: 50px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  background: var(--paper-2); border: var(--bw) solid var(--line-ink);
}
.level-row.locked { background: transparent; border-style: dashed; border-color: var(--line); box-shadow: none; }
.level-row.locked .lv-icon { border-style: dashed; border-color: var(--line); background: transparent; filter: grayscale(1); opacity: .6; }
.level-row .lv-body { flex: 1; }
.level-row .lv-title { font-weight: 700; font-size: var(--text-base); }
.level-row.locked .lv-title { color: var(--ink-2); font-weight: 500; }
.level-row .lv-sub { font-size: var(--text-xs); color: var(--ink-2); margin-top: 2px; }
.level-row .lv-stars { font-family: var(--font-num); color: var(--gold); font-size: 14px; letter-spacing: 2px; }
.level-row .lv-go { font-size: 20px; color: var(--accent); }

/* ---------- 答题 ---------- */
.play-box { max-width: 580px; margin: 0 auto; }
.play-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); font-size: var(--text-sm); color: var(--ink-2); font-weight: 700; }
.play-top .num { font-size: var(--text-base); }
.play-progress { height: 10px; border-radius: 999px; background: var(--paper-2); border: 1.5px solid var(--line-ink); overflow: hidden; margin-bottom: var(--s6); }
.play-progress .bar { height: 100%; width: 0%; border-radius: 999px; background: var(--accent); transition: width .3s cubic-bezier(.2, 0, 0, 1); }
.q-card {
  background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-sticker-lg); padding: var(--s6);
}
.q-text { font-size: var(--text-lg); font-weight: 700; line-height: 1.7; text-wrap: balance; }
.q-text + .q-text { margin-top: var(--s2); }
.q-audio {
  display: inline-flex; align-items: center; gap: var(--s2); margin-top: var(--s3);
  border: var(--bw) solid var(--line-ink); background: var(--paper-2); color: var(--ink);
  font-size: 15px; font-weight: 700; border-radius: 11px; padding: 7px var(--s3);
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
  transition: transform .16s, box-shadow .16s;
}
.q-audio:hover { transform: translateY(-1px); }
.q-audio.wiggle { animation: wiggle .4s ease; }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.q-options { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s6); }
.opt-btn {
  display: flex; align-items: center; gap: var(--s3);
  border: var(--bw) solid var(--line-ink); background: var(--surface);
  border-radius: 14px; padding: var(--s3) var(--s4);
  font-size: var(--text-base); text-align: left; color: var(--ink); font-weight: 700;
  box-shadow: 0 3px 0 rgb(53 50 44 / .13);
  transition: transform .16s cubic-bezier(.2, 0, 0, 1), box-shadow .16s, background .16s, border-color .16s;
}
.opt-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 5px 0 rgb(53 50 44 / .13); }
.opt-btn .opt-letter {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 800; font-size: 14px;
  background: var(--paper-2); border: 1.5px solid var(--line-ink);
}
.opt-btn.correct { background: var(--good-soft); border-color: var(--good); }
.opt-btn.correct .opt-letter { background: var(--good); color: #fff; border-color: var(--good); }
.opt-btn.wrong { background: var(--bad-soft); border-color: var(--bad); }
.opt-btn.wrong .opt-letter { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt-btn.dim { opacity: .45; }
.q-input-row { display: flex; gap: var(--s3); margin-top: var(--s6); }
.q-input {
  flex: 1; border: var(--bw) solid var(--line-ink); border-radius: 14px;
  font-size: 19px; padding: 11px var(--s4); outline: none; color: var(--ink);
  background: var(--surface); min-width: 0;
}
.q-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-input.good { background: var(--good-soft); border-color: var(--good); }
.q-input.bad { background: var(--bad-soft); border-color: var(--bad); }
.q-feedback { margin-top: var(--s4); border-radius: 12px; padding: var(--s3) var(--s4); font-size: 15px; line-height: 1.7; display: none; }
.q-feedback.show { display: block; animation: pop-in .2s ease; }
.q-feedback.good { background: var(--good-soft); color: #1d5e3f; border: 1.5px solid var(--good); }
.q-feedback.bad { background: var(--bad-soft); color: #8c2f2c; border: 1.5px solid var(--bad); }
.q-next { margin-top: var(--s4); text-align: right; }
#q-next { display: none; }
#q-next.show { display: inline-block; }

/* ---------- 结果弹窗 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.open { display: flex; align-items: center; justify-content: center; background: rgb(53 50 44 / .4); }
.modal {
  background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: 20px;
  box-shadow: var(--shadow-modal);
  max-width: 430px; width: calc(100% - 40px); max-height: 84vh; overflow: auto;
  padding: var(--s8) var(--s6); text-align: center; animation: bounce-in .4s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes bounce-in { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }
.modal h2 { margin: var(--s2) 0 var(--s3); font-family: var(--font-display); font-weight: 400; font-size: var(--text-xl); letter-spacing: .04em; }
.modal .big-emoji { font-size: 62px; line-height: 1.2; animation: float 2.4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-7px); } }
.stars-row { font-size: 40px; letter-spacing: 6px; margin: var(--s2) 0; }
.stars-row .star-pop { display: inline-block; color: var(--gold); }
.stars-row .star-pop.off { filter: grayscale(1) opacity(.3); }
.result-coins { font-family: var(--font-num); font-size: 16px; font-weight: 800; color: #9a6a10; background: #fdf3dd; border: 1.5px solid var(--gold); border-radius: 10px; display: inline-block; padding: 3px var(--s4); margin: var(--s2) 0 var(--s6); }
.modal .btn { margin: var(--s1) var(--s1) 0; }
.modal .plain-text { color: var(--ink-2); font-size: 14.5px; line-height: 1.8; text-align: left; }

/* 奖杯光芒射线（只在庆祝时出现） */
.rays { position: relative; width: 120px; height: 120px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.rays::before {
  content: ''; position: absolute; width: 160px; height: 160px;
  background: conic-gradient(rgb(240 165 30 / .4) 0 11deg, transparent 11deg 34deg,
    rgb(240 165 30 / .4) 34deg 45deg, transparent 45deg 68deg,
    rgb(240 165 30 / .4) 68deg 79deg, transparent 79deg 102deg,
    rgb(240 165 30 / .4) 102deg 113deg, transparent 113deg 136deg,
    rgb(240 165 30 / .4) 136deg 147deg, transparent 147deg 170deg,
    rgb(240 165 30 / .4) 170deg 181deg, transparent 181deg 204deg,
    rgb(240 165 30 / .4) 204deg 215deg, transparent 215deg 238deg,
    rgb(240 165 30 / .4) 238deg 249deg, transparent 249deg 272deg,
    rgb(240 165 30 / .4) 272deg 283deg, transparent 283deg 306deg,
    rgb(240 165 30 / .4) 306deg 317deg, transparent 317deg 340deg,
    rgb(240 165 30 / .4) 340deg 351deg, transparent 351deg 360deg);
  border-radius: 50%;
  animation: spin 10s linear infinite;
}
.rays .big-emoji { position: relative; z-index: 1; font-size: 70px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 宠物 ---------- */
.pet-stage {
  position: relative; text-align: center;
  background: var(--surface);
  border: var(--bw) solid var(--line-ink); border-radius: var(--radius);
  box-shadow: var(--shadow-sticker-lg);
  padding: var(--s8) var(--s6) var(--s6);
}
.pet-stage .pet-emoji { font-size: 104px; display: inline-block; animation: float 2.6s ease-in-out infinite; cursor: pointer; filter: drop-shadow(0 10px 12px rgb(53 50 44 / .18)); }
.pet-stage .pet-name { font-family: var(--font-display); font-size: var(--text-xl); margin-top: var(--s2); letter-spacing: .05em; }
.pet-stage .pet-stage-label {
  display: inline-block; margin-top: var(--s2); font-size: var(--text-xs); letter-spacing: .1em;
  font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 2px var(--s3);
}
.pet-exp { margin: var(--s4) auto 0; max-width: 340px; }
.pet-exp .bar-label { font-size: var(--text-xs); color: var(--ink-2); margin-bottom: var(--s1); }
.pet-exp .bar { height: 14px; background: var(--paper-2); border-radius: 999px; overflow: hidden; border: 1.5px solid var(--line-ink); }
.pet-exp .bar i { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width .4s cubic-bezier(.2, 0, 0, 1); }
.pet-actions { display: flex; gap: var(--s3); justify-content: center; margin-top: var(--s6); flex-wrap: wrap; }
.hearts { position: absolute; font-size: 20px; animation: rise 1s ease forwards; pointer-events: none; }
@keyframes rise { to { transform: translateY(-72px); opacity: 0; } }

.achievements { margin-top: var(--s8); }
.achievements h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--text-lg); letter-spacing: .04em; margin: 0 0 var(--s3); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--s3); }
.ach {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 13px;
  padding: var(--s3); text-align: center; font-size: var(--text-xs); color: var(--ink-2);
  filter: grayscale(1) opacity(.5);
}
.ach.got { filter: none; color: var(--ink); border: var(--bw) solid var(--line-ink); box-shadow: 0 3px 0 rgb(53 50 44 / .12); }
.ach .a-emoji { font-size: 28px; display: block; margin-bottom: var(--s1); }
.ach b { display: block; font-size: var(--text-sm); margin-bottom: 2px; }

/* ---------- 卡牌摊位（唯一的深色场景：夜市游戏摊） ---------- */
.gacha-box {
  text-align: center; border-radius: var(--radius);
  background: #35322c; color: var(--paper);
  border: var(--bw) solid var(--line-ink);
  box-shadow: var(--shadow-sticker-lg);
  padding: var(--s6) var(--s4);
}
.gacha-box .g-title { font-family: var(--font-display); font-size: var(--text-xl); letter-spacing: .06em; }
.gacha-box .g-sub { font-size: var(--text-xs); opacity: .75; margin: var(--s1) 0 var(--s4); }
.gacha-btns { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; }
.gacha-btns .btn { box-shadow: 0 4px 0 rgb(0 0 0 / .55); }
.gacha-hint { color: #f6c95c; font-size: 14px; margin-top: var(--s3); width: 100%; }
.gacha-result { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; margin-top: var(--s4); }

.flip-scene { perspective: 700px; display: inline-block; }
.flip-card { position: relative; width: 112px; height: 152px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.34, 1.3, .5, 1); }
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 14px; border: var(--bw) solid var(--line-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800;
}
.flip-face.front {
  background:
    radial-gradient(circle at 28% 24%, rgb(255 255 255 / .22) 0 10%, transparent 11%),
    radial-gradient(circle at 72% 72%, rgb(255 255 255 / .18) 0 8%, transparent 9%),
    #453f35;
  color: #f6c95c; font-size: 38px;
  box-shadow: inset 0 0 0 4px rgb(246 201 92 / .25);
}
.flip-face.back { background: var(--surface); color: var(--ink); transform: rotateY(180deg); padding: var(--s2) 6px; }
.flip-face.back .gc-emoji { font-size: 42px; }
.flip-face.back .gc-name { font-size: 12.5px; margin-top: 2px; text-align: center; line-height: 1.4; }
.gc-r { font-size: 11px; font-weight: 800; margin-top: 3px; display: inline-block; padding: 1px 9px; border-radius: 999px; color: #fff; font-family: var(--font-num); }
.r-N { background: #a29a88; } .r-R { background: #2f7fd0; } .r-SR { background: #7c58c7; } .r-SSR { background: linear-gradient(90deg, #f0a51e, #e85a35); }
.glow-R .flip-face.back { box-shadow: 0 0 16px rgb(47 127 208 / .75); }
.glow-SR .flip-face.back { box-shadow: 0 0 20px rgb(124 88 199 / .85); }
.glow-SSR .flip-face.back { animation: ssr-glow .9s ease-in-out infinite alternate; }
@keyframes ssr-glow {
  from { box-shadow: 0 0 14px rgb(240 165 30 / .8); }
  to { box-shadow: 0 0 32px rgb(232 90 53 / .95); }
}

#flash { position: fixed; inset: 0; z-index: 400; pointer-events: none; background: radial-gradient(circle, rgb(255 255 255 / .95), rgb(240 165 30 / .5)); opacity: 0; }

/* 图鉴 */
.album { margin-top: var(--s8); }
.album h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--text-lg); letter-spacing: .04em; margin: 0 0 var(--s3); }
.album .count { font-family: var(--font-num); color: var(--ink-2); font-size: var(--text-sm); font-weight: 800; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: var(--s2); }
.al-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: var(--s2) 4px; text-align: center; }
.al-card.owned { border: var(--bw) solid var(--line-ink); box-shadow: 0 3px 0 rgb(53 50 44 / .12); }
.al-card .gc-emoji { font-size: 32px; }
.al-card .gc-name { font-size: 11.5px; font-weight: 700; margin-top: 2px; }
.al-card:not(.owned) { filter: grayscale(1); opacity: .4; }
.al-card .gc-r { font-size: 10px; margin-top: 2px; }

/* ---------- 怪兽屋 ---------- */
.monster-tip { background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: var(--radius); box-shadow: var(--shadow-sticker); padding: var(--s3) var(--s4); font-size: 14.5px; color: var(--ink-2); line-height: 1.8; }
.monster-tip b { color: var(--ink); }
.monster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); margin-top: var(--s4); }
.monster-cell { background: var(--surface); border: var(--bw) solid var(--line-ink); border-radius: 15px; box-shadow: var(--shadow-sticker); padding: var(--s4); text-align: center; transition: transform .16s, box-shadow .16s; }
.monster-cell:not(:disabled):hover { transform: translateY(-3px); box-shadow: var(--shadow-sticker-lg); }
.monster-cell .m-emoji { font-size: 38px; display: block; }
.monster-cell .m-q { font-size: var(--text-xs); font-weight: 700; margin-top: var(--s2); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.monster-cell .m-sub { font-size: var(--text-xs); color: var(--ink-2); margin-top: var(--s1); }

.empty-box { text-align: center; padding: var(--s12) var(--s6); color: var(--ink-2); }
.empty-box .e-emoji { font-size: 64px; display: block; margin-bottom: var(--s3); }

/* ---------- 设置 ---------- */
.settings-box .card { margin-bottom: var(--s4); }
.settings-box h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--text-lg); letter-spacing: .04em; margin: 0 0 var(--s2); }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) 0; gap: var(--s4); }
.set-row > div:first-child { font-weight: 700; }
.set-row .desc { font-size: var(--text-xs); color: var(--ink-2); font-weight: 400; margin-top: 2px; }
.switch { position: relative; width: 54px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--paper-2); border: 1.5px solid var(--line-ink); border-radius: 999px; transition: .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: var(--surface); border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.switch input:checked + .track { background: var(--good); }
.switch input:checked + .track::after { transform: translateX(24px); }
.set-select {
  border: var(--bw) solid var(--line-ink); border-radius: 10px;
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  background: var(--surface); padding: 7px var(--s3); max-width: 240px;
}
.set-range { width: 170px; accent-color: var(--accent); }

/* ---------- Toast / 飞行物 / 彩带 ---------- */
#toast-root { position: fixed; left: 50%; bottom: var(--s8); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 700;
  border-radius: 999px; padding: 9px var(--s6);
  animation: toast-in .25s ease;
  box-shadow: 0 6px 18px rgb(53 50 44 / .3);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.confetti-piece { position: fixed; top: -20px; z-index: 300; font-size: 18px; animation: confetti-fall linear forwards; pointer-events: none; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(720deg); } }
.fly-coin { position: fixed; z-index: 500; pointer-events: none; font-size: 26px; }

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

/* ---------- 学科身份色：地图/单元页的图标染色 ---------- */
#screen-map[data-theme="math"] .m-icon,   #screen-unit[data-theme="math"] .lv-icon   { background: var(--c-math-bg); }
#screen-map[data-theme="chinese"] .m-icon, #screen-unit[data-theme="chinese"] .lv-icon { background: var(--c-chinese-bg); }
#screen-map[data-theme="english"] .m-icon, #screen-unit[data-theme="english"] .lv-icon { background: var(--c-english-bg); }
#screen-map[data-theme="science"] .m-icon, #screen-unit[data-theme="science"] .lv-icon { background: var(--c-science-bg); }
#screen-map[data-theme="df"] .m-icon,      #screen-unit[data-theme="df"] .lv-icon      { background: var(--c-df-bg); }
/* 继续闯关主卡图标也用学科色 */
.continue-card.t-math .cc-icon   { background: var(--c-math-bg); }
.continue-card.t-chinese .cc-icon { background: var(--c-chinese-bg); }
.continue-card.t-english .cc-icon { background: var(--c-english-bg); }
.continue-card.t-science .cc-icon { background: var(--c-science-bg); }
.continue-card.t-df .cc-icon      { background: var(--c-df-bg); }

/* ---------- 小屏适配 ---------- */
@media (max-width: 560px) {
  .logo { font-size: 17px; }
  .subject-grid { grid-template-columns: 1fr; }
  .subject-card.span2 { grid-column: span 1; }
  .home-title { font-size: var(--text-2xl); }
  .stat { font-size: 13px; padding: 3px 9px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
  .back-btn { width: 36px; height: 36px; font-size: 18px; }
  .map-node { width: 100%; }
  .continue-card .cc-play { display: none; }
}
