:root {
  --canvas: #0b0f14;
  --surface: #121821;
  --elevated: #1a2330;
  --line: #243041;
  --fg: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3ddcff;
  --up: #34d399;
  --down: #f87171;
  --ink: #0b0f14;
  --hk: #5b8cff;
  --asia: #3ddcff;
  --eu: #a78bfa;
  --anz: #34d399;
  --w: #ff8a3d;
  --q: #3ddcff;
  --pq: #a78bfa;
  --radius: 10px;
  --pad: 16px;
  font-family: 'Noto Sans SC', 'Noto Sans TC', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--fg);
}

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

.app {
  max-width: 450px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px var(--pad) 0;
  gap: 12px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding-bottom: 8px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-site {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.brand-site .em,
.brand-title .em {
  color: var(--accent);
}

.wib {
  white-space: nowrap;
  font: inherit;
  letter-spacing: inherit;
}

.wib-who {
  color: var(--fg);
}

.wib-is {
  color: var(--accent);
}

.wib-bet {
  color: var(--hk);
}

.wib-tld {
  color: var(--muted);
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.lang-toggle button.is-on {
  background: var(--accent);
  color: var(--ink);
}

.btn-back {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--elevated);
  color: var(--fg);
  cursor: pointer;
}

.race-id {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.countdown .t {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
}

.tip-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tip-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tip-title {
  font-size: 13px;
  font-weight: 600;
}

.tip-cta {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.tip-rate-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tip-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.tip-pill.is-hit {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(61, 220, 255, 0.08);
}

.tip-pill.is-rate {
  color: var(--up);
  background: rgba(52, 211, 153, 0.1);
}

.tip-history {
  margin-left: auto;
  color: var(--accent);
  font-size: 10px;
  text-decoration: underline;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.tip-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.range-chip {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--accent);
}

.tip-wait {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.table-row.is-tip .cell-no,
.horse-row.is-tip .horse-no {
  background: var(--accent);
  color: var(--ink);
  border-radius: 6px;
  padding: 2px 0;
}

.odds-panel {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1.6fr) repeat(4, minmax(36px, 0.7fr));
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
}

.table-head {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.table-head .col-hk {
  color: var(--hk);
}
.table-head .col-asia {
  color: var(--asia);
}
.table-head .col-eu {
  color: var(--eu);
}
.table-head button.col-stack {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: inherit;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.table-head button.col-stack.is-sorted {
  font-weight: 700;
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
}

.table-row {
  border-bottom: 1px solid rgba(36, 48, 65, 0.65);
  cursor: pointer;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row:active {
  background: rgba(61, 220, 255, 0.04);
}

.cell-no {
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.cell-horse {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell-horse-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 10px;
  min-width: 0;
}

.cell-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.cell-odd {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  justify-self: end;
  flex-shrink: 0;
}

.cell-odd.is-hot,
.win-odd.is-hot {
  color: #fff;
  background: #d84343;
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 800;
}

.cell-meta {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delta {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--muted);
}

.delta.up {
  color: var(--up);
}

.delta.down {
  color: var(--down);
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-plot {
  position: relative;
  height: 96px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  overflow: visible;
}

.chart-plot svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.chart-plot text {
  font-family: inherit;
  paint-order: stroke fill;
  stroke: rgba(11, 15, 20, 0.85);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.chart-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
}

.pool-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pool-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pool-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
}

.pool-group .nos {
  color: var(--fg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.gate-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.btn-primary {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.horse-list {
  display: flex;
  flex-direction: column;
}

.horse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(36, 48, 65, 0.65);
  cursor: pointer;
}

.horse-row:last-child {
  border-bottom: 0;
}

.horse-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.horse-no {
  width: 22px;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.horse-mid {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.horse-name-odd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 10px;
  min-width: 0;
}

.horse-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.horse-sub {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.horse-odds {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0;
  text-align: right;
  flex-shrink: 0;
}

.win-odd {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.pla-odd {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.heat-10 {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.heat-10 b {
  width: 8px;
  height: 16px;
  border-radius: 1px;
  display: block;
  flex-shrink: 0;
}

.dock {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, transparent, var(--canvas) 18%);
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 5;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61, 220, 255, 0.08);
}

.venue-race {
  display: flex;
  align-items: center;
  gap: 8px;
}

.venue-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.venue-tab {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.venue-tab.is-on {
  border-color: var(--accent);
  background: rgba(61, 220, 255, 0.12);
  color: var(--accent);
}

.venue-sep {
  color: var(--line);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: var(--elevated);
  color: var(--fg);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.tab.is-on {
  background: var(--accent);
  color: var(--ink);
}

.disc {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

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

.region-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.region-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.region-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.region-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.share-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--elevated);
}

.share-bar span {
  display: block;
  height: 100%;
}

.share-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.share-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 4px;
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
}

.spark b {
  width: 8px;
  border-radius: 2px;
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 20, 0.72);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 40;
}

.modal[hidden] {
  display: none !important;
}

.sheet {
  width: min(340px, 100%);
  background: var(--elevated);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

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

.sheet h2 {
  margin: 0;
  font-size: 16px;
}

.sheet-sub,
.sheet-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.btn-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  padding: 12px;
  font-size: 18px;
  letter-spacing: 0.2em;
  text-align: center;
}

.rate-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rate-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.rate-tag .lab {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
}

.cost-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.cost-num {
  margin: 6px 0;
  font-size: 28px;
  font-weight: 700;
}

.ok {
  color: var(--up);
}

.err {
  margin: 0;
  color: var(--down);
  font-size: 12px;
}

.dock[hidden] {
  display: none;
}

/* —— Page17 命中歷史 —— */
.hist-brand .brand-title {
  font-size: 16px;
}

.hist-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.hist-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.hist-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
}

.hist-tab.is-on {
  border-color: var(--accent);
  color: var(--fg);
  background: rgba(61, 220, 255, 0.08);
}

.hist-tab-lab {
  font-size: 13px;
  font-weight: 700;
}

.hist-tab-sub {
  font-size: 10px;
  opacity: 0.8;
}

.hist-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hist-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hist-stat strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

.hist-stat span {
  font-size: 10px;
  color: var(--muted);
}

.hist-stat.is-hk strong {
  color: var(--hk);
}

.hist-stat.is-eu strong {
  color: var(--eu);
}

.hist-stat.is-anz strong {
  color: var(--anz);
}

.hist-stat.is-accent strong {
  color: var(--accent);
}

.hist-stat.is-muted strong {
  color: var(--muted);
}

.hist-legend,
.hist-foot {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

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

.hist-day {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hist-day-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.hist-day-left strong {
  font-size: 14px;
}

.hist-venue {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.hist-region {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
}

.hist-day-count {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.hist-day-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist-race {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hist-race-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist-race-no {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--elevated);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.hist-race-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.hist-lab {
  flex-shrink: 0;
  width: 36px;
  font-size: 11px;
  color: var(--muted);
  padding-top: 4px;
}

.hist-lab.is-accent {
  color: var(--accent);
}

.hist-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.hist-chips.is-wrap {
  flex-wrap: wrap;
  overflow: visible;
}

.hist-chips::-webkit-scrollbar {
  display: none;
}

.hist-chip {
  flex-shrink: 0;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.hist-chip.is-result {
  background: rgba(61, 220, 255, 0.14);
  color: var(--accent);
  border: 1px solid rgba(61, 220, 255, 0.35);
}

.hist-chip.is-tip {
  background: var(--elevated);
  color: var(--fg);
  border: 1px solid var(--line);
}

.hist-hits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.hist-hit {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  opacity: 0.55;
}

.hist-hit.is-on {
  color: var(--up);
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.12);
  opacity: 1;
}
