.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-controls.active {
  pointer-events: auto;
}

.mobile-controls.paused {
  pointer-events: none;
}

.mobile-controls .look-zone {
  position: absolute;
  top: 0;
  right: 0;
  width: 52%;
  height: calc(100% - 110px);
  pointer-events: auto;
  touch-action: none;
  z-index: 1;
}

.mobile-controls .joystick-zone {
  position: absolute;
  left: max(20px, env(safe-area-inset-left, 20px));
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
  z-index: 5;
}

.mobile-controls .joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #2a2a2a;
  background: #000000;
  opacity: 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.mobile-controls .joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  border: 2px solid #3a3a3a;
  background: #000000;
  opacity: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  transition: transform 0.05s linear;
}

.mobile-controls .action-buttons {
  position: absolute;
  right: max(20px, env(safe-area-inset-right, 20px));
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  display: grid;
  grid-template-columns: repeat(3, 68px);
  gap: 12px;
  pointer-events: auto;
  z-index: 5;
}

.mobile-controls .action-btn {
  width: 68px;
  height: 68px;
  border: 2px solid #2a2a2a;
  border-radius: 50%;
  background: #000000;
  opacity: 1;
  color: #ffffff;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.mobile-controls .action-btn.pressed,
.mobile-controls .action-btn:active {
  background: #111111;
  border-color: #555555;
  transform: scale(0.95);
}

.mobile-controls .action-btn.fire,
.mobile-controls .action-btn.jump,
.mobile-controls .action-btn.weapon {
  background: #000000;
  border-color: #2a2a2a;
}

.mobile-controls .action-btn.fire.pressed,
.mobile-controls .action-btn.fire:active,
.mobile-controls .action-btn.jump.pressed,
.mobile-controls .action-btn.jump:active,
.mobile-controls .action-btn.weapon.pressed,
.mobile-controls .action-btn.weapon:active {
  background: #111111;
  border-color: #555555;
}

.mobile-controls .hint-bar {
  display: none;
}

@media (orientation: landscape) {
  .mobile-controls .look-zone {
    width: 48%;
    height: calc(100% - 96px);
  }

  .mobile-controls .joystick-zone {
    width: 130px;
    height: 130px;
    left: max(16px, env(safe-area-inset-left, 16px));
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }

  .mobile-controls .joystick-knob {
    width: 52px;
    height: 52px;
    margin-left: -26px;
    margin-top: -26px;
  }

  .mobile-controls .action-buttons {
    grid-template-columns: repeat(3, 64px);
    gap: 10px;
    right: max(16px, env(safe-area-inset-right, 16px));
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }

  .mobile-controls .action-btn {
    width: 64px;
    height: 64px;
    font-size: 11px;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  .mobile-controls .joystick-zone {
    width: 120px;
    height: 120px;
  }

  .mobile-controls .joystick-knob {
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
  }

  .mobile-controls .action-buttons {
    grid-template-columns: repeat(3, 58px);
    gap: 10px;
  }

  .mobile-controls .action-btn {
    width: 58px;
    height: 58px;
    font-size: 11px;
  }
}

#gameShell.active #canvas {
  z-index: 1;
}

body.mobile-playing {
  touch-action: none;
  overscroll-behavior: none;
}

body.mobile-playing #gameShell.active #canvas {
  touch-action: none;
  pointer-events: none;
}

body.mobile-playing #fullscreenBtn {
  display: none;
}

body.mobile-playing #mobileMenuBtn.visible {
  display: inline-flex;
}
