* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
}

#game-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: 'Segoe UI', Arial, sans-serif;
}

#hud.hidden { display: none; }

/* HUD Icons */
.hud-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Bottom left: Health + Fuel */
#hud-bottom-left {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-bar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

#hud-health {
  width: 180px;
  height: 14px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.hud-bar-group:first-child .hud-icon {
  color: #e44;
}

#health-bar {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, #e44 0%, #f66 100%);
  transition: width 0.2s ease, background 0.3s;
  box-shadow: 0 0 8px rgba(255,60,60,0.3);
}

#health-bar.medium {
  background: linear-gradient(90deg, #c90 0%, #eb0 100%);
  box-shadow: 0 0 8px rgba(220,180,0,0.3);
}

#health-bar.low {
  background: linear-gradient(90deg, #c22 0%, #e33 100%);
  box-shadow: 0 0 12px rgba(255,30,30,0.5);
  animation: healthPulse 0.8s ease-in-out infinite;
}

@keyframes healthPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#health-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: bold;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  line-height: 1;
}

#hud-fuel {
  width: 140px;
  height: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}

.fuel-icon {
  color: #4af;
}

#fuel-bar {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #28f 0%, #4af 100%);
  transition: width 0.15s ease;
  box-shadow: 0 0 6px rgba(60,150,255,0.3);
}

/* Bottom right: Ammo */
#hud-bottom-right {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 8px;
}

#hud-ammo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 18px 10px 6px;
  width: fit-content;
  margin-left: auto;
}

#weapon-name {
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}

.ammo-icon {
  width: 20px;
  height: 20px;
}

#ammo-numbers {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

#ammo-current {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 8px rgba(255,170,60,0.3);
  min-width: 28px;
  text-align: right;
}

#ammo-current.low {
  color: #f44;
  text-shadow: 0 0 8px rgba(255,60,60,0.4);
  animation: healthPulse 0.8s ease-in-out infinite;
}

#ammo-divider {
  font-size: 14px;
  color: #444;
  margin: 0 1px;
}

#ammo-reserve {
  font-size: 13px;
  color: #666;
}

/* Reload bar */
#reload-bar {
  position: relative;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: visible;
}
#reload-bar.hidden { display: none; }
#reload-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #fa4, #ffcc00);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255,170,68,0.6);
}
#reload-text {
  position: absolute;
  top: -14px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #fa4;
  letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(255,170,68,0.5);
  animation: reload-blink 0.6s ease-in-out infinite;
}
@keyframes reload-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Mine counter */
#hud-mine-info {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.12);
}

.mine-icon {
  width: 16px;
  height: 16px;
  color: #ff6644;
  opacity: 0.7;
}

#mine-key {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 1px;
}

#mine-count {
  font-size: 18px;
  font-weight: 800;
  color: #ff6644;
  text-shadow: 0 0 8px rgba(255,100,60,0.3);
  min-width: 16px;
  text-align: center;
}

#mine-count.empty {
  color: #555;
  text-shadow: none;
}

/* Leaderboard (top-left) */
#hud-leaderboard {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 150px;
  backdrop-filter: blur(6px);
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  animation: lbSlideIn 0.3s ease;
}

.lb-row + .lb-row {
  border-top: 1px solid rgba(255,255,255,0.06);
}

@keyframes lbSlideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.lb-rank {
  font-weight: 700;
  font-size: 11px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: rgba(255,255,255,0.4);
}

.lb-name {
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90px;
}

.lb-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lb-stat {
  display: flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.lb-stat-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.5;
}

.lb-kills-icon { color: rgba(255,255,255,0.5); }
.lb-deaths-icon { color: rgba(255,255,255,0.35); }
.lb-kills-val { color: rgba(255,255,255,0.6); font-weight: 600; min-width: 14px; text-align: right; }
.lb-deaths-val { color: rgba(255,255,255,0.4); font-weight: 600; min-width: 14px; text-align: right; }

/* Killfeed */
#hud-killfeed {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.kill-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  animation: killSlideIn 0.3s ease;
  white-space: nowrap;
}

@keyframes killSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.kill-entry .killer {
  color: #6f6;
  font-weight: 600;
}

.kill-entry .kill-icon {
  width: 14px;
  height: 14px;
  color: #f44;
  flex-shrink: 0;
}

.kill-entry .victim {
  color: #f66;
  font-weight: 600;
}

/* Alone popup */
#alone-popup {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  animation: popupFade 3s ease forwards;
  pointer-events: none;
  z-index: 5;
}

