* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.5;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill);
  font-size: var(--fs-md); font-weight: 700; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: var(--sh-2); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.lg { font-size: var(--fs-lg); padding: var(--sp-4) var(--sp-6); }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(180deg, #FFFDF6, #FFF8EC);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  box-shadow: var(--sh-1); font-size: 20px;
}
.brand .name { font-size: var(--fs-lg); color: var(--brand-deep); letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 14px; background: var(--surface);
  display: grid; place-items: center; color: var(--ink-soft); box-shadow: var(--sh-1);
  transition: transform var(--t) var(--ease), background var(--t) var(--ease);
}
.iconbtn:active { transform: scale(.92); }
.iconbtn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--accent); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid #fff;
}

/* ===== 容器 ===== */
.wrap { max-width: 960px; margin: 0 auto; padding: var(--sp-4); padding-bottom: 80px; }
.view { display: none; }
.view.active { display: block; animation: fade var(--t-slow) var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== 首页 hero ===== */
.hero { text-align: center; padding: var(--sp-5) var(--sp-2) var(--sp-4); }
.hero h1 {
  font-size: var(--fs-3xl); color: var(--brand-deep); font-weight: 900;
  text-shadow: 0 3px 0 #fff, 0 4px 0 rgba(0,0,0,.06); line-height: 1.15;
}
.hero .sub { margin-top: var(--sp-2); color: var(--ink-soft); font-size: var(--fs-md); }
.hero .stars-line { margin-top: var(--sp-3); display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--star); font-weight: 800; }

/* ===== 模块网格 ===== */
.mod-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4);
  margin-top: var(--sp-5);
}
.mod-card {
  position: relative; border-radius: var(--r-lg); padding: var(--sp-4);
  background: var(--surface); box-shadow: var(--sh-2); color: #fff;
  display: flex; flex-direction: column; gap: var(--sp-2); min-height: 132px;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  overflow: hidden;
}
.mod-card:active { transform: translateY(-4px) scale(.99); box-shadow: var(--sh-3); }
.mod-card .ic { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.22); display: grid; place-items: center; }
.mod-card .t { font-size: var(--fs-lg); font-weight: 800; }
.mod-card .d { font-size: var(--fs-xs); opacity: .92; line-height: 1.35; }
.mod-card .prog { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; }
.mod-card .prog .bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.35); overflow: hidden; }
.mod-card .prog .bar > i { display: block; height: 100%; background: #fff; border-radius: 3px; }

/* ===== 游戏区 ===== */
.game-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.game-head .title { font-size: var(--fs-xl); font-weight: 900; }
.game-head .lv { font-size: var(--fs-sm); color: var(--ink-soft); font-weight: 700; }
.stars-row { display: flex; gap: 4px; color: var(--star); }
.stars-row .s { opacity: .3; }
.stars-row .s.on { opacity: 1; }

.prompt {
  background: var(--surface); border-radius: var(--r-lg); padding: var(--sp-5);
  box-shadow: var(--sh-1); text-align: center; font-size: var(--fs-xl); font-weight: 800;
  margin: var(--sp-4) 0; color: var(--ink);
}
.prompt small { display: block; font-size: var(--fs-sm); color: var(--ink-soft); font-weight: 600; margin-top: 6px; }

/* 选项按钮（数物/奇偶/排序等） */
.opts { display: grid; gap: var(--sp-3); }
.opts.cols2 { grid-template-columns: repeat(2,1fr); }
.opts.cols3 { grid-template-columns: repeat(3,1fr); }
.opts.cols4 { grid-template-columns: repeat(4,1fr); }
.opt {
  background: var(--surface); border-radius: var(--r-md); padding: var(--sp-4);
  box-shadow: var(--sh-1); font-size: var(--fs-lg); font-weight: 800; color: var(--ink);
  display: grid; place-items: center; min-height: 64px; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  position: relative;
}
.opt:active { transform: scale(.95); }
.opt.correct { background: var(--ok-soft); color: var(--ok); box-shadow: 0 0 0 3px var(--ok) inset; }
.opt.wrong { background: var(--err-soft); color: var(--err); box-shadow: 0 0 0 3px var(--err) inset; }
.opt.dim { opacity: .35; }

/* 物体点阵（数物对应） */
.dots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 260px; }
.dots .d { width: 22px; height: 22px; border-radius: 50%; background: var(--m-numobj); }

