:root{
  --neon-blue:#00f3ff;
  --neon-red:#ff004c;
  --hud-bg: rgba(10,20,40,0.85);
  --text:#e0f0ff;
  --panel: linear-gradient(135deg, rgba(30,40,60,0.9), rgba(10,15,25,0.95));
  --border:#445577;
  --gold:#ffd700;
  --amber:#fbbf24;
  /* Sci-Fi Font Stack */
  --font-display: 'Orbitron', 'Segoe UI', sans-serif;
  --font-ui: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'Share Tech Mono', 'Consolas', monospace;
}
html,body { height:100%; }
body{
  margin:0;
  overflow:hidden;
  background:#050510;
  color:var(--text);
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.5px;
  user-select:none;
}
canvas{ display:block; }

/* Overlay layer */
#ui-layer{
  position:absolute; inset:0;
  pointer-events:none;
  display:flex; flex-direction:column; justify-content:space-between;
}

/* Screens */
.screen{
  position:absolute; inset:0;
  background:rgba(0,0,0,0.9);
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  z-index:100;
  pointer-events:auto;
  transition:opacity .35s;
}
.hidden{ opacity:0; pointer-events:none; }

h1{
  font-family: var(--font-display);
  font-size:4rem; margin:0 0 16px 0;
  font-weight: 900;
  text-transform:uppercase; letter-spacing:8px;
  background: linear-gradient(90deg, var(--neon-blue), #fff, var(--neon-blue));
  -webkit-background-clip:text; background-clip:text;
  color:transparent;
  text-shadow:0 0 30px rgba(0,243,255,.5);
  animation:pulseTitle 3s infinite;
  text-align:center;
}
.game-logo{
  height: 80px;
  width: auto;
  margin: 0 0 16px 0;
  filter: drop-shadow(0 0 30px rgba(0,243,255,.5));
  animation: pulseLogo 3s infinite;
}
@keyframes pulseLogo{
  0%{ filter: drop-shadow(0 0 30px rgba(0,243,255,.25)); }
  50%{ filter: drop-shadow(0 0 60px rgba(0,243,255,.8)); }
  100%{ filter: drop-shadow(0 0 30px rgba(0,243,255,.25)); }
}
h2{
  font-family: var(--font-display);
  color:#88aaff;
  font-weight:500;
  font-size: 1.1rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin:0 0 26px 0;
  text-align:center;
}
@keyframes pulseTitle{
  0%{ text-shadow:0 0 30px rgba(0,243,255,.25); }
  50%{ text-shadow:0 0 60px rgba(0,243,255,.8); }
  100%{ text-shadow:0 0 30px rgba(0,243,255,.25); }
}

.panel{
  background: var(--panel);
  border:1px solid var(--border);
  padding:26px;
  border-radius:6px;
  box-shadow:0 0 50px rgba(0,0,0,.8);
  width:min(520px, 92vw);
}
.control-group{
  margin-bottom:14px;
  display:flex; justify-content:space-between; align-items:center;
  gap:12px;
}
label{
  font-family: var(--font-ui);
  font-size:1.05rem;
  font-weight: 600;
  color:#aabbcc;
  white-space:nowrap;
  text-transform: uppercase;
  letter-spacing: 1px;
}
select,input[type="text"],input[type="range"]{
  background:rgba(0,0,0,0.3);
  border:1px solid var(--border);
  color:#fff;
  padding:8px 10px;
  border-radius:4px;
  font-family: var(--font-ui);
  font-weight: 500;
}
input[type="range"]{ -webkit-appearance:none; background:transparent; width:220px; }
input[type="range"]::-webkit-slider-runnable-track{
  height:6px; background:#445577; border-radius:3px;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  height:18px; width:18px; border-radius:50%;
  background:var(--neon-blue);
  margin-top:-6px; cursor:pointer;
}

button.btn-primary{
  width:100%;
  padding:14px;
  margin-top:16px;
  font-family: var(--font-display);
  font-size:1rem; font-weight:700;
  text-transform:uppercase; letter-spacing:3px;
  background:var(--neon-blue);
  color:#000;
  border:none;
  cursor:pointer;
  transition:transform .15s, box-shadow .15s, background .15s;
  box-shadow:0 0 20px rgba(0,243,255,.4);
}
button.btn-primary:hover{
  background:#fff;
  transform:scale(1.02);
  box-shadow:0 0 35px rgba(0,243,255,.85);
}

/* HUD */
#hud-top{
  pointer-events:auto;
  padding:10px 18px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
  gap:14px;
}
.stat-box{
  font-family: var(--font-mono);
  font-size:1.05rem;
  text-shadow:0 0 5px rgba(0,0,0,.9);
  white-space:nowrap;
  letter-spacing: 1px;
}
.hud-controls{ display:flex; align-items:center; gap:10px; }
.btn-hud{
  background:rgba(0,243,255,0.1);
  border:1px solid var(--neon-blue);
  color:var(--neon-blue);
  width:26px; height:26px;
  border-radius:6px;
  cursor:pointer;
  font-weight:800;
  display:flex; align-items:center; justify-content:center;
  transition:transform .1s, background .1s;
  pointer-events:auto;
}
.btn-hud:hover{ background:rgba(0,243,255,0.25); transform:scale(1.08); }
.btn-hud:active{ transform:scale(0.95); }

