/* =========================================================================
   cat-lab.xyz · 跨游戏共享 UI
   从 queens/styles.css 抽出的通用外壳组件：顶栏、分段切换、抽屉、
   按钮、日历、关卡网格与分页、列表行、图例、toast、主题变量。
   游戏专属样式（棋盘、棋子等）请留在各自项目的 CSS 里。
   ========================================================================= */

/* ============================================================
   Queens — LinkedIn Queens clone
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-glow: rgba(10, 102, 194, 0.10);
  --card: #ffffff;
  --ink: #1b2432;
  --muted: #6b7684;
  --line: #e3e7ee;
  --accent: #0a66c2;
  --accent-soft: rgba(10, 102, 194, 0.12);
  --boundary: rgba(27, 36, 50, 0.55);
  --cell-line: rgba(27, 36, 50, 0.09);
  --x-color: #5a6474;
  --bad: #d93025;
  --cal-solved: #cfeccd;
  --cal-solved-ink: #1f5b2b;
  --cal-progress: #fbeaa8;
  --cal-progress-ink: #6d5100;
  --shadow: 0 18px 44px -28px rgba(15, 23, 42, 0.55);
  --radius: 18px;
}

/* 主题由 data-theme 决定（自动模式下 JS 会把它解析成 light/dark），
   所以这里不写 prefers-color-scheme 分支，只有一个真相来源。 */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f141b;
  --bg-glow: rgba(80, 160, 255, 0.12);
  --card: #171d26;
  --ink: #e8edf5;
  --muted: #93a0b1;
  --line: #26303d;
  --accent: #6fb2ff;
  --accent-soft: rgba(111, 178, 255, 0.16);
  --boundary: rgba(10, 14, 20, 0.75);
  --cell-line: rgba(10, 14, 20, 0.16);
  --x-color: #4a5566;
  --cal-solved: rgba(96, 200, 122, 0.24);
  --cal-solved-ink: #a6e2b3;
  --cal-progress: rgba(240, 200, 82, 0.22);
  --cal-progress-ink: #f0d489;
  --shadow: 0 18px 44px -28px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -220px, var(--bg-glow), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
}

.app {
  width: 100%;
  max-width: var(--app-max, 560px);
  margin: 0 auto;
  padding: 0 16px 18px;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 20px);
}

/* 主内容区：占满剩余高度，棋盘/画布放里面 */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  width: 30px;
  height: 30px;
  flex: none;
  fill: var(--ink);
  padding: 5px;
  background: var(--card);
  border-radius: 9px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 2px 8px -4px rgba(15, 23, 42, 0.4);
}

.titles { min-width: 0; }

.titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.15;
  display: flex;
  align-items: center;
  gap: 6px;
}

.variant-chip {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--card);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1.5;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover { background: var(--accent-soft); border-color: transparent; }
.icon-btn:active { transform: scale(0.94); }

/* 主题按钮：图标显示"点一下会变成"的模式 —— 深色时给太阳，浅色时给月亮 */
.icon-btn .ico-sun { display: none; }
.icon-btn.is-dark .ico-sun { display: block; }
.icon-btn.is-dark .ico-moon { display: none; }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
}

.timer { letter-spacing: 0.6px; }
.counter { font-weight: 600; color: var(--ink); }
.counter.is-done { color: #1a7f37; }

/* --------------------------------------------------------- toolbar */

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* 玩法切换（日常 / 练习 / 挑战）单独一行，和对局操作区分开 */
.mode-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0 10px;
}

.mode-row .seg { flex: 1; }

.mode-row .seg-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 8px;
  font-size: 13px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, opacity 0.15s;
}

.tool svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.tool:active:not(:disabled) { transform: scale(0.96); }
.tool:disabled { opacity: 0.42; cursor: not-allowed; }

/* --------------------------------------------------------- date nav */

.datenav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

/* hidden 必须压过组件自己的 display 规则，否则藏不起来 */
[hidden] { display: none !important; }

