/* ==========================================================================
   INSIDE TRACK BETTING - GTA SAN ANDREAS THEME STYLESHEET
   ========================================================================== */

:root {
  --bg-cabinet: #0d0f12;
  --bg-crt-frame: #181d24;
  --bg-screen: #0a1118;
  --bg-card: rgba(14, 25, 38, 0.85);
  --bg-card-hover: rgba(22, 38, 58, 0.95);
  --border-neon: #1dd1a1;
  --border-subtle: #243447;
  --text-main: #f0f6fc;
  --text-muted: #8b9bb4;
  --gold: #feca57;
  --amber: #ff9f43;
  --neon-green: #10ac84;
  --neon-red: #ee5253;
  --neon-blue: #0abde3;
  --neon-pink: #ff6b6b;
  --neon-purple: #5f27cd;
  
  --font-pixel: 'Press Start 2P', monospace;
  --font-retro: 'VT323', monospace;
  --font-hud: 'Chakra Petch', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-cabinet);
  color: var(--text-main);
  font-family: var(--font-hud);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 14px;
  overflow-x: hidden;
}

/* ================= ARCADE CABINET & CRT EFFECT ================= */

.arcade-cabinet {
  width: 98vw;
  max-width: 1680px;
  min-height: 94vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 20%, #252b36 0%, #101318 100%);
  border-radius: 20px;
  padding: 14px;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    0 0 0 6px #12161f;
  position: relative;
}

.arcade-cabinet:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  border-radius: 0;
  padding: 8px;
}

.crt-screen {
  flex: 1;
  background: radial-gradient(ellipse at center, #0f1c29 0%, #05090f 100%);
  border-radius: 14px;
  border: 4px solid #1a2738;
  box-shadow: 
    inset 0 0 80px rgba(0, 0, 0, 0.85),
    0 0 20px rgba(16, 172, 132, 0.15);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* CRT Scanlines and curvature illusion */
.scanlines {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 99;
  opacity: 0.7;
}

.crt-glow {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle, rgba(16, 172, 132, 0.03) 0%, transparent 80%);
  pointer-events: none;
  z-index: 98;
}

/* ================= HEADER BANNER ================= */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: linear-gradient(180deg, #162436 0%, #0c1521 100%);
  border-bottom: 2px solid #203a56;
  position: relative;
  z-index: 10;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--gold);
}

.debug-badge {
  background: #ee5253;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  padding: 3px 6px;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(238, 82, 83, 0.7);
  animation: pulse-debug 1.2s infinite alternate;
}

@keyframes pulse-debug {
  0% { opacity: 0.7; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.04); }
}

/* ================= DEBUG MODE VISIBILITY ================= */

.debug-only {
  display: none !important;
}

body.debug-mode .debug-only {
  display: revert !important;
}

body.debug-mode .debug-only.flex {
  display: flex !important;
}

body.debug-mode .debug-only.grid {
  display: grid !important;
}

body.debug-mode .normal-only {
  display: none !important;
}

.arcade-pill {
  background: #243b55;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--gold);
}

.blinking-dot {
  width: 8px;
  height: 8px;
  background-color: var(--neon-red);
  border-radius: 50%;
  display: inline-block;
  animation: blink 1s infinite alternate;
}

@keyframes blink {
  0% { opacity: 0.2; }
  100% { opacity: 1; box-shadow: 0 0 8px var(--neon-red); }
}

.header-title {
  text-align: center;
}

.header-title h1 {
  font-family: var(--font-pixel);
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(29, 209, 161, 0.6), 2px 2px 0px #000;
  margin-bottom: 4px;
}

.header-title .subtitle {
  font-family: var(--font-retro);
  font-size: 1.15rem;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
}

.header-wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #09131e;
  border: 1px solid #1dd1a1;
  padding: 6px 14px;
  border-radius: 8px;
  box-shadow: inset 0 0 10px rgba(29, 209, 161, 0.2);
}

.wallet-label {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--text-muted);
}

.wallet-amount {
  font-family: var(--font-pixel);
  font-size: 1.05rem;
  color: #1dd1a1;
  text-shadow: 0 0 8px rgba(29, 209, 161, 0.8);
}

