:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5c6b7c;
  --line: #e1e6ee;
  --accent: #1f4b99;
  --accent-soft: #e8eef9;
  --good: #067647;
  --good-bg: #e7f6ee;
  --warn: #b54708;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 280px at 0% -10%, #e4ebf6, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:disabled,
input:disabled,
select:disabled { cursor: not-allowed; opacity: 0.55; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 18px 88px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.header { padding: 18px 18px 14px; }

.header-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

h1 {
  margin: 0 0 2px;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

h2 { margin: 0 0 8px; font-size: 20px; }

h3 { margin: 0; font-size: 16px; }

.muted, .hint, .placeholder, .rule, .legend, .note {
  color: var(--muted);
}

.nowrap { white-space: nowrap; }

.hint, .placeholder, .rule, .legend, .note, .summary, .desc {
  margin: 0;
}

.hint {
  flex: 1 1 220px;
  align-self: center;
  font-size: 13px;
}

.latest { text-align: right; }

.latest-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: flex-end;
  margin-top: 14px;
  padding: 14px 16px;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  color: var(--text);
}

input[type="number"], select {
  padding: 8px 10px;
  border: 1px solid #cfd6e0;
  border-radius: 10px;
  background: #fff;
  min-width: 7.5rem;
}

#bt-start { min-width: 16rem; max-width: 100%; }

.primary {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary:hover:not(:disabled) { background: #183e80; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}

.tab {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
}

.tab[aria-selected="true"] {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.panel { min-height: 120px; }

.lead {
  margin: 4px 0 16px;
  font-size: 18px;
  font-weight: 700;
}

.cat-block { margin-top: 22px; }

.cat-block .rule { margin: 4px 0 12px; font-size: 13px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.group-card, .strategy-card, .sum-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.group-card { padding: 14px; }

.group-head, .strategy-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.chip, .badge {
  display: inline-block;
  flex: none;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 600;
}

.chip {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge {
  margin-right: 6px;
  background: #fff6ed;
  color: var(--warn);
  border: 1px solid #f9dbaf;
  vertical-align: 1px;
}

.summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.reasons {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

.reasons li { margin: 4px 0; }

.ensemble-card {
  margin-top: 12px;
  border: 1.5px solid var(--accent);
  background: linear-gradient(180deg, #f4f7fd, #fff 92px);
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 35% 30%, #6d94dc, #1e3f86 72%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(16, 24, 40, 0.16);
}

.ball.actual {
  background: radial-gradient(circle at 35% 30%, #f08a84, #b42318 74%);
}

.ball.faded {
  background: #e7ebf0;
  color: #98a2b3;
  box-shadow: none;
  font-weight: 600;
}

.ball.star {
  background: #f2f4f7;
  color: #98a2b3;
  border: 1px dashed #c5ceda;
  box-shadow: none;
  font-weight: 600;
}

.ball.sm {
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.strategy-list { display: flex; flex-direction: column; gap: 14px; }

.strategy-card { padding: 16px; }

.strategy-card.ensemble-card { margin-top: 0; }

.desc { margin-bottom: 12px; font-size: 14px; line-height: 1.65; }

.heat-note { margin: 0 0 14px; font-size: 13px; }

.heat-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

table.heat {
  border-collapse: separate;
  border-spacing: 3px;
  min-width: 640px;
}

table.heat th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px;
}

table.heat td {
  min-width: 52px;
  padding: 7px 2px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

table.heat td.is-max {
  outline: 2px solid #1f4b99;
  outline-offset: -2px;
  font-weight: 800;
}

.sum-block { margin-bottom: 14px; padding: 12px 14px 6px; }

.sum-block h3 { margin-bottom: 2px; }

.sum-block .rule { margin-bottom: 8px; font-size: 13px; }

.table-scroll, .detail-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

.detail-scroll { max-height: 540px; }

table.data, table.detail {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

table.data th, table.data td, table.detail th, table.detail td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

table.data th:first-child, table.data td:first-child,
table.detail th:first-child, table.detail td:nth-child(-n+3) {
  text-align: left;
}

table.data thead th, table.detail thead th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  background: #fff;
}

table.detail thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

table.detail { min-width: 880px; }

tr.is-ensemble td {
  background: #f4f7fb;
  border-top: 2px solid #c5d0e0;
}

tr.is-any td { border-top: 2px solid #d5dbe3; background: #fbfcfd; }

tr.is-base td, tr.is-control td, tr.is-control th {
  color: #667085;
  background: #f3f4f6;
}

td.rate-good {
  color: var(--good);
  background: var(--good-bg);
  font-weight: 700;
}

td.rate-flat { color: #98a2b3; }

tr.is-ensemble td.rate-good { background: var(--good-bg); }

.beside {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.cat-cell {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.picks { display: flex; flex-direction: column; gap: 3px; }

.pick { font-size: 13px; color: var(--text); }

.pick-name {
  display: inline-block;
  min-width: 2.5em;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
}

.pick-num {
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

.pick.hit .pick-num { color: var(--good); font-weight: 800; }

.pick sup {
  margin-left: 1px;
  color: var(--warn);
  font-weight: 700;
  font-size: 10px;
}

.pick.hit sup { color: var(--good); }

.tick {
  color: var(--good);
  font-weight: 800;
  line-height: 1.4;
}

.note, .legend { margin: 8px 2px 14px; font-size: 13px; }

.detail-title { margin: 8px 0 4px; }

.message {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.message.error {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.message.ok {
  color: #067647;
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.disclaimer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: rgba(238, 241, 244, 0.94);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.pro {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.score-note { margin: 0 0 12px; font-size: 13px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 4px;
}

.filter {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}

.filter.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.coverage {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #183e80;
  font-weight: 650;
  font-size: 14px;
}

.ghost {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 650;
}

.ghost:hover { border-color: var(--accent); color: var(--accent); }

.gno {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  vertical-align: 1px;
}

.group-head { flex-wrap: wrap; }

.card-grid.many {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.card-grid.many .group-card { padding: 10px 12px; }

.card-grid.many .summary { margin-top: 6px; }

.why { margin-top: 8px; }

.why summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.insight { margin-top: 22px; }

.insight h2 { font-size: 20px; }

.insight h3 { margin: 16px 0 6px; }

.insight .toolbar { margin-top: 8px; }

.perm-progress { margin: 10px 2px; }

.perm-track {
  height: 8px;
  background: #e4e9f0;
  border-radius: 99px;
  overflow: hidden;
}

.perm-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.perm-status {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.cmp-up { color: var(--good); font-weight: 700; background: var(--good-bg); }

.cmp-down { color: #b42318; font-weight: 700; background: #fef3f2; }

.cmp-same { color: var(--muted); }

.tech {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.hit-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  background: #f2f4f7;
  color: #98a2b3;
  font-size: 12px;
  font-weight: 700;
}

.hit-badge.ok { background: var(--good-bg); color: var(--good); }

.hit-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 4px;
}

.hit-pick {
  color: var(--good);
  font-weight: 700;
  font-size: 13px;
  font-family: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

.ens-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ens-line.hit { color: var(--good); font-weight: 700; }

.day-details { margin-top: 4px; }

.day-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

table.detail td.cat {
  white-space: normal;
  min-width: 168px;
  vertical-align: top;
}

.plain-end { margin: 8px 2px 0; font-size: 14px; }

.roll-box {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d5e0f2;
  border-radius: 12px;
  background: #f4f7fd;
  font-weight: 650;
  line-height: 1.6;
}

.train-sub {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.ctrl-line {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.chart-card { margin: 4px 0 8px; }

.chart-wrap { position: relative; }

.chart-svg { display: block; width: 100%; max-width: 100%; height: auto; }

.chart-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: #1c2430;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
  font-size: 12px;
}

.legend-btn.off { opacity: 0.38; }

.swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.swatch.dash {
  background: repeating-linear-gradient(90deg, #94a3b8 0 4px, transparent 4px 7px);
}

.is-control-card { background: #f7f8fa; }

@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }

  .page { padding: 12px 12px 20px; }

  h1 { font-size: 22px; }

  .tagline { font-size: 13px; }

  .header { padding: 12px 12px 10px; }

  .header-top {
    flex-direction: column;
    gap: 10px;
  }

  .header-top > * {
    min-width: 0;
    max-width: 100%;
  }

  .latest { text-align: left; }

  .coverage, .rule, .note, .legend, .desc, .summary, .reasons,
  .tech, .pick-num, .hit-pick, .train-sub {
    overflow-wrap: anywhere;
  }

  #data-info, .tagline, .hint, .lead, .score-note, .message, .disclaimer,
  .roll-box, .plain-end, .placeholder, .strategy-head h3, .group-head h3 {
    overflow-wrap: break-word;
  }

  .toolbar {
    gap: 12px;
    padding: 12px;
  }

  .toolbar label {
    flex: 1 1 calc(50% - 12px);
    min-width: 0;
    font-size: 14px;
  }

  .toolbar label.span-2,
  .toolbar label.check,
  .toolbar .hint,
  .toolbar .primary {
    flex: 1 1 100%;
    width: 100%;
  }

  .toolbar label.check {
    min-height: 44px;
    padding-bottom: 0;
  }

  .toolbar label.check input {
    width: 22px;
    height: 22px;
    flex: none;
  }

  input[type="number"],
  select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 12px;
  }

  #bt-start { min-width: 0; }

  .primary {
    min-height: 44px;
    font-size: 16px;
    padding: 10px 16px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    margin: 10px 0;
    padding: 6px 0;
    background: var(--bg);
  }

  .tab {
    flex: 1 0 auto;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 15px;
    text-align: center;
    white-space: nowrap;
  }

  .card-grid,
  .card-grid.many {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  }

  .group-card,
  .strategy-card,
  .sum-block,
  .chart-card,
  .cat-block,
  .panel,
  .strategy-list > * {
    min-width: 0;
    max-width: 100%;
  }

  .cat-head {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .ball {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .filters { gap: 8px; }

  .filter,
  .legend-btn {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 15px;
  }

  .ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .why summary,
  .day-details summary {
    min-height: 40px;
    padding: 10px 0;
  }

  .why summary { font-size: 15px; }

  .heat-wrap,
  .table-scroll,
  .detail-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .chart-wrap { max-width: 100%; }

  .chart-svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .lead { font-size: 16px; }

  .group-card { padding: 12px; }

  .disclaimer {
    position: static;
    padding: 10px 12px 16px;
    font-size: 12px;
    text-align: left;
    background: transparent;
  }
}

@media (max-width: 420px) {
  .page { padding: 8px 10px 16px; }

  h1 { font-size: 20px; }

  .header { padding: 10px; }

  .toolbar { padding: 10px; gap: 10px; }

  .card-grid,
  .card-grid.many { grid-template-columns: 1fr; }

  .ball {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .chart-tip {
    white-space: normal;
    max-width: min(220px, 70vw);
    overflow-wrap: anywhere;
  }
}
