:root {
  --bg: #140c28;
  --panel: #ffffff;
  --ink: #1a1f2a;
  --muted: #6b7585;
  --green: #b6e600;
  --green2: #8bc400;
  --navy: #1a2a44;
  --orange: #ff7a18;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font-family: Rubik, sans-serif;
  color: #fff;
  background:
    radial-gradient(1200px 600px at 70% 20%, rgba(90,40,160,.35), transparent 60%),
    linear-gradient(180deg, #1a1035 0%, #0d0a1a 100%);
}
button { font: inherit; cursor: pointer; border: 0; }
.hide { display: none !important; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: relative; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: rgba(8,6,18,.55);
  overflow: visible;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 40px; }
.titles { display: flex; flex-direction: column; line-height: 1; }
.t1 { font-size: 11px; letter-spacing: .12em; opacity: .85; }
.t2 { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 28px; color: var(--orange); letter-spacing: .04em; }
.top-right { display: flex; gap: 14px; align-items: center; position: relative; z-index: 55; overflow: visible; }
.clock, .balance { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px; }
.balance { color: #9fe870; }
.exit-btn { background: #2a3550; color: #fff; padding: 8px 12px; border-radius: 6px; }

.layout {
  flex: 1; display: grid; grid-template-columns: 1fr 300px; gap: 14px;
  padding: 12px 18px 20px; max-width: 1280px; width: 100%; margin: 0 auto;
}
.stage {
  position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden;
  background: #000 url("/casino/horse/modules/FHST/bin_prod/data/images/preload/backgrounds/main-bg.jpg") center/cover;
  border: 1px solid rgba(255,255,255,.08);
}
#preview-video, #race-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.change-race {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  background: rgba(0,0,0,.55); color: #fff; padding: 8px 12px; border-radius: 6px;
}
.race-count {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  background: rgba(0,0,0,.45); padding: 6px 10px; border-radius: 6px; font-size: 13px;
}
.preview-tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 3;
  background: #f0c000; color: #1a1200; font-weight: 700; padding: 6px 10px; border-radius: 4px;
}
.mute-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 4;
  width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff;
}
.leaders {
  position: absolute; left: 12px; right: 50px; bottom: 12px; z-index: 3;
  display: flex; gap: 8px; align-items: center;
}

.markets {
  margin-top: 12px; background: var(--panel); color: var(--ink);
  border-radius: 10px; overflow: hidden;
}
.rt-head, .rt-row {
  display: grid;
  grid-template-columns: 1.4fr 80px 80px 110px;
  gap: 8px; align-items: center; padding: 8px 12px;
}
.rt-head {
  background: #eef2f7; color: var(--muted); font-size: 12px; text-transform: uppercase;
  font-weight: 700;
}
.rt-head .fc { display: flex; flex-direction: column; gap: 2px; }
.rt-head .fc .fc-label { display: block; width: 100%; }
.rt-head .fc .fc-pos { display: inline-block; width: 48%; text-align: center; }
.rt-row { border-top: 1px solid #e6ebf2; }
.rt-row:hover { background: #f7faff; }
.rt-row.hot { background: #fff8d9; }
.racer-meta { display: flex; gap: 10px; align-items: center; min-width: 0; }
.silk {
  width: 34px; height: 34px; border-radius: 6px; color: #fff; font-weight: 700;
  display: grid; place-items: center; flex: 0 0 auto; text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 12px; }
.odd-btn {
  background: #fff; border: 1px solid #d7dee8; border-radius: 6px; padding: 10px 6px;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 16px; color: var(--ink);
}
.odd-btn.on { background: var(--green); border-color: var(--green2); }
.fc-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* chrome: lang / help / stats */
.help-btn {
  width: 34px; height: 34px; padding: 0; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
}
.help-btn img {
  width: 26px; height: 26px; display: block;
  filter: brightness(0) saturate(100%) invert(72%) sepia(72%) saturate(1200%) hue-rotate(146deg) brightness(104%) contrast(101%);
}
.help-btn:hover { opacity: .85; }
.lang-switch { position: relative; z-index: 60; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 0; border-radius: 6px;
  background: #243050; color: #fff; cursor: pointer;
}
.lang-btn img { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; }
.lang-btn #lang-code { font-size: 12px; font-weight: 700; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  max-height: 280px; overflow: auto; min-width: 180px;
  background: #1a2238; border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
  z-index: 70;
}
.lang-menu.hide { display: none; }
.lang-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; text-align: left; border: 0;
  background: transparent; color: #fff; cursor: pointer; font-size: 12px;
}
.lang-item:hover, .lang-item.on { background: #2a3550; }
.lang-item img { width: 22px; height: 16px; object-fit: cover; }

.help-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7); padding: 16px;
}
.help-modal.hide { display: none; }
.help-modal-card {
  width: min(720px, 100%); max-height: min(86vh, 760px);
  display: flex; flex-direction: column;
  background: #2f343b; border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.55);
  overflow: hidden; color: #fff;
}
.help-modal-head {
  display: flex; align-items: center; justify-content: center;
  position: relative; padding: 14px; border-bottom: 1px solid #444;
}
.help-modal-head h2 { margin: 0; font-size: 16px; }
.help-close {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 22px; width: 32px; height: 32px;
  border: 0; background: transparent; color: #fff; cursor: pointer;
}
.help-modal-body {
  padding: 14px 16px; overflow: auto; flex: 1;
  font-size: 14px; line-height: 1.45; color: #e8eef5;
}
.help-modal-body p { margin: 0 0 12px; }
.stats-footer { padding: 10px 16px; border-top: 1px solid #444; }
.stats-clear {
  background: #243545; border: 0; color: #fff;
  padding: 8px 12px; border-radius: 6px; font-weight: 700; cursor: pointer;
}
.stats-row {
  padding: 8px 0; border-bottom: 1px solid #3a4048; font-size: 13px;
}
.stats-row .sub { opacity: .75; font-size: 12px; margin-top: 2px; }

.ticket {
  background: #101a2c;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  align-self: start;
  overflow: hidden;
  transition: box-shadow .35s ease, border-color .35s ease;
}
.ticket.has-bets {
  border-color: rgba(182,230,0,.35);
  box-shadow: 0 0 0 1px rgba(255,122,24,.18);
}
.ticket-toggle, .ticket-head.static {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  text-align: left;
  background: var(--navy);
  border: 0;
  cursor: pointer;
  color: inherit;
}
.ticket-head.static { cursor: default; }
.ticket-toggle:hover { filter: brightness(1.06); }
.ticket-toggle h2, .ticket-head.static h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: .04em;
  flex: 1;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  color: #fff;
}
.ticket-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--orange);
  color: #1a1000;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ticket-count.hide { display: none; }
