/* =========================================================================
 * Super初一 · 全局样式 (styles/main.css)
 * 设计规范见 DESIGN.md：晴空渐变、卡通扁平、大圆角、弹跳动效、移动优先。
 * ========================================================================= */

:root {
  /* 晴空 / 场景 */
  --sky-1: #7EC8FF;
  --sky-2: #A8E6FF;
  --cloud: #FFFFFF;
  --sun: #FFC53D;
  --sun-deep: #FF9F1C;
  --ink: #2D3142;
  --ink-soft: #4A5068;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 10px 24px rgba(45, 90, 140, 0.16);
  --shadow-sm: 0 4px 12px rgba(45, 90, 140, 0.12);

  /* 七科（龙珠）色 */
  --c-chinese: #FF6B6B;
  --c-math: #4D8DFF;
  --c-english: #A66BFF;
  --c-history: #FF9F45;
  --c-geography: #2EC4B6;
  --c-biology: #52C41A;
  --c-daofa: #FF7BA2;

  /* 动效 */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --radius: 20px;
  --radius-lg: 26px;
  --nav-h: 70px;
}

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

/* 关键：确保 hidden 属性始终生效（作者样式 display:flex 会覆盖 UA 默认的 [hidden]{display:none}，
   否则神龙/庆祝/加载遮罩在初始带 hidden 时仍会显示并拦截整页点击） */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 100%);
  overflow-x: hidden;
}

#app { position: relative; min-height: 100vh; }

