/* =============================================================
   专注小课堂 · 视觉层
   -------------------------------------------------------------
   与兄弟页 music-theory 同族（奶油纸 / 白卡 / 家族橙 / 圆角 20 /
   模糊光斑 / 粘顶栏），但不是换皮：

     music-theory 的身份符号 → 谱纸（横纹 + 红色装订线）
     focus-trainer 的身份符号 → 练习纸（点阵网格）+ 训练票（票根缺口）

   零外链：系统字体栈，无图片，无字体文件，图标用汉字/字符。
   ============================================================= */

/* ============================================================
   1. 设计令牌
   ============================================================ */
:root {
  /* ---------- 底色 / 背景 ---------- */
  --bg: #fff6ec; /* 主背景 奶油纸 */
  --bg-blob-1: #ffe8cf; /* 暖光斑 */
  --bg-blob-2: #ffe0e6; /* 粉光斑 */
  --bg-blob-3: #e6efff; /* 冷光斑（≥1024px 才渲染） */
  --card: #ffffff; /* 卡片纯白 */
  --paper: #fffdf8; /* 练习纸白 */
  --paper-tint: #fffaf2; /* 浅底 */
  --paper-line: #f0e4d6; /* 练习纸点阵线 */
  --paper-margin: #f3c9c2; /* 票根装订线 */

  /* ---------- 文字 ---------- */
  --ink: #2a2320; /* 正文（契约指定） */
  --ink-2: #584840; /* 次级文字 */
  --muted: #7d6a61; /* 辅助文字（对奶油底 ≥4.5:1） */
  --faint: #a2908a; /* 仅装饰，禁止承载文字 */
  --on-accent: #ffffff;

  /* ---------- 描边 ---------- */
  --line: #f3e5d8;
  --line-2: #ecd9c6;

  /* ---------- 主强调色（家族橙） ---------- */
  --accent: #f97316; /* 契约指定 */
  --accent-ink: #b4440f; /* 橙字 on --accent-soft */
  --accent-soft: #fff0e3;
  --accent-deep: #e2560a; /* 按钮底，白字 3.77:1 */
  --accent-deep-2: #d24d08;
  --accent-line: #ffd9b8;

  /* ---------- 反馈色 ---------- */
  --green: #16a34a;
  --green-ink: #116e33;
  --green-soft: #e3f7e9;
  --red: #dc2626;
  --red-ink: #a41b1b;
  --red-soft: #fdecec;
  --gold: #f5a623;
  --gold-ink: #8a5a06;
  --gold-soft: #fff3dc;

  /* ---------- 圆角 ---------- */
  --radius: 20px; /* 契约指定 */
  --radius-sm: 12px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  /* ---------- 阴影 ---------- */
  --shadow: 0 10px 30px rgba(180, 120, 60, 0.12); /* 契约指定 */
  --shadow-soft: 0 4px 14px rgba(180, 120, 60, 0.08);
  --shadow-lift: 0 14px 34px rgba(180, 120, 60, 0.18);
  --shadow-tone: 0 8px 20px rgba(90, 55, 30, 0.1);
  --shadow-inset: inset 0 2px 6px rgba(120, 85, 50, 0.09); /* 练习纸内阴影 */

  /* ---------- 字体 ---------- */
  --font: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  --font-num: ui-rounded, 'SF Pro Rounded', 'PingFang SC', var(--font);

  /* ---------- 间距 ---------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 44px;

  /* ---------- 动效 ---------- */
  --dur-1: 0.12s;
  --dur-2: 0.18s;
  --dur-3: 0.3s;
  --ease-out: cubic-bezier(0.34, 1.3, 0.64, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ---------- 层级 / 尺寸 ---------- */
  --tap: 44px; /* 最小触控目标 */
  --topbar-h: 62px;
  --tabbar-h: 62px;
  --z-sticky: 50;
  --z-toast: 200;

  /* ---------- 默认成分色（被 [data-dim] 覆盖） ---------- */
  --tone: #e2560a;
  --tone-soft: #fff0e3;
  --tone-ink: #b4440f;

  /* ---------- 内容区 ---------- */
  --wrap-max: 1040px;
}

/* ============================================================
   2. 成分色（FocusData.DIMENSIONS 的唯一来源）
   7 个成分各一色：tone / tone-soft / tone-ink
   tone-ink 在 tone-soft 上均 ≥ 4.5:1
   ============================================================ */
[data-dim='inhibition'] {
  --tone: #e2560a;
  --tone-soft: #ffeede;
  --tone-ink: #b4440f;
}
[data-dim='updating'] {
  --tone: #7c5cd6;
  --tone-soft: #efe9fd;
  --tone-ink: #5b21b6;
}
[data-dim='shifting'] {
  --tone: #2f9e6e;
  --tone-soft: #e0f5ec;
  --tone-ink: #17694a;
}
[data-dim='visuospatial'] {
  --tone: #2f7fd6;
  --tone-soft: #e2eefb;
  --tone-ink: #1a5598;
}
[data-dim='selective'] {
  --tone: #c2410c;
  --tone-soft: #ffeade;
  --tone-ink: #8f2d06;
}
[data-dim='timing'] {
  --tone: #0f766e;
  --tone-soft: #ddf3f1;
  --tone-ink: #0a544e;
}

/* ============================================================
   3. 重置
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
}
body::before {
  width: 420px;
  height: 420px;
  background: var(--bg-blob-1);
  top: -120px;
  right: -100px;
}
body::after {
  width: 380px;
  height: 380px;
  background: var(--bg-blob-2);
  bottom: -140px;
  left: -110px;
}
button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  text-align: inherit;
}
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
img,
svg,
canvas {
  max-width: 100%;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   4. 外壳：顶栏 / 视图 / 底部 tab / toast
   ============================================================ */

/* ---- 顶栏 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  padding-top: calc(9px + env(safe-area-inset-top));
  background: rgba(255, 246, 236, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tb-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tb-title b {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-title span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  font-size: 19px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease, opacity var(--dur-1);
}
.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn[hidden] {
  display: none;
}
.icon-btn[aria-pressed='false'] {
  opacity: 0.45;
}

/* ---- 视图容器 ---- */
.view {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 16px 16px calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom));
}
.screen {
  animation: ftFadeUp var(--dur-3) var(--ease-out) backwards;
}
.screen.is-leaving {
  animation: ftFadeOut var(--dur-2) ease forwards;
  pointer-events: none;
}
@keyframes ftFadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes ftFadeOut {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---- 底部 tab ---- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 246, 236, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] {
  display: none;
}
.tab {
  flex: 1;
  max-width: 150px;
  min-height: var(--tap);
  padding: 6px 8px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  transition: background var(--dur-1) ease, color var(--dur-1) ease, transform var(--dur-1) ease;
}
.tab:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tab:active {
  transform: scale(0.96);
}
.tab.is-on,
.tab[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 -3px 0 var(--accent);
}

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(70px);
  background: rgba(42, 35, 32, 0.94);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  max-width: min(86vw, 420px);
  text-align: center;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-3);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================================
   5. 通用文字 / 按钮
   ============================================================ */