@keyframes popupFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Lobby */
#lobby {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

/* Background image layer */
#lobby-bg {
  position: absolute;
  inset: 0;
  background: url('assets/images/background.jpg') center center / cover no-repeat;
  filter: blur(3px) brightness(0.45);
  transform: scale(1.05);
  animation: bgSlowZoom 25s ease-in-out infinite alternate;
}

@keyframes bgSlowZoom {
  0% { transform: scale(1.05); }
  100% { transform: scale(1.12); }
}

/* Overlay layers */
#lobby-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(255,50,50,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.65) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
}

/* Scan lines for tactical feel */
#lobby-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  opacity: 0.5;
}

/* Floating particles container */
#lobby-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.lobby-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFloat linear infinite;
  opacity: 0;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0);
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-100vh) translateX(30px);
  }
}

/* Vignette */
#lobby-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 150px 60px rgba(0,0,0,0.7);
  pointer-events: none;
}

#lobby-panel {
  width: 460px;
  text-align: center;
  position: relative;
  z-index: 2;
  background: rgba(10, 10, 15, 0.65);
  border: 1px solid rgba(255, 68, 68, 0.15);
  border-radius: 16px;
  padding: 40px 36px 32px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 40px rgba(0,0,0,0.5),
    0 0 80px rgba(255,50,50,0.04),
    inset 0 1px 0 rgba(255,255,255,0.05);
  animation: panelEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes panelEntrance {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#lobby h1 {
  font-size: 46px;
  letter-spacing: 10px;
  margin-bottom: 4px;
  color: #ff4444;
  text-shadow:
    0 0 20px rgba(255,60,60,0.6),
    0 0 40px rgba(255,40,40,0.3),
    0 0 80px rgba(255,30,30,0.15),
    0 2px 4px rgba(0,0,0,0.5);
  font-weight: 900;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0% {
    text-shadow:
      0 0 20px rgba(255,60,60,0.6),
      0 0 40px rgba(255,40,40,0.3),
      0 0 80px rgba(255,30,30,0.15),
      0 2px 4px rgba(0,0,0,0.5);
    filter: brightness(1);
  }
  100% {
    text-shadow:
      0 0 30px rgba(255,60,60,0.8),
      0 0 60px rgba(255,40,40,0.4),
      0 0 100px rgba(255,30,30,0.2),
      0 2px 4px rgba(0,0,0,0.5);
    filter: brightness(1.1);
  }
}

#lobby-subtitle {
  font-size: 11px;
  letter-spacing: 6px;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}

.hidden { display: none !important; }

/* Step: Name */
#step-name {
  margin-top: 28px;
}

.step-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 14px;
  text-transform: uppercase;
  font-weight: 600;
}

#name-input-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 16px;
}

#player-name {
  padding: 12px 16px;
  font-size: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  text-align: center;
  outline: none;
  width: 260px;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}

#player-name:focus {
  border-color: rgba(255,68,68,0.6);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 20px rgba(255,68,68,0.1);
}

#player-name::placeholder {
  color: rgba(255,255,255,0.2);
}

#btn-random-name {
  padding: 0 14px;
  font-size: 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #aaa;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s, background 0.3s, transform 0.15s;
  line-height: 1;
}

#btn-random-name:hover {
  border-color: rgba(255,68,68,0.5);
  color: #fff;
  background: rgba(255,68,68,0.1);
  transform: scale(1.05);
}

#btn-random-name:active {
  transform: scale(0.95);
}

#btn-confirm-name {
  padding: 12px 52px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #c33 0%, #e44 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

#btn-confirm-name::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

#btn-confirm-name:hover:not(:disabled)::before {
  transform: translateX(100%);
}

#btn-confirm-name:hover:not(:disabled) {
  background: linear-gradient(135deg, #d44 0%, #f55 100%);
  box-shadow: 0 0 30px rgba(255,68,68,0.3), 0 4px 15px rgba(0,0,0,0.3);
  transform: translateY(-1px);
}

#btn-confirm-name:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 0 15px rgba(255,68,68,0.2);
}

#btn-confirm-name:disabled {
  opacity: 0.25;
  cursor: default;
  filter: grayscale(0.5);
}

/* Step: Rooms */
#step-rooms {
  margin-top: 24px;
  animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#player-greeting {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 20px;
}

#greeting-name {
  color: #f44;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(255,68,68,0.3);
}

#btn-change-name {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  margin-left: 6px;
  transition: color 0.2s;
}

