/* 掼蛋九宫格 · 品味稿 v4 tokens */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0d10;
  --surface: #14181e;
  --cell: #1c222b;
  --border: #2e3641;
  --text: #f2f4f7;
  --mute: #8b93a1;
  --lock: #5c6570;
  --amber: #d4a017;
  --warning: var(--amber);
  --ok: #1f9d55;
  --bad: #d64545;
  --radius: 8px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  touch-action: manipulation;
}

.site-header { padding: 8px 0 4px; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.site-header h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}
.subtitle {
  font-size: 13px;
  color: var(--mute);
  margin-top: 4px;
}

/* 怎么玩：默认折叠 */
.howto {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 13px;
}
.howto summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after {
  content: "▾";
  float: right;
  color: var(--mute);
}
.howto[open] summary::after { content: "▴"; }
.howto-body {
  padding: 0 16px 12px;
  line-height: 1.65;
  color: var(--mute);
}
.howto-body p { margin-bottom: 8px; }
.howto-body strong { color: var(--text); font-weight: 600; }

.settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 16px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setting-label {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--mute);
}
.level-select {
  flex: 1;
  max-width: 120px;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.level-select option { color: #111; background: #fff; }
.streak-info {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
}
/* 满档标签：出牌闭卷与实战模拟共用。颜色/字号/字重沿用 .streak-info，形状是勾选圆。 */
.streak-info.tier-cap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.mark {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  display: block;
}
.tier-cap-mark { width: 11px; height: 11px; }

/* 本盘统计 */
.stats {
  display: flex;
  background: var(--cell);
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 0;
}
.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--mute);
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 28px;
  color: var(--text);
}
.stat-value.bad { color: var(--bad); }
.stat-value.ok { color: var(--ok); }

.row-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--mute);
  margin-bottom: 8px;
}

/* 翻牌面板：闭卷后隐藏列表 */
.flip-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.flip-panel.closed .last-cards,
.flip-panel.closed #current-card {
  visibility: hidden;
}
.flip-panel.closed #current-card::after {
  visibility: visible;
}
.card-back, .card-face {
  width: 56px;
  height: 76px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.card-back {
  background: var(--cell);
  border: 1.5px solid var(--border);
  color: var(--mute);
}
.card-face {
  background: var(--text);
  border: 1.5px solid var(--border);
  color: var(--bg);
}
.card-face.big { color: var(--bad); }
.flip-info { flex: 1; min-width: 0; }
.flip-count { font-size: 13px; margin-bottom: 4px; color: var(--mute); }
.flip-count b { color: var(--amber); font-weight: 700; }
.last-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}
.chip {
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--cell);
  border: 1px solid var(--border);
  color: var(--mute);
  font-size: 11px;
}
.chip.latest {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--bg);
  font-weight: 700;
}
.phase-hint {
  font-size: 11px;
  color: var(--mute);
  margin-top: 4px;
  line-height: 1.4;
}

/* 3×3 作答九宫格（v6.1 修订稿，三关共用） */
.ans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 4px;
  height: 76px;
  padding: 8px;
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
}

.cell:active:not(.locked):not(.done) { transform: scale(0.96); }

.cell .ans-cell-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 14px;
}
.cell .ans-cell-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 14px;
}

/* 数值行（右对齐）：作答值 / 锁定 ▢ / 错格「用户值 → 正确值」 */
.cell .ans-cell-val { width: 100%; text-align: right; line-height: 28px; }
.cell .count {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.cell .count.empty { color: var(--mute); }
.cell .ans-fix { font-size: 11px; font-weight: 600; }
.cell.wrong .ans-fix { color: var(--bad); }
.cell.ok .ans-fix { color: var(--ok); }

/* 判定 ✓/✕ 标在格名旁（仅反馈阶段显示） */
.cell .ans-verdict {
  display: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 14px;
}
.cell.done .ans-verdict { display: inline; }
.cell.ok .ans-verdict { color: var(--ok); }
.cell.wrong .ans-verdict { color: var(--bad); }

/* 锁定格（未开放）：原位灰显、虚线灰框 + ▢ */
.cell.locked {
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--lock);
  cursor: not-allowed;
}
.cell.locked .ans-cell-name,
.cell.locked .count { color: var(--lock); }
.cell.locked .count { font-size: 13px; font-weight: 600; }

/* 核对反馈：绿/红描边 + 同色薄底 */
.cell.ok {
  border: 1.5px solid var(--ok);
  background: rgba(31, 157, 85, 0.12);
}
.cell.wrong {
  border: 1.5px solid var(--bad);
  background: rgba(214, 69, 69, 0.12);
}