/* 百数表网格 */
.chart { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; max-width: 460px; margin: var(--sp-4) auto; }
.chart .cell {
  aspect-ratio: 1; border-radius: 8px; background: var(--surface); box-shadow: var(--sh-1);
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm); color: var(--ink);
  transition: transform var(--t) var(--ease), background var(--t) var(--ease);
}
.chart .cell.hl { background: var(--m-multi); color: #fff; }
.chart .cell.up { background: var(--m-updown); color: #fff; }
.chart .cell.down { background: #EF9A9A; color: #fff; }
.chart .cell.empty { background: var(--surface-2); color: var(--accent-deep); cursor: pointer; box-shadow: 0 0 0 2px var(--accent) inset; }
.chart .cell.empty:active { transform: scale(.92); }
.chart .cell.fixed { background: var(--surface-2); color: var(--ink-soft); }
.chart .cell.pick { outline: 3px solid var(--brand); }

/* 数位方块 */
.blocks { display: flex; gap: var(--sp-3); justify-content: center; align-items: flex-end; margin: var(--sp-4) 0; }
.blocks .ten { width: 84px; height: 84px; border-radius: 12px; background: var(--m-place); display: grid; place-items: center; color: #fff; font-weight: 900; font-size: var(--fs-lg); }
.blocks .ones { display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; }
.blocks .ones i { width: 38px; height: 38px; border-radius: 8px; background: var(--accent); display: block; }

/* 反馈遮罩 */
.feedback {
  position: fixed; inset: 0; z-index: 40; display: none; place-items: center;
  background: rgba(58,46,31,.45);
}
.feedback.show { display: grid; animation: fade var(--t) var(--ease); }
.feedback .card {
  background: var(--surface); border-radius: var(--r-xl); padding: var(--sp-6); text-align: center;
  box-shadow: var(--sh-3); max-width: 320px; width: 86%;
}
.feedback .big { font-size: 56px; margin-bottom: var(--sp-2); }
.feedback .ttl { font-size: var(--fs-xl); font-weight: 900; margin-bottom: var(--sp-2); }
.feedback.ok .ttl { color: var(--ok); }
.feedback.err .ttl { color: var(--err); }

/* 进度条 */
.pbar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--brand); border-radius: 5px; transition: width var(--t-slow) var(--ease); }

/* ===== 抽屉 ===== */
.scrim { position: fixed; inset: 0; background: rgba(58,46,31,.4); z-index: 30; display: none; }
.scrim.show { display: block; animation: fade var(--t) var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 31;
  background: var(--bg-soft); box-shadow: var(--sh-3); transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease); display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer .dhead { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 2px solid var(--line); }
.drawer .dhead h3 { font-size: var(--fs-lg); font-weight: 900; }
.drawer .dbody { padding: var(--sp-4); overflow-y: auto; flex: 1; }

/* 关卡选择 */
.lv-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: var(--sp-2); }
.lv-cell {
  aspect-ratio: 1; border-radius: 14px; background: var(--surface); box-shadow: var(--sh-1);
  display: grid; place-items: center; font-weight: 800; position: relative;
}
.lv-cell.done { background: var(--ok-soft); color: var(--ok); }
.lv-cell.locked { opacity: .4; }
.lv-cell .st { position: absolute; bottom: 2px; font-size: 10px; color: var(--star); }

/* 家长仪表盘 */
.stat-card { background: var(--surface); border-radius: var(--r-md); padding: var(--sp-4); box-shadow: var(--sh-1); margin-bottom: var(--sp-3); }
.stat-card h4 { font-size: var(--fs-sm); color: var(--ink-soft); margin-bottom: var(--sp-2); }
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.stat-row:last-child { border-bottom: none; }
.stat-row b { color: var(--accent-deep); }

/* 授权/价格 */
.tier {
  display: flex; align-items: center; gap: var(--sp-3); background: var(--surface);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); box-shadow: var(--sh-1); margin-bottom: var(--sp-2);
}
.tier .nm { font-weight: 800; flex: 1; }
.tier .pr { font-weight: 900; color: var(--accent-deep); font-size: var(--fs-lg); }
.tier.best { box-shadow: 0 0 0 2px var(--brand) inset; }
.qrbox { text-align: center; padding: var(--sp-4) 0; }
.qrbox canvas, .qrbox img { width: 200px; height: 200px; margin: 0 auto; background: #fff; border-radius: var(--r-md); padding: 8px; box-shadow: var(--sh-1); }
.field { width: 100%; padding: var(--sp-3); border-radius: var(--r-md); border: 2px solid var(--line); font-size: var(--fs-md); font-family: inherit; background: #fff; }
.field:focus { outline: none; border-color: var(--brand); }
.lic-state { text-align: center; padding: var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); margin-bottom: var(--sp-3); }
.lic-state.ok { background: var(--ok-soft); color: var(--ok); }
.lic-state.free { background: var(--surface-2); color: var(--ink-soft); }

/* 一行一个列表（官网风格对齐） */
.row1 { border-bottom: 1px dashed var(--line); padding: var(--sp-3) 0; }
.row1:last-child { border-bottom: none; }
.row1 summary { cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; }
.row1 summary::-webkit-details-marker { display: none; }
.row1[open] summary .chev { transform: rotate(90deg); }
.row1 .chev { transition: transform var(--t) var(--ease); }

/* 底部导航 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 19; display: flex;
  background: var(--surface); border-top: 2px solid var(--line); padding: 6px; max-width: 960px; margin: 0 auto; }
.tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; color: var(--ink-soft); font-size: 11px; font-weight: 700; border-radius: 12px; }
.tabbar .tab.active { color: var(--accent-deep); background: var(--surface-2); }

/* 提示吐司 */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill);
  font-weight: 700; opacity: 0; pointer-events: none; transition: all var(--t) var(--ease); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 响应式 ===== */