.nav-btn {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.date-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.date-btn:hover { background: var(--accent-soft); border-color: transparent; }
.date-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 挑战模式下这个按钮显示"尺寸 + 第几关 / 共几关"，点开是关卡列表。
   不再额外挂图标：右边的"第 k / N 关"已经说明它通向列表。 */
.date-btn .pool-icon { display: none; width: 16px; height: 16px; }
.date-btn.is-pool .cal-icon,
.date-btn.is-pool .pool-icon { display: none; }

.date-btn .date-level {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.date-btn.is-pool,
.date-btn.is-book { gap: 6px; }

/* 练习模式：这个按钮变成"练习本"，同样不带图标 */
.date-btn .book-icon { display: none; width: 16px; height: 16px; }
.date-btn.is-book .cal-icon,
.date-btn.is-book .pool-icon,
.date-btn.is-book .book-icon { display: none; }

/* 练习本面板 */
.book-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 4px;
}
.book-actions .btn { padding: 9px 8px; font-size: 12.5px; }

/* 练习模式标题行右侧的"导入"：文字按钮，不抢视觉 */
.practice-lede {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
/* 点"导出"后展开的两个复制入口 */
.share-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 4px;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.share-btn svg { width: 20px; height: 20px; color: var(--muted); }
.share-btn:hover { background: var(--accent-soft); border-color: transparent; }
.share-btn:hover svg { color: var(--accent); }

.book-list { display: flex; flex-direction: column; margin-top: 8px; }

.book-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 13px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.book-list .book-row:last-child { border-bottom: 0; }

/* 状态色和日历 / 关卡列表完全相同：绿=完成，黄=做了一半，素=未开始，蓝环=当前 */
.book-row.is-solved { background: var(--cal-solved); color: var(--cal-solved-ink); }
.book-row.is-progress { background: var(--cal-progress); color: var(--cal-progress-ink); }
.book-row.is-current { box-shadow: inset 0 0 0 2px var(--accent); }
.book-row:hover { filter: brightness(0.965); }
.book-row .book-left { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.book-row .book-size { font-size: 14px; font-weight: 700; }
.book-row .book-state,
.book-row .book-time {
  font-size: 12px;
  color: inherit;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

/* 头像那个小圆点不再需要：整行就是状态 */
.book-row .book-dot { display: none; }
.book-row .book-right { display: flex; align-items: center; gap: 8px; flex: none; }
.book-row .book-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cal-solved);
}
.book-row.is-open .book-dot { background: var(--accent); }
.book-empty { padding: 18px 4px; font-size: 12.5px; color: var(--muted); }

.book-io { margin-top: 12px; }
.book-io textarea {
  width: 100%;
  height: 108px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}
.book-io-actions { display: flex; gap: 8px; margin-top: 8px; }
.book-io-actions .btn { flex: 1; }

.cal-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ------------------------------------------------------ calendar popover */


.cal-sheet { max-width: 380px; padding: 18px 16px 16px; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 12px;
}

.cal-head-group { display: flex; align-items: center; gap: 6px; }

/* 翻年按钮小一号，和翻月按钮区分开 */
.nav-btn.is-year { width: 32px; height: 32px; border-radius: 10px; }

.cal-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  flex: 1;
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekdays {
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, transform 0.1s;
}

.cal-day:hover:not(:disabled) { background: var(--accent-soft); }
.cal-day:active:not(:disabled) { transform: scale(0.94); }

/* 没有题目：灰掉、不可点 */
.cal-day.is-none { color: var(--muted); opacity: 0.34; cursor: not-allowed; }

/* 当月之外的日子只做占位，不显示状态 */
.cal-day.is-out { visibility: hidden; }

/* 做了一半：浅黄 —— 日历的日子和挑战的关卡共用这套状态色 */
.cal-day.is-progress,
.level-cell.is-progress {
  background: var(--cal-progress);
  color: var(--cal-progress-ink);
}

/* 已完成：浅绿 */
.cal-day.is-solved,
.level-cell.is-solved {
  background: var(--cal-solved);
  color: var(--cal-solved-ink);
}

/* 今天：虚线描边；当前正在看的那天：实线环 */
.cal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--muted); }
.cal-day.is-selected { box-shadow: inset 0 0 0 2px var(--accent); }

.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--muted);
}

.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

.cal-dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
  background: var(--line);
}