.section-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.3px;
}
.section-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 2px;
}
.hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.6;
}

.big-btn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 15px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent-deep-2));
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 1.5px;
  box-shadow: 0 10px 24px rgba(226, 86, 10, 0.3);
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease, opacity var(--dur-1);
}
.big-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(226, 86, 10, 0.36);
}
.big-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.big-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.big-btn.secondary {
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--line-2);
  box-shadow: var(--shadow-soft);
  font-size: 16px;
  letter-spacing: 1px;
}
.big-btn.ghost {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 2px solid var(--accent-line);
  box-shadow: none;
  font-size: 16px;
}

/* ============================================================
   6. 首页：今日计划「训练票」
   ============================================================ */
.plan-card {
  position: relative;
  display: grid;
  grid-template-columns: 78px 1fr;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
  animation: ftCardIn var(--dur-3) var(--ease-out) backwards;
}
@keyframes ftCardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 左侧竖排「票根」：时间 + 关数 */
.plan-head {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 16px 8px;
  background: linear-gradient(160deg, var(--accent-soft), #ffe4cd);
  border-right: 2px dashed var(--accent-line);
  text-align: center;
}
/* 票根缺口：虚线两侧的小半圆，纯 CSS 径向渐变，无图片 */
.plan-head::before,
.plan-head::after {
  content: '';
  position: absolute;
  right: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 0 0 var(--bg);
}
.plan-head::before {
  top: -8px;
}
.plan-head::after {
  bottom: -8px;
}
.plan-title {
  font-size: 30px;
  font-weight: 900;
  font-family: var(--font-num);
  color: var(--accent-ink);
  line-height: 1;
  letter-spacing: -0.5px;
}
.plan-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  opacity: 0.85;
  line-height: 1.4;
}
.plan-meta b {
  font-family: var(--font-num);
  font-size: 14px;
}