/* Leaderboard (collapsible) */
#leaderboard{
  position:absolute;
  top:70px; right:18px;
  width:240px;
  background:rgba(5,10,20,0.85);
  border:1px solid var(--border);
  border-radius:6px;
  pointer-events:auto;
  display:flex;
  flex-direction:column;
  box-shadow:0 4px 16px rgba(0,0,0,0.55);
}
#lb-header{
  padding:8px 12px;
  background:rgba(30,40,60,0.9);
  cursor:pointer;
  font-family: var(--font-display);
  font-weight:700;
  font-size:0.7rem;
  display:flex; justify-content:space-between; align-items:center;
  border-bottom:1px solid var(--border);
  text-transform:uppercase;
  letter-spacing:2px;
  color:#88aaff;
  user-select:none;
}
#lb-header:hover{ background:rgba(50,70,100,0.9); color:#fff; }
#lb-list{
  padding:6px;
  max-height:420px;
  overflow:auto;
}
#lb-list::-webkit-scrollbar{ width:6px; }
#lb-list::-webkit-scrollbar-track{ background:rgba(0,0,0,.25); }
#lb-list::-webkit-scrollbar-thumb{ background:#445577; border-radius:4px; }

#leaderboard.collapsed #lb-list{ display:none; }
#leaderboard.collapsed #lb-header{ border-bottom:none; }

.lb-row{
  display:flex; justify-content:space-between;
  padding:4px 8px;
  margin-bottom:2px;
  font-family: var(--font-ui);
  font-size:0.85rem;
  border-radius:3px;
}
.lb-row.dead{ opacity:.35; text-decoration:line-through; }
.lb-name{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:160px;
  font-weight:700;
  letter-spacing: 0.5px;
}
.lb-count{ color:#fff; font-family: var(--font-mono); letter-spacing: 1px; }

/* ============================================================
   HUMAN PLAYER INDICATORS IN LEADERBOARD
   Human players are highlighted to distinguish them from AI
   ============================================================ */

/* Human player row - subtle glow background */
.lb-row.human-player {
  background: rgba(0, 243, 255, 0.08);
  border-left: 2px solid var(--neon-blue);
  padding-left: 6px;
  margin-left: -2px;
}

/* Local player (You) gets extra emphasis */
.lb-row.local-player {
  background: rgba(0, 243, 255, 0.15);
  border-left: 3px solid var(--neon-blue);
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.2);
}

/* Human player icon emoji styling */
.lb-human-icon {
  font-size: 0.75rem;
  margin-right: 4px;
  vertical-align: middle;
  filter: grayscale(0.3);
}

/* "(You)" tag styling */
.lb-you-tag {
  font-size: 0.7rem;
  color: var(--neon-blue);
  margin-left: 4px;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(0, 243, 255, 0.5);
}

/* Instructions */
#instructions{
  position:absolute;
  bottom:18px; left:50%;
  transform:translateX(-50%);
  color:rgba(255,255,255,0.5);
  font-size:0.9rem;
  text-align:center;
  pointer-events:none;
  width:min(980px, 94vw);
  line-height:1.35;
}
.key{ color:var(--neon-blue); font-weight:800; }
.key-amber{ color:var(--amber); font-weight:900; }

