* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #05050d;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: #fff;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0c0d20 0%, #040409 100%);
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 50px rgba(0, 243, 255, 0.15), 0 0 100px rgba(176, 38, 255, 0.1);
  border-radius: 4px;
}

/* UI Overlays */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Header HUD */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(5, 5, 15, 0.8) 0%, rgba(5, 5, 15, 0) 100%);
}

.hud-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-title {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a8db5;
  font-weight: 700;
}

.hud-value-large {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #00f3ff;
  text-shadow: 0 0 12px rgba(0, 243, 255, 0.6);
  font-variant-numeric: tabular-nums;
}

.hud-value-medium {
  font-size: 18px;
  font-weight: 700;
  color: #ff0077;
  text-shadow: 0 0 10px rgba(255, 0, 119, 0.5);
  font-variant-numeric: tabular-nums;
}

.hud-value-gold {
  font-size: 18px;
  font-weight: 700;
  color: #ffb703;
  text-shadow: 0 0 10px rgba(255, 183, 3, 0.5);
  font-variant-numeric: tabular-nums;
}

/* Center Threat Radar */
.radar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.radar-frame {
  width: 260px;
  height: 28px;
  background: rgba(10, 12, 30, 0.8);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 243, 255, 0.15);
}

.radar-track {
  width: 100%;
  height: 100%;
  position: relative;
}

.radar-player-marker {
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00f3ff;
  box-shadow: 0 0 8px #00f3ff;
}

.radar-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(0, 243, 255, 0.2);
}

/* Bottom HUD: Energy Meter */
.hud-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 20px;
  gap: 8px;
}

.suit-energy-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(8, 10, 24, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.4);
  padding: 10px 24px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
  backdrop-filter: blur(8px);
}

.energy-title-row {
  display: flex;
  justify-content: space-between;
  width: 320px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.energy-label {
  color: #00f3ff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.energy-pct {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.energy-bar-track {
  width: 320px;
  height: 14px;
  background: rgba(20, 24, 50, 0.9);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.energy-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00f3ff 0%, #00ff88 50%, #00f3ff 100%);
  border-radius: 7px;
  box-shadow: 0 0 14px #00f3ff;
  transition: width 0.05s linear;
}

.energy-bar-fill.active {
  background: linear-gradient(90deg, #ff0077 0%, #ff00ff 50%, #ff0077 100%);
  box-shadow: 0 0 18px #ff0077;
}

.energy-bar-fill.low {
  background: linear-gradient(90deg, #ff0055 0%, #ff5500 100%);
  box-shadow: 0 0 18px #ff0055;
  animation: pulse-low 0.4s infinite alternate;
}

@keyframes pulse-low {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.suit-status-msg {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8a8db5;
}

.suit-status-msg.active {
  color: #ff0077;
  text-shadow: 0 0 8px #ff0077;
}

.suit-status-msg.overheat {
  color: #ff0055;
  text-shadow: 0 0 8px #ff0055;
}

/* Modals & Screens */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 5, 14, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 100;
  transition: opacity 0.25s ease;
}

.hidden {
  display: none !important;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: linear-gradient(145deg, rgba(16, 19, 45, 0.95) 0%, rgba(8, 10, 26, 0.98) 100%);
  border: 1px solid rgba(0, 243, 255, 0.4);
  box-shadow: 0 0 40px rgba(0, 243, 255, 0.2), inset 0 0 20px rgba(0, 243, 255, 0.05);
  border-radius: 16px;
  padding: 36px 44px;
  max-width: 540px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(90deg, #00f3ff, #ff0077);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-desc {
  font-size: 14px;
  line-height: 1.6;
  color: #b8bde5;
}

.controls-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  text-align: left;
}

.ctrl-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.key-badge {
  background: rgba(0, 243, 255, 0.15);
  border: 1px solid #00f3ff;
  color: #00f3ff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 6px rgba(0, 243, 255, 0.3);
}

.btn-primary {
  background: linear-gradient(90deg, #00f3ff 0%, #00b4d8 100%);
  color: #040814;
  border: none;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.8);
}

.btn-primary:active {
  transform: translateY(1px);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: rgba(0, 0, 0, 0.35);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-lbl {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #8a8db5;
  font-weight: 700;
}

.stat-val {
  font-size: 22px;
  font-weight: 900;
  color: #00f3ff;
}

/* Sound and Pause Top Buttons */
.top-action-bar {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
  z-index: 50;
}

.icon-btn {
  background: rgba(14, 18, 40, 0.8);
  border: 1px solid rgba(0, 243, 255, 0.4);
  color: #00f3ff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(0, 243, 255, 0.2);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.5);
}

/* Touch Controls Overlay */
.touch-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  pointer-events: none;
  z-index: 40;
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    display: none !important;
  }
}

.touch-group {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(16, 20, 48, 0.7);
  border: 2px solid rgba(0, 243, 255, 0.4);
  color: #00f3ff;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
  touch-action: none;
}

.touch-btn:active, .touch-btn.pressed {
  background: rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.7);
  transform: scale(0.95);
}

.touch-btn-antigrav {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 0, 119, 0.3) 0%, rgba(176, 38, 255, 0.3) 100%);
  border: 2px solid #ff0077;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  box-shadow: 0 0 20px rgba(255, 0, 119, 0.4);
  touch-action: none;
}