/* 右侧：5 个关卡小方块（自动换行，永不横向滚动） */
.plan-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 12px 10px;
}
.plan-item {
  flex: 1 1 0;
  min-width: 56px;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 3px 7px;
  border-radius: 13px;
  background: var(--tone-soft);
  border: 1.5px solid transparent;
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.plan-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}
.plan-item .pi-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--tone);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(90, 55, 30, 0.16);
  flex: none;
}
.pi-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--tone-ink);
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pi-dur {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-num);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* 底部大按钮（在票根下方横跨整卡） */
.plan-card > .big-btn,
.plan-cta {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}
.plan-cta {
  padding: 0 14px 14px;
}

/* ---- 成分进度条 ---- */
.dim-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.dim-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: var(--radius-pill);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}
.dim-pill i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tone);
  flex: none;
}
.dim-pill b {
  font-family: var(--font-num);
  font-weight: 800;
  color: var(--tone-ink);
}

/* ---- 任务网格 ---- */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.task-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 148px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  border: 2px solid transparent;
  text-align: left;
  overflow: hidden;
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease, border-color var(--dur-1) ease;
}
.task-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.task-card:active {
  transform: scale(0.985);
}
.task-card.is-done {
  border-color: var(--tone);
}
.tc-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--tone-soft);
  color: var(--tone-ink);
  font-size: 23px;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  flex: none;
}
.tc-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
}
.tc-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 10px;
  width: 100%;
  border-top: 1px dashed var(--line);
}
.tc-level {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--tone-ink);
  background: var(--tone-soft);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
}
.tc-dur {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-num);
  white-space: nowrap;
}
.tc-stars {
  margin-left: auto;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--line-2);
  white-space: nowrap;
}
.tc-stars .on {
  color: var(--gold);
}