#btn-change-name:hover {
  color: rgba(255,255,255,0.6);
}

/* Room Browser */
#room-browser {
  width: 100%;
  text-align: left;
}

#room-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
}

#room-list-header span {
  font-size: 11px;
  letter-spacing: 4px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
}

#btn-refresh {
  width: 30px;
  height: 30px;
  font-size: 16px;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#btn-refresh:hover {
  border-color: rgba(255,68,68,0.4);
  color: #fff;
  background: rgba(255,68,68,0.1);
  transform: rotate(180deg);
}

#room-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}

.room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.room-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #f44;
  transition: width 0.2s;
  border-radius: 0 2px 2px 0;
}

.room-row:hover {
  background: rgba(255, 68, 68, 0.08);
}

.room-row:hover::before {
  width: 3px;
}

.room-row:last-child {
  border-bottom: none;
}

.room-row.room-active {
  background: rgba(76, 175, 80, 0.08);
  border-bottom-color: rgba(76, 175, 80, 0.12);
}

.room-row.room-active::before {
  width: 3px;
  background: #4caf50;
}

.room-row.room-active:hover {
  background: rgba(76, 175, 80, 0.16);
}

.room-row.room-active:hover::before {
  width: 3px;
  background: #4caf50;
}

.room-row.room-full {
  opacity: 0.3;
  cursor: default;
}

.room-row.room-full:hover {
  background: none;
}

.room-row.room-full:hover::before {
  width: 0;
}

.room-name {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

.room-row.room-active .room-name {
  color: rgba(255,255,255,0.95);
}

.room-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.room-players {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.room-players.active {
  color: #4caf50;
  font-weight: 700;
}

.room-players.full {
  color: #f44;
}

#room-list-empty {
  padding: 28px;
  text-align: center;
  color: rgba(255,255,255,0.2);
  font-size: 13px;
}

#room-create {
  display: flex;
  gap: 6px;
  margin-top: 20px;
}

#room-name {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #fff;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#room-name::placeholder {
  color: rgba(255,255,255,0.2);
}

#room-name:focus {
  border-color: rgba(255,68,68,0.5);
  box-shadow: 0 0 15px rgba(255,68,68,0.08);
}

#btn-create-room {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #c33 0%, #e44 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

#btn-create-room:hover {
  background: linear-gradient(135deg, #d44 0%, #f55 100%);
  box-shadow: 0 0 20px rgba(255,68,68,0.25);
  transform: translateY(-1px);
}

#btn-create-room:active {
  transform: translateY(1px);
}

#room-list::-webkit-scrollbar {
  width: 4px;
}

#room-list::-webkit-scrollbar-track {
  background: transparent;
}

#room-list::-webkit-scrollbar-thumb {
  background: rgba(255,68,68,0.2);
  border-radius: 2px;
}

#room-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,68,68,0.4);
}

/* Status */
#lobby-status {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  min-height: 20px;
}

#lobby-status.error {
  color: #f44;
  text-shadow: 0 0 10px rgba(255,68,68,0.3);
}

/* Controls */
#controls-info {
  margin-top: 24px;
  font-size: 12px;
  color: rgba(255,255,255,0.25);
  line-height: 2;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 16px;
}

#controls-info b {
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Mobile desktop hint */
#mobile-hint {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  animation: mobileHintFade 5s ease forwards;
}

@keyframes mobileHintFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================
   TOUCH CONTROLS (mobile/tablet)
   ============================ */

#touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

/* --- Virtual Joystick --- */
#touch-joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40%;
  height: 60%;
  pointer-events: auto;
  touch-action: none;
}

#touch-joystick-hint {
  position: absolute;
  left: 60px;
  bottom: 80px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,0.1);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s;
}

#touch-joystick-zone:active #touch-joystick-hint,
#touch-joystick-base.active ~ #touch-joystick-hint {
  opacity: 0;
}

#touch-joystick-base {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
}

#touch-joystick-base.active {
  display: block;
}

#touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.35);
  transition: background 0.1s;
}

/* --- Touch Buttons --- */
#touch-buttons {
  position: absolute;
  right: 16px;
  bottom: 80px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
  touch-action: none;
}

