/* Cyberpunk Space Sim UI Style */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;600;800&display=swap');

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #030508;
  color: #e0f0ff;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  touch-action: none;
  -webkit-touch-callout: none;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Top Status Bar */
#topBar {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 10;
  pointer-events: auto;
}

.stat-box {
  background: rgba(8, 16, 28, 0.75);
  border: 1px solid rgba(80, 180, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 140, 255, 0.15);
  backdrop-filter: blur(6px);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-box b {
  color: #60c5ff;
  font-size: 15px;
}

.net-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 6px #00ff88;
  display: inline-block;
}
.net-good { background: #00ff88 !important; box-shadow: 0 0 6px #00ff88 !important; }
.net-medium { background: #ffbb00 !important; box-shadow: 0 0 6px #ffbb00 !important; }
.net-bad { background: #ff4444 !important; box-shadow: 0 0 6px #ff4444 !important; }

.badge-blue {
  background: #0077ff;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.badge-yellow {
  background: #e6a100;
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.badge-red {
  background: #e61919;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.hud-btn {
  background: rgba(10, 30, 50, 0.85);
  border: 1px solid #3090e0;
  color: #e0f0ff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: #1e60a0;
  box-shadow: 0 0 12px rgba(48, 144, 224, 0.6);
}

/* Radar (Top Left) */
#radarContainer {
  position: absolute;
  top: 12px;
  left: 16px;
  background: rgba(5, 12, 22, 0.85);
  border: 1px solid rgba(0, 200, 255, 0.35);
  box-shadow: 0 0 15px rgba(0, 200, 255, 0.2);
  border-radius: 50%;
  width: 124px;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  overflow: hidden;
}

/* Bottom Left: Vitals (Health & Shield) */
#vitalsPanel {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 240px;
  background: rgba(6, 14, 24, 0.8);
  border: 1px solid rgba(60, 160, 255, 0.3);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bar-label {
  font-size: 11px;
  color: #a0c0e0;
}

.bar-track {
  width: 100%;
  height: 10px;
  background: rgba(20, 30, 45, 0.8);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-fill {
  height: 100%;
  transition: width 0.15s ease-out;
}

.shield-fill {
  background: linear-gradient(90deg, #0099ff, #00eeff);
  box-shadow: 0 0 8px #00eeff;
  width: 100%;
}

.health-fill {
  background: linear-gradient(90deg, #00cc66, #33ff99);
  box-shadow: 0 0 8px #33ff99;
  width: 100%;
}

/* Bottom Right: Cargo Bay */
#cargoPanel {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(6, 14, 24, 0.8);
  border: 1px solid rgba(60, 160, 255, 0.3);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 10;
  width: 220px;
}

.panel-title {
  font-size: 12px;
  color: #a0c0e0;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 600;
}

.cargo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
}

.cargo-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.c-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.iron-dot { background: #b0b8c0; box-shadow: 0 0 4px #b0b8c0; }
.silicon-dot { background: #68d8d6; box-shadow: 0 0 4px #68d8d6; }
.titanium-dot { background: #e0e0e0; box-shadow: 0 0 4px #e0e0e0; }
.crystal-dot { background: #bd00ff; box-shadow: 0 0 6px #bd00ff; }

/* Alert Banner */
#alertBanner {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(180, 20, 20, 0.85);
  border: 1px solid #ff4444;
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 20;
  pointer-events: none;
  animation: pulseAlert 1.5s infinite alternate;
}

@keyframes pulseAlert {
  0% { transform: translateX(-50%) scale(1); }
  100% { transform: translateX(-50%) scale(1.05); }
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 12, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.hidden {
  display: none !important;
}

.modal-content {
  background: #091424;
  border: 1px solid #3090e0;
  box-shadow: 0 0 30px rgba(48, 144, 224, 0.35);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}

.modal-content h2 {
  color: #60c5ff;
  margin-bottom: 12px;
}

.modal-content p {
  color: #a0c0e0;
  font-size: 14px;
  margin-bottom: 16px;
}

.sector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sector-card {
  background: rgba(15, 30, 50, 0.8);
  border: 1px solid #1e5080;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.sector-card:hover {
  background: #184068;
  border-color: #40a0ff;
  transform: translateX(-4px);
}

.death-box {
  border-color: #ff3333;
  box-shadow: 0 0 35px rgba(255, 51, 51, 0.5);
}

.death-box h2 {
  color: #ff4444;
}

/* Touch Controls (Mobile) */
#touchControls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  display: none; /* Shown via JS if touch device detected or enabled */
}

#joystickZone {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
}

#joystickBase {
  width: 140px;
  height: 140px;
  background: rgba(20, 50, 80, 0.35);
  border: 2px solid rgba(80, 180, 255, 0.4);
  border-radius: 50%;
  position: absolute;
  bottom: 30px;
  left: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#joystickStick {
  width: 54px;
  height: 54px;
  background: radial-gradient(circle, #60c5ff, #1e70b0);
  border: 2px solid #ffffff;
  box-shadow: 0 0 12px #60c5ff;
  border-radius: 50%;
  position: absolute;
}

#touchActions {
  position: absolute;
  bottom: 25px;
  right: 25px;
  display: grid;
  grid-template-columns: repeat(2, 70px);
  gap: 15px;
  pointer-events: auto;
}

.touch-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

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

.touch-btn-fire {
  background: radial-gradient(circle, #ff5533, #aa1100);
  border-color: #ff8866;
  box-shadow: 0 0 14px rgba(255, 85, 51, 0.6);
}

.touch-btn-missile {
  background: radial-gradient(circle, #ffaa00, #996600);
  border-color: #ffcc00;
  box-shadow: 0 0 14px rgba(255, 170, 0, 0.6);
}

.touch-btn-flare {
  background: radial-gradient(circle, #00ddff, #0066aa);
  border-color: #88eeff;
  box-shadow: 0 0 14px rgba(0, 221, 255, 0.6);
}

.touch-btn-brake {
  background: radial-gradient(circle, #778899, #334455);
  border-color: #aabbcc;
}

.cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: height 0.1s linear;
}

/* Responsive Tweaks */
@media (max-width: 768px) {
  #topBar {
    font-size: 11px;
    gap: 6px;
  }
  .stat-box {
    padding: 4px 8px;
  }
  #vitalsPanel {
    bottom: auto;
    top: 70px;
    left: 10px;
    width: 160px;
    padding: 6px 10px;
  }
  #cargoPanel {
    bottom: auto;
    top: 70px;
    right: 10px;
    width: 160px;
    padding: 6px 10px;
    font-size: 10px;
  }
  #radarContainer {
    display: none; /* Keep screen clean on mobile */
  }
}