/* Messages */
#message-area{
  position:absolute;
  top:18%;
  width:100%;
  text-align:center;
  pointer-events:none;
  font-size:2rem;
  font-weight:800;
  text-shadow:0 0 10px rgba(0,0,0,.95);
  opacity:0;
  transition:opacity .35s;
}

/* Rally mode badge */
#rally-badge{
  position:absolute;
  top:16px;
  left:50%;
  transform:translateX(-50%);
  padding:6px 12px;
  border-radius:999px;
  border:1px solid rgba(251,191,36,0.7);
  background: rgba(20, 14, 2, 0.55);
  color: rgba(251,191,36,0.95);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  pointer-events:none;
  display:none;
  box-shadow: 0 0 18px rgba(251,191,36,0.15);
}

/* Planet name tooltip */
#planet-tooltip{
  position:absolute;
  padding:6px 12px;
  border-radius:4px;
  border:1px solid var(--border);
  background: rgba(10, 20, 40, 0.95);
  color: #e0f0ff;
  font-family: var(--font-mono);
  font-size: 13px;
  pointer-events:none;
  display:none;
  z-index:50;
  white-space:nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
#planet-tooltip .planet-name{
  color: var(--neon-blue);
  font-weight: 700;
  font-size: 14px;
}
#planet-tooltip .planet-owner{
  color: #888;
  font-size: 11px;
  margin-top: 2px;
}

/* ============================================================
   MULTIPLAYER UI STYLES
   ============================================================ */

/* Mode Selection */
.mode-buttons {
  display: flex;
  gap: 16px;
  margin: 24px 0;
}

.btn-large {
  width: auto !important;
  flex: 1;
  padding: 20px 24px !important;
  font-size: 1.2rem !important;
}

.mode-desc {
  color: #667788;
  font-size: 0.9rem;
  margin-top: 16px;
  line-height: 1.5;
}

/* Button Variants */
.btn-secondary {
  padding: 14px 24px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: rgba(60, 80, 110, 0.5);
  color: #88aacc;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s, background .15s;
  border-radius: 4px;
}

.btn-secondary:hover {
  background: rgba(80, 100, 140, 0.7);
  color: #fff;
}

.btn-small {
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(0, 243, 255, 0.1);
  color: var(--neon-blue);
  border: 1px solid var(--neon-blue);
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s;
}

.btn-small:hover {
  background: rgba(0, 243, 255, 0.25);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.button-row .btn-secondary {
  flex: 0 0 auto;
}

.button-row .btn-primary {
  flex: 1;
  margin-top: 0;
}

/* Lobby Panel */
.lobby-panel {
  width: min(600px, 92vw) !important;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

#lobby-status {
  color: var(--neon-blue);
  font-weight: 600;
}

#player-count {
  color: #667788;
  font-size: 0.9rem;
}

/* Game List */
.game-list-container {
  margin-bottom: 16px;
}

.game-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  color: #aabbcc;
}

