@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #02040a;
  font-family: 'Orbitron', 'Share Tech Mono', monospace, sans-serif;
  color: #e0f2fe;
}

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

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Screen FX Overlays */
#screen-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease-out;
  z-index: 50;
}

#damage-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 100px rgba(239, 68, 68, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
  z-index: 49;
}

/* Sci-fi Crosshair */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 40;
  transition: transform 0.05s ease-out;
}

.crosshair-reticle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(56, 189, 248, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4), inset 0 0 8px rgba(56, 189, 248, 0.3);
  animation: reticlePulse 2s infinite alternate ease-in-out;
}

.crosshair-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: #f43f5e;
  box-shadow: 0 0 10px #f43f5e, 0 0 20px #f43f5e;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.crosshair-bracket {
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: #38bdf8;
  border-style: solid;
}
.bracket-tl { top: -6px; left: -6px; border-width: 2px 0 0 2px; }
.bracket-tr { top: -6px; right: -6px; border-width: 2px 2px 0 0; }
.bracket-bl { bottom: -6px; left: -6px; border-width: 0 0 2px 2px; }
.bracket-br { bottom: -6px; right: -6px; border-width: 0 2px 2px 0; }

.crosshair-lock {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 1px;
  color: #38bdf8;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

#crosshair.locked .crosshair-reticle {
  border-color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.8), inset 0 0 10px rgba(239, 68, 68, 0.5);
  animation: lockSpin 0.6s infinite linear;
}
#crosshair.locked .crosshair-lock {
  opacity: 1;
  color: #ef4444;
  text-shadow: 0 0 8px #ef4444;
}

@keyframes reticlePulse {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.05); }
}

@keyframes lockSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(180deg); }
}

/* Star Wars HUD */
#hud-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
}

/* Top HUD Bar */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-panel {
  background: rgba(8, 14, 26, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 10px 18px;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.15), inset 0 0 10px rgba(56, 189, 248, 0.05);
}

.hud-title {
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.hud-value {
  font-size: 22px;
  font-weight: 700;
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.hud-center-top {
  text-align: center;
}

.difficulty-badge {
  display: inline-block;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 900;
  border-radius: 4px;
  letter-spacing: 1px;
  margin-top: 4px;
  text-transform: uppercase;
}
.diff-easy { background: rgba(34, 197, 94, 0.2); color: #4ade80; border: 1px solid #4ade80; }
.diff-normal { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid #38bdf8; }
.diff-hard { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid #f87171; }
.diff-god { background: rgba(234, 179, 8, 0.25); color: #facc15; border: 1px solid #facc15; box-shadow: 0 0 12px rgba(250, 204, 21, 0.6); }

/* Shield & Hull Gauges */
.hud-status {
  width: 240px;
}

.meter-wrapper {
  margin-top: 6px;
}

.meter-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 3px;
  color: #cbd5e1;
}

.meter-bar {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease, background 0.3s ease;
}

#shield-fill {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  box-shadow: 0 0 10px #38bdf8;
}

#dodge-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
  box-shadow: 0 0 8px #34d399;
}

/* Bottom HUD Bar */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.weapon-panel {
  display: flex;
  gap: 16px;
}

.weapon-box {
  background: rgba(8, 14, 26, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.weapon-box:hover {
  transform: translateY(-2px);
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

.weapon-empty {
  color: #f87171 !important;
  font-size: 14px !important;
}

.weapon-box.active {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.weapon-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.weapon-name {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 1px;
}

.weapon-count {
  font-size: 18px;
  font-weight: 900;
  color: #f8fafc;
  margin-top: 2px;
}

.weapon-key {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #0284c7;
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #38bdf8;
  box-shadow: 0 0 6px #0284c7;
}

.hud-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}
.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
}

/* Modals & Overlays */
.overlay-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(8, 14, 26, 0.98));
  border: 2px solid #38bdf8;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.35), inset 0 0 20px rgba(56, 189, 248, 0.1);
  border-radius: 12px;
  padding: 32px 40px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  position: relative;
}

.modal-title {
  font-size: 32px;
  font-weight: 900;
  color: #facc15;
  text-shadow: 0 0 15px rgba(250, 204, 21, 0.7), 0 0 30px rgba(250, 204, 21, 0.3);
  letter-spacing: 3px;
  margin-bottom: 12px;
}

.modal-subtitle {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 24px;
  line-height: 1.6;
}

.rules-list {
  text-align: left;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.8;
  color: #e2e8f0;
}

.rules-list strong {
  color: #38bdf8;
}

.rules-list .highlight-missile {
  color: #f43f5e;
}
.rules-list .highlight-bomb {
  color: #facc15;
}

.difficulty-selection {
  margin-bottom: 24px;
}

.diff-title {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.diff-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.diff-btn {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #cbd5e1;
  padding: 10px 18px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
  transform: translateY(-2px);
}

.diff-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.25);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.diff-btn[data-diff="god"].selected {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.25);
  color: #fef08a;
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.7);
}

.modal-action-btn {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 18px;
  font-weight: 900;
  padding: 14px 40px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 0 0 20px rgba(2, 132, 199, 0.6);
  transition: all 0.2s;
  text-transform: uppercase;
}

.modal-action-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 28px rgba(37, 99, 235, 0.85);
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 15px;
  left: 15px;
  right: 15px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 45;
}

.mobile-actions {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.mobile-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid #38bdf8;
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  touch-action: manipulation;
}
.mobile-btn:active {
  background: #0284c7;
  transform: scale(0.92);
}
.mobile-btn-missile {
  border-color: #f43f5e;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
}
.mobile-btn-bomb {
  border-color: #facc15;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5);
}
.mobile-btn-dodge {
  border-color: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.5);
}

/* Touch Joystick */
#touch-stick-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 70%;
  pointer-events: none;
  z-index: 35;
}

#touch-stick-base {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px dashed rgba(56, 189, 248, 0.6);
  background: rgba(15, 23, 42, 0.45);
  transform: translate(-50%, -50%);
  display: none;
  pointer-events: none;
}

#touch-stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #38bdf8, #0284c7);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
  transform: translate(-50%, -50%);
}

/* Orientation Hint */
#orientation-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(250, 204, 21, 0.7);
  color: #fef08a;
  font-size: 11px;
  padding: 5px 14px;
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.35);
  z-index: 80;
  display: none;
  pointer-events: none;
}

@media (orientation: portrait) and (max-width: 900px) {
  #orientation-hint {
    display: block;
  }
}

/* Responsive Tablet & Mobile Media Queries */
@media (pointer: coarse), (max-width: 1024px), (hover: none) {
  #mobile-controls {
    display: flex;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .hud-status {
    width: 160px;
  }
}

.has-touch #mobile-controls {
  display: flex;
}

/* Supply Pickup Floating Toast */
#supply-toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  border: 2px solid #38bdf8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.7);
  color: #ffffff;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 60;
}

#supply-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#supply-toast.toast-missile {
  border-color: #38bdf8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.8);
  color: #e0f2fe;
}

#supply-toast.toast-bomb {
  border-color: #facc15;
  box-shadow: 0 0 25px rgba(250, 204, 21, 0.8);
  color: #fef08a;
}

#supply-toast.toast-medkit {
  border-color: #34d399;
  box-shadow: 0 0 25px rgba(52, 211, 153, 0.8);
  color: #d1fae5;
}