.btn-tiny {
  background: #254433;
  color: #1dd1a1;
  border: 1px solid #1dd1a1;
  padding: 3px 8px;
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tiny:hover {
  background: #1dd1a1;
  color: #000;
}

/* ================= MAIN STAGE & VIEWS ================= */

.game-stage {
  padding: 18px;
  min-height: 580px;
  position: relative;
  z-index: 10;
}

.view-panel {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= VIEW 1: BETTING / ODDS TABLE ================= */

.betting-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 22px;
}

.odds-board {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #1f344d;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.board-header h2 {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 1px;
}

.track-condition {
  font-family: var(--font-retro);
  font-size: 1.1rem;
  color: var(--neon-blue);
  letter-spacing: 1px;
}

.horses-table-wrapper {
  overflow-x: auto;
}

.horses-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.horses-table th {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--text-muted);
  padding: 10px 8px;
  border-bottom: 1px solid #20354b;
  letter-spacing: 0.5px;
}

.horses-table td {
  padding: 12px 8px;
  border-bottom: 1px solid #162436;
  font-size: 0.95rem;
  vertical-align: middle;
}

.horse-row {
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

.horse-row:hover {
  background-color: var(--bg-card-hover);
}

.horse-row.selected {
  background: linear-gradient(90deg, rgba(29, 209, 161, 0.18) 0%, rgba(29, 209, 161, 0.05) 100%);
  border-left: 4px solid var(--border-neon);
}

.horse-num-badge {
  display: inline-block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 6px;
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  font-weight: bold;
  color: #000;
}

.horse-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  vertical-align: middle;
}

.horse-name-cell {
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.weight-pill {
  background: #132435;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-retro);
  font-size: 1.15rem;
  color: var(--neon-blue);
  border: 1px solid #1f3d5c;
}

.odds-pill {
  background: #2a1f11;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  border: 1px solid #77511a;
}

.bet-badge {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: #1dd1a1;
}

.btn-select-horse {
  background: #1c334d;
  color: #fff;
  border: 1px solid #315885;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-select-horse:hover, .horse-row.selected .btn-select-horse {
  background: #1dd1a1;
  color: #000;
  border-color: #1dd1a1;
  box-shadow: 0 0 10px rgba(29, 209, 161, 0.5);
}

/* ================= BET CONTROL SIDEBAR ================= */

.bet-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
}