.game-list {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.game-list::-webkit-scrollbar { width: 6px; }
.game-list::-webkit-scrollbar-track { background: rgba(0,0,0,.25); }
.game-list::-webkit-scrollbar-thumb { background: #445577; border-radius: 4px; }

/* ============================================================
   GAME LIST - Enhanced with player type indicators
   ============================================================ */

.game-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: #556677;
}

.game-list-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.game-list-empty-hint {
  font-size: 0.85rem;
  color: #445566;
  margin-top: 8px;
}

.game-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(68, 85, 119, 0.4);
  cursor: pointer;
  transition: background .15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-item:last-child {
  border-bottom: none;
}

.game-item:hover {
  background: rgba(0, 243, 255, 0.08);
}

.game-item-info {
  flex: 1;
}

.game-item-name {
  font-weight: 600;
  color: #e0f0ff;
  margin-bottom: 4px;
}

.game-item-details {
  font-size: 0.85rem;
  color: #778899;
}

.game-item-players {
  text-align: right;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

.game-item-count {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  gap: 10px;
}

/* Human player count in game list */
.game-player-humans {
  color: var(--neon-blue);
}

/* AI player count in game list */
.game-player-ai {
  color: #889;
}

/* Slot count display */
.game-item-slots {
  font-size: 0.75rem;
  color: #667788;
  margin-top: 2px;
}

/* Game details styling */
.game-item-details {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: #778899;
}

.game-host {
  color: #aabbcc;
}

.game-size {
  color: #667788;
  padding: 1px 6px;
  background: rgba(100, 100, 100, 0.2);
  border-radius: 3px;
  font-size: 0.75rem;
}

.game-item-status {
  font-size: 0.75rem;
  color: #667788;
  text-transform: uppercase;
  margin-top: 4px;
}

.game-item-status.waiting { color: #44cc66; }
.game-item-status.running { color: #ffaa00; }

.lobby-buttons {
  display: flex;
  gap: 12px;
}

.lobby-buttons .btn-secondary {
  flex: 0 0 auto;
}

.lobby-buttons .btn-primary {
  flex: 1;
  margin-top: 0;
}

/* Waiting Room */
.waiting-room-panel {
  width: min(500px, 92vw) !important;
}

.game-info {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

#waiting-game-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--neon-blue);
  margin-bottom: 6px;
}

#waiting-game-settings {
  font-size: 0.9rem;
  color: #778899;
}

.player-list-container {
  margin-bottom: 20px;
}

.player-list-header {
  font-weight: 600;
  color: #aabbcc;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.player-list {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 240px;
  overflow-y: auto;
  min-height: 120px;
}

/* ============================================================
   WAITING ROOM PLAYER LIST - Enhanced with human/AI indicators
   ============================================================ */

.player-item {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(68, 85, 119, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.player-item:last-child {
  border-bottom: none;
}

/* Local player highlight */
.player-item.is-local-player {
  background: rgba(0, 243, 255, 0.1);
  border-left: 3px solid var(--neon-blue);
  margin-left: -3px;
}

/* Host player subtle indicator */
.player-item.is-host-player {
  background: rgba(255, 215, 0, 0.05);
}

/* AI player styling - more muted */
.player-item.ai-player {
  opacity: 0.7;
  background: rgba(100, 100, 100, 0.1);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.player-icon {
  font-size: 1rem;
  filter: grayscale(0.2);
}

.player-icon.ai-icon {
  filter: grayscale(0.5);
}

.player-name-text {
  font-weight: 600;
  color: #e0f0ff;
}

.player-name-text.ai-name {
  color: #889;
  font-style: italic;
}

/* Player badges container */
.player-badges {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

/* Player badge base styles */
.player-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Host badge - gold themed */
.player-badge.host-badge {
  background: rgba(255, 215, 0, 0.2);
  color: var(--gold);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

/* You badge - cyan themed */
.player-badge.you-badge {
  background: rgba(0, 243, 255, 0.2);
  color: var(--neon-blue);
  border: 1px solid rgba(0, 243, 255, 0.4);
}

/* Player faction color indicator */
.player-faction {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

/* AI faction indicator - greyed out */
.player-faction.ai-faction {
  background: linear-gradient(135deg, #444, #666) !important;
  opacity: 0.5;
}

/* Divider between human and AI sections */
.player-list-divider {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(68, 85, 119, 0.5);
  border-bottom: 1px solid rgba(68, 85, 119, 0.3);
  font-size: 0.75rem;
  color: #667788;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* Player count breakdown in header */
.player-count-breakdown {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.player-count-breakdown .human-count {
  color: var(--neon-blue);
}

.player-count-breakdown .ai-count {
  color: #889;
}

.player-count-breakdown .total-count {
  color: #aabbcc;
}

/* Legacy class support */
.player-name {
  font-weight: 600;
}

.player-name.is-you {
  color: var(--neon-blue);
}

.player-name.is-host::after {
  content: ' (Host)';
  color: var(--gold);
  font-size: 0.85rem;
}

.waiting-buttons {
  display: flex;
  gap: 12px;
}

.waiting-buttons .btn-secondary {
  flex: 0 0 auto;
}

.waiting-buttons .btn-primary {
  flex: 1;
  margin-top: 0;
}

.waiting-buttons .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #445566;
  box-shadow: none;
}

.host-note {
  text-align: center;
  color: var(--gold);
  font-size: 0.9rem;
  margin-top: 16px;
  margin-bottom: 0;
}

/* Chat Panel */
#chat-panel {
  position: absolute;
  bottom: 80px;
  left: 18px;
  width: 300px;
  background: rgba(5, 10, 20, 0.85);
  border: 1px solid var(--border);
  border-radius: 6px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  max-height: 200px;
}

#chat-messages {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  font-size: 0.85rem;
  max-height: 150px;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: #445577; border-radius: 2px; }

.chat-message {
  margin-bottom: 4px;
  line-height: 1.3;
}

.chat-sender {
  font-weight: 600;
  margin-right: 6px;
}

.chat-text {
  color: #aabbcc;
}

.chat-system {
  color: var(--amber);
  font-style: italic;
}

/* ============================================================
   ENHANCED CHAT NOTIFICATIONS - Join/Leave with animations
   ============================================================ */

/* Base notification styling */
.chat-notification {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  margin: 4px 0;
  animation: notificationSlideIn 0.3s ease-out;
}

/* Join notification - green themed */
.chat-notification.chat-join {
  background: rgba(68, 204, 102, 0.15);
  border-left: 3px solid #44cc66;
}

.chat-notification.chat-join .chat-notification-icon {
  color: #44cc66;
}

.chat-notification.chat-join .chat-notification-text {
  color: #88ddaa;
}

/* Leave notification - red themed */
.chat-notification.chat-leave {
  background: rgba(255, 0, 76, 0.15);
  border-left: 3px solid var(--neon-red);
}

.chat-notification.chat-leave .chat-notification-icon {
  color: var(--neon-red);
}

.chat-notification.chat-leave .chat-notification-text {
  color: #ff8899;
}

/* Notification icon styling */
.chat-notification-icon {
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* Notification text styling */
.chat-notification-text {
  font-size: 0.8rem;
  font-weight: 500;
}

/* Slide-in animation for notifications */
@keyframes notificationSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

#chat-input-container {
  border-top: 1px solid var(--border);
  padding: 6px;
}

#chat-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  box-sizing: border-box;
}

#chat-input:focus {
  outline: none;
  border-color: var(--neon-blue);
}

/* Connection Status */
.connection-status {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 1000;
}

.connection-status.connected {
  background: rgba(68, 204, 102, 0.2);
  color: #44cc66;
  border: 1px solid #44cc66;
}

.connection-status.disconnected {
  background: rgba(255, 0, 76, 0.2);
  color: var(--neon-red);
  border: 1px solid var(--neon-red);
}

.connection-status.connecting {
  background: rgba(255, 170, 0, 0.2);
  color: #ffaa00;
  border: 1px solid #ffaa00;
}

/* ============================================================
   OPTIONS DIALOG
   ============================================================ */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

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

.dialog-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: min(420px, 90vw);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8), 0 0 60px rgba(0, 243, 255, 0.1);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(30, 40, 60, 0.95);
  border-bottom: 1px solid var(--border);
}

.dialog-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--neon-blue);
  text-transform: uppercase;
  letter-spacing: 3px;
}

.dialog-close {
  background: transparent;
  border: none;
  color: #667788;
  font-size: 1.6rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

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

.dialog-content {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.dialog-content::-webkit-scrollbar { width: 6px; }
.dialog-content::-webkit-scrollbar-track { background: rgba(0,0,0,.25); }
.dialog-content::-webkit-scrollbar-thumb { background: #445577; border-radius: 4px; }

.dialog-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.options-section {
  margin-bottom: 20px;
}

.options-section:last-child {
  margin-bottom: 0;
}

.options-section h4 {
  margin: 0 0 12px 0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: #88aacc;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(68, 85, 119, 0.4);
  padding-bottom: 8px;
}

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(68, 85, 119, 0.2);
}

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

.option-row label {
  font-size: 0.95rem;
  color: #aabbcc;
}

.option-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-control input[type="range"] {
  width: 120px;
}

.option-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--neon-blue);
  min-width: 50px;
  text-align: right;
  letter-spacing: 1px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(60, 80, 110, 0.5);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: #88aacc;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--neon-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--neon-blue);
}

.toggle-row {
  padding: 12px 0;
}

/* ============================================================
   RADAR MAP (Canvas-based, styles for legend overlay)
   ============================================================ */

#radar-legend {
  position: absolute;
  bottom: 0;
  right: 0;
  padding: 6px 10px;
  background: rgba(5, 10, 20, 0.9);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.7rem;
  pointer-events: none;
  display: none;
}

.radar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.radar-legend-item:last-child {
  margin-bottom: 0;
}

.radar-legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.radar-legend-label {
  color: #aabbcc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}
