body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background: #2c3e50;
  color: white;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: none;
  margin: 0 auto;
  padding: 5px;
  width: 99vw;
}

.betting-panel {
  background: #34495e;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 5px;
}

.bet-controls {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.balance {
  font-size: 1.1em;
  font-weight: bold;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 5px;
  white-space: nowrap;
}

select, input, button {
  padding: 6px;
  font-size: 0.9em;
  border-radius: 5px;
  border: none;
  flex: 1;
  min-width: 80px;
}

#horseSelect {
  flex: 2;
}

#betAmount {
  flex: 1;
  min-width: 60px;
}

#placeBet {
  background: #27ae60;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

#placeBet:hover {
  background: #219a52;
}

#placeBet:disabled {
  background: #95a5a6;
  cursor: not-allowed;
}

.status-panel {
  background: #34495e;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.countdown-timer {
  font-size: 1.1em;
  font-weight: bold;
  color: #2ecc71;
  text-align: center;
}

.results-display {
  text-align: center;
}

.results-display h3 {
  margin: 5px 0;
  font-size: 1.2em;
}

.results-display p {
  margin: 5px 0;
  font-size: 1em;
}

.all-bets-list {
  text-align: left;
  padding: 5px;
  background: rgba(0,0,0,0.2);
  border-radius: 5px;
  font-size: 0.9em;
}

.all-bets-list h3 {
  margin-top: 0;
  margin-bottom: 5px;
  color: #bdc3c7;
  font-size: 1em;
}

.bet {
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.1);
  display: flex; 
  align-items: center; 
}

.bet .player-info {
    display: flex;
    align-items: center;
    flex-grow: 1; 
    margin-right: 10px; 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bet .player-avatar {
    width: 20px; 
    height: 20px;
    border-radius: 50%;
    margin-right: 5px;
    background: #555; 
    flex-shrink: 0; 
}

.bet strong {
  color: #ecf0f1;
  flex-shrink: 0; 
}

.race-track {
  background: #95a5a6;
  flex: 1;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  margin: 0 auto;
  width: 99%;
}

.lanes {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.lane {
  flex: 1;
  border-bottom: 2px dashed white;
  position: relative;
  display: flex;
  align-items: center;
}

.horse {
  width: 80px;
  height: 80%;
  position: absolute;
  left: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: left 0.05s linear;
  image-rendering: pixelated;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: brightness(1.2);
}

.horse-number {
  position: absolute;
  left: -15px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px;
  font-weight: bold;
  font-size: 12px;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
}

.galloping {
  animation: gallop 0.3s infinite;
}

@keyframes gallop {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.finish-line {
  position: absolute;
  right: 150px;
  top: 0;
  bottom: 0;
  width: 5px;
  background: white;
  z-index: 1;
}

/* Hide the start race button */
#startRace {
  display: none;
}

.horse-position-label {
  position: absolute;
  top: 50%;
  left: -60px;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.horse-position-label.visible {
  opacity: 1;
}

.horse-position-label.first {
  background: #2ecc71;
  color: black;
  font-weight: bold;
}

.horse-position-label.second {
  background: #f39c12;
  color: black;
  font-weight: bold;
}

.horse-position-label.third {
  background: #f1c40f;
  color: black;
  font-weight: bold;
}

.bet-overlay {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 350px;
  max-height: 40vh;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 8px;
  padding: 10px;
  overflow-y: auto;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.bet-overlay.visible {
  pointer-events: auto;
  opacity: 1;
}

.results-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  max-height: 80vh;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 8px;
  padding: 15px;
  overflow-y: auto;
  z-index: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  text-align: center;
}

.results-overlay.visible {
  pointer-events: auto;
  opacity: 1;
}

.race-results-list {
  text-align: left;
}

.race-results-list h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #f39c12;
  font-size: 1.2em;
  text-align: center;
}

.player-result {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255,255,255,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-result:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.player-result .player-info {
    display: flex;
    align-items: center;
    flex-grow: 1; 
    margin-right: 10px; 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-result .player-avatar {
    width: 30px; 
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
    background: #555; 
    flex-shrink: 0; 
}

.player-result strong {
  color: #ecf0f1;
}

.player-result span {
  font-weight: bold;
  color: #2ecc71;
  white-space: nowrap;
  flex-shrink: 0; 
}

.message-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.message-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.message-content {
  background: #34495e;
  color: white;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  max-width: 300px;
  width: 90%;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.message-content p {
  margin-bottom: 15px;
  font-size: 1.1em;
}

#messageOkButton {
  padding: 8px 15px;
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
}

#messageOkButton:hover {
  background: #219a52;
}

@media (max-width: 768px) {
  .bet-controls {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  select, input, button {
    flex: 1 1 auto;
    min-width: unset;
  }

  #horseSelect {
    flex: 1 1 100%;
  }

  #betAmount {
    flex: 1 1 100px;
  }

  #placeBet, #startRace {
    flex: 1 1 100px;
  }

  .horse {
    width: 60px;
  }

  .finish-line {
    right: 80px;
  }

  .bet-overlay {
    width: 250px;
    max-height: 30vh;
    bottom: 5px;
    right: 5px;
    padding: 8px;
  }

  .results-overlay {
    width: 250px;
    padding: 10px;
  }

  .race-results-list h3 {
    font-size: 1em;
  }

  .player-result strong {
    font-size: 0.9em;
  }

  .player-result span {
    font-size: 0.9em;
  }

  .message-content {
    padding: 15px;
  }

  .message-content p {
    font-size: 1em;
  }
}