.touch-btn-antigrav:active, .touch-btn-antigrav.pressed {
  background: linear-gradient(135deg, rgba(255, 0, 119, 0.6) 0%, rgba(176, 38, 255, 0.6) 100%);
  box-shadow: 0 0 35px rgba(255, 0, 119, 0.9);
  transform: scale(0.93);
}

/* Banner Notifications */
.alert-banner-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 60;
}

.alert-banner {
  background: rgba(14, 18, 40, 0.9);
  border: 1px solid #00f3ff;
  border-radius: 20px;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #00f3ff;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
  animation: banner-pop 2.5s forwards cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes banner-pop {
  0% { opacity: 0; transform: translateY(-20px) scale(0.9); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

@media (max-width: 768px) {
  .hud-header { padding: 10px 14px; }
  .hud-value-large { font-size: 24px; }
  .radar-frame { width: 150px; }
  .suit-energy-box { padding: 8px 14px; width: 95%; max-width: 280px; }
  .energy-title-row, .energy-bar-track { width: 100%; }
}

/* Mode Selection Tabs */
.mode-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  width: 100%;
}

.mode-tab {
  flex: 1;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #8a8db5;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.mode-tab.active {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.2) 0%, rgba(176, 38, 255, 0.2) 100%);
  border-color: #00f3ff;
  color: #00f3ff;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.35);
}

/* Flyer Starfighter HUD */
.flyer-status-box {
  background: rgba(10, 12, 28, 0.88);
  border: 1px solid rgba(0, 243, 255, 0.4);
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.15);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  width: 95%;
  max-width: 580px;
}

.flyer-meters-row {
  display: flex;
  gap: 18px;
  width: 100%;
}

.flyer-meter-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flyer-hull-fill {
  background: linear-gradient(90deg, #00f3ff, #00ff88);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.flyer-hull-fill.warning {
  background: linear-gradient(90deg, #ffb703, #ff7b00);
  box-shadow: 0 0 10px rgba(255, 183, 3, 0.5);
}

.flyer-hull-fill.critical {
  background: linear-gradient(90deg, #ff0055, #ff0000);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.7);
  animation: pulse-danger 0.5s infinite alternate;
}

.flyer-heat-fill {
  background: linear-gradient(90deg, #00f3ff, #ffb703);
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

.flyer-heat-fill.overheated {
  background: linear-gradient(90deg, #ff0055, #ff0000);
  box-shadow: 0 0 12px rgba(255, 0, 85, 0.8);
  animation: pulse-danger 0.4s infinite alternate;
}

.flyer-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.shield-on {
  background: rgba(0, 243, 255, 0.2);
  border: 1px solid #00f3ff;
  color: #00f3ff;
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
  animation: pulse-shield 1s infinite alternate;
}

.shield-off {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #666a8a;
}

.weapon-standard {
  background: rgba(176, 38, 255, 0.15);
  border: 1px solid rgba(176, 38, 255, 0.4);
  color: #d880ff;
}

.weapon-spread {
  background: rgba(255, 183, 3, 0.2);
  border: 1px solid #ffb703;
  color: #ffb703;
  box-shadow: 0 0 8px rgba(255, 183, 3, 0.4);
}

@keyframes pulse-shield {
  0% { box-shadow: 0 0 6px rgba(0, 243, 255, 0.3); }
  100% { box-shadow: 0 0 14px rgba(0, 243, 255, 0.8); }
}

@keyframes pulse-danger {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Touch Controls Flex Layout */
.touch-flex-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  pointer-events: auto;
}

.touch-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.touch-dpad-row {
  display: flex;
  gap: 8px;
}

.touch-btn-fire {
  width: 100px;
  height: 60px;
  background: linear-gradient(135deg, rgba(255, 0, 85, 0.4) 0%, rgba(255, 119, 0, 0.4) 100%);
  border: 1.5px solid #ff0055;
  border-radius: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
  cursor: pointer;
  touch-action: none;
}

.touch-btn-fire:active {
  transform: scale(0.92);
  background: linear-gradient(135deg, rgba(255, 0, 85, 0.7) 0%, rgba(255, 119, 0, 0.7) 100%);
}
