/* ============================================
   ASCII DERBY - Horse Racing Game Styles
   ============================================ */

:root {
  --bg-primary: #080B12;
  --bg-secondary: #0D1117;
  --bg-card: #131A24;
  --bg-track: #0A0E16;
  --accent-primary: #FFD600;
  --accent-secondary: #ef4444;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.10);
  --glow-gold: 0 4px 0 rgba(255, 214, 0, 0.3);
  --glow-green: 0 4px 0 rgba(34, 197, 94, 0.3);
  --radius: 10px;
  --radius-sm: 6px;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-display: 'JetBrains Mono', 'Courier New', monospace;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-display);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: none;
}

.app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 60vh;
}

/* ---- Race focus: dim non-track elements ---- */
.race-dimmed {
  opacity: 0.35;
  filter: blur(1.5px);
  pointer-events: none;
  transition: opacity 0.5s ease, filter 0.5s ease;
}

.betting-panel,
.stats-bar {
  transition: opacity 0.5s ease, filter 0.5s ease;
}

/* ---- Header ---- */
.header {
  text-align: center;
  padding: 30px 0 20px;
  position: relative;
}

.header-glow {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 120px;
  background: none;
  pointer-events: none;
}

.title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.title-text {
  background: linear-gradient(135deg, #FFD600, #FFC107);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: none;
}

.title-icon {
  font-size: 2rem;
  animation: bounce 2s ease-in-out infinite;
}

.title-icon:last-child {
  animation-delay: 0.3s;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 6px;
  letter-spacing: 2px;
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.3s;
}

.stat:hover {
  border-color: rgba(255, 214, 0, 0.3);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* ---- Betting Panel ---- */
.betting-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.horse-selection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.horse-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
}

.horse-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.horse-card.selected {
  border-color: var(--accent-primary);
  box-shadow: var(--glow-gold);
  background: rgba(255, 214, 0, 0.06);
}

.horse-card-emoji {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.horse-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.horse-card-odds {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.horse-card-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 4px;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.horse-card-stats span {
  display: flex;
  align-items: center;
  gap: 1px;
}

.horse-card-condition {
  font-size: 0.65rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.result-odds {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Bet Amount ---- */
.bet-amount {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.bet-amount label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.bet-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bet-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.bet-btn:hover {
  border-color: var(--accent-primary);
}

.bet-btn.active {
  background: rgba(255, 214, 0, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ---- Start Button ---- */
.start-btn {
  width: 100%;
  padding: 14px;
  background: #FFD600;
  border: 2px solid #FFD600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(255, 214, 0, 0.5);
}

.start-btn:active {
  transform: translateY(0);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-text {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: #080B12;
  letter-spacing: 2px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.btn-glow {
  display: none;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

/* ---- Track ---- */
.track-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.track-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.track-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.track-lap {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-primary);
}

.track {
  position: relative;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  background: var(--bg-track);
  overflow-x: auto;
}

.racing .track {
  animation: trackPulse 2s ease-in-out infinite;
}

@keyframes trackPulse {

  0%,
  100% {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.01);
  }

  50% {
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.04);
  }
}

/* ---- Lane ---- */
.lane {
  position: relative;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  white-space: nowrap;
  height: 64px;
  overflow-y: visible;
}

.lane.my-horse {
  background: rgba(255, 214, 0, 0.05);
  border-left: 2px solid rgba(255, 214, 0, 0.6);
}

.lane.my-horse .lane-number {
  font-size: 1.1rem;
  color: var(--accent-primary);
}

.lane:last-child {
  border-bottom: none;
}

.lane-number {
  width: 24px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
}

.lane-track {
  flex: 1;
  position: relative;
  height: 100%;
  overflow-x: hidden;
  overflow-y: visible;
}

.lane-scenery {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.05;
  color: rgba(255, 255, 255, 0.10);
  pointer-events: none;
  will-change: transform;
  user-select: none;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
}

.lane-ground {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 20px;
  height: 1px;
  background: repeating-linear-gradient(90deg,
      rgba(255, 255, 255, 0.08) 0px,
      rgba(255, 255, 255, 0.08) 4px,
      transparent 4px,
      transparent 8px);
}

.horse-sprite {
  position: absolute;
  left: 0;
  bottom: 8px;
  transition: none;
  color: var(--horse-color, #FFD600);
  text-shadow: 0 0 4px var(--horse-color, rgba(255, 214, 0, 0.4));
  filter: drop-shadow(0 0 2px var(--horse-color, rgba(255, 214, 0, 0.3)));
}

.horse-sprite pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.1;
}

.track-finish-line {
  position: absolute;
  right: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  z-index: 2;
  pointer-events: none;
}

.lane-name {
  position: absolute;
  left: 30px;
  top: 2px;
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  opacity: 0.5;
}

/* ---- Results ---- */
.results-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  animation: fadeIn 0.5s ease;
}

.results-panel.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-title {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.result-item.winner {
  border-color: var(--accent-primary);
  background: rgba(255, 214, 0, 0.06);
  box-shadow: var(--glow-gold);
}

.result-pos {
  font-weight: 700;
  font-size: 1rem;
  width: 28px;
  text-align: center;
}

.result-name {
  flex: 1;
  font-weight: 600;
}

.result-time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.results-bet {
  text-align: center;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 16px;
}

.results-bet.win {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--accent-green);
}

.results-bet.lose {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-secondary);
}

/* ---- Racing animation ---- */
.racing .horse-sprite {
  animation: gallop 0.3s steps(2) infinite;
}

@keyframes gallop {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-1px);
  }

  100% {
    transform: translateY(0);
  }
}

/* ---- Dust particles ---- */
.dust {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  pointer-events: none;
  animation: dustFade 0.6s ease-out forwards;
}

@keyframes dustFade {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-15px, -8px) scale(0);
  }
}

/* ---- Confetti ---- */
.confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 100;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .title {
    font-size: 1.6rem;
    gap: 8px;
  }

  .title-icon {
    font-size: 1.3rem;
  }

  .subtitle {
    font-size: 0.75rem;
  }

  .track-label {
    display: none;
  }

  .stats-bar {
    gap: 8px;
  }

  .stat {
    padding: 8px 10px;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .horse-selection {
    grid-template-columns: repeat(2, 1fr);
  }

  .track {
    font-size: 10px;
    padding: 10px;
  }

  .horse-sprite pre {
    font-size: 9px;
  }
}