:root, html[data-theme="dark"] {
  --ink: #0e1a14;
  --panel: #14241c;
  --panel-2: #1b3026;
  --line: #2a4a38;
  --gold: #d4a017;
  --gold-2: #f0d78c;
  --cream: #f4efe4;
  --win: #1f8a4c;
  --loss: #b42318;
  --live: #e11d48;
  --muted: #9bb5a5;
  --input-bg: #0c1611;
  --header-bg: rgba(10, 18, 14, 0.92);
  --nav-bg: #0b140f;
  --body-bg: radial-gradient(1200px 600px at 10% -10%, #1d3a2a, var(--ink));
  --shadow: 0 20px 50px rgba(0,0,0,.35);
  --kyc-bg: #2a2410;
  --alert-danger-bg: #3f1d1d;
  --alert-danger-fg: #fecaca;
  --alert-danger-bd: #7f1d1d;
  --alert-success-bg: #163325;
  --alert-success-fg: #bbf7d0;
  --alert-success-bd: #166534;
  --alert-info-bg: #1e293b;
  --alert-info-fg: #bfdbfe;
  --alert-info-bd: #1d4ed8;
  --theme-color: #0e1a14;
}
html[data-theme="light"] {
  --ink: #f6f1e8;
  --panel: #ffffff;
  --panel-2: #f3eee4;
  --line: #d7cebe;
  --gold: #b8860b;
  --gold-2: #8a6a12;
  --cream: #142018;
  --win: #157a42;
  --loss: #b42318;
  --live: #c1143c;
  --muted: #5d6e64;
  --input-bg: #fffdf8;
  --header-bg: rgba(255, 252, 246, 0.94);
  --nav-bg: #fffdf8;
  --body-bg: radial-gradient(1200px 600px at 10% -10%, #efe6d4, #f6f1e8);
  --shadow: 0 16px 40px rgba(40, 30, 10, .12);
  --kyc-bg: #fff6dd;
  --alert-danger-bg: #fde8e8;
  --alert-danger-fg: #7f1d1d;
  --alert-danger-bd: #f0b4b4;
  --alert-success-bg: #e6f6ec;
  --alert-success-fg: #14532d;
  --alert-success-bd: #86efac;
  --alert-info-bg: #e8f0fe;
  --alert-info-fg: #1e3a8a;
  --alert-info-bd: #93c5fd;
  --theme-color: #f6f1e8;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  font-family: "Source Sans 3", system-ui, sans-serif;
  background: var(--body-bg);
  color: var(--cream);
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}
body.auth-page { padding-bottom: 0; }
body.auth-page .pwa-install { display: none !important; }
.brand-name, h1, h2, .display, .auth-brand h1 {
  font-family: Fraunces, Georgia, serif;
}
.app-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(8px);
  padding-top: env(safe-area-inset-top, 0px);
}
.brand-mark { font-size: 1.4rem; }
.brand-name { color: var(--gold-2); display: block; line-height: 1.1; }
.brand-tag { color: var(--muted); font-size: 0.72rem; }
.wallet-chip {
  background: var(--panel-2);
  color: var(--gold-2);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
}
.icon-btn { color: var(--cream); font-size: 1.2rem; }
.notify-badge { position: absolute; top: -6px; right: -8px; font-size: 0.65rem; }
.page-shell { padding: 1rem 0 2rem; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
}
.auth-theme-bar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.35rem;
  z-index: 2;
}
.auth-theme-bar .theme-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--cream);
  font-size: 0.85rem;
  cursor: pointer;
}
.auth-theme-bar .theme-option.is-active {
  border-color: var(--gold);
  color: var(--gold-2);
  font-weight: 700;
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand .brand-mark { font-size: 2rem; line-height: 1; }
.auth-brand h1 { font-size: 1.65rem; margin: 0.4rem 0 0.2rem; }
.auth-brand p { color: var(--muted); margin: 0; }
.auth-card .form-label { display: block; margin-bottom: 0.35rem; font-weight: 600; }
.auth-card .form-control {
  display: block;
  width: 100%;
  min-height: 2.7rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}
.auth-card .form-check { display: flex; align-items: center; gap: 0.45rem; }
.auth-card .form-check-input {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--input-bg);
  appearance: auto;
}
html[data-theme="light"] .auth-card .form-check-input {
  border-color: #8a7b5f;
  background: #fff;
}
.auth-card .btn-gold {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.8rem;
  margin: 0.25rem 0 1rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 0.6rem;
  cursor: pointer;
  font-size: 1rem;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}