/* ---- 研究说明 ---- */
.notes {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 2px dashed var(--line-2);
}
.notes > .section-title {
  margin-bottom: 10px;
}
details.note {
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  margin-bottom: 8px;
  overflow: hidden;
}
details.note > summary {
  cursor: pointer;
  list-style: none;
  min-height: var(--tap);
  padding: 13px 40px 13px 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  position: relative;
  transition: background var(--dur-1) ease;
}
details.note > summary::-webkit-details-marker {
  display: none;
}
details.note > summary::after {
  content: '＋';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
}
details.note[open] > summary::after {
  content: '－';
}
details.note > summary:hover {
  background: var(--paper-tint);
}
details.note .note-body {
  padding: 0 14px 14px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* ============================================================
   7. 训练中：HUD + 提示 + 游戏区
   ============================================================ */
.hud {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  background: var(--bg);
  padding: 10px 0 8px;
  margin-bottom: 10px;
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.hud-task {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.hud-task b {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-level {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-num);
  white-space: nowrap;
}
.hud-timer {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.hud-num {
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent-ink);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.hud-num small {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}
/* 细进度条 */
.hud-bar {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(180, 120, 60, 0.14);
}
.hud-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width 0.35s var(--ease-out);
}

/* 提示一句话 */
.prompt {
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  line-height: 1.5;
  color: var(--ink);
  padding: 6px 8px 10px;
  min-height: 34px;
}

/* 对 / 错 徽标 */
.feed {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: var(--shadow-lift);
}
.feed.ok {
  background: var(--green);
}
.feed.no {
  background: var(--red);
}
.feed.show {
  animation: ftFeed 0.9s var(--ease-pop);
}
@keyframes ftFeed {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(0.96);
  }
}

/* ---- 游戏区：练习纸 ---- */
.stage {
  position: relative;
  width: 100%;
  height: min(58vh, 460px);
  min-height: 320px;
  background-color: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(120, 85, 50, 0.09) 1px, transparent 0);
  background-size: 22px 22px;
  border-radius: 18px;
  box-shadow: var(--shadow), var(--shadow-inset);
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage > * {
  flex: none;
}
canvas.fx-canvas {
  display: block;
  width: 100%;
  border-radius: 12px;
  touch-action: manipulation;
}

/* 目标顺序提示（旋转数字）：按顺序点出 4 → 5 → 6 */
.g-seq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}
.g-seq .sq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--card);
  border: 2px solid var(--line);
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}
.g-seq .sq.is-now {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
/* 进度条（旋转数字：已经按序找到几个） */
.g-track {
  display: inline-block;
  width: 116px;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(180, 120, 60, 0.12);
}
.g-track i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.3s var(--ease-out);
}
.g-count {
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 一组游戏的容器：换组时新画面先画好，旧画面再撤（中间不清屏） */
.game-slot {
  position: relative;
  width: 100%;
}

/* 答对 / 答错时舞台轻轻闪一下 */
.stage.flash-ok {
  animation: ftFlashOk 0.42s var(--ease-out);
}
.stage.flash-no {
  animation: ftFlashNo 0.42s var(--ease-out);
}
@keyframes ftFlashOk {
  0%,
  100% {
    box-shadow: var(--shadow), var(--shadow-inset);
  }
  30% {
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.4), var(--shadow-inset);
  }
}
@keyframes ftFlashNo {
  0%,
  100% {
    box-shadow: var(--shadow), var(--shadow-inset);
  }
  30% {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.4), var(--shadow-inset);
  }
}

/* ============================================================
   8. 结果页
   ============================================================ */
.result {
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px 18px;
  text-align: center;
}
.res-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.res-stars > span {
  font-size: 44px;
  line-height: 1;
  color: var(--line-2);
  transform: scale(0.6);
  opacity: 0;
}
.res-stars > span.on {
  color: var(--accent);
  -webkit-text-stroke: 1px var(--accent-deep);
  animation: ftStarIn 0.34s var(--ease-pop) forwards;
}
.res-stars > span.off {
  animation: ftStarIn 0.34s var(--ease-pop) forwards;
}
@keyframes ftStarIn {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-14deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.14) rotate(4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}
.res-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 4px;
}
.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 14px;
}
.stat {
  background: var(--paper-tint);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  min-width: 0;
}
.stat b {
  display: block;
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}
.res-adapt {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  margin-bottom: 16px;
}
.res-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.res-actions .big-btn {
  width: 100%;
}

/* ============================================================
   9. 关卡地图
   ============================================================ */
.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: none;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--card);
  border: 2px solid var(--line);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--dur-1) ease, border-color var(--dur-1) ease,
    color var(--dur-1) ease, transform var(--dur-1) ease;
}
.chip:hover {
  border-color: var(--accent-line);
}
.chip:active {
  transform: scale(0.96);
}
.chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.28);
}
.chip.is-on[data-dim] {
  background: var(--tone);
  border-color: var(--tone);
}
.map-count {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.map-count b {
  font-family: var(--font-num);
  font-weight: 800;
  color: var(--ink);
}
.map-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--tone);
  text-align: left;
  width: 100%;
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.map-row:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow);
}
.map-row.is-locked {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}
.mr-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mr-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.mr-dur {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 800;
  color: var(--tone-ink);
  flex: none;
}
.mr-lock {
  flex: none;
  width: 26px;
  text-align: center;
  font-size: 16px;
  color: var(--muted);
  letter-spacing: -1px;
}
.mr-stars {
  flex: none;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--line-2);
  white-space: nowrap;
}
.mr-stars .on {
  color: var(--gold);
}

