body {
  margin: 0;
  overflow: hidden;
  font-family: "Arial", sans-serif;
  background-color: #74b9ff; /* Match the new sky color */
  cursor: crosshair;
  touch-action: none;
  width: 100%;
  height: 100%;
  position: fixed;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Homepage Styles */
#home-page, #login-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('../assets/images/homePageBackground.png') no-repeat center center;
  background-size: cover;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Login Page Styles */
#login-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.login-btn {
  background-color: #ffffff;
  color: #333;
  border: none;
  padding: 10px 20px;
  font-size: 16px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.login-icon {
  width: 20px;
  height: 20px;
  margin-right: 10px;
}

#google-login-btn {
  background-color: #ffffff;
  color: #333;
}

#guest-login-btn {
  background-color: #74b9ff;
  color: #fff;
}

#user-profile {
  text-align: center;
  padding: 15px;
  border-radius: 8px;
}

#user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 10px;
}

#user-name {
  font-size: 18px;
  margin-bottom: 15px;
  color: #ffffff;
}

.small-btn {
  background-color: #ff6b6b;
  color: white;
  border: none;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 15px;
  cursor: pointer;
  margin-top: 10px;
}

.title-container {
  background-color: rgba(0, 0, 0, 0.6);
  padding: 30px 50px;
  border-radius: 15px;
  text-align: center;
  color: white;
  max-width: 90%;
}

.title-container h1 {
  font-size: 48px;
  margin: 0 0 10px 0;
  color: #ffeaa7; /* Lighter yellow matching our new palette */
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.title-container h2 {
  font-size: 24px;
  margin: 0 0 30px 0;
  font-weight: normal;
  color: #ff9ff3; /* Pink color to match cherry blossoms */
}

.start-game-btn {
  background-color: #fdcb6e; /* Match bee color */
  color: #333;
  border: none;
  padding: 12px 30px;
  font-size: 20px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.start-game-btn:hover {
  background-color: #ffeaa7; /* Lighter yellow on hover */
  transform: scale(1.05);
}

.start-game-btn:active {
  transform: scale(0.98);
}

/* Multiplayer Toggle */
#multiplayer-toggle {
  margin: 15px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffeaa7;
}

#multiplayer-toggle label {
  margin-right: 10px;
  cursor: pointer;
}

#multiplayer-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

#player-welcome {
  color: #ffffff;
  margin-bottom: 15px;
  font-size: 18px;
}

#home-logout-btn {
  margin-top: 15px;
}

/* Game UI Styles */
#game-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none; /* Let clicks pass through to the canvas */
}

#ui-container {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 8px;
  font-size: 16px;
  z-index: 10;
  pointer-events: auto; /* Make the UI clickable */
}

#player-status {
  margin-top: 5px;
  font-size: 14px;
  color: #ffeaa7;
}

/* Player name update animation */
@keyframes nameHighlight {
  0% { color: inherit; }
  30% { color: #FFD700; text-shadow: 0 0 5px rgba(255, 215, 0, 0.8); }
  100% { color: inherit; }
}

.name-updated {
  animation: nameHighlight 1.5s ease-out;
}

#controls-info {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10;
  transition: opacity 1s ease-in-out;
  pointer-events: auto; /* Make the UI clickable */
}

#message-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  background-color: rgba(253, 203, 110, 0.9); /* Matching bee color */
  color: #333;
  border-radius: 10px;
  font-size: 18px;
  text-align: center;
  display: none; /* Hidden by default */
  z-index: 100;
  border: 2px solid #e17055; /* Orange border */
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  pointer-events: auto; /* Make the UI clickable */
}

#pointer-lock-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 10px;
  font-size: 20px;
  text-align: center;
  z-index: 101; /* Above message box */
  pointer-events: auto; /* Make the UI clickable */
}

#tilt-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 10px;
  font-size: 20px;
  text-align: center;
  z-index: 102; /* Above all other overlays */
  display: none;
  pointer-events: auto; /* Make the UI clickable */
}

#error-message {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: bold;
  z-index: 1000;
  display: none;
  max-width: 80%;
  text-align: center;
}

/* Mobile controls */
#mobile-buttons {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  display: none; /* Hidden by default, shown on mobile */
  pointer-events: auto;
}

#action-button {
  width: 80px;
  height: 80px;
  background-color: rgba(253, 203, 110, 0.8); /* Match bee color */
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: #333;
  font-size: 14px;
  border: 2px solid #e17055; /* Orange border */
  user-select: none;
  pointer-events: auto;
}