@media (max-width: 720px) {
  .mod-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: var(--fs-2xl); }
  .opts.cols4 { grid-template-columns: repeat(2,1fr); }
  .lv-grid { grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 420px) {
  .mod-grid { grid-template-columns: repeat(2,1fr); gap: var(--sp-3); }
  .chart .cell { font-size: 11px; border-radius: 6px; }
  .planet .ring { gap: 6px; }
}

/* ============================================================
   v1.1 新增样式
   ============================================================ */

/* ===== 行星探索环 ===== */
.home-top { margin-top: var(--sp-3); }
.planet {
  background: var(--surface); border-radius: var(--r-lg); padding: var(--sp-4);
  box-shadow: var(--sh-1); text-align: center; border: 2px dashed var(--brand);
}
.planet .ring {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  flex-wrap: wrap; color: var(--line);
}
.planet .ring .rp {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--line);
  transition: transform var(--t-slow) var(--ease), background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
}
.planet .ring .rp.on { background: var(--star); color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.06); }
.planet .ring .rp.latest { animation: popStar .8s var(--ease); }
@keyframes popStar { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }
.planet .pl-tt { margin-top: var(--sp-3); color: var(--ink-soft); font-weight: 700; font-size: 14px; }
.planet .pl-tt b { color: var(--brand-deep); font-size: 18px; }

/* ===== 形状标识（色弱友好） ===== */
.shape-tag {
  position: absolute; top: 8px; right: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.85); color: var(--ink); font-size: 14px; font-weight: 900;
  display: grid; place-items: center; line-height: 1;
}
.game-shape, .lv-shape {
  display: inline-block; width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 900; font-size: 16px;
  text-align: center; line-height: 26px; margin-right: 8px; vertical-align: middle;
}
.lv-shape { background: var(--accent); }
.mod-card .actions { display: flex; gap: 6px; margin-top: 4px; }
.mod-card .act-print {
  font-size: 11px; padding: 2px 6px; border-radius: 8px;
  background: rgba(255,255,255,.28); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.mod-card.custom { background: var(--surface-2); color: var(--brand-deep); border: 2px dashed var(--brand); }
.mod-card.custom .ic { background: var(--brand); color: #fff; }

/* ===== 徽章墙 ===== */
.badge-wall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bcell {
  background: var(--surface-2); border-radius: 14px; padding: 8px 4px;
  text-align: center; color: var(--line); opacity: .5; transition: all var(--t) var(--ease);
}
.bcell.got { background: var(--star-soft); color: var(--star); opacity: 1; box-shadow: var(--sh-1); }
.bcell .bic { width: 32px; height: 32px; margin: 0 auto; display: grid; place-items: center; }
.bcell .bnm { font-size: 11px; font-weight: 800; margin-top: 4px; line-height: 1.1; }

/* ===== 错题条形 ===== */
.mistake-bar { display: flex; flex-direction: column; gap: 8px; }
.mistake-bar .mr { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mistake-bar .mr-l { width: 100px; display: flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 700; }
.mistake-bar .mr-r { flex: 1; display: flex; align-items: center; gap: 6px; }
.mistake-bar .mr-r > i {
  display: block; height: 10px; border-radius: 5px;
  background: var(--accent); max-width: calc(100% - 30px);
}
.mistake-bar .mr-r b { font-size: 12px; color: var(--ink-soft); min-width: 30px; text-align: right; }

.stat-card.advice { background: var(--surface-2); border-left: 4px solid var(--brand); }
.stat-card.advice h4 { color: var(--brand-deep); }

/* ===== 设置抽屉 ===== */
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) 0; border-bottom: 1px dashed var(--line); font-weight: 700;
}
.set-row:last-of-type { border-bottom: none; }
.set-row select, .set-row button.sm {
  padding: 6px 10px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: 14px; color: var(--ink);
  font-family: inherit;
}
.switch { position: relative; width: 52px; height: 28px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch > span {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--line); border-radius: 28px; transition: var(--t) var(--ease);
}
.switch > span::before {
  content: ""; position: absolute; width: 22px; height: 22px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: var(--t) var(--ease); box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(24px); }

/* ===== 自定义练习 ===== */
.cust-card { background: var(--surface); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--sh-1); }
.cust-card .row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cust-card .row label { flex: 0 0 84px; font-weight: 800; font-size: 14px; color: var(--ink-soft); }
.cust-card .row input, .cust-card .row select {
  flex: 1; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-size: 14px; font-family: inherit; font-weight: 700;
}