.cell.done { cursor: default; }
.cell.done:active { transform: none; }

/* 按钮 */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.btn {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-secondary {
  background: var(--cell);
  color: var(--mute);
  border-color: var(--border);
  font-weight: 500;
}

.message {
  min-height: 1.4em;
  margin-top: 12px;
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  color: var(--mute);
}
.message.good { color: var(--ok); }
.message.warn { color: var(--bad); }
.message.info { color: var(--mute); }

.site-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--lock);
}

.hidden { display: none !important; }

@media (max-width: 360px) {
  body { padding: 12px 12px 28px; }
}

/* ===== v5：首页双入口 + 开局扫牌 + 数字直选 ===== */

/* 视图顶栏（返回 + 关名） */
.mode-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 16px;
}
.btn-back {
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--mute);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-back:active { transform: scale(0.97); }
.mode-name-sm { font-size: 16px; font-weight: 600; color: var(--text); }
.mode-topbar .streak-info { margin-left: auto; }

/* 首页入口 */
.entry-head { margin: 0 0 12px; }
.entry-eyebrow {
  font-size: 11px;
  font-weight: 500;
  color: var(--mute);
  margin-bottom: 4px;
}
.entry-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  color: var(--text);
}
.entry-sub { font-size: 13px; color: var(--mute); margin-top: 4px; }
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:first-child { border: 1.5px solid rgba(242, 244, 247, 0.6); }
.mode-card:active { transform: scale(0.98); }
.mode-name { font-size: 16px; font-weight: 600; line-height: 20px; }
.mode-desc { font-size: 13px; line-height: 16px; color: var(--mute); }
.mode-tag { font-size: 11px; font-weight: 500; line-height: 14px; color: var(--amber); }

/* 数字键（三关共用） */
.num-row { display: flex; flex-wrap: wrap; gap: 4px; }
.num-btn {
  height: 40px;
  min-width: 44px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--mute);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.num-btn.dense { min-width: 26px; padding: 0; }
.num-btn:active:not(:disabled) { transform: scale(0.95); }
.num-btn.selected { background: var(--text); border-color: var(--text); color: var(--bg); }
.num-btn.ok { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.num-btn.bad { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.num-btn:disabled { cursor: default; }

/* 选中格：白色 2px 实框（v6.1） */
.cell.picked { border: 2px solid var(--text); }

/* 开局扫牌 */
.scan-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}
.scan-title { font-size: 16px; font-weight: 600; line-height: 20px; color: var(--text); }
.scan-sub { font-size: 13px; line-height: 16px; color: var(--mute); margin-top: 4px; margin-bottom: 12px; line-height: 18px; }
.scan-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.scan-timer-label { font-size: 11px; font-weight: 500; color: var(--mute); }
.scan-countdown {
  font-size: 22px;
  font-weight: 700;
  line-height: 28px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.scan-progress {
  height: 4px;
  margin-top: 8px;
  background: var(--cell);
  border-radius: 2px;
  overflow: hidden;
}
.scan-progress i {
  display: block;
  height: 4px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
}
.scan-hand { display: flex; flex-wrap: wrap; gap: 6px 4px; margin-top: 12px; }
.scan-card {
  width: 26px;
  height: 36px;
  background: #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #1a1a1f;
}
.scan-card.red { color: #bf3333; }
.scan-card.tight { font-size: 9px; }
.scan-card.lvl { border: 2px solid var(--amber); }
.scan-note { font-size: 11px; line-height: 14px; color: var(--mute); margin-top: 12px; }

.scan-cover {
  margin: 16px 0 12px;
  padding: 12px;
  background: var(--cell);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  color: var(--mute);
}
.scan-badge {
  padding: 1px 4px;
  background: var(--amber);
  border-radius: 4px;
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
}
.scan-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ===== v6：统一作答九宫格 + 实战模拟 ===== */

/* 点格后九宫格下方弹出的数字键（深色垫：标签 + 等分数字 chips） */
.ans-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: var(--cell);
  border-radius: var(--radius);
}
.ans-picker-label { font-size: 11px; color: var(--mute); }
.ans-picker-row { gap: 3px; }
.ans-picker-row .num-btn { flex: 1; height: 44px; }

/* 实战模拟：大牌舞台 / 细进度条 / 停牌 / 三段反馈 / 回看 */
.sim-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 24px 12px;
  background: var(--bg);
  border-radius: var(--radius);
}
.sim-flip-card {
  width: 88px;
  height: 124px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #1a1a1f;
}
.sim-flip-card.red { color: #bf3333; }
.sim-flip-card.tight { font-size: 19px; }
.sim-flip-card.lvl { outline: 2px solid var(--amber); outline-offset: 2px; }
.sim-stage-label { font-size: 11px; color: var(--mute); }
.sim-beat {
  height: 2px;
  margin-top: 12px;
  background: var(--cell);
  border-radius: 1px;
  overflow: hidden;
}
.sim-beat i {
  display: block;
  height: 2px;
  width: 0;
  background: var(--mute);
  border-radius: 1px;
}
.sim-stop {
  margin-bottom: 12px;
  padding: 12px;
  background: var(--cell);
  border-radius: 6px;
  text-align: center;
}
.sim-stop-title { font-size: 16px; font-weight: 700; color: var(--text); }
.sim-stop-sub { font-size: 12px; color: var(--mute); margin-top: 4px; }
.sim-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--cell);
  border-radius: 6px;
}
.sim-bd-line { font-size: 12px; line-height: 16px; color: var(--mute); }
.sim-bd-line:last-child { color: var(--text); font-weight: 600; }
.sim-streak-note {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 14px;
  color: var(--amber);
  margin-top: 4px;
}
/* 退档：琥珀（--warning = --amber）+ 向下箭头，无底、无渐变 */
.sim-demote-note { color: var(--warning); }
/* 错一盘小字：字色/字号/字重用 .stat-label（--mute）。无底、不用红。放在反馈最底。 */
.sim-hold-note {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  background: transparent;
}
.sim-review {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
  margin-top: 12px;
  padding: 12px;
  background: var(--cell);
  border-radius: 6px;
}
.sim-review-chip {
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--mute);
  font-size: 12px;
  font-weight: 600;
}
.sim-review-chip.latest { border-color: var(--amber); color: var(--amber); }
.sim-review-chip.lvl { border-color: var(--amber); }
.sim-review-chip.lvl.latest { color: var(--amber); }

