body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE/Edge */
  touch-action: manipulation;
  -webkit-touch-callout: none; /* iOS Safari */
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.instructions {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  padding: 20px;
  border-radius: 8px;
  font-size: 18px;
  color: #fff;
  z-index: 100;
  max-width: 400px;
  text-align: center;
}

.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  display: none; /* Hide crosshair for third-person view */
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background-color: white;
}

.crosshair::before {
  top: 9px;
  left: 0;
  width: 20px;
  height: 2px;
}

.crosshair::after {
  top: 0;
  left: 9px;
  width: 2px;
  height: 20px;
}

#joystick-container {
  position: fixed;
  bottom: 50px;
  left: 20px;
  width: 150px;  
  height: 150px; 
  z-index: 1000;
  display: none; 
  touch-action: none;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

#jump-button {
  position: fixed;
  bottom: 50px;
  right: 20px;
  width: 80px;
  height: 80px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  display: none; 
  z-index: 1000;
  touch-action: none;
  text-align: center;
  line-height: 80px;
  font-weight: bold;
  color: #333;
  user-select: none;
}

#camera-controls {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.3);
  color: white;
  padding: 5px;
  border-radius: 5px;
  font-size: 12px;
  z-index: 100;
}

.player-name {
  position: absolute;
  font-size: 14px;
  color: white;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.chat-message {
  position: absolute;
  font-size: 14px;
  color: white;
  background-color: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translate(-50%, -100%);
  margin-top: -25px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 1100;
}

#chat-input-container {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 500px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  padding: 10px;
  display: none;
  z-index: 2000;
}

#chat-input {
  width: calc(100% - 30px);
  padding: 8px;
  border-radius: 4px;
  border: none;
  background-color: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 16px;
}

#chat-button {
  position: fixed;
  bottom: 50px;
  right: 20px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  font-weight: bold;
  color: #333;
  z-index: 1000;
  touch-action: none;
  cursor: pointer;
}

#close-chat {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
}

@keyframes warning-pulse {
    0% { background-color: rgba(255, 0, 0, 0); }
    50% { background-color: rgba(255, 0, 0, 0.2); }
    100% { background-color: rgba(255, 0, 0, 0); }
}

.vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(0,0,0,0) 30%, rgba(0,0,0,0.8) 100%);
  z-index: 99;
}

.warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    animation: warning-pulse 1s infinite;
    z-index: 100;
    display: none;
    background: radial-gradient(circle, rgba(255,0,0,0) 30%, rgba(255,0,0,0.3) 100%);
}

.game-ui {
  position: fixed;
  z-index: 1500;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  font-size: 24px;
  font-weight: bold;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 10px 20px;
  border-radius: 8px;
}

#timer {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

#game-message {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  text-align: center;
  display: none;
}

#restart-button {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  cursor: pointer;
  border: none;
  display: none;
}

#restart-button:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

@media (max-width: 768px) {
  #joystick-container {
    display: block;
  }
  
  #jump-button {
    bottom: 50px;
    right: 100px;
    display: block;
  }
  
  #chat-button {
     bottom: 50px;
     right: 20px;
     display: block;
  }
  
  .instructions {
    display: none !important; 
  }

  .game-ui {
    font-size: 18px;
    padding: 8px 15px;
  }

  #game-message {
    font-size: 28px;
  }
  
  #chat-input-container {
    width: 90%;
  }
}