/* ===== 休息弹窗 ===== */
.rest-modal { position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
  background: rgba(58,46,31,.65); backdrop-filter: blur(4px); }
.rest-modal.show { display: grid; animation: fade var(--t) var(--ease); }
.rest-modal .rm-card {
  background: var(--surface); border-radius: var(--r-xl); padding: var(--sp-6);
  text-align: center; max-width: 320px; width: 90%; box-shadow: var(--sh-3);
  border: 3px solid var(--brand);
}
.rest-modal .rm-ic {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto var(--sp-3);
  background: var(--brand); display: grid; place-items: center; color: #fff; font-size: 32px;
}
.rest-modal h2 { color: var(--brand-deep); font-size: 22px; margin-bottom: 8px; }
.rest-modal p { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin-bottom: 16px; }

/* ===== 徽章解锁吐司 ===== */
.badge-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--star), #FF9D40); color: #fff;
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-pill);
  font-weight: 800; box-shadow: var(--sh-3); opacity: 0; pointer-events: none;
  transition: all var(--t-slow) var(--ease); z-index: 55; max-width: 320px;
}
.badge-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.badge-toast .bd-ic {
  width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.22);
  display: grid; place-items: center;
}
.badge-toast .bd-tt { font-size: 14px; }
.badge-toast .bd-tp { font-size: 11px; opacity: .85; font-weight: 600; margin-top: 2px; }

/* ===== 夜间柔光模式 ===== */
body.night { background: #2A2118; color: #F1E5CC; }
body.night .topbar { background: linear-gradient(180deg, #38291A, #2A2118); border-bottom-color: #4A3827; }
body.night .brand .name { color: #FFCA28; }
body.night .iconbtn { background: #3D2D1C; color: #F1E5CC; }
body.night .mod-card.custom { background: #3D2D1C; color: #FFCA28; border-color: #FFCA28; }
body.night .opt, body.night .stat-card, body.night .lv-cell,
body.night .cust-card, body.night .planet { background: #3D2D1C; color: #F1E5CC; }
body.night .pbar { background: #4A3827; }
body.night .pbar > i { background: #FFCA28; }
body.night .prompt { background: #3D2D1C; color: #F1E5CC; }
body.night .field, body.night .cust-card .row input, body.night .cust-card .row select,
body.night .set-row select { background: #2A2118; color: #F1E5CC; border-color: #4A3827; }
body.night .tabbar { background: #2A2118; border-top-color: #4A3827; }
body.night .drawer { background: #2A2118; color: #F1E5CC; }
body.night .lic-state { background: #3D2D1C; color: #F1E5CC; }
body.night .lic-state.ok { background: rgba(67,160,71,.2); color: #81C784; }
body.night .toast { background: #4A3827; }
body.night .bcell { background: #2A2118; }
body.night .bcell.got { background: rgba(255,179,0,.18); color: #FFCA28; }
body.night .mistake-bar .mr-r > i { background: #FF7043; }
