/* ===== 养脑训练营 · 马卡龙毛绒风 ===== */
:root {
  --bg: #FFF6F0;
  --card: #FFFFFF;
  --ink: #4A3F55;
  --ink-soft: #8B8098;
  --peach: #FFD9C7;
  --peach-deep: #F6A87C;
  --mint: #D9F2E3;
  --mint-deep: #6FC79A;
  --lav: #E4DFF6;
  --lav-deep: #9B8EDB;
  --lemon: #FDF3C9;
  --lemon-deep: #E8C34A;
  --pink: #FBDCE8;
  --pink-deep: #ED8FB0;
  --radius: 22px;
  --shadow: 0 8px 24px rgba(122, 92, 130, 0.12);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
#app { max-width: 500px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; position: relative; }

/* ===== 顶栏 ===== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 10px; position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, var(--bg) 82%, rgba(255,246,240,0));
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-icon { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.15)); }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.top-stats { display: flex; gap: 8px; }
.stat-chip {
  background: var(--card); border-radius: 999px; padding: 6px 12px;
  box-shadow: var(--shadow); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 4px;
}
.stat-ico { font-size: 14px; }

/* ===== 主内容 ===== */
main { flex: 1; padding: 4px 16px 90px; }
.view-title { font-size: 22px; font-weight: 800; margin: 10px 2px 12px; }
.view-title small { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 500; margin-top: 3px; }

/* ===== 卡片通用 ===== */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}

/* ===== 首页 hero ===== */
.hero {
  border-radius: 26px; padding: 22px 20px; color: #6B4A3A; text-align: center;
  background: linear-gradient(135deg, var(--peach) 0%, var(--lemon) 100%);
  box-shadow: var(--shadow); margin: 8px 0 16px; position: relative; overflow: hidden;
}
.hero .day-badge {
  display: inline-block; background: rgba(255,255,255,.75); border-radius: 999px;
  padding: 4px 14px; font-size: 13px; font-weight: 700; margin-bottom: 8px;
}
.hero h1 { font-size: 24px; font-weight: 900; letter-spacing: 1px; }
.hero p { font-size: 13px; opacity: .8; margin-top: 6px; }
.hero .hero-btns { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }

.btn {
  border: none; border-radius: 999px; padding: 11px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.12); transition: transform .08s;
  color: #fff; font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn-main { background: linear-gradient(135deg, var(--lav-deep), #B79CED); }