.panel-box h3 {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.selected-horse-card {
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #0d1824;
  border: 2px dashed #223852;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s;
}

.selected-horse-card.has-selection {
  border-style: solid;
  border-color: var(--border-neon);
  box-shadow: inset 0 0 15px rgba(29, 209, 161, 0.15);
}

.selected-horse-card.empty .prompt-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.sel-horse-name {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #fff;
  margin-bottom: 6px;
}

.sel-horse-meta {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Bet chips & inputs */
.quick-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chip {
  flex: 1;
  background: #1a2a3c;
  color: var(--gold);
  border: 1px solid #334d6c;
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  padding: 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: var(--gold);
  color: #000;
  box-shadow: 0 0 8px rgba(254, 202, 87, 0.5);
}

.custom-bet-input {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.currency-prefix {
  font-family: var(--font-pixel);
  color: #1dd1a1;
  font-size: 1rem;
}

.custom-bet-input input {
  flex: 1;
  background: #09121a;
  border: 1px solid #233a52;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
}

.custom-bet-input input:focus {
  border-color: #1dd1a1;
  box-shadow: 0 0 8px rgba(29, 209, 161, 0.3);
}

.btn-action {
  background: #1dd1a1;
  color: #000;
  border: none;
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  font-weight: bold;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover {
  background: #10ac84;
  box-shadow: 0 0 10px rgba(29, 209, 161, 0.5);
}

.payout-estimate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0b1520;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--gold);
  font-size: 0.85rem;
}

.highlight-payout {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: var(--gold);
}

/* Start button */
.action-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-start {
  width: 100%;
  background: linear-gradient(180deg, #1dd1a1 0%, #10ac84 100%);
  color: #071510;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(29, 209, 161, 0.4);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.btn-start small {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  letter-spacing: 1px;
  opacity: 0.85;
}

.btn-start:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(29, 209, 161, 0.6);
  background: linear-gradient(180deg, #38ef7d 0%, #11998e 100%);
}

.btn-start:disabled {
  background: #233140;
  color: #55677d;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  background: #142232;
  color: var(--text-muted);
  border: 1px solid #283e58;
  padding: 8px;
  border-radius: 6px;
  font-family: var(--font-hud);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  color: #fff;
  border-color: #436691;
  background: #1c2e42;
}

.btn-toggle-pace {
  width: 100%;
  background: #0f1c2a;
  border: 1px solid #1dd1a1;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-toggle-pace:hover {
  background: #172d45;
  box-shadow: 0 0 12px rgba(29, 209, 161, 0.35);
}

.pace-toggle-title {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.pace-mode-highlight {
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  color: var(--gold);
}

/* ================= VIEW 2: RACE TRACK ANIMATION ================= */

.race-hud {
  display: grid;
  grid-template-columns: 140px 1fr 1fr 120px;
  gap: 12px;
  margin-bottom: 12px;
}

.hud-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-label {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.time-counter {
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  color: var(--neon-blue);
}

.leader-name {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-horse-info {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #1dd1a1;
}

.dist-target {
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  color: var(--neon-blue);
}

.canvas-container {
  position: relative;
  width: 100%;
  background: #1c140b;
  border: 3px solid #2f3b4c;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}

#race-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.commentary-banner {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 14, 22, 0.88);
  border: 1px solid var(--border-neon);
  padding: 6px 18px;
  border-radius: 20px;
  font-family: var(--font-retro);
  font-size: 1.25rem;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

/* Minimap Overview */
.minimap-track {
  margin-top: 10px;
  background: #0c141e;
  border: 1px solid #1f334a;
  border-radius: 8px;
  padding: 8px 12px;
}

.minimap-distance-marks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-retro);
  font-size: 0.9rem;
  color: var(--text-muted);
  border-bottom: 1px dashed #20354c;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.finish-label {
  color: var(--gold);
  font-weight: bold;
}

.minimap-horses-lane {
  position: relative;
  height: 28px;
  background: #070d14;
  border-radius: 4px;
  overflow: hidden;
}

.minimap-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  font-weight: bold;
  color: #000;
  box-shadow: 0 0 6px rgba(0,0,0,0.8);
  transition: left 0.1s linear;
}

/* Live Telemetry */
.live-telemetry {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px;
}

.telemetry-title {
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  color: var(--neon-blue);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.tele-card {
  background: #0a131c;
  border: 1px solid #1c2e42;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.tele-card.user-horse {
  border-color: #1dd1a1;
  box-shadow: inset 0 0 10px rgba(29, 209, 161, 0.2);
}

.tele-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.tele-name {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.tele-rank {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--gold);
}

.tele-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tele-val {
  font-family: var(--font-retro);
  font-size: 1.05rem;
  color: #fff;
}

.tele-val.accent {
  color: var(--border-neon);
  font-weight: bold;
}

/* ================= VIEW 3: RESULTS SCREEN ================= */

.results-card {
  background: var(--bg-card);
  border: 2px solid var(--border-neon);
  border-radius: 14px;
  padding: 24px;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 0 40px rgba(29, 209, 161, 0.2);
}

.results-header {
  text-align: center;
  margin-bottom: 20px;
}

.results-header h2 {
  font-family: var(--font-pixel);
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.result-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.result-badge.win {
  background: rgba(29, 209, 161, 0.2);
  color: #1dd1a1;
  border: 2px solid #1dd1a1;
  box-shadow: 0 0 15px rgba(29, 209, 161, 0.5);
}

.result-badge.loss {
  background: rgba(238, 82, 83, 0.2);
  color: #ee5253;
  border: 2px solid #ee5253;
}

/* Podium */
.results-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 16px;
  margin: 24px 0;
}

.podium-item {
  width: 170px;
  text-align: center;
  border-radius: 10px 10px 0 0;
  padding: 12px 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.podium-item.first {
  height: 160px;
  background: linear-gradient(180deg, #594212 0%, #291e07 100%);
  border: 2px solid var(--gold);
}

.podium-item.second {
  height: 125px;
  background: linear-gradient(180deg, #324354 0%, #17202a 100%);
  border: 2px solid #718093;
}

.podium-item.third {
  height: 105px;
  background: linear-gradient(180deg, #442a19 0%, #20130b 100%);
  border: 2px solid #cd6133;
}

.podium-crown {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.podium-rank {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.podium-horse {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.podium-time {
  font-family: var(--font-retro);
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Results Table */
.results-table-box {
  margin-bottom: 18px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--text-muted);
  padding: 8px;
  border-bottom: 1px solid #233b54;
  text-align: left;
}

.results-table td {
  padding: 8px;
  border-bottom: 1px solid #162638;
  font-size: 0.9rem;
}

.payout-summary {
  background: #09131d;
  border: 1px solid #1e334a;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 18px;
  text-align: center;
  font-size: 1.05rem;
}

.payout-summary .amount-won {
  color: #1dd1a1;
  font-weight: bold;
  font-family: var(--font-pixel);
  font-size: 1.1rem;
}

.payout-summary .amount-lost {
  color: #ee5253;
  font-weight: bold;
  font-family: var(--font-pixel);
}

.results-actions {
  display: flex;
  justify-content: center;
}

/* ================= FOOTER ================= */

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #0c1520;
  border-top: 1px solid #1f334a;
  position: relative;
  z-index: 10;
}

.btn-pill {
  background: #172738;
  border: 1px solid #284463;
  color: var(--text-muted);
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pill:hover {
  background: #243e5c;
  color: #fff;
}

.footer-msg {
  font-family: var(--font-retro);
  font-size: 1.15rem;
  color: #5d7594;
  letter-spacing: 1px;
}

.crt-tag {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: #274360;
}

/* ================= MODAL CONFIG ================= */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 999;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: #121c27;
  border: 2px solid var(--border-neon);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  padding: 20px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #233b54;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: var(--gold);
}

.btn-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.config-global-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-field label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.config-field input {
  background: #09121a;
  border: 1px solid #284463;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  padding: 8px;
  border-radius: 4px;
}

.config-horses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 18px;
}

.config-horse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #09121c;
  padding: 8px 12px;
  border-radius: 6px;
}

.config-horse-row input {
  width: 90px;
  background: #142232;
  border: 1px solid #2b4566;
  color: #1dd1a1;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  padding: 4px 6px;
  border-radius: 4px;
  text-align: right;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ================= HISTORY BOARD & DYNAMIC HANDICAP ================= */

.history-board {
  margin-top: 18px;
  background: #09121c;
  border: 1px solid #1c2e42;
  border-radius: 10px;
  padding: 14px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1a2d40;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.history-header h3 {
  font-family: var(--font-pixel);
  font-size: 0.68rem;
  color: var(--gold);
  letter-spacing: 1px;
}

.history-tag {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--neon-blue);
  background: #102131;
  padding: 3px 8px;
  border-radius: 4px;
}

.race-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 14px;
}

.history-card {
  display: grid;
  grid-template-columns: 80px 1fr 140px 100px;
  align-items: center;
  background: #0d1927;
  border: 1px solid #1d334a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.history-card:hover {
  background: #122235;
  border-color: #2e537a;
}

.hist-race-id {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.hist-winner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.hist-podium-preview {
  display: flex;
  gap: 6px;
  font-family: var(--font-retro);
  font-size: 1rem;
  color: var(--text-muted);
}

.hist-bet-outcome {
  text-align: right;
  font-family: var(--font-pixel);
  font-size: 0.65rem;
}

.hist-bet-outcome.won {
  color: #1dd1a1;
}

.hist-bet-outcome.lost {
  color: #ee5253;
}

.hist-bet-outcome.none {
  color: var(--text-muted);
}

/* Weight delta indicators */
.delta-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.72rem;
  font-weight: bold;
  font-family: var(--font-hud);
}

.delta-badge.up {
  color: #ee5253; /* Red/Orange for heavier weight handicap */
}

.delta-badge.down {
  color: #1dd1a1; /* Green for lighter agile relief */
}

.wins-badge {
  background: #2b2311;
  color: var(--gold);
  border: 1px solid #634b17;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-pixel);
  font-size: 0.6rem;
}

/* Handicap Summary Box in Results */
.handicap-summary-box {
  background: #0a1420;
  border: 1px solid #233b54;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  text-align: left;
}

.handicap-summary-box h3 {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.handicap-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.handicap-chips-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.handicap-chip {
  background: #111e2d;
  border: 1px solid #1f3750;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: center;
}

.handicap-chip .h-name {
  font-weight: bold;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handicap-chip .h-delta {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
}

.handicap-chip .h-new {
  font-family: var(--font-retro);
  font-size: 1.05rem;
  color: #fff;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 960px) {
  .betting-layout {
    grid-template-columns: 1fr;
  }
  .race-hud {
    grid-template-columns: 1fr 1fr;
  }
  .telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .results-podium {
    flex-direction: column;
    align-items: center;
  }
  .podium-item {
    width: 100%;
    height: auto !important;
  }
  .history-card {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .handicap-chips-grid {
    grid-template-columns: 1fr 1fr;
  }
}