.cal-dot.is-solved { background: var(--cal-solved); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.cal-dot.is-progress { background: var(--cal-progress); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.cal-dot.is-none { background: var(--line); opacity: 0.5; }

.ghost-btn {
  height: 36px;
  padding: 0 12px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }

.foot {
  padding: 16px 4px 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.link-btn {
  flex: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* --------------------------------------------------------- toast */

/* toast 用 popover 挂进顶层：否则会被 showModal() 对话框的遮罩压住 */

.toast {
  position: fixed;
  inset: auto auto max(24px, env(safe-area-inset-bottom)) 50%;
  margin: 0;
  transform: translate(-50%, 14px);
  max-width: min(92vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(27, 36, 50, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 40;
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast:popover-open { display: block; }

/* --------------------------------------------------------- dialogs */

.sheet {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  padding: 22px;
  width: calc(100% - 32px);
  max-width: 420px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
}

/* 关闭只放在右上角：底部按钮留给"要做的事"（确认/取消某项操作），
   纯展示或即时生效的弹窗不再重复放一个"关闭"。 */
.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sheet-close:hover { background: var(--bg); color: var(--ink); }
.sheet-close svg { width: 15px; height: 15px; display: block; }
.sheet-close + h2,
.sheet-head h2 { padding-right: 34px; }

/* 二级面板的"返回上一级"：和 × 对称地放在左边，但跟标题同一行 */
.sheet-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

/* 选择器要比 .sheet h2 更具体，否则 margin/行高会被后者覆盖，标题会被顶高 */
.sheet .sheet-head h2 {
  margin: 0;
  line-height: 1.25;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.sheet-back {
  flex: none;
  width: 28px;
  height: 28px;
  margin-left: -7px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sheet-back:hover { background: var(--bg); color: var(--ink); }
.sheet-back svg { width: 17px; height: 17px; display: block; }

.sheet::backdrop { background: rgba(12, 18, 27, 0.5); backdrop-filter: blur(3px); }

.sheet h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.sheet h3 {
  margin: 18px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.lede { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }

.rules {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.75;
}

.rules.tight li { margin-bottom: 4px; }
.rules b { font-weight: 700; }

.fine {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

kbd {
  font: inherit;
  font-size: 11.5px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg);
}

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.btn:hover { background: var(--accent-soft); border-color: transparent; }
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }

.settings { display: flex; flex-direction: column; gap: 4px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.switch-row:last-child { border-bottom: 0; }
.switch-row span { display: flex; flex-direction: column; gap: 2px; }
.switch-row b { font-size: 13.5px; font-weight: 600; }
.switch-row small { font-size: 11.5px; color: var(--muted); }

/* 外观：三选一的分段控件 */
.seg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.seg-row > span { display: flex; flex-direction: column; gap: 2px; }
.seg-row b { font-size: 13.5px; font-weight: 600; }
.seg-row small { font-size: 11.5px; color: var(--muted); }

.seg {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--bg);
}

.seg-btn {
  min-width: 46px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn:hover { color: var(--ink); }

.seg-btn.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.switch-row input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 25px;
  flex: none;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}

.switch-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
  transition: transform 0.18s;
}

.switch-row input[type="checkbox"]:checked { background: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(17px); }

/* 练习尺寸：一整块网格，格子之间用细线分隔（不再是八个圆角卡片） */
.size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;                 /* 露出来的 1px 就是分隔线 */
  background: var(--line);
  margin: 16px 0 4px;
}

.size-btn {
  padding: 15px 4px;
  border: 0;
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.size-btn small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.size-btn:hover { background: var(--accent-soft); }
.size-btn:active { background: var(--accent-soft); }

/* 挑战题库：一行一个尺寸，左边尺寸、右边「已完成 / 总数」。
   行缩进到内容区（左边缘和标题对齐），行内再留内边距 —— 对齐线和留白都要。 */

.pool-list {
  display: flex;
  flex-direction: column;
  margin: 16px 0 4px;
}

.pool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 17px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.pool-list .pool-row:last-child { border-bottom: 0; }

.pool-row b { font-size: 14.5px; font-weight: 700; }
.pool-row .pool-progress {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pool-row:hover { background: var(--accent-soft); }
.pool-row:active { background: var(--accent-soft); }

/* 关卡列表：100 关一页的方格 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin: 4px 0 12px;
}

/* 关卡格子：和日历里的日子是同一套"状态"语义，所以共用 .is-solved / .is-progress 的配色 */
.level-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.1s;
}

.level-cell:active { transform: scale(0.94); }

/* 没做过的关：和日历里"没做的日子"一样，素色、浅字 */
.level-cell.is-todo { background: transparent; color: var(--muted); }

/* 当前所在的那一关：和日历"选中那天"同款描边环 */
.level-cell.is-current { box-shadow: inset 0 0 0 2px var(--accent); }

/* 悬停反馈对所有状态一视同仁：不管做过没做过，都铺同一层浅色。
   必须写在各种 .is-* 之后，并用 :hover 提高优先级，否则会被状态底色压掉。 */
.level-cell:hover,
.level-cell.is-todo:hover,
.level-cell.is-progress:hover,
.level-cell.is-solved:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.level-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.level-nav .btn { flex: none; padding: 7px 12px; font-size: 12px; }
.level-nav .btn:disabled { opacity: 0.45; cursor: default; }
.level-range { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat {
  padding: 14px;
  border-radius: 12px;
  background: var(--bg);
  text-align: center;
}

.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }

.win { text-align: center; }
.win-badge { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.win .lede { margin-bottom: 14px; }

.share-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.35;
  white-space: pre;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  overflow: auto;
  max-height: 190px;
}

.win .sheet-actions { justify-content: center; }

@media (max-width: 380px) {
  .app { padding: 0 10px 14px; }
  .titles h1 { font-size: 18px; }
  .tool { font-size: 11px; }
  /* four date controls now share the row: keep the date field readable */
  .datenav { gap: 6px; }
  .ghost-btn { padding: 0 8px; font-size: 11px; }
  .seg-btn { min-width: 34px; padding: 6px 5px; font-size: 11px; }
}

@media (max-height: 620px) {
  .foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

