:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --card: #fff;
  --text: #0b1f33;
  --muted: #6b7785;
  --line: #dfe4ea;
  --blue: #0b72e7;
  --blue-soft: #e9f3ff;
  --green: #0e8a56;
  --warn: #825900;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", "PingFang HK", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, a { font: inherit; }
button { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 2; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar-inner { max-width: 1180px; min-height: 64px; margin: auto; padding: 12px 22px; display: flex; align-items: center; gap: 20px; }
.main-nav { display: flex; align-items: center; gap: 8px; }
.nav-item { padding: 9px 14px; color: #34445a; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 260px; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; line-height: 1; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.logo { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: #fff; background: #c8102e; font-weight: 800; }
.nav-link { padding: 9px 14px; border-radius: 9px; background: var(--blue-soft); color: var(--blue); font-weight: 700; text-decoration: none; }
.auth-entry { border: 0; cursor: pointer; }
.auth-entry-error { position: absolute; top: 58px; right: max(22px, calc((100% - 1180px) / 2)); z-index: 3; max-width: min(360px, calc(100vw - 44px)); margin: 0; padding: 8px 10px; border: 1px solid #f1c3c1; border-radius: 8px; background: #fff7f6; color: #a12622; font-size: 12px; }
.wrap { max-width: 1180px; min-height: calc(100vh - 120px); margin: auto; padding: 28px 22px 60px; }
.hero { display: grid; grid-template-columns: 1.15fr .85fr; align-items: end; gap: 44px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.kicker, .muted { color: var(--muted); font-size: 13px; }
h1 { margin: 0 0 20px; font-size: clamp(34px, 4vw, 44px); letter-spacing: -.03em; }
.venue-row { min-height: 38px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.venue-chip { padding: 8px 13px; border: 1px solid var(--blue); border-radius: 10px; background: var(--blue); color: #fff; }
.next-card { padding: 4px 0 4px 22px; border-left: 3px solid var(--blue); display: grid; justify-items: start; gap: 8px; }
.blue-label { color: var(--blue); font-size: 13px; font-weight: 700; }
.next-card > strong { font-size: 27px; }
.schedule-value { font: 800 28px ui-monospace, SFMono-Regular, Menlo, monospace; }
.small-note { color: var(--warn); font-size: 12px; }
.section-head { margin: 30px 0 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-head h2, .status-card h2 { margin: 4px 0 0; font-size: 24px; }
.state-message { min-height: 22px; margin: 10px 0; color: var(--muted); }
.race-list { position: relative; margin: 0; padding: 14px 0 18px; list-style: none; display: flex; gap: 14px; overflow-x: auto; scrollbar-width: thin; }
.race-list::before { position: absolute; top: 39px; left: 22px; right: 22px; height: 1px; background: var(--line); content: ""; }
.race-item { position: relative; z-index: 1; flex: 0 0 86px; min-height: 104px; padding: 0 5px 8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 7px; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: center; cursor: pointer; }
.race-item:hover, .race-item.selected { border-color: var(--blue); outline: 1px solid var(--blue); }
.race-number { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #e9edf2; color: #46576a; font-weight: 800; }
.race-item.selected .race-number { border: 3px double #fff; outline: 3px solid var(--blue); background: var(--blue); color: #fff; }
.race-details { min-width: 0; display: grid; gap: 4px; }
.race-details strong { overflow-wrap: anywhere; font-size: 13px; }
.race-details small { color: var(--muted); }
.status-card, .schedule-banner { padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.current-line { color: var(--muted); font-size: 13px; }
.status-row { display: flex; justify-content: space-between; gap: 15px; padding: 14px 0; border-top: 1px solid var(--line); }
.status-row strong { color: var(--green); }
.button { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: white; font-weight: 700; cursor: pointer; }
.button.primary { border-color: var(--blue); color: white; background: var(--blue); }
.button:disabled { opacity: .45; cursor: not-allowed; }
[hidden] { display: none !important; }
.back-button { margin: 0 0 16px; padding: 6px 0; border: 0; background: transparent; color: #4d5965; cursor: pointer; }
.racecard-heading { display: flex; justify-content: space-between; align-items: start; gap: 15px; }
.racecard-heading h1 { margin: 4px 0 10px; font-size: 36px; }
.badge { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: #f3f5f7; color: #6a7480; font-size: 12px; }
.description { margin: 8px 0 20px; color: var(--muted); line-height: 1.6; }
.schedule-banner { margin-bottom: 18px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.schedule-banner strong { color: var(--warn); }
.schedule-banner small { color: var(--muted); }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
.runner-table { width: 100%; border-collapse: collapse; }
.runner-table th, .runner-table td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; white-space: nowrap; }
.runner-table th { background: #f8fafc; color: #596675; font-size: 12px; }
.runner-table tbody tr:last-child td { border-bottom: 0; }
.identity-proof { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.market-card { margin: 18px 0; padding: 20px; border: 1px solid #cfdef3; border-radius: var(--radius); background: #fff; }
.market-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.market-heading h2 { margin: 0; font-size: 20px; }
.market-meta, .market-times { color: var(--muted); font-size: 12px; }
.market-pools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.market-pool { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.market-pool h3 { margin: 0 0 8px; font-size: 14px; }
.market-odds-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid #f0f2f5; font-size: 12px; }
.market-times { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px; }
.error-message { color: #a12622; font-size: 12px; }
.footer { padding: 12px 22px 24px; color: #95a0aa; text-align: center; font-size: 11px; }
@media (max-width: 800px) {
  .topbar-inner { padding: 12px 16px; }
  .brand { min-width: 0; flex: 1; }
  .main-nav { gap: 0; }
  .nav-item { padding: 9px 6px; font-size: 12px; }
  .auth-entry { padding: 9px 8px; font-size: 12px; }
  .auth-entry-error { right: 16px; max-width: calc(100vw - 32px); }
  .wrap { padding: 22px 16px 40px; }
  .hero { grid-template-columns: 1fr; gap: 22px; padding-bottom: 22px; }
  .next-card { border-left: 0; border-top: 3px solid var(--blue); padding: 16px 0 0; }
  .section-head { align-items: start; flex-direction: column; gap: 8px; }
  .race-list { gap: 8px; }
  .race-item { flex-basis: 72px; padding: 0 3px 8px; }
  .race-number { width: 36px; height: 36px; flex-basis: 36px; }
  .status-card, .schedule-banner { padding: 18px; }
  .racecard-heading h1 { font-size: 32px; }
  .runner-table th, .runner-table td { padding: 11px; }
  .market-card { padding: 16px; }
  .market-pools { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .brand { flex: 0 0 100%; }
  .main-nav { width: 100%; justify-content: space-between; }
  .main-nav > * { flex-shrink: 0; white-space: nowrap; }
  .auth-entry-error { position: static; max-width: 100%; }
  .wrap { overflow-wrap: anywhere; }
  .wrap > section, .hero > * { min-width: 0; }
  .wrap > section { scroll-margin-top: 160px; }
  .venue-row, .status-row, .racecard-heading { flex-wrap: wrap; }
  .button { display: inline-block; max-width: 100%; white-space: normal; }
  .table-scroll { max-width: 100%; }
}