.btn-warm { background: linear-gradient(135deg, var(--peach-deep), #F5B48A); }
.btn-mint { background: linear-gradient(135deg, var(--mint-deep), #8FD9AE); }
.btn-ghost { background: rgba(255,255,255,.8); color: var(--ink); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ===== 分类入口 ===== */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.cat-card {
  border-radius: var(--radius); padding: 16px 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .08s; position: relative;
}
.cat-card:active { transform: scale(.97); }
.cat-card .cat-emoji { font-size: 30px; }
.cat-card .cat-name { font-weight: 800; font-size: 16px; margin-top: 6px; }
.cat-card .cat-num { font-size: 12px; color: rgba(0,0,0,.5); margin-top: 2px; }
.cat-a { background: linear-gradient(160deg, var(--peach), #FFE9DD); }
.cat-b { background: linear-gradient(160deg, var(--mint), #E2F8EC); }
.cat-c { background: linear-gradient(160deg, var(--lav), #EFEAFB); }
.cat-d { background: linear-gradient(160deg, var(--lemon), #FCF6DA); }

/* ===== 训练卡片 ===== */
.train-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: transform .08s;
}
.train-card:active { transform: scale(.98); }
.train-card .tc-icon {
  width: 54px; height: 54px; border-radius: 18px; display: flex; align-items: center;
  justify-content: center; font-size: 26px; flex-shrink: 0;
}
.tc-body { flex: 1; min-width: 0; }
.tc-name { font-weight: 800; font-size: 16px; }
.tc-desc { font-size: 12px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; }
.tc-best { font-size: 12px; margin-top: 4px; color: var(--peach-deep); font-weight: 700; }
.tc-best.none { color: var(--ink-soft); font-weight: 500; }
.tc-go { font-size: 13px; color: var(--ink-soft); }
.train-card.locked { opacity: .62; cursor: default; }
.train-card.locked:active { transform: none; }
.badge-soon {
  position: absolute; top: 10px; right: 10px; background: var(--lemon);
  color: #8a6d1a; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px;
}

/* ===== 游戏页 ===== */
.game-wrap { min-height: 70vh; display: flex; flex-direction: column; align-items: center; padding-top: 8px; }
.game-head { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.game-title { font-size: 18px; font-weight: 800; }
.game-timer {
  background: var(--card); border-radius: 999px; padding: 7px 16px; font-weight: 800;
  font-size: 17px; box-shadow: var(--shadow); color: var(--peach-deep);
}
.game-timer.warn { color: #E4575B; animation: pulse .7s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

.rule-box {
  background: var(--lemon); border-radius: 16px; padding: 12px 16px; font-size: 14px;
  margin-bottom: 14px; width: 100%; text-align: center; color: #7a6120; line-height: 1.5;
}

/* 舒尔特棋盘 */
.board {
  display: grid; gap: 8px; width: 100%; max-width: 400px;
  padding: 14px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
}
.tile {
  aspect-ratio: 1; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; cursor: pointer; color: #fff;
  background: linear-gradient(150deg, #F6B0A0, #ED8FB0);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), 0 3px 8px rgba(0,0,0,.10);
  transition: transform .08s, opacity .2s;
  position: relative;
}
.tile:active { transform: scale(.93); }
.tile.done { opacity: .25; cursor: default; }
.tile.bump { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.12); } }
.tile.miss { animation: shake .3s; background: linear-gradient(150deg, #F0B4B4, #E4575B); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.tile .tl-idx { position: absolute; top: 6px; left: 9px; font-size: 10px; opacity: .55; }

/* 追踪 */
.track-field {
  position: relative; width: 100%; max-width: 400px; aspect-ratio: 1;
  background: linear-gradient(160deg, #EAF7F0, #E4F0FB);
  border-radius: 24px; box-shadow: var(--shadow); overflow: hidden;
}
.dot {
  position: absolute; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 12px; font-weight: 700;
  box-shadow: 0 3px 8px rgba(0,0,0,.18); cursor: pointer; transition: transform .05s;
}
.dot:active { transform: scale(1.15); }
.dot.target-dot { box-shadow: 0 0 0 4px #fff, 0 3px 10px rgba(0,0,0,.3); }

/* 记忆 */
.mem-flash {
  width: 100%; max-width: 400px; aspect-ratio: 1; border-radius: 24px;
  background: var(--card); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 900; letter-spacing: 10px; color: var(--lav-deep);
}
.dots-field {
  width: 100%; max-width: 400px; aspect-ratio: 1; border-radius: 24px;
  background: linear-gradient(160deg, #FDF1E3, #FDE8EC);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.dot-flash { position: absolute; border-radius: 50%; background: linear-gradient(150deg, var(--lav-deep), #C4AEF0); }

/* 感知力 */
.char-stage {
  width: 100%; max-width: 400px; aspect-ratio: 1.25; border-radius: 24px;
  background: var(--card); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.char-broken { position: relative; font-size: 110px; font-weight: 900; color: var(--lav-deep); }
.char-broken .half { position: absolute; top: 0; overflow: hidden; height: 100%; }
.char-broken .hl { left: 0; width: 48%; clip-path: inset(0 0 0 0); }
.char-broken .hr { left: 50%; width: 50%; transform: translateX(16px); clip-path: inset(0 0 0 0); }
.char-mirror { font-size: 110px; font-weight: 900; color: var(--peach-deep); transform: rotate(180deg) scaleX(-1); }

.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 400px; margin-top: 16px; }
.opt {
  border: none; border-radius: 18px; padding: 18px 6px; font-size: 26px; font-weight: 800;
  background: linear-gradient(150deg, var(--mint), #EAF8F0); color: var(--ink);
  cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.08); font-family: inherit;
}
.opt:active { transform: scale(.95); }
.opt.right { background: linear-gradient(150deg, var(--mint-deep), #A9E3C4); color: #fff; }
.opt.wrong { background: linear-gradient(150deg, #F0A9A9, #E4575B); color: #fff; }

/* 结算 */
.result-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 26px 22px; width: 100%; max-width: 400px; text-align: center; margin-top: 8px;
}
.result-stars { font-size: 40px; letter-spacing: 6px; margin-bottom: 6px; }
.result-score { font-size: 52px; font-weight: 900; color: var(--lav-deep); }
.result-score small { font-size: 16px; color: var(--ink-soft); font-weight: 600; }
.result-metrics {
  display: flex; justify-content: center; gap: 14px; margin: 14px 0; flex-wrap: wrap;
}
.metric { background: var(--bg); border-radius: 14px; padding: 8px 14px; font-size: 13px; }
.metric b { display: block; font-size: 17px; color: var(--ink); }
.result-msg { font-size: 14px; color: var(--ink-soft); margin-bottom: 18px; line-height: 1.5; }
.result-btns { display: flex; gap: 10px; }
.result-btns .btn { flex: 1; }
.record-tag {
  display: inline-block; background: var(--lemon); color: #8a6d1a; font-size: 12px;
  font-weight: 700; border-radius: 999px; padding: 3px 10px; margin-bottom: 10px;
}

/* ===== 成绩 / 排行榜 ===== */
.rank-tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.rank-tab {
  border: none; background: var(--card); box-shadow: var(--shadow); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.rank-tab.active { background: linear-gradient(135deg, var(--lav-deep), #B79CED); color: #fff; }
.rank-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px;
  border-bottom: 1px dashed #EFE7F2;
}
.rank-row .rk { width: 30px; text-align: center; font-weight: 900; font-size: 16px; }
.rank-row .rk.r1 { color: #E8C34A; font-size: 20px; }
.rank-row .rk.r2 { color: #B0A8C0; font-size: 18px; }
.rank-row .rk.r3 { color: #D9A066; font-size: 17px; }
.rank-row .rk-name { flex: 1; font-weight: 700; font-size: 15px; }
.rank-row .rk-name .rk-tag { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.rank-row .rk-score { font-weight: 900; color: var(--lav-deep); font-size: 16px; }
.rank-row.me { background: var(--lemon); border-radius: 12px; padding: 11px 8px; }
.me-badge { font-size: 11px; background: var(--lemon-deep); color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.empty-tip { text-align: center; color: var(--ink-soft); font-size: 14px; padding: 30px 0; line-height: 1.8; }

/* 成绩汇总 */
.best-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px dashed #EFE7F2; }
.best-row .br-name { font-weight: 700; font-size: 14px; }
.best-row .br-score { font-weight: 800; color: var(--peach-deep); }

/* ===== 打卡日历 ===== */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 12px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-soft); box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.cal-cell .cd { font-size: 13px; font-weight: 700; }
.cal-cell.on { background: linear-gradient(150deg, var(--mint-deep), #A9E3C4); color: #fff; }
.cal-cell.today { outline: 2px solid var(--lemon-deep); }
.streak-box {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px;
}
.streak-cell { background: var(--card); border-radius: 18px; padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.streak-cell b { display: block; font-size: 24px; font-weight: 900; color: var(--lav-deep); }
.streak-cell span { font-size: 12px; color: var(--ink-soft); }

/* ===== 昵称弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(74, 63, 85, .45); z-index: 99;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--card); border-radius: 24px; padding: 24px; width: 100%; max-width: 340px;
  text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.25);
}
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal p { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.modal input {
  width: 100%; border: 2px solid #EFE7F2; border-radius: 14px; padding: 11px 14px;
  font-size: 16px; text-align: center; margin-bottom: 14px; outline: none; font-family: inherit;
}
.modal input:focus { border-color: var(--lav-deep); }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 500px; display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px); border-radius: 22px 22px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.08);
  z-index: 40; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0;
  cursor: pointer; color: var(--ink-soft); font-size: 11px; font-weight: 700;
  border-radius: 16px; transition: background .15s;
}
.tab .tab-ico { font-size: 20px; }
.tab.active { color: var(--lav-deep); background: var(--lav); }

.hidden { display: none !important; }
.section-title { font-size: 15px; font-weight: 800; margin: 18px 2px 10px; display: flex; align-items: center; gap: 6px; }

/* ===== 难度选择 ===== */
.diff-row { display: flex; gap: 10px; width: 100%; max-width: 400px; margin-bottom: 12px; }
.diff-btn {
  flex: 1; border: none; border-radius: 14px; padding: 12px 4px; font-size: 15px;
  font-weight: 800; background: var(--card); color: var(--ink-soft); cursor: pointer;
  box-shadow: var(--shadow); font-family: inherit;
}
.diff-btn.on { background: linear-gradient(135deg, var(--peach-deep), #F5B48A); color: #fff; }
.diff-hint {
  width: 100%; max-width: 400px; margin: -4px 0 12px; font-size: 13px;
  color: #A087B8; font-weight: 600; text-align: center; min-height: 18px;
}

/* ===== 圆盘舒尔特 ===== */
.board.circle-board {
  position: relative; max-width: 400px; aspect-ratio: 1; border-radius: 50%;
  border: none; background: transparent; box-shadow: none; display: block;
}
.board.circle-board .tile { position: absolute; box-shadow: var(--shadow); }

/* ===== 旋转舒尔特 ===== */
.board.spin { animation: spin 22s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 蜂巢舒尔特 ===== */
.board.honey-board { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 10px 4px; }
.honey-row { display: flex; gap: 8px; align-items: center; }
.honey-row.off { margin-left: 36px; }
.hex-tile {
  width: 60px !important; height: 60px !important; border-radius: 12px !important;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

/* ===== 蝴蝶振翅舒尔特 ===== */
.flutter-tile { animation: flutter 1.6s ease-in-out infinite; }
@keyframes flutter {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: .22; transform: translateY(4px); }
}

/* ===== 词语接龙舒尔特 ===== */
.word-tile { font-size: 15px !important; font-weight: 800; }

/* ===== 子弹轨迹追踪 ===== */
.bullet {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #F0A94E 45%, #D97A1E);
  box-shadow: 0 0 12px rgba(240, 169, 78, .9), 0 0 24px rgba(240, 169, 78, .45);
  cursor: pointer;
}
.bullet.boom {
  background: radial-gradient(circle, #fff, #FFD28A);
  box-shadow: 0 0 30px rgba(255, 210, 138, 1);
  transform: scale(1.6); transition: all .2s;
}

/* ===== 视觉瞬时记忆 ===== */
.fm-cell {
  aspect-ratio: 1; border-radius: 12px; background: var(--bg);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .06);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #9B8EDB; cursor: pointer;
}
.fm-cell.done { background: linear-gradient(135deg, var(--mint-deep), #8FD9AE); color: #fff; }
.fm-cell.miss { background: #FFD6D6; }

/* ===== 整合被撕开的文字 ===== */
.torn-wrap { position: relative; width: 150px; height: 160px; margin: 0 auto; }

/* ===== 视觉偏好测试 ===== */
.pref-opt { padding: 18px 10px !important; font-size: 16px !important; }

/* ===== 顶栏设置按钮 ===== */
.stat-gear {
  width: 34px; height: 34px; border-radius: 50%; background: var(--card);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
}

/* ===== 每日任务 ===== */
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed #EFE7F2; }
.task-row:last-child { border-bottom: none; }
.task-ico { font-size: 20px; }
.task-name { flex: 1; font-size: 14px; font-weight: 600; }
.task-reward { font-size: 12px; color: var(--peach-deep); font-weight: 700; }
.task-row.done .task-name { color: var(--ink-soft); text-decoration: line-through; }
.task-reward-line {
  background: var(--lemon); color: #8a6d1a; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 700; display: inline-block; margin-bottom: 10px;
}

/* ===== 进步曲线 ===== */
.spark { display: flex; gap: 3px; align-items: flex-end; height: 28px; margin: 0 8px; flex: 1; max-width: 90px; }
.spark i { width: 7px; background: linear-gradient(180deg, var(--mint-deep), #8FD9AE); border-radius: 3px; min-height: 3px; }

/* ===== 设置弹窗 ===== */
.set-label { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 700; margin: 6px 0; }
.mode-row { display: flex; gap: 8px; }
.mode-btn {
  flex: 1; border: none; border-radius: 14px; padding: 11px 4px; font-size: 14px;
  font-weight: 700; background: var(--bg); color: var(--ink-soft); cursor: pointer; font-family: inherit;
}
.mode-btn.on { background: linear-gradient(135deg, var(--lav-deep), #B79CED); color: #fff; }

/* ===== 模式适配 ===== */
body.mode-child .result-stars { font-size: 52px; }
body.mode-child .tile { font-size: 26px; }
body.mode-child .btn { font-size: 17px; padding: 12px 22px; }
body.mode-big { font-size: 17px; }
body.mode-big .tile { font-size: 26px; }
body.mode-big .game-timer { font-size: 20px; }
body.mode-big .btn { font-size: 17px; padding: 13px 22px; }
body.mode-big .tc-name, body.mode-big .brand-name, body.mode-big .view-title { font-size: 1.12em; }
