:root {
  --bg: #071018;
  --panel: #0d1822;
  --line: #1c2e3d;
  --cyan: #2ee6d6;
  --gold: #d4a017;
  --text: #e8f1f7;
  --muted: #8aa0b2;
  --danger: #ff5b45;
  --ok: #15d817;
  --horse: #1ecad8;
  --dog: #f0a020;
  --car: #9b6bff;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font-family: Roboto, sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(7,16,24,.92), rgba(10,24,36,.95)),
    repeating-linear-gradient(-45deg, #0a1620 0 12px, #0c1a26 12px 24px);
}
button { font: inherit; cursor: pointer; border: 0; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(5,12,18,.85);
  border-bottom: 1px solid var(--line);
}
.brand .logo { height: 36px; display: block; }
.sport-tabs { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.sport-tab {
  min-width: 108px;
  padding: 8px 14px 10px;
  border-radius: 999px;
  background: #132231;
  color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px solid transparent;
  position: relative;
}
.sport-tab img { width: 30px; height: 30px; object-fit: contain; display: block; }
.sport-tab .tm { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px; letter-spacing: .04em; }
.sport-tab.active { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(46,230,214,.25) inset; }
.sport-tab[data-sport="horses"].active {
  background: #2ee6d6;
  border-color: #2ee6d6;
  color: #0b1a22;
}
.sport-tab[data-sport="horses"].active .tm { color: #0b1a22; }
.sport-tab[data-sport="greyhound"].active { background: linear-gradient(180deg,#3a2a14,#241910); border-color: var(--dog); }
.sport-tab[data-sport="nascar"].active { background: linear-gradient(180deg,#2a1f3f,#1a1428); border-color: #f4bb56; }
.sport-tab[data-sport="greyhound"] { border-color: rgba(244,187,86,.35); }
.sport-tab[data-sport="nascar"] { border-color: rgba(244,187,86,.35); }
.top-right { display: flex; align-items: center; gap: 12px; }
.clock, .balance { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px; }
.balance { color: var(--cyan); }
.exit-btn { background: #243545; color: #fff; padding: 8px 12px; border-radius: 6px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
  padding: 12px 16px 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.stage {
  position: relative;
  aspect-ratio: 16/9;
  background: #000 url("/casino/races/modules/FASV/bin_prod/data/images/horses/poster.webp") center/cover;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
#race-video, .poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#race-video { background: #000; z-index: 1; }
.poster { z-index: 2; }
.poster.hide, #race-video.hide { display: none; }
.mute-btn {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff;
}
.track-banner {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  background: linear-gradient(90deg, #f0b429, #e08a12);
  color: #1a1200; font-family: Rajdhani, sans-serif; font-weight: 700;
  font-size: 15px; letter-spacing: .03em;
  padding: 6px 12px; border-radius: 4px;
}
.phase-label {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  background: rgba(0,0,0,.55); padding: 6px 10px; border-radius: 4px;
  font-size: 13px; color: #fff;
}
.racer-grid {
  position: absolute; inset: 0; z-index: 4;
  display: grid; grid-template-columns: repeat(4, minmax(56px, 72px));
  gap: 10px; place-content: center; pointer-events: none;
}
.racer-grid.hide { display: none; }
.racer-grid img { width: 64px; height: 64px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.45)); }

.results {
  position: absolute; inset: 0; z-index: 7;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
}
.results.show { display: flex; }
.results-inner {
  width: min(420px, 92%);
  background: linear-gradient(180deg, #102433, #0a1720);
  border: 1px solid rgba(46,230,214,.35);
  border-radius: 10px; padding: 18px 20px;
}
.results-inner h2 {
  margin: 0 0 12px; text-align: center;
  font-family: Rajdhani, sans-serif; color: var(--cyan); letter-spacing: .08em;
}
.results-inner ol { margin: 0; padding: 0; list-style: none; }
.results-inner li {
  display: grid; grid-template-columns: 36px 40px 1fr auto; gap: 10px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.results-inner li:last-child { border-bottom: 0; }
.results-inner .pos { font-family: Rajdhani, sans-serif; font-weight: 700; color: var(--gold); font-size: 18px; }
.results-inner img { width: 34px; height: 34px; }

.status-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 4px; color: var(--muted); font-size: 13px;
}
.status-bar #bets-status { color: var(--cyan); }

.markets {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.market-tabs { display: flex; gap: 4px; padding: 8px; background: #0a141c; }
.market-tabs button {
  background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 6px;
}
.market-tabs button.active { background: #163040; color: var(--cyan); }

.racer-table { max-height: 360px; overflow: auto; }
.rt-head, .rt-row {
  display: grid;
  grid-template-columns: 1fr 90px 90px 70px;
  gap: 8px; align-items: center;
  padding: 8px 12px;
}
.rt-head {
  position: sticky; top: 0; background: #101c27; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; z-index: 1;
}
.rt-row { border-top: 1px solid var(--line); }
.rt-row:hover { background: rgba(46,230,214,.05); }
.racer-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.racer-meta img { width: 34px; height: 34px; flex: 0 0 auto; }
.racer-meta .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.racer-meta .form { color: var(--muted); font-size: 12px; }
.odd-btn, .ew-btn {
  background: #152433; color: #fff; border-radius: 6px; padding: 10px 8px;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 16px;
}
.odd-btn:hover, .ew-btn:hover { background: #1d3346; }
.odd-btn.on { background: linear-gradient(180deg, #15d817, #8de706); color: #071008; }
.ew-btn { font-size: 13px; color: var(--cyan); }
.ew-btn.on { background: #163a30; color: #fff; border: 1px solid var(--cyan); }
.odd-btn:disabled, .ew-btn:disabled { opacity: .45; cursor: not-allowed; }

.aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex; flex-direction: column; min-height: 480px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; color: var(--cyan); font-family: Rajdhani, sans-serif;
  font-weight: 700; font-size: 18px; border-bottom: 1px solid var(--line);
}
.linkish { background: none; color: var(--muted); font-size: 12px; }
.slip-body { flex: 1; padding: 12px; overflow: auto; }
.slip-empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.slip-item {
  background: #101c27; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin-bottom: 8px; position: relative;
}
.slip-item .rm {
  position: absolute; top: 6px; right: 8px; background: none; color: var(--muted); font-size: 16px;
}
.slip-item .title { font-weight: 700; padding-right: 18px; }
.slip-item .sub { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.slip-item .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.slip-item input {
  width: 90px; background: #0a141c; border: 1px solid var(--line); color: #fff;
  border-radius: 4px; padding: 6px 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
.chips button {
  background: #152433; color: #fff; border-radius: 999px; padding: 6px 12px;
  font-family: Rajdhani, sans-serif; font-weight: 700;
}
.chips button.on { background: var(--gold); color: #1a1200; }
.totals {
  padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.totals > div { display: flex; justify-content: space-between; margin: 4px 0; }
.totals strong { color: #fff; font-family: Rajdhani, sans-serif; font-size: 16px; }
.submit-wrap { padding: 10px 12px 14px; }
.submit-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(180deg, #8a6110, #5c3f08);
  color: #f7e2a1; font-family: Rajdhani, sans-serif; font-weight: 700;
  font-size: 18px; letter-spacing: .06em; border-radius: 6px;
}
.submit-btn:enabled { background: linear-gradient(180deg, #d4a017, #9a6f0c); color: #1a1200; }
.submit-btn:disabled { opacity: .55; cursor: not-allowed; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(8,16,24,.95); border: 1px solid var(--cyan);
  padding: 10px 16px; border-radius: 8px; display: none; z-index: 50;
}
.toast.show { display: block; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .aside { min-height: 280px; }
  .rt-head, .rt-row { grid-template-columns: 1fr 70px 70px 56px; }
}