.ticket-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid #9aa8bd;
  border-bottom: 2px solid #9aa8bd;
  transform: rotate(45deg);
  transition: transform .35s ease;
  margin-top: -4px;
  flex-shrink: 0;
}
.ticket:not(.is-collapsed) .ticket-chevron {
  transform: rotate(225deg);
  margin-top: 4px;
}
.ticket-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .45s cubic-bezier(.22,.61,.36,1);
}
.ticket:not(.is-collapsed) .ticket-panel {
  grid-template-rows: 1fr;
}
.ticket-panel-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 10px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .3s ease, transform .35s ease, padding .35s ease;
  background: #0c1524;
}
.ticket:not(.is-collapsed) .ticket-panel-inner {
  padding: 0 10px 10px;
  opacity: 1;
  transform: translateY(0);
}
.ticket-panel-inner.open-always {
  opacity: 1;
  transform: none;
  padding: 0 10px 10px;
  overflow: visible;
}
.ticket-tools {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 6px;
}
.linkish {
  background: none;
  color: #9fe870;
  font-size: 12px;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.stake-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: Rajdhani, sans-serif;
  color: #9aa8bd;
}
.stake-row input {
  width: 64px;
  text-align: center;
  background: #0a1018;
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 4px;
  padding: 6px;
  font-family: Rubik, sans-serif;
}
.stake-row button {
  width: 26px;
  height: 26px;
  background: #243552;
  border: 0;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chips button {
  min-width: 48px;
  padding: 6px 8px;
  background: #243552;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #fff;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.chips button.on {
  background: var(--orange);
  color: #1a1000;
}
.ticket .slip-body {
  overflow: auto;
  min-height: 0;
  max-height: 0;
  transition: max-height .35s ease;
  color: #fff;
}
.aside {
  background: #101a2c;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
  align-self: start;
}
.panel-head {
  background: var(--navy);
  padding: 12px 14px;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  font-size: 18px;
}
.aside .slip-body {
  flex: 1;
  padding: 12px;
  overflow: auto;
  min-height: 0;
  color: #fff;
}
.ticket:not(.is-collapsed) .slip-body {
  max-height: 160px;
  min-height: 48px;
}
.ticket.ticket--grow:not(.is-collapsed) .slip-body { max-height: 240px; }
.ticket.ticket--grow2:not(.is-collapsed) .slip-body { max-height: 320px; }
.ticket-open .slip-body,
.ticket-panel-inner.open-always .slip-body {
  max-height: 280px;
  min-height: 80px;
}
.slip-empty {
  color: #9fe870;
  font-size: 13px;
  padding: 12px 4px;
  text-align: center;
}
.slip-item {
  background: #162238;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  position: relative;
  animation: slipIn .28s ease;
}
@keyframes slipIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.slip-item .rm {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: 0;
  color: #9aa8bd;
  font-size: 16px;
  cursor: pointer;
}
.slip-item .title { font-weight: 700; padding-right: 18px; }
.slip-item .subline { color: #9aa8bd; margin-top: 2px; font-size: 12px; }
.ticket-totals {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 8px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #9aa8bd;
}
.ticket-totals strong {
  float: right;
  color: var(--orange);
  font-family: Rajdhani, sans-serif;
  font-size: 15px;
}
.start-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: linear-gradient(180deg, var(--green), var(--green2));
  color: #111;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .04em;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.start-btn:disabled { opacity: .45; cursor: not-allowed; }

.results-screen {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.results-card {
  width: min(560px, 96%);
  background: rgba(12,18,32,.92);
  border: 1px solid rgba(182,230,0,.35);
  border-radius: 14px; padding: 22px;
  text-align: center;
}
.results-card h1 {
  margin: 0 0 14px; font-family: Rajdhani, sans-serif; font-size: 42px;
  color: var(--green); letter-spacing: .06em;
}
.results-card ol { list-style: none; margin: 0 0 16px; padding: 0; text-align: left; }
.results-card li {
  display: grid; grid-template-columns: 48px 44px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.08);
}
.won-bets { text-align: left; margin-bottom: 14px; }
.won-bets .wb {
  background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 10px;
  display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px;
}
.won-bets .wb strong { color: #1a8f2e; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-actions button {
  flex: 1; min-width: 100px; padding: 12px; border-radius: 8px;
  background: #fff; color: #111; font-weight: 700;
}
.result-actions .next { background: var(--green); flex: 1.4; }

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

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .ticket { width: 100%; }
  .rt-head, .rt-row { grid-template-columns: 1.2fr 64px 64px 96px; }
}