.mode-grid-3 { grid-template-columns: repeat(3, 1fr); }
.mode-grid-3 .mode-card { padding: 12px; }
.mode-grid-3 .mode-name { font-size: 15px; }
.mode-grid-3 .mode-desc { font-size: 12px; line-height: 15px; }
.mode-grid-3 .mode-tag { font-size: 10px; }

@media (max-width: 360px) {
  .mode-grid-3 { gap: 6px; }
  .mode-grid-3 .mode-card { padding: 10px 8px; }
}

@media (max-width: 360px) {
  .mode-grid { gap: 6px; }
  .mode-card { padding: 12px; }
}

/* ===== v7：整场计时器（顶栏小组件 + 细进度线 + 暂停盖屏 + 小结） ===== */

/* 顶栏右侧：13px 分秒 + 边框暂停钮（作答时 .dim 淡到 35%，暂停时 .pause 变灰） */
.mode-topbar .tm {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.mode-topbar .tm.dim { opacity: 0.35; }
.mode-topbar .tm.pause { color: var(--mute); }
.tm-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 16px;
  color: var(--mute);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tm-btn:active:not(:disabled) { transform: scale(0.95); }
.tm-btn:disabled { opacity: 0.45; cursor: default; }

/* 顶栏下方 2px 细进度线：整场已用，#8B93A1 on #1C222B */
.tm-line {
  height: 2px;
  margin: -8px 0 12px;
  background: var(--cell);
  overflow: hidden;
}
.tm-line.dim { opacity: 0.35; }
.tm-line i {
  display: block;
  height: 2px;
  width: 0;
  background: var(--mute);
}

/* 暂停盖屏：不透明底，盖住当前这盘防偷看 */
.pause-cover {
  position: fixed;
  left: 0; right: 0; bottom: 0; top: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.pause-cover-title { font-size: 16px; font-weight: 600; color: var(--text); }
.pause-cover .btn { width: 200px; }

/* 小结：一屏，不滚动 */
#view-summary { min-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.sum-head { padding: 8px 0 4px; }
.sum-title { font-size: 22px; font-weight: 700; line-height: 1.3; }
.sum-hero { margin: 28px 0 24px; }
.sum-big {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.sum-sub { font-size: 13px; color: var(--mute); margin-top: 4px; }
.sum-rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
}
.sum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.sum-row:last-child { border-bottom: 0; }
.sum-row-sug { margin-left: 6px; font-size: 11px; font-weight: 500; color: var(--mute); }
.sum-row-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
}
