:root {
  --bg: #0c1118;
  --bg-2: #141c27;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3f8;
  --muted: #93a1b3;
  --red: #e23b3b;
  --blue: #2f6dff;
  --gold: #e2b857;
  --ok: #3ecf8e;
  --pad: 16px;
  --radius: 16px;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(226, 59, 59, 0.18), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(47, 109, 255, 0.14), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

#boot-mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--pad);
}
#boot-mask.hide { display: none; }
.boot-card, .card {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.boot-card { width: min(100%, 420px); padding: 28px 22px; text-align: center; }
.boot-spin {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar, main, footer {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}
.topbar {
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; flex: 1; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #e23b3b, #9b1d1d);
  font-weight: 800; letter-spacing: 0.5px;
}
.brand strong { display: block; font-size: 16px; }
.brand span, #sync-status {
  color: var(--muted); font-size: 12px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.game-switch {
  display: flex;
  background: #243246;
  border-radius: 12px;
  padding: 3px;
}
.game-btn {
  border: 0;
  background: transparent;
  color: #d7e0ea;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}
.game-btn.active {
  background: #e2b857;
  color: #1b1406;
}
.logo.ssq { background: linear-gradient(135deg, #2f6dff, #163fad); }
#btn-refresh, .search-form button, .pager button {
  border: 0; border-radius: 12px; cursor: pointer;
  min-height: var(--tap);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 15px;
}
#btn-refresh, .pager button { background: #243246; color: #fff; }
.search-form button { background: #e2b857; color: #1b1406; }
#btn-refresh:hover, .pager button:hover, .search-form button:hover { filter: brightness(1.08); }

main { padding-top: 8px; padding-bottom: 32px; }
.card { padding: 16px; margin: 12px 0; }
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.eyebrow { color: var(--gold); margin: 0 0 6px; letter-spacing: 1px; font-size: 12px; }
.hero h1 { margin: 0; font-size: clamp(22px, 6vw, 34px); word-break: break-all; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.hero-draw { min-width: 0; }
.hero-draw .chips { margin-top: 12px; }
.hero-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.hero-stats div, .math-kpis div {
  background: var(--bg-2); border-radius: 12px; padding: 10px 12px;
}
.hero-stats label, .math-kpis label { display: block; color: var(--muted); font-size: 12px; }
.balls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.balls.nowrap { flex-wrap: nowrap; }
.ball {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  font-weight: 800; color: #fff; font-size: 14px;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.35), 0 6px 16px rgba(0,0,0,0.25);
}
.ball.red { background: radial-gradient(circle at 30% 25%, #ff7a7a, var(--red) 58%, #9a1c1c); }
.ball.blue { background: radial-gradient(circle at 30% 25%, #7aa6ff, var(--blue) 58%, #163fad); }
.ball.sm { width: 32px; height: 32px; font-size: 12px; }
.plus { color: var(--muted); font-weight: 700; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.section-head h2, .card h2 { margin: 0 0 6px; font-size: 18px; }
.section-head p, .card h3, .field span { color: var(--muted); font-weight: 500; }
.section-head p { margin: 0; font-size: 13px; line-height: 1.5; }
.card h3 { margin: 16px 0 8px; font-size: 14px; }
.badge {
  background: rgba(226, 184, 87, 0.15); color: var(--gold);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; white-space: nowrap;
}

.pick-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}
.pick {
  background: var(--bg-2); border-radius: 16px; padding: 14px;
  border: 1px solid var(--line);
}
.pick b { display: block; margin-bottom: 10px; color: var(--gold); font-size: 13px; }
.pick .meta { margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.disclaimer { color: #b7c0cc; font-size: 12px; line-height: 1.7; margin: 16px 0 0; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.hot-list, .pattern-box { display: grid; gap: 8px; }
.hot-row, .bar-row {
  display: grid; grid-template-columns: minmax(64px, auto) minmax(0, 1fr) 64px; gap: 8px; align-items: center;
  font-size: 13px;
}
.bar-row.filterable {
  cursor: pointer;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 8px;
}
.bar-row.filterable:hover { background: rgba(255, 255, 255, 0.04); }
.bar-row.filterable.active {
  background: rgba(226, 184, 87, 0.12);
  outline: 1px solid rgba(226, 184, 87, 0.35);
}
.bar { height: 8px; background: #243246; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #e23b3b, #e2b857); }
.bar.blue > i { background: linear-gradient(90deg, #2f6dff, #7aa6ff); }

.search-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 14px 0;
}
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; }
input, select {
  width: 100%;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px; outline: none;
  font-size: 16px; min-height: var(--tap);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 13px) calc(50% - 3px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  font-size: 12px;
  color: var(--gold);
  background: rgba(226, 184, 87, 0.10);
  border: 1px solid rgba(226, 184, 87, 0.22);
  border-radius: 99px;
  padding: 4px 10px;
}
.shape-grid { display: grid; gap: 16px; }
.shape-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0 0 14px;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.draw-table .balls { flex-wrap: nowrap; }
th { color: var(--muted); font-weight: 600; }
.row-issue { color: var(--gold); cursor: pointer; font-weight: 700; }
.pager {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding-top: 16px; flex-wrap: wrap;
}
.pager button { flex: 1; max-width: 140px; }
#page-info { color: var(--muted); font-size: 13px; text-align: center; }
.hidden { display: none !important; }
.detail-box {
  margin: 8px 0 16px; padding: 14px; border-radius: 16px;
  background: rgba(226, 184, 87, 0.08); border: 1px solid rgba(226, 184, 87, 0.2);
}
footer {
  text-align: center; color: var(--muted);
  padding-top: 8px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  font-size: 12px; line-height: 1.6;
}
.ok { color: var(--ok); }

.math-card {
  border: 1px solid rgba(226, 184, 87, 0.35);
  background: linear-gradient(180deg, rgba(226, 184, 87, 0.10), rgba(255,255,255,0.02));
}
.math-body { margin-top: 12px; }
.math-main { display: grid; grid-template-columns: 1fr; gap: 14px; }
.math-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rate-table { width: 100%; margin-top: 14px; font-size: 13px; }
.model-note { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 12px 0 0; }

.draw-table td[data-label]::before { display: none; }

@media (max-width: 719px) {
  .draw-table thead { display: none; }
  .draw-table, .draw-table tbody, .draw-table tr, .draw-table td { display: block; width: 100%; }
  .draw-table tr {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 10px;
    padding: 8px 12px 4px;
  }
  .draw-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 0;
    padding: 8px 0;
  }
  .draw-table td[data-label]::before {
    display: block;
    content: attr(data-label);
    color: var(--muted);
    flex-shrink: 0;
  }
  .draw-table td:first-child { font-size: 16px; }
  .draw-table .balls { justify-content: flex-end; }
  .draw-table .ball.sm { width: 28px; height: 28px; font-size: 11px; }
}

@media (min-width: 640px) {
  .hero-stats { grid-template-columns: repeat(3, 1fr); }
  .pick-grid { grid-template-columns: 1fr 1fr; }
  .search-form { grid-template-columns: 1fr 1fr; }
  .search-form .field:first-child, .search-form button { grid-column: 1 / -1; }
  .shape-filters { grid-template-columns: 1fr 1fr; }
  .shape-filters button { grid-column: 1 / -1; }
  .ball { width: 44px; height: 44px; }
}

@media (min-width: 900px) {
  .topbar { padding-top: 22px; }
  .brand strong { font-size: 18px; }
  .card { padding: 22px; margin: 16px 0; }
  .hero { grid-template-columns: 200px minmax(0, 1fr) 220px; align-items: center; }
  .hero-stats { grid-template-columns: 1fr; }
  .pick-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .math-main { grid-template-columns: 1.2fr 1fr; align-items: center; }
  .search-form { grid-template-columns: minmax(0, 1.4fr) 160px 160px auto; align-items: end; }
  .search-form .field:first-child, .search-form button { grid-column: auto; }
  .shape-filters { grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
  .shape-filters button { grid-column: auto; }
  .shape-grid { grid-template-columns: 1fr 1fr 1fr; align-items: start; }
  .pager button { flex: none; }
}
