@font-face {
  font-family: 'Orbitron';
  src: url('orbitron.ttf') format('truetype');
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #202020;
  --background2: #1a1a1a;
  --muted-white: #8e8e8e;
  --white: #f1f1f1;
  --page: var(--background);
  --panel: var(--background2);
  --panel-raised: var(--background);
  --line: #383838;
  --text: var(--white);
  --muted: var(--muted-white);
  --accent: #D2A2BE;
  --accent-bright: #edcde0;
  --display: 'Orbitron', 'Arial Black', sans-serif;
  --sans: 'Segoe UI', Arial, sans-serif;
  font-family: var(--sans);
  color: var(--text);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--background); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; transition: background .18s, border-color .18s, box-shadow .18s, transform .18s; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:active:not(:disabled) { transform: translateY(1px); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* The game starts directly under a compact arcade marquee. */
.site-header { min-height: 90px; display: flex; justify-content: space-between; align-items: center; gap: 28px; padding: 18px max(4%, calc((100vw - 1480px) / 2)); border-bottom: 1px solid var(--line); background: var(--background2); box-shadow: 0 1px 0 #D2A2BE10; }
.brand { color: var(--text); text-decoration: none; padding-left: 15px; border-left: 3px solid var(--accent); flex-shrink: 1; min-width: 0; }
.brand h1 { font-family: var(--display); font-size: clamp(14px, 1.35vw, 20px); line-height: 1.4; font-weight: 700; margin: 0; }
.brand > span { display: block; font-size: 13px; color: var(--muted); margin-top: 5px; letter-spacing: .4px; }
.brand > span strong { color: var(--accent); font-weight: 600; }
.header-actions { display: flex; gap: 14px; align-items: center; flex-shrink: 0; }
.icon-button { position: relative; display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--background2); color: var(--white); }
.icon-button:hover { background: var(--background); border-color: var(--line); }
.mute-slash { position: absolute; width: 25px; height: 2px; background: currentColor; transform: rotate(-48deg); border-top: 1px solid var(--background2); }
.help-button { display: flex; align-items: center; gap: 8px; min-height: 38px; border: 0; background: none; font-size: 14px; color: var(--white); padding: 4px 0; }
.help-button:hover { color: var(--accent); }
main { max-width: 1480px; width: 92%; margin: 28px auto 40px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.race-column { display: contents; }
.race-panel { grid-column: 1 / -1; grid-row: 1; }
.runners-section { grid-column: 1; grid-row: 2; min-width: 0; }
.betting-column { grid-column: 2; grid-row: 2 / span 2; }
.recent-race { grid-column: 1; grid-row: 3; }

/* Live racing display. */
.race-panel { overflow: hidden; background: var(--background2); border: 1px solid #45374a; border-radius: 12px; box-shadow: 0 12px 40px #0004, 0 0 25px #D2A2BE06; }
.race-panel-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 23px 24px 18px; background: var(--background2); }
.track-eyebrow { font: 600 15px/1.6 var(--display); margin: 0; color: var(--white); }
.race-separator { padding: 0 9px; color: var(--muted-white); font-family: var(--sans); font-weight: 400; }
#round-number { color: var(--accent); font-variant-numeric: tabular-nums; }
.race-status { display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #FFAA4555; background: #FFAA4514; color: #FFAA45; padding: 8px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; letter-spacing: .6px; white-space: nowrap; }
.race-status > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.race-status[data-phase="running"] { color: #38E58A; background: #38E58A14; border-color: #38E58A55; }
.race-status[data-phase="finished"] { color: #FF5B64; background: #FF5B6414; border-color: #FF5B6455; }
.race-status[data-phase="running"] > span, .race-status[data-phase="countdown"] > span { animation: pulse 1s infinite; }
.track-facts { display: flex; align-items: center; gap: 13px; padding: 0 24px 17px; background: var(--background2); border-bottom: 1px solid var(--line); color: var(--muted-white); font-size: 12px; }
.track-facts > span { display: flex; align-items: center; gap: 6px; }
.track-facts > i { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-white); }
.track-facts svg { width: 14px; height: 14px; }
.track-facts .track-live { margin-left: auto; font-size: 12px; letter-spacing: 1px; color: var(--muted-white); }
.track-stage { position: relative; width: 100%; height: clamp(510px, 46vw, 650px); overflow: hidden; background: var(--background2); }
#race-canvas { display: block; width: 100%; height: 100%; }
.infield { position: absolute; left: 50%; top: 48.5%; transform: translate(-50%, -50%); pointer-events: none; }
.infield-name { display: block; font: 900 clamp(23px, 3vw, 42px)/1 var(--display); color: #f4dfed; letter-spacing: 1px; transform: skewX(-12deg) scaleY(.87); text-shadow: 2px 2px 0 #82516d, 0 0 28px #D2A2BE22; white-space: nowrap; }
.track-distance { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 12px; font: 500 12px/1.5 var(--sans); letter-spacing: 1.8px; color: var(--muted-white); white-space: nowrap; }
.track-distance span { color: var(--accent); font-size: 21px; line-height: 1; }
.countdown-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #080c15d9; backdrop-filter: blur(4px); }
.countdown-overlay > span { color: var(--accent); font-size: 12px; letter-spacing: 2px; }
.countdown-overlay strong { font: 800 96px/1.3 var(--display); color: var(--accent); text-shadow: 0 0 35px #D2A2BE30; }
.track-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 24px; margin-top: 7px; border-top: 1px solid var(--line); background: var(--background2); }
.race-clock { display: flex; align-items: center; gap: 8px; color: var(--accent); font: 500 13px var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.race-clock svg { height: 15px; width: 15px; }
.live-positions { display: flex; flex: 1; min-width: 0; gap: 12px; padding: 0; overflow-x: auto; font-size: 12px; }
.position-item { display: flex; flex-direction: column; align-items: center; gap: 4px; white-space: nowrap; }
.position-item > span:first-child { color: var(--muted-white); }
.position-number { display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 3px 6px; font-weight: 700; border-radius: 3px; background: var(--horse-color); }

/* Runner buttons echo illuminated controls on an arcade cabinet. */
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 17px; }
.section-heading h2 { display: flex; align-items: center; gap: 11px; font-size: 19px; font-weight: 600; margin: 0; }
.section-heading p { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 6px 0 0; }
.horse-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.horse-card { min-width: 0; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; padding: 17px 14px 0; background: linear-gradient(135deg, color-mix(in srgb, var(--horse-color) 8%, var(--background)), var(--background2) 65%); text-align: left; }
.horse-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--horse-color); opacity: .8; }
.horse-card.has-bet { border-color: var(--horse-color); background: color-mix(in srgb, var(--horse-color) 14%, var(--background2)); box-shadow: 0 0 20px color-mix(in srgb, var(--horse-color) 12%, transparent); }
.horse-card.is-locked { opacity: .65; }
.horse-card.has-bet.is-locked { opacity: .9; }
.horse-card.winner { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px #D2A2BE20; }
.horse-card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.horse-identity { min-width: 0; }
.runner-number { display: grid; place-items: center; width: 31px; height: 33px; border-radius: 4px; background: var(--horse-color); color: white; font-size: 16px; font-weight: 700; box-shadow: inset 0 -3px 0 #0002; }
.horse-name { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; }
.horse-name, .pick-name { overflow-wrap: anywhere; }
.horse-form { min-height: 31px; margin: 3px 0 9px; font-size: 12px; color: var(--muted-white); line-height: 1.4; }
.horse-card-bottom { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px 0 10px; font-size: 12px; }
.bet-option { min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 4px; background: var(--background); padding: 6px; text-align: left; }
.bet-option-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 5px; font-size: 12px; line-height: 1.2; }
.bet-option-heading b { white-space: nowrap; }
.bet-option[data-bet-type="win"] .bet-option-heading b { font-size: 14px; }
.bet-multiplier { color: var(--accent); font-variant-numeric: tabular-nums; }
.bet-amount { display: block; margin-top: 4px; font-size: 12px; color: var(--muted-white); line-height: 1.2; }
.bet-option:hover:not(:disabled), .bet-option.has-bet { border-color: var(--horse-color); background: color-mix(in srgb, var(--horse-color) 20%, var(--background2)); }
.bet-option.has-bet .bet-amount { color: var(--white); }
.bet-option:disabled { cursor: default; }
.recent-race { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 17px 0 0; margin-top: 22px; border-top: 1px solid var(--line); color: var(--muted-white); font-size: 13px; line-height: 1.5; }
.recent-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.recent-links { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.history-link { flex-shrink: 0; border: 0; padding: 0; background: none; color: var(--muted-white); font: inherit; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.history-link:hover { color: var(--accent); }
.recent-race { flex-wrap: nowrap; }
.recent-label { color: var(--accent); font-size: 12px; letter-spacing: .8px; }

/* Dollar balance, chip selection and the bet slip. */
.wallet { background: var(--background2); border: 1px solid #63495d; border-radius: 10px; padding: 22px; position: relative; }
.wallet-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; letter-spacing: 1.5px; color: #bd9eb4; }
.wallet-top svg { color: var(--accent); }
.balance-display { margin: 14px 0 0; }
.balance-display strong { font: 700 clamp(28px, 2.7vw, 39px)/1.3 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-shadow: 0 0 24px #D2A2BE15; }
.credit-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #bd8baa; background: #503549; color: #f1d2e5; padding: 12px; margin-top: 20px; border-radius: 5px; font-size: 14px; font-weight: 600; }
.credit-button svg { width: 16px; height: 16px; }
.credit-button:hover:not(:disabled) { background: #67465e; }
.credit-button:disabled { opacity: .45; }
.credit-overlay { position: fixed; inset: 0; z-index: 30; background: #000b; pointer-events: none; }
.credit-button.credit-highlight { position: relative; z-index: 31; background: var(--accent); color: var(--background2); border-color: var(--accent-bright); box-shadow: 0 0 0 4px #D2A2BE30, 0 0 24px #D2A2BE50; animation: credit-pulse 1.8s ease-in-out infinite; }
.credit-button.credit-highlight:hover:not(:disabled) { background: var(--accent-bright); }
.credit-button.credit-highlight:disabled { animation: none; opacity: .75; }
@keyframes credit-pulse { 50% { transform: scale(1.035); box-shadow: 0 0 0 8px #D2A2BE15, 0 0 38px #D2A2BE80; } }
.bet-slip { border: 1px solid var(--line); border-radius: 10px; background: var(--background2); padding: 22px; margin-top: 18px; }
.slip-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.slip-title h2 { font-size: 20px; font-weight: 600; margin: 0; }
.slip-title > span { color: var(--muted-white); background: var(--background); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; font-size: 12px; white-space: nowrap; }
.chip-picker { margin-top: 25px; }
.field-label { font-size: 12px; color: var(--muted-white); letter-spacing: 1px; }
.chips { display: flex; justify-content: space-between; gap: 12px; margin-top: 17px; }
.chip { width: 49px; height: 49px; flex-shrink: 0; padding: 4px; border: 2px dashed #8c9cab; border-radius: 50%; color: #d7dfe7; background: #273340; box-shadow: 0 0 0 3px #1c252f, 0 3px 6px #0006; font-size: 14px; font-weight: 600; }
.chip[data-chip="10"] { border-color: #55baff; background: #155089; color: #e6f4ff; box-shadow: 0 0 0 3px #12365b, 0 3px 6px #0006; }
.chip[data-chip="50"] { border-color: #c583ff; background: #6a28a8; color: #f5eaff; box-shadow: 0 0 0 3px #422063, 0 3px 6px #0006; }
.chip[data-chip="100"] { border-color: #fff0b7; background: linear-gradient(145deg, #ffe59a, #ffbd38); color: #382408; box-shadow: 0 0 0 3px #855c1e, 0 3px 6px #0006, 0 0 12px #ffca4b35; font-weight: 700; }
.chip > span { display: grid; place-items: center; height: 100%; border: 1px solid #ffffff35; border-radius: 50%; }
.chip[data-chip="100"] > span { border-color: #80520b60; font-size: .9em; }
.chip.selected { position: relative; }
.chip.selected::after { content: ''; position: absolute; inset: -5px; border: 2px solid #fff; border-radius: 50%; pointer-events: none; box-shadow: 0 0 15px #ffffff90; animation: chip-selection-glow 2s ease-in-out infinite; }
.chip.selected:disabled::after { animation: none; }
@keyframes chip-selection-glow { 0%, 100% { opacity: 1; box-shadow: 0 0 15px #ffffff90; } 50% { opacity: .7; box-shadow: 0 0 6px #ffffff40; } }
.chip:hover:not(:disabled):not(.selected) { filter: brightness(1.25); }
.chip:disabled { opacity: .55; filter: grayscale(1); }
.slip-picks { min-height: 172px; padding: 26px 0 20px; }
.slip-empty { display: flex; align-items: center; flex-direction: column; text-align: center; padding-top: 13px; }
.slip-empty svg { color: var(--muted-white); width: 28px; height: 28px; margin-bottom: 17px; }
.slip-empty strong { font-size: 13px; font-weight: 500; color: var(--muted-white); line-height: 1.5; }
.slip-empty p { font-size: 12px; line-height: 1.5; color: var(--muted-white); margin: 7px 0 0; }
.pick { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto 24px; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pick:last-child { border: 0; }
.pick-badge { display: grid; place-items: center; width: 25px; height: 28px; border-radius: 3px; color: white; background: var(--horse-color); font-size: 13px; font-weight: 600; }
.pick-name { display: block; font-size: 13px; line-height: 1.3; font-weight: 600; }
.pick-odds { display: block; margin-top: 4px; color: var(--muted-white); font-size: 12px; line-height: 1.4; }
.pick-amount { font-size: 14px; font-weight: 600; color: var(--white); overflow-wrap: anywhere; }
.pick-remove { display: grid; place-items: center; border: 0; background: transparent; color: var(--muted-white); width: 24px; height: 32px; padding: 3px; }
.pick-remove svg { width: 16px; height: 16px; }
.pick-remove:hover { color: #ff7e89; }
.slip-divider { border-top: 1px dashed var(--line); margin-bottom: 20px; }
.slip-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.slip-action-button { width: 100%; min-width: 0; min-height: 38px; padding: 8px; border: 1px solid var(--accent); border-radius: 5px; background: var(--background); color: var(--accent); font-size: 13px; font-weight: 600; }
.slip-action-button:hover:not(:disabled) { background: #D2A2BE18; color: var(--accent-bright); }
.slip-action-button:disabled { border-color: var(--line); color: var(--muted-white); opacity: .65; }
.slip-total, .slip-potential { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.slip-total > strong { font: 600 21px var(--display); }
.slip-potential { margin-top: 13px; color: var(--muted-white); font-size: 13px; }
.slip-potential > strong { font-size: 16px; color: var(--accent); font-variant-numeric: tabular-nums; }
.slip-potential > span > span { margin-left: 3px; }
.start-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 16px; margin-top: 25px; border: 1px solid #e5bed5; border-radius: 6px; background: var(--accent); color: #23131d; font-size: 15px; font-weight: 700; box-shadow: 0 3px 0 #82596f, 0 0 24px #D2A2BE14; }
.start-button svg { width: 19px; height: 19px; }
.start-button:hover:not(:disabled) { background: #e2bad3; box-shadow: 0 3px 0 #82596f, 0 0 24px #D2A2BE30; }
.start-button:disabled { color: #9a8092; background: #302431; border-color: #4d3949; box-shadow: none; }
.clear-button { display: block; margin: 10px auto 0; padding: 10px; border: 0; background: none; font-size: 13px; color: var(--muted-white); text-decoration: underline; text-underline-offset: 4px; }
.clear-button:hover:not(:disabled) { color: var(--text); }
.clear-button:disabled { color: var(--muted-white); }

/* Dialogs and feedback share the dark arcade palette. */
.info-dialog, .result-dialog { width: min(540px, calc(100% - 32px)); max-height: 85dvh; padding: 36px; border: 1px solid var(--line); border-radius: 12px; background: var(--background2); color: var(--text); box-shadow: 0 25px 90px #0009; }
.info-dialog::backdrop, .result-dialog::backdrop { background: #030710dd; backdrop-filter: blur(6px); }
.dialog-close { position: absolute; right: 14px; top: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1.5px; color: var(--accent); padding-right: 30px; }
.info-dialog h2, .result-dialog h2 { font-family: var(--display); font-size: 26px; line-height: 1.4; font-weight: 700; margin: 15px 0 27px; }
.how-to-list { list-style: none; margin: 0; padding: 0; }
.how-to-list li { display: flex; gap: 17px; margin-bottom: 24px; }
.how-to-list li > span { font: 600 19px var(--display); color: var(--accent); }
.how-to-list strong { font-size: 16px; }
.how-to-list p { font-size: 14px; line-height: 1.7; color: var(--muted-white); margin: 5px 0 0; }
.help-footnote { border-top: 1px solid var(--line); padding-top: 18px; font-size: 12px; line-height: 1.8; color: var(--muted-white); }
.history-empty { font-size: 15px; line-height: 1.8; color: var(--muted); padding: 20px 0; }
#history-dialog { width: min(1120px, calc(100% - 24px)); padding: 28px; }
.history-scroll { overflow: auto; max-height: 60dvh; border: 1px solid var(--line); border-radius: 6px; }
.history-table { width: 100%; min-width: 900px; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 1.4; }
.history-table th, .history-table td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.history-table thead th { position: sticky; top: 0; z-index: 1; background: #292329; color: var(--white); font-size: 12px; white-space: nowrap; }
.history-table tbody tr:nth-child(even) { background: #ffffff03; }
.history-table tbody tr:last-child > * { border-bottom: 0; }
.history-table .numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-round { font: 600 14px var(--display); color: var(--muted-white); }
.history-order { display: flex; gap: 7px; }
.history-order .position-item:nth-child(-n+3) > span:first-child { color: var(--accent); }
.history-ticket { display: flex; align-items: flex-start; gap: 7px; margin-bottom: 9px; white-space: nowrap; }
.history-ticket:last-child { margin-bottom: 0; }
.history-ticket small { display: block; margin-top: 2px; font-size: 12px; }
.history-ticket b { font-size: 12px; }
.history-legacy { color: var(--muted-white); }
.net-positive { color: #38E58A; }
.net-negative { color: #FF5B64; }
.net-even { color: var(--muted-white); }
.result-dialog { text-align: center; }
.result-dialog .eyebrow { padding: 0 20px; margin-top: 7px; }
.result-rosette { display: grid; place-items: center; width: 74px; height: 74px; margin: 30px auto 24px; border-radius: 10px; color: white; background: var(--horse-color); border: 2px solid #ffffff80; outline: 1px solid var(--accent); outline-offset: 5px; font: 700 32px var(--display); box-shadow: 0 0 30px #D2A2BE1a; }
.runner-number, .pick-badge, .position-number, .result-rosette { color: var(--background2); }
.result-dialog h2 { margin: 14px 0; }
.result-dialog > p { font-size: 14px; color: var(--muted-white); line-height: 1.7; }
.result-podium { display: flex; justify-content: center; gap: 12px; padding: 22px 0; }
.podium-horse { display: flex; align-items: center; flex-direction: column; width: 100%; gap: 10px; color: var(--muted-white); font-size: 12px; }
.podium-horse > strong { font-size: 13px; font-weight: 500; color: var(--white); }
.result-payout { padding: 22px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.result-payout > span { display: block; font-size: 12px; letter-spacing: 1.5px; color: var(--muted-white); }
.result-payout > strong { display: block; margin: 10px 0; font: 700 38px var(--display); color: var(--accent); overflow-wrap: anywhere; }
.result-payout p { margin: 0; font-size: 13px; color: var(--muted-white); }
.result-breakdown { max-width: 260px; margin: 16px auto 0; display: grid; gap: 9px; }
.result-breakdown p { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.result-breakdown strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.result-dialog .start-button { justify-content: center; }
.result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 25px; }
.result-actions .start-button { margin-top: 0; padding: 12px 10px; gap: 8px; font-size: 14px; }
.result-history-button { min-height: 44px; padding: 12px 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--background); color: var(--accent); font-size: 14px; font-weight: 600; }
.result-history-button:hover { background: #D2A2BE18; color: var(--accent-bright); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 30px); padding: 15px 22px; border: 1px solid #997086; border-radius: 7px; background: #2c1e2b; color: #f1d5e5; box-shadow: 0 8px 35px #0008; font-size: 14px; line-height: 1.6; text-align: center; }
.toast.error { border-color: #b05d6b; background: #341f2b; color: #ffd7df; }
.noscript { position: fixed; inset: auto 0 0; background: #592438; color: white; text-align: center; padding: 20px; }
@keyframes pulse { 50% { opacity: .35; } }

@media (min-width: 1600px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 350px; gap: 28px; }
  .horse-name { min-height: auto; margin-bottom: 8px; font-size: 15px; }
  .horse-form { min-height: auto; }
  .chip { width: 53px; height: 53px; }
}
@media (max-width: 1150px) {
  .site-header { gap: 20px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; }
  .track-facts .track-live { display: none; }
  .race-panel-header { padding: 19px 18px 16px; }
  .track-eyebrow { font-size: 13px; }
  .race-status { font-size: 12px; letter-spacing: 0; }
  .race-separator { padding: 0 5px; }
  .horse-grid { gap: 9px; }
  .horse-card { padding: 15px 11px 0; }
  .wallet, .bet-slip { padding: 20px 17px; }
  .chips { gap: 10px; }
  .chip { width: 47px; height: 47px; }
  .pick { gap: 6px; grid-template-columns: 23px minmax(0, 1fr) auto 22px; }
}
@media (max-width: 950px) {
  .brand h1 { font-size: 16px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; }
  .horse-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .horse-card { padding: 17px 15px 0; }
  .horse-name { min-height: auto; margin-bottom: 7px; }
  .horse-form { min-height: auto; margin-bottom: 13px; }
  .race-panel-header { flex-wrap: wrap; gap: 12px; }
  .track-eyebrow { font-size: 14px; }
  .race-status { padding: 6px 8px; }
  .track-facts { padding: 0 18px 15px; gap: 10px; }
  .track-stage { height: clamp(450px, 62vw, 540px); }
  .infield-name { font-size: clamp(23px, 3.8vw, 33px); }
  .track-bottom { padding: 15px 18px; }
  .race-clock { font-size: 12px; gap: 5px; }
  .track-distance { font-size: 12px; letter-spacing: .8px; }
  .live-positions { gap: 10px; }
  .chips { gap: 9px; }
  .chip { width: 44px; height: 44px; padding: 3px; }
  .slip-title h2 { font-size: 18px; }
  .pick-amount { font-size: 13px; }
  .pick-name { font-size: 12px; }
  .balance-display strong { font-size: 28px; }
}
@media (max-width: 640px) {
  .site-header { min-height: 86px; gap: 15px; padding: 17px 4%; }
  .brand { padding-left: 10px; }
  .brand h1 { font-size: 13px; line-height: 1.6; max-width: 260px; }
  .brand > span { font-size: 12px; margin-top: 3px; }
  .header-actions { gap: 8px; }
  .help-button { width: 34px; justify-content: center; }
  .help-button > span { display: none; }
  .icon-button { width: 34px; height: 36px; padding: 7px; }
  main { margin-top: 18px; }
  .game-layout { display: flex; flex-direction: column; gap: 19px; }
  .race-column, .betting-column { display: contents; }
  .race-panel { order: 0; width: 100%; }
  .race-panel-header { padding: 17px 15px 15px; }
  .track-eyebrow { font-size: 12px; line-height: 1.6; }
  .race-status { font-size: 12px; }
  .track-facts { padding: 0 15px 14px; font-size: 12px; gap: 10px; }
  .track-stage { height: clamp(240px, 72vw, 440px); }
  .infield-name { font-size: clamp(18px, 5.5vw, 30px); }
  .track-bottom { padding: 14px 15px; align-items: flex-start; }
  .race-clock { padding-top: 3px; }
  .live-positions { padding: 0; gap: 6px; }
  .track-bottom .race-clock { display: none; }
  .wallet { order: 1; width: 100%; padding: 19px; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 18px; }
  .wallet-top { grid-column: 1; font-size: 12px; }
  .wallet-top svg { display: none; }
  .balance-display { grid-column: 1; margin-top: 9px; }
  .balance-display strong { font-size: 28px; }
  .credit-button { grid-column: 2; grid-row: 1 / 3; width: auto; min-width: 120px; padding: 12px; margin: 0; }
  .runners-section { order: 2; width: 100%; }
  .section-heading { margin: 4px 0 16px; }
  .section-heading h2 { font-size: 19px; }
  .section-heading p { font-size: 13px; }
  .runners-section > .chip-picker { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 0; margin: 0 0 21px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .runners-section > .chip-picker > .field-label { font-size: 12px; line-height: 1.6; max-width: 100px; letter-spacing: .5px; }
  .runners-section > .chip-picker > .chips { gap: 11px; margin: 0; }
  .runners-section > .chip-picker .chip { width: 43px; height: 43px; font-size: 13px; }
  .horse-card { padding: 17px 14px 0; }
  .horse-name { min-height: 36px; margin-bottom: 0; }
  .horse-form { min-height: 32px; margin: 4px 0 8px; }
  .horse-card-bottom { font-size: 13px; }
  .bet-slip { order: 3; width: 100%; margin: 0; padding: 23px 20px; }
  .slip-title h2 { font-size: 21px; }
  .slip-picks { min-height: 145px; }
  .slip-empty strong { font-size: 14px; }
  .slip-empty p { font-size: 13px; }
  .pick { grid-template-columns: 28px minmax(0, 1fr) auto 28px; gap: 10px; }
  .pick-name { font-size: 14px; }
  .pick-amount { font-size: 15px; }
  .pick-remove { width: 28px; height: 36px; }
  .recent-race { order: 4; width: 100%; margin: 0; padding-top: 17px; }
  .info-dialog, .result-dialog { padding: 33px 23px; }
  .info-dialog h2, .result-dialog h2 { font-size: 23px; }
  #history-dialog { padding: 28px 12px 16px; }
}
@media (max-width: 370px) {
  .runners-section > .chip-picker { gap: 8px; }
  .runners-section > .chip-picker > .field-label { max-width: 78px; }
  .runners-section > .chip-picker > .chips { gap: 8px; }
  .runners-section > .chip-picker .chip { width: 39px; height: 39px; font-size: 12px; }
  .track-eyebrow { font-size: 12px; }
  .track-facts { gap: 7px; }
}
/* Desktop cabinet: a flexible track, two short runner rows and a slim sidebar. */
@media (min-width: 1000px) {
  :root { --header-height: 64px; }
  .site-header { height: var(--header-height); min-height: var(--header-height); padding: 8px 20px; gap: 20px; }
  .brand { padding-left: 11px; }
  .brand h1 { font-size: clamp(14px, 1.15vw, 18px); line-height: 1.35; }
  .brand > span { margin-top: 3px; font-size: 12px; }
  main { max-width: none; width: calc(100% - 32px); margin: 12px auto; }
  .game-layout { grid-template-columns: minmax(0, 1fr) clamp(240px, 18.5vw, 266px); grid-template-rows: minmax(0, 1fr); gap: 14px; align-items: stretch; }
  .race-column { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
  .race-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(200px, 1fr) auto auto; flex: 1 1 auto; min-height: 0; }
  .race-panel-header { grid-column: 1; grid-row: 1; padding: 10px 14px; gap: 10px; }
  .track-eyebrow { font-size: 13px; line-height: 1.5; }
  .race-separator { padding: 0 5px; }
  .race-status { font-size: 12px; letter-spacing: 0; padding: 5px 7px; }
  .track-facts { grid-column: 2; grid-row: 1; padding: 10px 14px 10px 0; gap: 8px; border-bottom: 0; font-size: 12px; }
  .track-facts .track-live { display: none; }
  .track-stage { grid-column: 1 / -1; grid-row: 2; height: auto; min-height: 200px; }
  .track-bottom { grid-column: 1 / -1; grid-row: 3; margin: 0; padding: 7px 14px; gap: 10px; }
  .race-clock { font-size: 12px; }
  .live-positions { padding: 0; gap: 12px; }
  .track-distance { bottom: 3px; font-size: 12px; letter-spacing: 1px; gap: 8px; }
  .track-distance span { font-size: 18px; }

  .runners-section { flex: 0 0 auto; }
  .section-heading { margin: 0 0 8px; gap: 10px; }
  .section-heading > div { display: flex; align-items: center; gap: 12px; }
  .section-heading h2 { font-size: 16px; gap: 7px; }
  .section-heading p { font-size: 12px; margin: 0; }
  .horse-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .horse-card { display: flex; flex-direction: column; gap: 5px; padding: 8px; border-radius: 6px; }
  .horse-card-top { display: flex; gap: 7px; margin: 0; flex: 1; }
  .horse-card .runner-number { width: 25px; height: 27px; font-size: 14px; flex-shrink: 0; }
  .horse-name { min-height: 0; margin: 0; font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .horse-form { min-height: 0; margin: 2px 0 0; font-size: 12px; line-height: 1.2; }
  .horse-card-bottom { padding: 0; gap: 5px; }
  .bet-option { padding: 5px; min-height: 39px; }
  .recent-race { flex: 0 0 auto; padding: 5px 0 0; margin: 0; gap: 10px; font-size: 12px; line-height: 1.4; }
  .recent-label { font-size: 12px; letter-spacing: .4px; }

  .betting-column { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
  .wallet { flex: 0 0 auto; padding: 13px 14px; border-radius: 8px; }
  .wallet-top { font-size: 12px; letter-spacing: 1px; }
  .wallet-top svg { width: 17px; height: 17px; }
  .balance-display { margin-top: 7px; }
  .balance-display strong { font-size: clamp(25px, 2vw, 30px); line-height: 1.2; }
  .credit-button { margin-top: 10px; padding: 9px; font-size: 13px; }
  .bet-slip { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin: 0; padding: 14px; border-radius: 8px; }
  .bet-slip > :not(.slip-picks) { flex-shrink: 0; }
  .slip-title { gap: 5px; }
  .slip-title h2 { font-size: 17px; }
  .slip-title > span { font-size: 12px; padding: 3px 5px; }
  .chip-picker { margin-top: 16px; }
  .field-label { font-size: 12px; letter-spacing: .6px; }
  .chips { gap: 9px; margin-top: 12px; }
  .chip { width: 41px; height: 41px; padding: 3px; font-size: 13px; }
  .slip-picks { flex: 1 1 auto; min-height: 65px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--accent) var(--background2); padding: 14px 0 10px; }
  .slip-empty { min-height: 100%; justify-content: center; padding: 5px 0; }
  .slip-empty svg { width: 23px; height: 23px; margin-bottom: 9px; }
  .slip-empty strong { font-size: 12px; line-height: 1.45; }
  .slip-empty p { font-size: 12px; line-height: 1.45; margin-top: 5px; }
  .pick { grid-template-columns: 21px minmax(0, 1fr) auto 20px; gap: 5px; padding: 8px 0; }
  .pick-badge { width: 21px; height: 24px; font-size: 12px; }
  .pick-name { font-size: 12px; }
  .pick-odds { font-size: 12px; margin-top: 2px; }
  .pick-amount { font-size: 13px; }
  .pick-remove { width: 20px; height: 30px; padding: 2px; }
  .pick-remove svg { width: 14px; height: 14px; }
  .slip-divider { margin: 8px 0 12px; }
  .slip-total { font-size: 14px; }
  .slip-total > strong { font-size: 19px; }
  .slip-potential { margin-top: 8px; font-size: 12px; }
  .slip-potential > strong { font-size: 14px; }
  .bet-slip .start-button { padding: 12px; margin-top: 16px; font-size: 14px; }
  .clear-button { margin-top: 5px; padding: 6px; font-size: 12px; }
}

/* Size the game to the available desktop height; allow scrolling on shorter windows. */
@media (min-width: 1000px) and (min-height: 640px) {
  main { height: calc(100dvh - var(--header-height) - 24px); }
  .game-layout { height: 100%; }
}
@media (min-width: 1000px) and (max-height: 639px) {
  .game-layout { min-height: 540px; }
  .track-stage { min-height: 260px; }
  .slip-picks { max-height: 250px; }
}
@media (min-width: 1000px) and (max-width: 1190px) {
  .track-facts { gap: 6px; padding-right: 10px; }
  .track-facts > i { display: none; }
  .race-panel-header { padding-left: 10px; padding-right: 10px; gap: 7px; }
  .track-eyebrow { font-size: 12px; }
  .section-heading p { display: none; }
  .horse-card { padding-left: 8px; padding-right: 8px; column-gap: 6px; }
  .horse-name { font-size: 13px; }
}
@media (min-width: 1000px) and (max-width: 1190px) and (max-height: 720px) {
  .horse-form { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
