/* Custom Font Loading */
@font-face {
  font-family: 'GameFont';
  src: url('../assets/fonts/MBJ-Chunky.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap; /* Improves loading performance */
}

/* UI State Management */
.lobby-view .game-screen {
  display: none !important;
}

.game-view .lobby-screen {
  display: none !important;
}

.lobby-view {
  /* Lobby is visible by default */
}

.game-view {
  /* Game screen is visible, lobby is hidden */
}

body {
  margin: 0;
  padding: 10px;
  background: #222 url('../assets/images/background.jpg') center center fixed;
  background-size: cover;
  color: white;
  font-family: 'GameFont', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Add a semi-transparent overlay to ensure text readability */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: -1;
}

h1 {
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 2em;
  margin: 5px 0;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
  color: #fff;
}

#gameCanvas {
  border: 3px solid #fff;
  background: #333;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#gameInfo {
  margin: 5px 0;
  display: flex;
  gap: 15px;
  align-items: center;
  font-family: 'GameFont', Arial, sans-serif;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 15px;
  border-radius: 8px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  font-size: 14px;
}

/* Heads-up display above the board */
.hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 800px;
  margin-bottom: 8px;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
}

.hud-timer {
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}

.hud-timer.urgent {
  color: #ff4444;
}

.hud-mode {
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#playerList {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid #000;
  border-left-width: 4px;
  background: rgba(0, 0, 0, 0.75);
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.player-info.eliminated {
  opacity: 0.45;
}

.player-tag {
  font-size: 13px;
}

.player-you {
  font-size: 9px;
  color: #000;
  background: #ffd700;
  border-radius: 3px;
  padding: 1px 4px;
}

.player-pips {
  letter-spacing: 1px;
  color: #ffd700;
}

.player-score {
  font-variant-numeric: tabular-nums;
}

.player-stat {
  color: #9fd9ff;
  font-weight: normal;
}

.player-frozen {
  color: #00ffff;
}

.player-out {
  font-size: 9px;
  color: #ff6b6b;
}

#controls {
  margin: 5px 0;
  text-align: center;
  font-family: 'GameFont', Arial, sans-serif;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 15px;
  border-radius: 8px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  font-size: 12px;
}

button {
  padding: 6px 12px;
  margin: 3px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 11px;
  transition: all 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

button:hover {
  background: #45a049;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.control-hint {
  margin: 4px 0;
  font-size: 12px;
}

.control-hint.dim {
  color: #999;
  font-size: 11px;
}

.lobby-hint {
  margin: 10px 0 0;
  color: #8f8;
  font-size: 11px;
  line-height: 1.5;
}

.lobby-notice {
  color: #ffb347;
  font-size: 12px;
}

#connectionStatus {
  padding: 4px 8px;
  border-radius: 4px;
  margin: 3px;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 12px;
}

.connected {
  background: #4caf50;
}

.disconnected {
  background: #f44336;
}

/* Loading screen styles */
.loading-screen {
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 24px;
  text-align: center;
}

/* Multiplayer UI Styles */
.multiplayer-section {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #00ff00;
  border-radius: 8px;
  padding: 15px;
  margin: 10px 0;
  color: #ffffff;
  width: 100%;
  max-width: 800px;
}

.multiplayer-section h3 {
  color: #00ff00;
  margin: 0 0 10px 0;
  font-size: 16px;
  text-align: center;
}

.multiplayer-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.multiplayer-buttons button {
  flex: 1;
  min-width: 80px;
  padding: 8px 12px;
  background: linear-gradient(45deg, #ff6b35, #f7931e);
  color: white;
  border: none;
  border-radius: 4px;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.multiplayer-buttons button:hover {
  background: linear-gradient(45deg, #e55a2b, #e8841a);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.multiplayer-buttons button:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.room-info {
  background: rgba(0, 255, 0, 0.1);
  border: 1px solid #00ff00;
  border-radius: 4px;
  padding: 10px;
  margin: 10px 0;
  font-size: 12px;
}

.room-info p {
  margin: 5px 0;
  color: #ffffff;
}

.room-info span {
  color: #00ff00;
  font-weight: bold;
}

.join-room-input {
  display: flex;
  gap: 5px;
  margin: 10px 0;
  align-items: center;
}

.join-room-input input {
  flex: 1;
  padding: 8px;
  border: 1px solid #00ff00;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 12px;
  text-transform: uppercase;
}

.join-room-input input::placeholder {
  color: #888;
}

.join-room-input button {
  padding: 8px 12px;
  background: linear-gradient(45deg, #00ff00, #00cc00);
  color: #000;
  border: none;
  border-radius: 4px;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.join-room-input button:hover {
  background: linear-gradient(45deg, #00cc00, #009900);
  transform: translateY(-1px);
}

.join-room-input button:last-child {
  background: linear-gradient(45deg, #ff4444, #cc0000);
  color: white;
}

.join-room-input button:last-child:hover {
  background: linear-gradient(45deg, #cc0000, #990000);
}

#readyButton,
#startMultiplayerButton {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  background: linear-gradient(45deg, #00ff00, #00cc00);
  color: #000;
  border: none;
  border-radius: 4px;
  font-family: 'GameFont', Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

#readyButton:hover,
#startMultiplayerButton:hover {
  background: linear-gradient(45deg, #00cc00, #009900);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#startMultiplayerButton:disabled {
  background: #666;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 800px;
}

.status-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #00ff00;
  border-radius: 8px;
  padding: 10px 15px;
  color: #ffffff;
}

.status-info p {
  margin: 0;
  font-size: 14px;
}

#connectionStatus {
  color: #ff4444;
  font-weight: bold;
}

#connectionStatus.connected {
  color: #00ff00;
}

.single-player-section {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #ff9f1c;
  border-radius: 8px;
  padding: 15px;
  margin: 10px 0;
  width: 100%;
  max-width: 800px;
}

.single-player-section h3 {
  color: #ff9f1c;
  margin: 0 0 10px 0;
  font-size: 16px;
  text-align: center;
}

.single-player-buttons button {
  width: 100%;
  padding: 10px;
  background: linear-gradient(45deg, #ff9f1c, #ff7b00);
  color: #000;
  font-size: 13px;
  font-weight: bold;
}

.controls {
  margin-top: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 8px;
  padding: 10px 18px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .multiplayer-buttons {
    flex-direction: column;
  }

  .join-room-input {
    flex-direction: column;
    gap: 10px;
  }

  .join-room-input input {
    width: 100%;
  }
}