.auth-links a { color: var(--gold-2); }
.auth-card, .card-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}
.auth-card { max-width: 480px; width: 100%; padding: 2rem; }
.form-control, .form-select {
  background: var(--input-bg);
  color: var(--cream);
  border-color: var(--line);
}
.form-control:focus, .form-select:focus {
  background: var(--input-bg);
  color: var(--cream);
  border-color: var(--gold);
  box-shadow: 0 0 0 .2rem rgba(212,160,23,.2);
}
.btn-header, .btn-outline-light {
  color: var(--cream);
  border-color: var(--line);
  background: transparent;
}
.btn-header:hover, .btn-outline-light:hover {
  color: var(--gold-2);
  border-color: var(--gold);
  background: var(--panel-2);
}
.text-secondary { color: var(--muted) !important; }
.btn-gold {
  background: linear-gradient(180deg, #f0d78c, var(--gold));
  color: #1a1204;
  font-weight: 700;
  border: 0;
}
.btn-gold:hover { color: #1a1204; filter: brightness(1.05); }
.race-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
  color: inherit;
  display: block;
  text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.race-card:hover { transform: translateY(-2px); border-color: var(--gold); color: inherit; }
.badge-status { font-weight: 700; letter-spacing: .02em; }
.badge-LIVE { background: var(--live); }
.badge-OPEN { background: var(--win); }
.badge-UPCOMING { background: #3b4a42; }
.badge-SUSPENDED { background: #b45309; color: #fff; }
.badge-FINISHED, .badge-RESULT_DECLARED, .badge-SETTLED { background: #334155; }
.section-title { font-size: 1.15rem; margin-bottom: .75rem; }
.table { color: var(--cream); }
.table > :not(caption) > * > * { background: transparent; color: var(--cream); border-color: var(--line); }
.mobile-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav a {
  flex: 1; text-align: center; color: var(--muted);
  padding: .55rem 0 .4rem; font-size: .7rem; text-decoration: none;
}
.mobile-nav a i { display: block; font-size: 1.15rem; }
.mobile-nav a.active { color: var(--gold-2); }
.odds-up { color: #86efac; }
.odds-down { color: #fca5a5; }
.live-dot {
  width: .65rem; height: .65rem; border-radius: 50%;
  background: var(--live); display: inline-block;
  box-shadow: 0 0 0 0 rgba(225,29,72,.7);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(225,29,72,0); }
}
.bet-slip {
  position: sticky; bottom: 4.5rem;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  border-radius: 1rem 1rem 0 0;
  padding: 1rem;
  z-index: 30;
}
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bet-slip { bottom: 0; border-radius: 1rem; }
}
.empty-state { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.win-modal { border: 2px solid var(--win); }
.loss-modal { border: 2px solid var(--loss); }
.stat-tile {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: .85rem;
  padding: 1rem;
}
.stat-tile .n { font-size: 1.4rem; font-weight: 700; color: var(--gold-2); }
.dropdown-menu { background: var(--panel); border-color: var(--line); }
.dropdown-item { color: var(--cream); }
.dropdown-item:hover { background: var(--panel-2); color: var(--gold-2); }
.modal-content {
  background: var(--panel);
  color: var(--cream);
  border-color: var(--line);
}
.staff-nav {
  display: flex; flex-wrap: wrap; gap: .4rem .85rem;
  padding: .65rem .85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .85rem;
}
.staff-nav a { color: var(--muted); text-decoration: none; font-size: .92rem; }
.staff-nav a:hover, .staff-nav a.active { color: var(--gold-2); }
.kyc-banner {
  background: var(--kyc-bg);
  border: 1px solid var(--gold);
  border-radius: .85rem;
  padding: .85rem 1rem;
}
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.alert-error, .alert-danger { background: var(--alert-danger-bg); color: var(--alert-danger-fg); border-color: var(--alert-danger-bd); }
.alert-success { background: var(--alert-success-bg); color: var(--alert-success-fg); border-color: var(--alert-success-bd); }
.alert-info { background: var(--alert-info-bg); color: var(--alert-info-fg); border-color: var(--alert-info-bd); }
.theme-icon { width: 1.1rem; height: 1.1rem; flex-shrink: 0; display: block; }
.dropdown-item.theme-option {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  background: none;
  border: 0;
}
.dropdown-item.theme-option.is-active {
  color: var(--gold-2);
  font-weight: 700;
}
.pwa-install {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 1rem;
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.pwa-install[hidden] { display: none !important; }
.pwa-install p { color: var(--muted); font-size: 0.85rem; }
.pwa-install-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
@media (min-width: 768px) {
  .pwa-install {
    left: auto;
    right: 1rem;
    bottom: 1rem;
    max-width: 26rem;
  }
}
@media (display-mode: standalone) {
  .pwa-install { display: none !important; }
}
.live-stream-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0c1611;
  border-radius: .75rem;
  overflow: hidden;
}
.live-stream-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.live-stream-telegram { aspect-ratio: auto; min-height: 12rem; }
.live-stream-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}
.live-stream-placeholder {
  background: #0c1611;
  border: 1px dashed var(--line);
  border-radius: .75rem;
  padding: 1.25rem;
  text-align: center;
}
.race-kicker {
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}
.runner-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.75rem 0 0.4rem;
}
.runner-board {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
}
.runner-row {
  display: grid;
  grid-template-columns: 2.35rem minmax(0, 1fr) auto;
  gap: 0.55rem 0.7rem;
  align-items: center;
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.runner-row:last-child { border-bottom: 0; }
.runner-cloth {
  font-weight: 800;
  color: var(--gold-2);
  text-align: center;
  font-size: 1.05rem;
}
.runner-name {
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}
.runner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.8rem;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.runner-odds {
  min-width: 3.35rem;
  margin: -0.35rem 0;
  padding: 0.55rem 0.4rem 0.55rem 0.7rem;
  border: 0;
  border-left: 3px solid var(--gold);
  background: transparent;
  color: var(--cream);
  font-weight: 800;
  font-size: 1.2rem;
  line-height: 1;
  text-align: right;
}
button.runner-odds { cursor: pointer; }
button.runner-odds:hover,
button.runner-odds:focus-visible {
  color: var(--gold-2);
  outline: none;
}
.runner-odds.is-static { cursor: default; }