/* ---------- 晴空背景装饰 ---------- */
.sky-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud { position: absolute; font-size: 64px; opacity: 0.85; filter: drop-shadow(0 4px 6px rgba(255,255,255,.4)); animation: drift linear infinite; }
.cloud-1 { top: 6%; left: -10%; font-size: 72px; animation-duration: 42s; }
.cloud-2 { top: 24%; left: 60%; font-size: 52px; animation-duration: 55s; animation-delay: -8s; }
.cloud-3 { top: 64%; left: 8%; font-size: 44px; animation-duration: 50s; animation-delay: -20s; }
@keyframes drift {
  from { transform: translateX(-40px); }
  to { transform: translateX(120vw); }
}
.star { position: absolute; color: rgba(255,255,255,0.9); font-size: 18px; animation: twinkle 3s ease-in-out infinite; }
.s1 { top: 12%; left: 18%; }
.s2 { top: 30%; left: 84%; animation-delay: 1s; }
.s3 { top: 70%; left: 30%; animation-delay: 2s; }
.s4 { top: 80%; left: 82%; animation-delay: 0.5s; }
@keyframes twinkle { 0%,100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

/* ---------- 字体工具 ---------- */
.font-cute { font-family: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif; }

/* ---------- 顶部栏 ---------- */
.top-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(126,200,255,.9), rgba(126,200,255,0));
  margin-bottom: -14px;
}
.top-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; border: 2px solid #fff; flex: none;
}
.top-info { flex: 1; min-width: 0; }
.top-name { font-family: "ZCOOL KuaiLe"; font-size: 17px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title { font-size: 12px; color: var(--ink-soft); }
.top-points {
  font-family: "ZCOOL KuaiLe"; font-size: 15px; color: #7a5200;
  background: linear-gradient(180deg, #FFE7A0, #FFC53D);
  padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---------- 视图容器 ---------- */
.view-wrap { position: relative; z-index: 1; padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
.view { display: none; padding: 8px 16px 24px; animation: viewIn .4s var(--spring); }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.page { max-width: 640px; margin: 0 auto; }

/* section 标题 */
.sec { margin: 12px 2px 10px; font-family: "ZCOOL KuaiLe"; font-size: 19px; display: flex; align-items: center; gap: 6px; }
.sec small { font-family: "Noto Sans SC"; font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-left: auto; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .15s var(--ease);
}
.card:active { transform: scale(0.97); }
.card-title { font-family: "ZCOOL KuaiLe"; font-size: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  font-family: "ZCOOL KuaiLe"; border: none; cursor: pointer;
  border-radius: 999px; padding: 12px 26px; font-size: 16px;
  transition: transform .15s var(--spring), box-shadow .2s;
  box-shadow: var(--shadow-sm); color: #fff;
}
.btn:active { transform: scale(0.94); }
.btn-primary { background: linear-gradient(135deg, #5BA8FF, #3D7BFF); }
.btn-gold { background: linear-gradient(135deg, #FFD66B, #FF9F1C); color: #6b4400; }
.btn-ghost { background: rgba(255,255,255,.85); color: var(--ink-soft); box-shadow: none; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,0.94); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.6);
  display: flex; box-shadow: 0 -6px 20px rgba(45,90,140,.12);
}
.nav-item {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: "Noto Sans SC"; font-size: 11px; color: var(--ink-soft);
  transition: color .2s, transform .15s var(--spring);
}
.nav-item:active { transform: scale(.9); }
.nav-ico { font-size: 22px; line-height: 1; }
.nav-item.active { color: #2f6fd6; font-weight: 700; }
.nav-item.active .nav-ico { transform: translateY(-2px) scale(1.12); }

/* =========================================================================
 * 角色选择页
 * ========================================================================= */
#view-select { min-height: 88vh; padding-top: 30px; }
.select-hero { text-align: center; margin-bottom: 20px; }
.logo {
  font-family: "ZCOOL KuaiLe"; font-size: 44px; color: #fff;
  text-shadow: 0 4px 0 rgba(61,123,255,.35), 0 10px 20px rgba(0,0,0,.08);
  letter-spacing: 2px;
}
.logo-sub { font-size: 14px; color: #fff; opacity: .95; margin-top: 4px; }
.select-hint { font-size: 13px; color: #fff; opacity: .85; margin-top: 16px; }

.char-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 560px; margin: 0 auto; }
.char-card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px 12px 14px; cursor: pointer;
  text-align: center; transition: transform .18s var(--spring), box-shadow .2s;
  position: relative; overflow: hidden;
}
.char-card:active { transform: scale(0.96); }
.char-card.selected { outline: 3px solid #fff; box-shadow: 0 0 0 4px var(--sun), 0 12px 28px rgba(0,0,0,.18); }
.char-ava {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.12);
}
.char-name { font-family: "ZCOOL KuaiLe"; font-size: 17px; }
.char-tag { font-size: 11px; color: var(--ink-soft); margin: 2px 0 8px; }
.char-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.5; min-height: 54px; }
.char-quote { font-size: 12px; color: #7a5200; background: #FFF4D6; border-radius: 999px; padding: 4px 8px; margin-top: 6px; display: inline-block; }
.select-cta { text-align: center; margin-top: 22px; }

/* =========================================================================
 * 首页：角色问候 + 七龙珠
 * ========================================================================= */
.hello-card { display: flex; align-items: center; gap: 14px; }
.hello-ava {
  width: 58px; height: 58px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.12);
}
.hello-quote { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; flex: 1; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.stat-chip {
  background: var(--card); border-radius: 16px; padding: 14px 6px 12px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-num { font-family: "ZCOOL KuaiLe"; font-size: 24px; color: #2f6fd6; line-height: 1.2; }
.stat-num.sun { color: #d97706; }
.stat-num.green { color: #2f9e44; }
.stat-label { font-size: 11px; color: var(--ink-soft); margin-top: 6px; line-height: 1.3; }

.dragon-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dragon-progress-text { font-size: 12px; color: var(--ink-soft); }

/* 进度条 */
.progress-track { height: 14px; background: rgba(255,255,255,.7); border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.08); }
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #FFD66B, #FF9F1C);
  transition: width .6s var(--spring); position: relative;
}
.progress-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent); background-size: 200% 100%; animation: shine 2s linear infinite; }
@keyframes shine { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* 七龙珠 */
.dragon-balls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
.ball {
  aspect-ratio: 1; border-radius: 50%; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,.4);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,.1), inset 0 6px 12px rgba(255,255,255,.6);
  border: 2px solid rgba(255,255,255,.8);
  transition: transform .25s var(--spring);
}
.ball.done {
  animation: ballPop .5s var(--spring);
  box-shadow: 0 0 18px rgba(255,255,255,.9), inset 0 -6px 10px rgba(0,0,0,.15);
}
.ball.done::before {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.9), var(--bc) 70%);
  box-shadow: 0 0 20px var(--bc);
}
@keyframes ballPop { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.ball:active { transform: scale(0.9); }
.ball-img { font-size: 30px; position: relative; z-index: 2; filter: drop-shadow(0 2px 2px rgba(0,0,0,.15)); }
.ball-name { font-size: 11px; color: #fff; position: absolute; bottom: 14%; z-index: 2; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.ball.locked .ball-img { filter: grayscale(1) opacity(.45); }
.ball.locked .ball-name { color: #8a93ac; text-shadow: none; }
.ball.locked::before { content: "🔒"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.ball.locked { border-style: dashed; }

/* 召唤神龙入口 */
.summon-hint { margin-top: 12px; text-align: center; padding: 12px; background: linear-gradient(135deg, #FFF4D6, #FFE9B8); border-radius: 16px; font-size: 13px; color: #7a5200; }

/* ---------- 知识树 ---------- */
.tree-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.tree-tab {
  flex: 1; padding: 10px; text-align: center; border: none; cursor: pointer;
  border-radius: 999px; font-family: "ZCOOL KuaiLe"; font-size: 14px;
  background: rgba(255,255,255,.7); color: var(--ink-soft); box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.tree-tab.active { background: #fff; color: #2f6fd6; box-shadow: 0 0 0 2px #2f6fd6; }

.tree-view { display: none; }
.tree-view.active { display: block; animation: viewIn .35s var(--spring); }

.tree-trunk { position: relative; }
.tree-node {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 12px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm); border-left: 6px solid var(--nc);
}
.tree-node .ball-img { font-size: 26px; }
.tree-info { flex: 1; }
.tree-name { font-family: "ZCOOL KuaiLe"; font-size: 15px; }
.tree-count { font-size: 11px; color: var(--ink-soft); }
.tree-mini { width: 70px; height: 8px; background: rgba(0,0,0,.08); border-radius: 999px; overflow: hidden; }
.tree-mini > i { display: block; height: 100%; background: var(--nc); border-radius: 999px; transition: width .5s var(--spring); }

/* =========================================================================
 * 任务页
 * ========================================================================= */
.week-switch { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.week-pill {
  flex: none; padding: 9px 18px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(255,255,255,.7); font-family: "ZCOOL KuaiLe"; font-size: 14px; color: var(--ink-soft);
  box-shadow: var(--shadow-sm); transition: all .2s;
}
.week-pill.active { background: #2f6fd6; color: #fff; box-shadow: 0 4px 14px rgba(47,111,214,.35); }

.task-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  box-shadow: var(--shadow); border-left: 6px solid var(--tc);
  transition: transform .15s var(--ease), opacity .3s;
}
.task-card:active { transform: scale(0.98); }
.task-card.done { opacity: .72; }
.task-subject {
  width: 50px; height: 50px; border-radius: 16px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; box-shadow: var(--shadow-sm);
}
.task-subject .t-icon { font-size: 22px; }
.task-subject .t-name { font-size: 11px; font-weight: 700; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-family: "ZCOOL KuaiLe"; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.task-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.5; margin: 4px 0 6px; }
.task-meta { display: flex; gap: 12px; align-items: center; font-size: 11px; color: var(--ink-soft); }
.stars { color: var(--sun); letter-spacing: 2px; }
.stars .off { color: #d8dce6; }
.points-chip { font-family: "ZCOOL KuaiLe"; color: #d97706; background: #FFF4D6; padding: 2px 8px; border-radius: 999px; }
.task-done-flag { font-family: "ZCOOL KuaiLe"; color: #2f9e44; font-size: 13px; }

.task-complete {
  flex: none; align-self: center; border: none; cursor: pointer;
  font-family: "ZCOOL KuaiLe"; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #5BA8FF, #3D7BFF);
  border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow-sm);
  transition: transform .15s var(--spring);
}
.task-complete:active { transform: scale(.9); }
.task-complete.done-btn { background: #cfd6e4; color: #fff; }

/* =========================================================================
 * 成就页
 * ========================================================================= */
.achieve-hero {
  background: linear-gradient(135deg, #FFF4D6, #FFCE9B); border-radius: var(--radius);
  padding: 16px; text-align: center; margin-bottom: 14px; box-shadow: var(--shadow);
}
.achieve-hero .big { font-family: "ZCOOL KuaiLe"; font-size: 26px; color: #b45309; }
.achieve-hero .mini { font-size: 12px; color: #8a5a00; }

.achieve-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.achieve-card {
  background: var(--card); border-radius: 16px; padding: 14px; text-align: center;
  box-shadow: var(--shadow-sm); position: relative;
}
.achieve-card.locked { opacity: .6; }
.achieve-card.locked .ach-icon { filter: grayscale(1); opacity: .5; }
.ach-icon { font-size: 40px; }
.ach-lock {
  position: absolute; inset: 0; border-radius: 16px; background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: default;
}
.ach-name { font-family: "ZCOOL KuaiLe"; font-size: 14px; margin-top: 4px; }
.ach-desc { font-size: 11px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; }

/* =========================================================================
 * 记录页
 * ========================================================================= */
.rec-hero { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; justify-content: space-around; text-align: center; }
.rec-hero .stat-num { color: #2f9e44; }
.rec-subject-bar { display: flex; gap: 6px; margin-top: 10px; }
.rec-subject-slot { flex: 1; text-align: center; font-size: 11px; color: var(--ink-soft); }
.rec-subject-slot .bar { height: 40px; background: rgba(0,0,0,.06); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.rec-subject-slot .bar > i { width: 100%; background: var(--bc); border-radius: 8px 8px 0 0; }

.record-item {
  background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 12px;
}
.record-item .r-icon { font-size: 26px; width: 40px; height: 40px; border-radius: 12px; background: var(--rc); display: flex; align-items: center; justify-content: center; }
.record-mid { flex: 1; min-width: 0; }
.record-title { font-size: 13px; font-weight: 700; }
.record-sub { font-size: 11px; color: var(--ink-soft); }
.record-pts { font-family: "ZCOOL KuaiLe"; color: #d97706; font-size: 15px; white-space: nowrap; }
.empty-tip { text-align: center; color: #fff; opacity: .9; padding: 40px 20px; font-size: 14px; line-height: 1.8; }

/* =========================================================================
 * 加载 / toast / 庆祝 / 神龙
 * ========================================================================= */
.loading {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(180deg, var(--sky-1), var(--sky-2)); color: #fff;
  font-family: "ZCOOL KuaiLe"; font-size: 16px;
}
.spinner { width: 44px; height: 44px; border: 5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px);
  background: rgba(45,49,66,.92); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; z-index: 110; box-shadow: var(--shadow); opacity: 0; transition: all .3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.celebration {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: rgba(45,49,66,.5); backdrop-filter: blur(4px);
}
#confetti-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celeb-card {
  position: relative; z-index: 2; width: min(320px, 86vw); text-align: center;
  background: #fff; border-radius: var(--radius-lg); padding: 26px 20px 22px; box-shadow: var(--shadow);
  animation: cardUp .5s var(--spring);
}
@keyframes cardUp { from { transform: scale(.5) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.celeb-badge { font-size: 60px; animation: bounce 1s var(--spring) infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.celeb-title { font-family: "ZCOOL KuaiLe"; font-size: 22px; margin-top: 6px; }
.celeb-points { font-family: "ZCOOL KuaiLe"; font-size: 34px; color: #d97706; animation: riseUp 1s var(--spring); }
@keyframes riseUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.celeb-quote { font-size: 13px; color: var(--ink-soft); margin: 6px 0 16px; line-height: 1.5; }

.dragon-overlay {
  position: fixed; inset: 0; z-index: 130;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(circle at 50% 40%, #fff8e1, #ffe9a8 40%, #fbc24d 70%, #f6a821 100%);
}
.dragon-flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, rgba(255,255,255,.9), transparent 60%); animation: flashPulse 1.6s ease-in-out infinite; }
@keyframes flashPulse { 0%,100% { opacity: .2; } 50% { opacity: .7; } }
#dragonClose { position: relative; z-index: 3; pointer-events: auto; }
.dragon { position: relative; text-align: center; animation: dragonIn 1s var(--spring); }
@keyframes dragonIn { from { transform: scale(2) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.dragon-glow { width: 220px; height: 220px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle, rgba(255,220,120,.9), transparent 60%); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.dragon-head { font-size: 120px; line-height: 1; filter: drop-shadow(0 6px 12px rgba(0,0,0,.2)); }
.dragon-title { font-family: "ZCOOL KuaiLe"; font-size: 32px; color: #8a4a00; margin-top: 4px; }
.dragon-sub { font-size: 14px; color: #7a5200; }

/* ---------- 响应式 ---------- */
@media (min-width: 560px) {
  .char-grid { grid-template-columns: repeat(3, 1fr); }
  .dragon-balls { grid-template-columns: repeat(7, 1fr); }
}
@media (max-width: 360px) {
  .char-grid { grid-template-columns: 1fr; }
  .ball-img { font-size: 24px; }
  .dragon-balls { grid-template-columns: repeat(4, 1fr); }
}

/* ============ 训练面板（真实做题） ============ */
.train-overlay {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(24, 32, 62, 0.62);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}

.train-panel {
  width: 100%; max-width: 420px;
  background: #fff; color: #2D3142;
  border-radius: 24px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 50px rgba(24, 32, 62, 0.35);
  animation: popIn 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 86vh; overflow-y: auto;
}
@keyframes popIn { from { transform: scale(0.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.train-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.train-subj { font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 14px; color: #2D3142; background: #EFF6FF; padding: 4px 10px; border-radius: 20px; }
.train-progress { margin-left: auto; font-size: 12px; color: #8A93A6; }
.train-close { border: none; background: #F1F3F8; color: #6B7488; width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer; flex: none; }
.train-close:active { transform: scale(0.92); }
.train-mk { border: none; background: #FFF1E0; color: #E8820C; font-size: 12px; font-weight: 700; padding: 0 10px; height: 30px; border-radius: 15px; cursor: pointer; flex: none; white-space: nowrap; }
.train-mk:active { transform: scale(0.94); }

.train-title { font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 19px; color: #2D3142; }
.train-desc { font-size: 12.5px; color: #6B7488; margin: 4px 0 14px; line-height: 1.5; }

.train-qcard { display: flex; align-items: flex-start; gap: 10px; background: #F6F8FC; border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.train-qno { flex: none; font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 13px; color: #fff; background: #FFC53D; border-radius: 8px; padding: 3px 7px; }
.train-qtext { font-size: 15px; line-height: 1.6; color: #2D3142; }

.train-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.train-opt {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid #E4E9F2; background: #fff;
  border-radius: 14px; padding: 11px 12px; font-size: 14.5px;
  color: #2D3142; cursor: pointer; text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.train-opt:active { transform: scale(0.98); }
.train-opt.picked { border-color: #52C41A; background: #EFFCE9; }
.train-opt-key { flex: none; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; background: #EFF1F6; font-weight: 700; font-size: 13px; color: #5A6378; }
.train-opt.picked .train-opt-key { background: #52C41A; color: #fff; }

.train-input-row { margin: 6px 0 10px; }
.train-input {
  width: 100%; height: 52px; border: 2px solid #E4E9F2; border-radius: 14px;
  font-size: 20px; text-align: center; color: #2D3142; padding: 0 12px;
  outline: none; box-sizing: border-box;
}
.train-input:focus { border-color: #FFC53D; }

.train-result { text-align: center; padding: 16px 6px 20px; }
.train-result-emoji { font-size: 46px; }
.train-result-title { font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 18px; margin: 8px 0 6px; }
.train-result-note { font-size: 13px; color: #6B7488; line-height: 1.5; }

/* ===== 错题订正模式 ===== */
.train-review-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 2px; padding: 10px 12px;
  border-radius: 12px; background: #FFF6E5; border: 1px solid #FFE2A8;
}
.train-review-banner .rb-score {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif;
  font-size: 14px; color: #fff; background: #FF9F45;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.train-review-banner .rb-text { font-size: 12.5px; color: #8A5A1E; line-height: 1.4; }
.train-review-banner .rb-warn { color: #B5651D; }

.train-dots { display: flex; gap: 7px; margin: 10px 0 2px; flex-wrap: wrap; }
.train-dot {
  width: 30px; height: 30px; border-radius: 9px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 700; color: #fff;
  transition: transform 0.15s var(--bounce);
}
.train-dot:active { transform: scale(0.9); }
.train-dot.right { background: #52C41A; }
.train-dot.corrected { background: #2EC4B6; }
.train-dot.wrong { background: #FF6B6B; }
.train-dot.current { outline: 3px solid rgba(45, 49, 66, 0.25); outline-offset: 1px; }

/* 题卡状态色 */
.train-qcard.is-wrong { background: #FFF1F1; border: 1px solid #FFC9C9; }
.train-qcard.is-right, .train-qcard.is-corrected { background: #F2FBEC; border: 1px solid #CDEFB8; }
.train-qno.bad { background: #FF6B6B; }
.train-qno.good { background: #52C41A; }

/* 选项订正态 */
.train-opt.opt-correct {
  border-color: #52C41A; background: #F2FBEC;
  box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.15);
}
.train-opt.opt-correct .train-opt-key { background: #52C41A; color: #fff; }
.train-opt.opt-pickwrong {
  border-color: #FF6B6B; background: #FFF1F1;
}
.train-opt.opt-pickwrong .train-opt-key { background: #FF6B6B; color: #fff; }
.train-opt.locked { opacity: 0.92; cursor: default; }
.train-opt-mark {
  margin-left: auto; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.train-opt-mark.ok { color: #389E0D; }
.train-opt-mark.no { color: #E04545; }

.train-input.input-wrong { border-color: #FF6B6B; background: #FFF7F7; }
.train-input.input-good { border-color: #52C41A; background: #F6FDF2; }
.train-input:disabled { opacity: 0.85; }

.train-explain {
  margin-top: 12px; padding: 11px 13px; border-radius: 12px; line-height: 1.55;
}
.train-explain.wrong { background: #FFF1F1; border: 1px solid #FFD4D4; }
.train-explain.good { background: #F2FBEC; border: 1px solid #D3F0BE; }
.train-explain.muted { background: #F4F7FC; border: 1px solid #E3E9F4; }
.train-explain-title { font-size: 14px; font-weight: 700; }
.train-explain.wrong .train-explain-title { color: #E04545; }
.train-explain.good .train-explain-title { color: #389E0D; }
.train-explain.muted .train-explain-title { color: #5A6478; }
.train-explain-tip { font-size: 12.5px; color: #5A6478; margin-top: 5px; }
.train-explain-hint { font-size: 12px; color: #B5651D; margin-top: 5px; }
.train-result.pass .train-result-title { color: #52C41A; }
.train-result.fail .train-result-title { color: #FF9F45; }

.train-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.btn-ghost {
  flex: 1; border: 2px solid #E4E9F2; background: #fff; color: #5A6378;
  border-radius: 999px; padding: 10px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-ghost:active { transform: scale(0.97); }
.train-foot .btn-primary { flex: 1; }

/* ============ 错题本 (mistake book) ============ */
.mk-empty { text-align: center; padding: 56px 24px 24px; color: var(--ink-soft); }
.mk-empty-emoji { font-size: 54px; margin-bottom: 12px; }
.mk-empty-title { font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 20px; color: var(--ink); }
.mk-empty-note { margin-top: 6px; font-size: 13px; }

.mk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mk-head-num { font-size: 13px; color: var(--ink-soft); }
.mk-clear {
  font-family: "Noto Sans SC"; font-size: 13px; color: #d64545;
  background: #fff4f2; border: 1px solid #ffd1c8; border-radius: 999px; padding: 5px 13px; cursor: pointer;
}
.mk-clear:active { transform: scale(.95); }

.mk-card {
  background: #fff; border-radius: 16px; padding: 13px 14px; margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(45,90,140,.08); border-left: 6px solid #ff6b6b;
}
.mk-tag {
  align-self: flex-start; color: #fff; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; display: inline-block; margin-bottom: 8px;
}
.mk-question { font-size: 15px; color: var(--ink); line-height: 1.45; margin-bottom: 9px; }
.mk-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 9px; }
.mk-mine { font-size: 13px; color: #d64545; background: #fff1ef; border-radius: 8px; padding: 4px 9px; }
.mk-right { font-size: 13px; color: #1d9b48; background: #eafaef; border-radius: 8px; padding: 4px 9px; }
.mk-tip { font-size: 13px; color: var(--ink-soft); background: #f3f6fb; border-radius: 8px; padding: 6px 9px; margin-bottom: 9px; line-height: 1.45; }
.mk-actions { display: flex; gap: 8px; }
.mk-redrill {
  flex: 1; font-family: "Noto Sans SC"; font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg,#4D8DFF,#4b6cff); border: none; border-radius: 11px; padding: 8px 0; cursor: pointer;
}
.mk-redrill:active { transform: scale(.97); }
.mk-del {
  font-family: "Noto Sans SC"; font-size: 13px; color: var(--ink-soft);
  background: #f2f4f8; border: none; border-radius: 11px; padding: 8px 14px; cursor: pointer;
}
.mk-del:active { transform: scale(.95); }

/* ================= 即时赞美 & 激励动效 ================= */
#trainQuestion { position: relative; }

/* 题目区中央弹起的大赞美泡泡 */
.praise-pop {
  position: absolute; top: 8px; left: 0; right: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; pointer-events: none;
  animation: praiseRise 1.15s cubic-bezier(.34, 1.56, .64, 1) both;
}
.praise-stars {
  font-size: 24px; color: #FFC53D; letter-spacing: 6px;
  text-shadow: 0 2px 10px rgba(255, 197, 61, .65);
  animation: spark .8s ease both;
}
.praise-text {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 22px; color: #2D3142;
  background: rgba(255, 255, 255, .94); border-radius: 20px; padding: 6px 18px;
  box-shadow: 0 6px 22px rgba(45, 49, 66, .16);
}
.praise-pop.combo .praise-stars { color: #FF5C00; text-shadow: 0 0 14px rgba(255, 92, 0, .6); }
.praise-pop.combo .praise-text { color: #E8820C; }

@keyframes praiseRise {
  0%   { opacity: 0; transform: translateY(16px) scale(.5); }
  35%  { opacity: 1; transform: translateY(0) scale(1.12); }
  65%  { transform: scale(1); }
  100% { opacity: 0; transform: translateY(-20px) scale(.96); }
}
@keyframes spark {
  0%   { transform: rotate(-24deg) scale(0); opacity: 0; }
  100% { transform: rotate(8deg) scale(1); opacity: 1; }
}

/* 答错时的暖心鼓励行 */
.train-explain-cheer { font-size: 12.5px; color: #B5651D; margin-top: 5px; font-weight: 600; }

/* 通关/完美：全屏庆祝大字 */
.big-praise {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(circle, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .55) 60%, rgba(255,255,255,0) 100%);
  animation: bigIn 1.8s cubic-bezier(.34, 1.56, .64, 1) both;
}
.big-emoji { font-size: 46px; letter-spacing: 8px; animation: spark .7s ease both; }
.big-text {
  font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 34px; color: #2D3142;
  text-shadow: 0 3px 0 rgba(255, 197, 61, .9); letter-spacing: 2px;
}
.big-praise.perfect .big-text { color: #FF6B00; text-shadow: 0 3px 0 rgba(255,197,61,.95); }
.big-sub { font-size: 15px; color: #5A6478; max-width: 82vw; text-align: center; }
@keyframes bigIn {
  0%   { opacity: 0; transform: scale(.4); }
  22%  { opacity: 1; transform: scale(1.06); }
  38%  { transform: scale(1); }
  74%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}

/* ================= AI 讲解老师 ================= */
.mk-ai { --b: #4D8DFF; }
.mk-ai { border-color: var(--b); color: var(--b); background: #fff; }

.ai-overlay {
  position: fixed; inset: 0; z-index: 1002;
  background: rgba(45, 49, 66, .45); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.ai-panel {
  width: 100%; max-width: 430px; height: 78vh; border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #ffffff, #f4faff);
  box-shadow: 0 -8px 40px rgba(45, 49, 66, .25);
  display: flex; flex-direction: column; overflow: hidden;
  animation: aiUp .32s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes aiUp { 0% { transform: translateY(40px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

.ai-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px;
  background: linear-gradient(135deg, #7EC8FF, #A8E6FF);
}
.ai-avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.6);
}
.ai-meta { flex: 1; min-width: 0; }
.ai-name { font-family: "ZCOOL KuaiLe", "PingFang SC", sans-serif; font-size: 16px; color: #2D3142; }
.ai-sub { font-size: 11.5px; color: #4a5a75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ai-body {
  flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px;
}
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.assistant { justify-content: flex-start; }
.ai-bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user .ai-bubble { background: #4D8DFF; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.assistant .ai-bubble { background: #fff; color: #2D3142; border: 1px solid #dfe9f5; border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(45,49,66,.06); }

.ai-input {
  display: flex; gap: 8px; padding: 10px 12px 14px; border-top: 1px solid #e7eef8;
  background: #fff;
}
.ai-input input {
  flex: 1; border: 1.5px solid #d6e3f2; border-radius: 20px; padding: 9px 14px; font-size: 14px;
  outline: none; background: #f7fbff; color: #2D3142;
}
.ai-input input:focus { border-color: #4D8DFF; background: #fff; }
.ai-send {
  border: none; border-radius: 20px; padding: 0 18px; background: #4D8DFF; color: #fff;
  font-weight: 700; cursor: pointer;
}
.ai-send:disabled { opacity: .5; }
/* AI 讲解：正在打字占位动画 */
.ai-bubble.loading { display: inline-flex; align-items: center; gap: 5px; background: #eef3fb; border: 1px solid #e2ebf7; box-shadow: none; padding: 12px 16px; min-width: 0; }
.ai-bubble.loading .dot { width: 7px; height: 7px; border-radius: 50%; background: #7d8baa; animation: aiBlink 1.2s ease-in-out infinite; }
.ai-bubble.loading .dot:nth-child(2) { animation-delay: 0.18s; }
.ai-bubble.loading .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiBlink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ========== 自定义角色 ========== */
.char-card { position: relative; }
.char-card-new { border: 2px dashed rgba(80,140,255,.5); background: rgba(255,255,255,.35); cursor: pointer; justify-content: center; align-items: center; text-align: center; }
.char-card-new .char-ava { background: rgba(255,255,255,.6); color: #7b8ff0; font-size: 30px; }
.char-card-new:hover { border-color: rgba(80,140,255,.9); background: rgba(255,255,255,.6); }
.char-ops { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; z-index: 2; }
.char-op { width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); box-shadow: 0 1px 4px rgba(30,50,90,.18); font-size: 14px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.char-op:active { transform: scale(.9); }

/* 自定义弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(30,40,70,.45); z-index: 200; display: flex; align-items: flex-end; justify-content: center; padding: 0; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-box { width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; background: #fffdf8; border-radius: 24px 24px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(20,40,80,.22); animation: modalUp .28s cubic-bezier(.34,1.56,.64,1); }
@keyframes modalUp { from { transform: translateY(30%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-family: 'ZCOOL KuaiLe', 'Noto Sans SC', sans-serif; font-size: 20px; color: var(--ink); margin-bottom: 12px; text-align: center; }
.modal-label { display: block; font-size: 13px; color: var(--ink-soft); margin: 12px 0 6px; font-weight: 700; }
.modal-input, .modal-textarea { width: 100%; box-sizing: border-box; border: 1.5px solid #dde6f5; border-radius: 12px; padding: 11px 12px; font-size: 14px; background: #fff; color: var(--ink); outline: none; transition: border-color .15s; }
.modal-input:focus, .modal-textarea:focus { border-color: #7b8ff0; }
.modal-textarea { resize: none; font-family: inherit; line-height: 1.5; }
.modal-err { color: #e05252; font-size: 12px; margin-top: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 22px; border-radius: 12px; background: #f4f7ff; cursor: pointer; }
.emoji-cell.on { background: #dceaff; box-shadow: inset 0 0 0 2px #7b8ff0; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-cell { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-cell.on { border-color: #3d4c7a; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