#mobile-height-controls {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: none; /* Hidden by default, shown on mobile */
  pointer-events: auto;
}

#height-up, #height-down {
  width: 60px;
  height: 60px;
  background-color: rgba(116, 185, 255, 0.8); /* Slightly more opaque sky blue */
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: white;
  font-size: 24px;
  margin: 15px 0; /* Increased vertical spacing */
  border: 3px solid rgba(255, 255, 255, 0.7); /* More visible border */
  user-select: none;
  pointer-events: auto;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); /* Add subtle shadow */
  transition: all 0.2s ease; /* Smooth transition for hover/active states */
  position: relative;
}

.control-hint {
  position: absolute;
  font-size: 10px;
  bottom: 8px;
  color: white;
  font-weight: bold;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}

#height-up:active, #height-down:active {
  transform: scale(0.95); /* Slight scale down effect when pressed */
  background-color: rgba(116, 185, 255, 0.9); /* Darker when pressed */
}

#joystick-left,
#joystick-right {
  position: absolute;
  bottom: 80px;
  width: 120px;
  height: 120px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  display: none; /* Hidden by default */
  touch-action: none;
  z-index: 10;
  pointer-events: auto; /* Make the joysticks accept touch events */
}

#joystick-left {
  left: 30px;
}

#joystick-right {
  right: 30px;
}

.joystick-knob {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  position: relative;
  top: 30px;
  left: 30px;
  pointer-events: none;
}

/* Desktop-specific styles */
.desktop-controls {
  display: none;
}

/* Mobile-specific styles */
.mobile-controls {
  display: none;
}

/* Ensure mobile controls are displayed when the mobile-device class is present */
body.mobile-device .mobile-controls {
  display: block !important;
}

body.mobile-device #joystick-left,
body.mobile-device #joystick-right,
body.mobile-device #mobile-buttons,
body.mobile-device #mobile-height-controls {
  display: block !important;
}

body.mobile-device .desktop-controls,
body.mobile-device #pointer-lock-info {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #controls-info {
    font-size: 12px;
    max-width: 150px;
    bottom: 90px;
  }
  #ui-container {
    font-size: 14px;
    padding: 8px;
    top: 5px;
    left: 5px;
  }
  #message-box {
    font-size: 16px;
    padding: 15px;
    max-width: 80%;
  }
  #pointer-lock-info {
    display: none !important; /* Never show on mobile */
  }
  
  /* Adjust height controls position for smaller screens */
  #mobile-height-controls {
    right: 15px; /* Move slightly closer to edge */
  }
  
  /* Make height control buttons smaller on very small screens */
  @media (max-width: 360px) {
    #height-up, #height-down {
      width: 50px;
      height: 50px;
      font-size: 20px;
    }
  }
  .mobile-controls {
    display: block !important;
  }
  #joystick-left,
  #joystick-right,
  #mobile-buttons,
  #mobile-height-controls {
    display: block; /* Show on mobile */
  }
  
  .title-container h1 {
    font-size: 36px;
  }
  
  .title-container h2 {
    font-size: 18px;
  }
  
  #start-game-btn {
    padding: 10px 20px;
    font-size: 18px;
  }
}

@media (min-width: 769px) {
  .desktop-controls {
    display: block !important;
  }
  #joystick-left,
  #joystick-right,
  #mobile-buttons,  #mobile-height-controls,
  .mobile-controls {
    display: none !important; /* Never show on desktop */
  }
}

/* Multiplayer Styles */
#leaderboard {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  padding: 10px;
  color: white;
  min-width: 200px;
  z-index: 100;
}

#leaderboard h3 {
  margin: 0 0 10px 0;
  text-align: center;
  font-size: 16px;
  color: #FFD700;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  padding: 3px 5px;
  border-radius: 4px;
}

.leaderboard-entry.current-player {
  background-color: rgba(255, 215, 0, 0.3);
  font-weight: bold;
}

.leaderboard-entry .rank {
  width: 20px;
  text-align: center;
}

.leaderboard-entry .name {
  flex-grow: 1;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-entry .score {
  text-align: right;
  font-weight: bold;
}

.multiplayer-indicator {
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 14px;
  padding: 5px 10px;
  border-radius: 15px;
  margin-top: 5px;
}

.status-connecting {
  background-color: rgba(255, 165, 0, 0.7);
  color: black;
  border: 1px solid orange;
}

.status-connected {
  background-color: rgba(0, 128, 0, 0.7);
  border: 1px solid green;
}