/* ============================================================
   10. 我的
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-grid .stat {
  background: var(--card);
  box-shadow: var(--shadow-soft);
}
.stat-grid .stat b {
  font-size: 28px;
  color: var(--accent-ink);
}

/* 成分横向条形 */
.dim-bars {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 16px 14px;
  margin-bottom: 20px;
}
.dim-bars .section-title {
  margin-bottom: 14px;
}
.dim-bar {
  display: grid;
  grid-template-columns: 72px 1fr 46px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.dim-bar:last-child {
  margin-bottom: 0;
}
.dim-bar > span:first-child {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dim-bar i {
  display: block;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(180, 120, 60, 0.12);
}
.dim-bar i::before {
  content: '';
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: var(--radius-pill);
  background: var(--tone);
  transition: width 0.5s var(--ease-out);
}
.dim-bar > b {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 800;
  color: var(--tone-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 近 7 天柱状图（纯 CSS） */
.section-title + .week {
  margin-top: -12px;
}
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 6px;
  height: 128px;
  padding: 16px 16px 10px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}
.week .wd {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
  min-width: 0;
}
.week .wd > i {
  display: block;
  width: 100%;
  max-width: 26px;
  height: var(--h, 6px);
  min-height: 4px;
  border-radius: 7px 7px 3px 3px;
  background: var(--accent-line);
  transition: height 0.5s var(--ease-out);
}
.week .wd.is-today > i {
  background: var(--accent);
}
.week .wd > span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.week .wd > b {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-2);
  font-weight: 800;
  white-space: nowrap;
}

/* 设置 */
.settings {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  transition: background var(--dur-1) ease;
}
.set-row:last-child {
  border-bottom: none;
}
.set-row:hover {
  background: var(--paper-tint);
}
.set-row > span:first-child {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.set-row > small {
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
.set-row .switch {
  flex: none;
  width: 46px;
  height: 27px;
  border-radius: var(--radius-pill);
  background: var(--line-2);
  position: relative;
  transition: background var(--dur-2) ease;
}
.set-row .switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(90, 55, 30, 0.28);
  transition: transform var(--dur-2) var(--ease-pop);
}
.set-row[aria-checked='true'] .switch,
.set-row.is-on .switch {
  background: var(--accent);
}
.set-row[aria-checked='true'] .switch::after,
.set-row.is-on .switch::after {
  transform: translateX(19px);
}

/* ============================================================
   11. 游戏内部原子类（任务实现直接使用，不写内联样式）
   ============================================================ */
.g-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  text-align: center;
}
.g-digit {
  font-family: var(--font-num);
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.g-msg {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
}
.g-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.g-btn {
  min-height: 56px;
  min-width: 76px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--card);
  border: 2px solid var(--accent-line);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-num);
  box-shadow: var(--shadow-soft);
  transition: transform var(--dur-1) ease, background var(--dur-1) ease,
    border-color var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.g-btn:hover:not(:disabled) {
  border-color: var(--accent);
}
.g-btn:active:not(:disabled) {
  transform: scale(0.96);
}
.g-btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.3);
}
.g-btn.is-ok {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green-ink);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16);
}
.g-btn.is-no {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red-ink);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}
.g-btn:disabled {
  cursor: default;
}
.g-key {
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 12px;
  background: var(--card);
  border: 2px solid var(--line-2);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-num);
  display: grid;
  place-items: center;
  transition: transform var(--dur-1) ease, background var(--dur-1) ease,
    border-color var(--dur-1) ease;
}
.g-key:hover {
  border-color: var(--accent);
}
.g-key:active {
  transform: scale(0.94);
}
.g-key.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.g-tile {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 2px solid rgba(42, 35, 32, 0.14);
  transition: transform var(--dur-1) ease, box-shadow var(--dur-1) ease;
}
.g-tile:hover {
  transform: translateY(-2px);
}
.g-caption {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

/* ============================================================
   12. 响应式
   ============================================================ */

/* ---- 390px 基准 ---- */
@media (max-width: 419px) {
  .plan-card {
    grid-template-columns: 62px 1fr;
  }
  .plan-title {
    font-size: 25px;
  }
  .plan-list {
    gap: 5px;
    padding: 12px 10px 8px;
  }
  .plan-item {
    padding: 8px 2px 6px;
  }
  .plan-item .pi-icon {
    width: 30px;
    height: 30px;
    font-size: 16px;
    border-radius: 10px;
  }
  .pi-name {
    font-size: 11px;
  }
  .pi-dur {
    font-size: 10.5px;
  }
  .task-grid {
    grid-template-columns: 1fr;
  }
  .task-card {
    min-height: 0;
  }
  .res-stars > span {
    font-size: 38px;
  }
  .res-actions .big-btn {
    width: 100%;
  }
}

/* ---- ≥720px：双列 ---- */
@media (min-width: 720px) {
  .view {
    padding: 22px 22px calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom));
  }
  .topbar {
    padding: 10px 22px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }
  .tb-title b {
    font-size: 20px;
  }
  .task-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .plan-card {
    grid-template-columns: 92px 1fr;
  }
  .plan-title {
    font-size: 34px;
  }
  .plan-list {
    gap: 8px;
    padding: 14px 14px 10px;
  }
  .plan-item {
    padding: 10px 5px 8px;
  }
  .plan-item .pi-icon {
    width: 38px;
    height: 38px;
    font-size: 20px;
    border-radius: 12px;
  }
  .pi-name {
    font-size: 13px;
  }
  .dim-strip {
    gap: 10px;
  }
  .res-actions {
    flex-direction: row;
  }
  .res-actions .big-btn {
    flex: 1;
  }
  .week {
    height: 150px;
    gap: 10px;
  }
  .stat-grid {
    gap: 14px;
  }
  .filters {
    gap: 10px;
  }
}

