/* Mundo Abierto 3D - estilos base */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* El canvas ocupa toda la pantalla y se escala a cualquier resolución */
#game {
  display: none;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

/* --- Pantalla de inicio (multijugador) --- */
#start-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #3a5f7a, #2c4a61);
}

#start-screen.hidden {
  display: none;
}

#start-screen .panel {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  padding: 28px 32px;
  width: min(340px, 90vw);
  text-align: center;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#start-screen .panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

#start-screen .panel p {
  margin: 0 0 18px;
  opacity: 0.9;
}

#start-screen label {
  display: block;
  text-align: left;
  font-size: 13px;
  margin-bottom: 6px;
  opacity: 0.9;
}

#start-screen input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  outline: none;
}

#start-screen input:focus {
  border-color: #fff;
}

#start-btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: #2f9e5f;
  color: #fff;
  cursor: pointer;
}

#start-btn:hover:not(:disabled) {
  background: #35b46d;
}

#start-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

#status-msg {
  margin-top: 12px;
  min-height: 18px;
  font-size: 14px;
}

#status-msg.error {
  color: #ffb3b3;
}

/* Instrucciones superpuestas (no bloquean el input) */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 14px;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
  font-size: 14px;
  line-height: 1.5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

#hud h1 {
  margin: 0;
  font-size: 16px;
}

#hud p {
  margin: 2px 0 0;
  opacity: 0.9;
}

/* Mensaje de error (si WebGL no está disponible) — solo se muestra con texto */
#error {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ff6b6b;
  background: rgba(0, 0, 0, 0.8);
  padding: 12px 18px;
  border-radius: 8px;
  z-index: 20;
  max-width: 80%;
  text-align: center;
}

#error:not(:empty) {
  display: block;
}

/* --- Joystick táctil (inferior izquierda, solo dispositivos táctiles) --- */
#touch-ui {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  pointer-events: none;
}

#touch-ui.active {
  display: block;
}

#joystick {
  position: absolute;
  left: 0;
  top: 0;
  width: 132px;
  height: 132px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  will-change: transform;
}