:root {
  --bg: #f3f5f8;
  --bg-elev: #ffffff;
  --bg-soft: #eef2f6;
  --line: rgba(20, 32, 48, 0.1);
  --text: #1a2433;
  --muted: #66758a;
  --front: #e14b3a;
  --front-deep: #c23528;
  --back: #1f9e8f;
  --back-deep: #178075;
  --accent: #c98900;
  --lose: #d64538;
  --win: #178075;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(26, 36, 51, 0.06);
  --font: "IBM Plex Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
  /* Source Code Pro：0 是斜杠不是中间圆点，和 8 更好区分 */
  --mono: "Source Code Pro", "SF Mono", ui-monospace, monospace;
  --num-features: "tnum" 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 8% -8%, rgba(225, 75, 58, 0.1), transparent 55%),
    radial-gradient(900px 480px at 92% 0%, rgba(31, 158, 143, 0.1), transparent 50%),
    linear-gradient(180deg, #f7f9fb 0%, var(--bg) 40%, #eef2f6 100%);
  min-height: 100vh;
  line-height: 1.5;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(26, 36, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 36, 51, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 18%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.top, .status, .hero-strip, .tabs, .panel, .foot {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 28px 0 12px;
  flex-wrap: wrap;
}

.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
  background: linear-gradient(145deg, var(--front), var(--front-deep));
  box-shadow: 0 10px 24px rgba(225, 75, 58, 0.28);
}
h1 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.window-ctrl {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
select, input[type="number"] {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.window-ctrl select { border: 0; background: transparent; padding: 0; }

.status {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 auto 14px;
}

.hero-strip {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 820px) {
  .hero-strip { grid-template-columns: 1fr; }
}

.latest-card, .mini-stats, .block {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.latest-card { padding: 18px 20px; }
.latest-meta {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  align-items: baseline; margin-bottom: 14px; color: var(--muted); font-size: 0.9rem;
}
.latest-meta strong { color: var(--text); font-size: 1.15rem; }
.latest-meta .next { margin-left: auto; color: var(--accent); font-weight: 600; }
.latest-balls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.ball {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  font-feature-settings: var(--num-features);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15), 0 6px 14px rgba(26, 36, 51, 0.12);
}
.ball.front { background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--front) 45%, var(--front-deep)); }
.ball.back { background: radial-gradient(circle at 35% 30%, #7ee0d3, var(--back) 45%, var(--back-deep)); }
.ball.sm { width: 30px; height: 30px; font-size: 0.75rem; }
.plus { color: var(--muted); font-weight: 700; margin: 0 2px; }
.plus.sm { font-size: 0.85rem; }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
}
.mini-stats > div {
  padding: 16px 12px;
  text-align: center;
  border-right: 1px solid var(--line);
}
.mini-stats > div:last-child { border-right: 0; }
.mini-stats span { display: block; color: var(--muted); font-size: 0.78rem; margin-bottom: 6px; }
.mini-stats b { font-family: var(--mono); font-size: 1.15rem; }

.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.tab {
  appearance: none; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 14px; border-radius: 9px; cursor: pointer;
}
.tab.active {
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tab:hover { color: var(--text); }

.panel { display: none; padding-bottom: 40px; }
.panel.active { display: block; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.grid-pick { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
@media (max-width: 960px) {
  .grid-2, .grid-3, .grid-pick { grid-template-columns: 1fr; }
}

.block { padding: 16px 18px 18px; margin-bottom: 14px; }
.block h2 { margin: 0 0 12px; font-size: 1.05rem; }
.block-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.block-head h2 { margin: 0; }
.label { color: var(--muted); font-size: 0.8rem; margin: 10px 0 8px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }
.note strong { color: var(--accent); font-weight: 600; }
.warn-line {
  margin-top: 16px; padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(201, 137, 0, 0.08);
  color: #8a6200;
}

.btn {
  appearance: none; border: 1px solid var(--line);
  background: #fff; color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.9rem;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(26, 36, 51, 0.08);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--front), var(--front-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(225, 75, 58, 0.22);
}
.btn.ghost { background: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row.wrap { margin-top: 16px; }
.icon-btn {
  margin-left: auto; border: 0; background: transparent;
  color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 4px;
}
.linkish {
  appearance: none; border: 0; background: transparent;
  color: var(--back-deep); cursor: pointer; font: inherit; padding: 0;
  text-decoration: underline; text-underline-offset: 3px;
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.heat-grid.back { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 600px) {
  .heat-grid { grid-template-columns: repeat(5, 1fr); }
}
.heat {
  appearance: none; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 4px;
  display: grid; gap: 2px; justify-items: center;
  cursor: pointer; color: var(--text);
  background: #fff;
  position: relative; overflow: hidden;
}
.heat::before {
  content: ""; position: absolute; inset: 0;
  background: var(--front);
  opacity: calc(var(--h) * 0.007);
  pointer-events: none;
}
.heat.back::before { background: var(--back); }
.heat .hn {
  font-family: var(--mono); font-weight: 700; position: relative;
  font-feature-settings: var(--num-features);
  font-variant-numeric: tabular-nums;
}
.heat .hf, .heat .hm { font-size: 0.68rem; color: var(--muted); position: relative; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  font-family: var(--mono); font-weight: 700; font-size: 0.8rem;
  font-feature-settings: var(--num-features);
  font-variant-numeric: tabular-nums;
  padding: 4px 8px; border-radius: 999px;
}
.chip.front { background: rgba(225, 75, 58, 0.12); color: #b83226; }
.chip.back { background: rgba(31, 158, 143, 0.12); color: #0f6f64; }

.kv-list { margin-top: 12px; display: grid; gap: 8px; }
.kv {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--bg-soft);
  font-size: 0.88rem; color: var(--muted);
}
.kv b { color: var(--text); font-family: var(--mono); font-weight: 600; }

.bars { display: grid; gap: 8px; }
.bar-row {
  display: grid; grid-template-columns: 52px 1fr 88px;
  gap: 8px; align-items: center; font-size: 0.85rem; color: var(--muted);
}
.bar-row em { font-style: normal; text-align: right; font-family: var(--mono); font-size: 0.8rem; }
.bar {
  height: 8px; border-radius: 999px; background: rgba(26, 36, 51, 0.08); overflow: hidden;
}
.bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--front), #e0a100);
  border-radius: inherit;
}

#sumChart { width: 100%; height: 180px; display: block; }

.pick-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.pick-grid.back { grid-template-columns: repeat(6, 1fr); max-width: 420px; }
.pick {
  appearance: none; border: 1px solid var(--line);
  background: #fff; color: var(--text);
  border-radius: 50%; aspect-ratio: 1;
  font-family: var(--mono); font-weight: 700; cursor: pointer;
  font-feature-settings: var(--num-features);
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s ease, background 0.1s ease;
}
.pick:hover { transform: scale(1.05); }
.pick.front.on {
  background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--front) 45%, var(--front-deep));
  border-color: transparent; color: #fff;
}
.pick.back.on {
  background: radial-gradient(circle at 35% 30%, #7ee0d3, var(--back) 45%, var(--back-deep));
  border-color: transparent; color: #fff;
}

.ticket-list { display: grid; gap: 8px; margin-top: 12px; max-height: 420px; overflow: auto; }
.ticket {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.tn { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; min-width: 28px; }
.cost-line { margin-top: 12px; }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid label {
  display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted);
}
.form-grid .check {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.form-grid .check input { width: 16px; height: 16px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 700px) { .metrics { grid-template-columns: 1fr 1fr; } }
.metric {
  padding: 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.metric span { display: block; color: var(--muted); font-size: 0.78rem; margin-bottom: 6px; }
.metric b { font-family: var(--mono); font-size: 1.05rem; }
.metric b.win { color: var(--win); }
.metric b.lose { color: var(--lose); }

.level-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.level-pills span {
  font-size: 0.8rem; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line);
}
.hit-list {
  max-height: 240px; overflow: auto;
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  display: grid; gap: 4px;
}
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
table.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.balls-cell { white-space: nowrap; }
.mini {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700; color: #fff;
  font-feature-settings: var(--num-features);
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}
.mini.front { background: var(--front); }
.mini.back { background: var(--back); }

.prose ul { padding-left: 1.2em; color: var(--muted); }
.prose li { margin: 8px 0; }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 0 36px; color: var(--muted); font-size: 0.8rem;
}
.foot code {
  font-family: var(--mono); background: rgba(26, 36, 51, 0.06);
  padding: 2px 6px; border-radius: 4px;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #fff; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 18px; font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20; max-width: min(90vw, 480px); text-align: center;
  box-shadow: 0 12px 40px rgba(26, 36, 51, 0.16);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { border-color: rgba(201, 137, 0, 0.45); color: #8a6200; }