/* ---- ≥1080px：内容区居中 1040px，任务网格 3 列 ---- */
@media (min-width: 1080px) {
  body::after {
    display: none;
  }
  body::before {
    width: 520px;
    height: 520px;
    top: -160px;
    right: -140px;
  }
  .view {
    padding-left: 24px;
    padding-right: 24px;
  }
  .task-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
  .plan-card {
    grid-template-columns: 104px 1fr;
  }
  .plan-list {
    gap: 10px;
    padding: 16px 18px 12px;
  }
  .plan-item {
    padding: 12px 8px 10px;
  }
  .plan-item .pi-icon {
    width: 42px;
    height: 42px;
    font-size: 22px;
    border-radius: 13px;
  }
  .pi-name {
    font-size: 14px;
  }
  .pi-dur {
    font-size: 12px;
  }
  .task-card {
    min-height: 172px;
    padding: 16px 16px 14px;
  }
  .hud {
    top: var(--topbar-h);
  }
  .hud-num {
    font-size: 40px;
  }
  .stage {
    height: min(58vh, 460px);
  }
  .res-stats {
    gap: 12px;
  }
  .stat b {
    font-size: 30px;
  }
  .dim-bar {
    grid-template-columns: 96px 1fr 56px;
  }
  .map-row {
    padding: 12px 18px;
  }
}

/* ---- 桌面端第三层冷色光斑 ---- */
@media (min-width: 1024px) {
  /* 桌面端把游戏区放大：环、块、数字都能画得更大 */
  .stage {
    height: min(68vh, 620px);
    min-height: 420px;
  }

  body::after {
    display: block;
    width: 460px;
    height: 460px;
    background: var(--bg-blob-3);
    opacity: 0.4;
    bottom: -180px;
    right: -120px;
    left: auto;
  }
}

/* ============================================================
   13. 无障碍 / 减少动效
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .stage.flash-ok,
  .stage.flash-no {
    animation: none;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  /* 位移与缩放关闭，但保留颜色 / 描边 / 星级形状等状态反馈 */
  .res-stars > span,
  .res-stars > span.on,
  .res-stars > span.off {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .feed.show {
    opacity: 1;
    transform: translate(-50%, -50%);
    animation: none;
  }
  .big-btn:hover,
  .task-card:hover,
  .plan-item:hover,
  .map-row:hover,
  .icon-btn:hover {
    transform: none;
  }
  .g-btn.is-ok,
  .g-btn.is-no {
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.3);
  }
  .g-btn.is-no {
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.28);
  }
}

/* 打印：不需要 */
@media print {
  .topbar,
  .tabbar,
  .toast {
    display: none;
  }
}