.touch-btn {
  border: none;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: transform 0.08s, background 0.08s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.touch-btn.active {
  transform: scale(0.92);
}

/* Fire button - large red */
.touch-btn-large {
  width: 76px;
  height: 76px;
  font-size: 13px;
  background: rgba(220, 50, 50, 0.45);
  border: 2px solid rgba(255, 80, 80, 0.5);
  box-shadow: 0 0 20px rgba(255, 50, 50, 0.2);
}
.touch-btn-large.active {
  background: rgba(255, 60, 60, 0.7);
  box-shadow: 0 0 30px rgba(255, 50, 50, 0.5);
}

/* Jump / Jet - medium */
.touch-btn-medium {
  width: 56px;
  height: 56px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
}
.touch-btn-medium.active {
  background: rgba(255, 255, 255, 0.3);
}

/* Reload / Mine - small */
.touch-btn-small {
  width: 42px;
  height: 42px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.touch-btn-small.active {
  background: rgba(255, 255, 255, 0.25);
}

/* Layout: Fire bottom-right, Jump and Jet above, Reload and Mine top row */
#touch-buttons {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto auto;
  gap: 8px;
  align-items: end;
  justify-items: center;
}

#touch-btn-reload {
  grid-column: 1;
  grid-row: 1;
}
#touch-btn-mine {
  grid-column: 2;
  grid-row: 1;
}
#touch-btn-jet {
  grid-column: 1;
  grid-row: 2;
}
#touch-btn-jump {
  grid-column: 2;
  grid-row: 2;
}
#touch-btn-fire {
  grid-column: 1 / span 2;
  grid-row: 3;
  justify-self: center;
}

/* ============================
   RESPONSIVE / MOBILE STYLES
   ============================ */

/* Mobile: adjust HUD positioning to avoid touch controls overlap */
@media (pointer: coarse), (max-width: 768px) {
  /* Lobby panel responsive */
  #lobby-panel {
    width: 92vw;
    max-width: 460px;
    padding: 28px 20px 24px;
  }

  #lobby h1 {
    font-size: 32px;
    letter-spacing: 6px;
  }

  #lobby-subtitle {
    font-size: 9px;
    letter-spacing: 4px;
  }

  #player-name {
    width: 200px;
    font-size: 16px;
    padding: 10px 14px;
  }

  #btn-confirm-name {
    padding: 10px 36px;
    font-size: 14px;
  }

  /* Hide desktop controls info on mobile */
  #controls-info {
    display: none;
  }

  /* HUD adjustments */
  #hud-bottom-left {
    bottom: 12px;
    left: 12px;
  }

  #hud-health {
    width: 120px;
    height: 12px;
  }

  #hud-fuel {
    width: 90px;
    height: 6px;
  }

  #hud-bottom-right {
    bottom: 12px;
    right: 120px; /* shift left to avoid fire button */
  }

  #ammo-current {
    font-size: 18px;
  }

  #ammo-reserve {
    font-size: 11px;
  }

  #hud-leaderboard {
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    min-width: 120px;
  }

  .lb-row {
    font-size: 10px;
    gap: 4px;
  }

  .lb-name {
    max-width: 60px;
  }

  #hud-killfeed {
    top: 8px;
    right: 8px;
  }

  .kill-entry {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* Hide mine key hint on mobile (has button instead) */
  #mine-key {
    display: none;
  }

  #hud-ammo {
    padding: 14px 8px 4px;
  }

  #weapon-name {
    font-size: 8px;
  }

  /* Canvas cursor visible on mobile */
  #game-canvas {
    cursor: default;
  }

  /* Alone popup smaller */
  #alone-popup {
    font-size: 12px;
    padding: 8px 16px;
    top: 50px;
  }
}

/* Extra small screens (phones) */
@media (max-width: 480px) {
  #lobby-panel {
    padding: 20px 16px 18px;
  }

  #lobby h1 {
    font-size: 24px;
    letter-spacing: 4px;
  }

  #player-name {
    width: 160px;
    font-size: 14px;
  }

  .touch-btn-large {
    width: 64px;
    height: 64px;
    font-size: 11px;
  }

  .touch-btn-medium {
    width: 46px;
    height: 46px;
    font-size: 9px;
  }

  .touch-btn-small {
    width: 36px;
    height: 36px;
    font-size: 9px;
  }

  #touch-buttons {
    right: 10px;
    bottom: 70px;
    gap: 6px;
  }

  #hud-bottom-right {
    right: 90px;
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  #hud-bottom-left {
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }

  #hud-bottom-right {
    padding-bottom: env(safe-area-inset-bottom);
    padding-right: env(safe-area-inset-right);
  }

  #touch-buttons {
    margin-bottom: env(safe-area-inset-bottom);
    margin-right: env(safe-area-inset-right);
  }

  #touch-joystick-zone {
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
}
