:root {
  --bg: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #898781;
  --line: #e1e0d9; --axis: #c3c2b7; --accent: #2a78d6; --accent-ink: #fff;
  --red: #d03b3b; --blue: #2a78d6; --hot: #eb6834; --cold: #2a78d6; --mid: #f0efec; --seq: #2a78d6;
  --good: #006300; --bad: #b42b2b; --hit-ring: #0b0b0b;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --axis: #383835; --accent: #3987e5;
    --red: #d03b3b; --blue: #3987e5; --hot: #d95926; --cold: #3987e5; --mid: #383835; --seq: #3987e5;
    --good: #0ca30c; --bad: #e66767; --hit-ring: #f0efec;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--ink2); font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ── 顶栏 ── */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.topbar h1 { font-size: 17px; }
.game-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.game-tabs button, .sub-tabs button {
  border: 0; background: none; color: var(--ink2); font: inherit; padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.game-tabs button:hover, .sub-tabs button:hover { background: var(--mid); }
.game-tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }

/* ── 卡片 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.card > h2 { margin-bottom: 12px; }
h2 .muted { font-weight: 400; font-size: 13px; margin-left: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.hero { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.hero-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-title h2 { font-size: 22px; }
.hero-draw { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } .hero-actions { justify-content: flex-start; } }

.log { margin-top: 12px; }
.log summary { cursor: pointer; color: var(--ink2); font-size: 13px; }
.log pre, pre.json {
  margin: 8px 0 0; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}

/* ── 按钮 / 表单 ── */
.btn {
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: progress; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 6px 10px; max-width: 100%;
}
textarea { width: 100%; min-height: 96px; font: 12.5px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }
.form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink2); }
.form label.grow { flex: 1 1 220px; }
.form label.grow input { width: 100%; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }

.sub-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-top: 4px; }
.sub-tabs button { border-radius: 8px 8px 0 0; padding: 8px 14px; border-bottom: 2px solid transparent; }
.sub-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--ink2); font: inherit; font-size: 13px; padding: 4px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--axis); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* ── 号码球 ── */
.balls { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ball, .digit {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; color: #fff; flex: none;
}
.ball { border-radius: 50%; }
.ball.main { background: var(--red); }
.ball.sub { background: var(--blue); }
.digit { border-radius: 8px; background: var(--ink); color: var(--surface); }
.balls.sm .ball, .balls.sm .digit { width: 26px; height: 26px; font-size: 12.5px; }
.balls .sep { width: 6px; }
/* 复盘时：命中保持实心并加环，未命中变空心 */
.balls.judged .ball:not(.hit), .balls.judged .digit:not(.hit) { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--axis); }
.balls.judged .hit { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--hit-ring); }

/* ── 热度网格 ── */
.grid-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 0 6px; }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; }
.heat .cell {
  aspect-ratio: 1; min-height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 4px; background: var(--mid); color: var(--ink); cursor: default; line-height: 1.15;
}
.heat .cell b { font-size: 14px; font-variant-numeric: tabular-nums; }
.heat .cell i { font-style: normal; font-size: 10.5px; opacity: .75; font-variant-numeric: tabular-nums; }
.heat .cell:hover, .heat .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); margin-top: 10px; flex-wrap: wrap; }
.legend .ramp { width: 160px; height: 10px; border-radius: 3px; }
.ramp.div { background: linear-gradient(90deg, var(--cold), var(--mid) 50%, var(--hot)); }
.ramp.seq { background: linear-gradient(90deg, var(--mid), var(--seq)); }

.dheat { border-collapse: separate; border-spacing: 2px; width: 100%; table-layout: fixed; }
.dheat th { font-weight: 500; font-size: 12.5px; color: var(--ink2); padding: 2px 4px; text-align: center; }
.dheat th[scope="row"] { text-align: left; width: 56px; }
.dheat td { text-align: center; border-radius: 4px; height: 36px; font-variant-numeric: tabular-nums; font-size: 13.5px; background: var(--mid); }
.dheat td:hover { outline: 2px solid var(--ink); }

/* ── 指标 ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tile .k { font-size: 12.5px; color: var(--ink2); }
.tile .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12.5px; color: var(--muted); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; margin: 0; }
.facts dt { color: var(--ink2); font-size: 13.5px; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; min-width: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 2px 0; } .facts dd { margin-bottom: 8px; } }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--mid); font-size: 13px; font-variant-numeric: tabular-nums; }

.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl th { color: var(--ink2); font-weight: 500; font-size: 12.5px; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }

/* ── 推荐 / 存档 ── */
.picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.pick { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.pick-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink2); }
.pick-head b { color: var(--ink); }
.pick .meta { font-size: 12.5px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.prize { font-weight: 600; }
.prize.win { color: var(--good); }

.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 4px 10px; align-items: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.bars .track { height: 10px; }
.bars .fill { height: 100%; background: var(--seq); border-radius: 0 4px 4px 0; min-width: 2px; }

.entry { border-top: 1px solid var(--line); padding: 14px 0; }
.entry:first-of-type { border-top: 0; padding-top: 0; }
.entry-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 8px; font-size: 13.5px; }
.entry-head .sp { flex: 1; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--axis); color: var(--ink2); }
.badge.done { border-color: transparent; background: var(--mid); color: var(--ink); }
.row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.row .lab { color: var(--ink2); min-width: 2.5em; }

.note { font-size: 13px; color: var(--ink2); border-left: 3px solid var(--axis); padding: 4px 0 4px 10px; margin: 10px 0 0; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.stack > * + * { margin-top: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.foot { color: var(--muted); font-size: 12.5px; padding-top: 8px; padding-bottom: 32px; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 260px; background: var(--ink); color: var(--surface);
  font-size: 12.5px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; white-space: pre-line;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--surface);
  padding: 8px 16px; border-radius: 999px; font-size: 13.5px; max-width: calc(100vw - 32px);
}
