/* ==========================================================================
   SPACESHIP FLIGHT - MODERN RETRO ARCADE STYLESHEET
   Design: Deep space glassmorphism, neon HUD, tactile controls
   ========================================================================== */

:root {
  --bg-space: #030712;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(56, 189, 248, 0.25);
  --panel-glow: rgba(56, 189, 248, 0.15);
  
  --neon-cyan: #38bdf8;
  --neon-cyan-bright: #00f0ff;
  --neon-yellow: #facc15;
  --neon-red: #f43f5e;
  --neon-green: #22c55e;
  
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --font-display: 'Orbitron', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

.hidden {
  display: none !important;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed;
  background-color: var(--bg-space);
  color: var(--text-primary);
  font-family: var(--font-display);
  touch-action: none;
  -webkit-overflow-scrolling: none;
}

#gameContainer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  width: 100vw;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When played vertically (portrait), enforce horizontal 16:9 arcade aspect ratio with letterbox padding */
@media (orientation: portrait) {
  #gameContainer {
    background: radial-gradient(circle at center, #020617 0%, #000000 100%);
  }

  #gameCanvas {
    position: relative !important;
    max-width: 100vw !important;
    max-height: calc(100vw * 9 / 16) !important;
    border-top: 2px solid rgba(56, 189, 248, 0.4) !important;
    border-bottom: 2px solid rgba(56, 189, 248, 0.4) !important;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.95), 0 0 20px rgba(56, 189, 248, 0.2) !important;
  }

  /* Keep HUD anchored to the top of the screen */
  #hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  /* Keep touch controls anchored at the bottom of the screen */
  #touchControls {
    position: absolute;
    bottom: 24px;
    left: 0;
    width: 100%;
  }
}

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

/* ==========================================================================
   TOP HUD BAR
   ========================================================================== */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  padding: max(10px, env(safe-area-inset-top, 10px)) max(12px, env(safe-area-inset-right, 12px)) 6px max(12px, env(safe-area-inset-left, 12px));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.hud-view-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: clamp(4px, 1.2vw, 14px);
  min-width: 0;
}

#hudSolo {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  gap: clamp(4px, 1.2vw, 14px);
  min-width: 0;
}

#hudSolo .hud-left {
  justify-self: start;
}

#hudSolo .hud-center {
  justify-self: center;
}

#hudSolo .hud-right {
  justify-self: end;
}

#hud.multiplayer-active #hudSolo {
  display: none !important;
}

#hud:not(.multiplayer-active) #hudMultiplayer {
  display: none !important;
}

#hud.multiplayer-active #hudMultiplayer {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  gap: clamp(8px, 1.8vw, 24px);
  min-width: 0;
  box-sizing: border-box;
  padding: 0;
  position: static;
}

/* Multiplayer Corner Controls (Mute / Pause) */
.mp-hud-right {
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 10px));
  top: max(8px, env(safe-area-inset-top, 8px));
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8vw, 8px);
  z-index: 25;
  pointer-events: auto;
}

.mp-hud-right .hud-btn {
  pointer-events: auto;
}

/* Multiplayer Cockpit Layout */
.hud-mp-player {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.9vw, 8px);
  min-width: 0;
}

.hud-mp-p2 {
  justify-content: flex-start;
}

.hud-mp-p1 {
  justify-content: flex-end;
}

/* On desktop, order P1 so gauges sit on the left (towards center) and badge sits on the right */
.hud-mp-p1 .mp-player-badge {
  order: 3;
}
.hud-mp-p1 #p1EnergyHud {
  order: 2;
}
.hud-mp-p1 #p1ShieldHud {
  order: 1;
}

.hud-mp-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  justify-self: center;
}

.mp-player-badge {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center;
  gap: 2px;
  padding: 4px clamp(8px, 1vw, 12px) 5px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.mp-player-badge.p1-badge {
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.mp-player-badge.p2-badge {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.mp-tag {
  font-family: var(--font-display);
  font-size: clamp(9px, 1.4vw, 11px);
  font-weight: 900;
  letter-spacing: 0.6px;
  white-space: nowrap;
  /* NEVER TRUNCATE TEXT */
  overflow: visible !important;
  text-overflow: clip !important;
  max-width: none !important;
  vertical-align: middle;
  transition: font-size 0.2s ease, letter-spacing 0.2s ease;
}

.mp-tag-pill {
  display: inline-block;
  padding: 1.5px 4px;
  border-radius: 3px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
}

.mp-tag-pill.you {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid currentColor;
}

.mp-tag-pill.partner {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #94a3b8;
}

.mp-tag.red {
  color: #f87171;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

.mp-tag.blue {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.7);
}

.mp-player-badge .lives-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 0;
}

.mp-player-badge .life-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 9px;
  height: 11px;
  filter: none;
  vertical-align: middle;
}

.mp-player-badge .life-icon svg {
  width: 9px;
  height: 11px;
  display: block;
}

.p1-life.active polygon {
  transition: fill 0.2s ease, filter 0.2s ease;
}

.p2-life.active polygon {
  transition: fill 0.2s ease, filter 0.2s ease;
}

.mp-gauge {
  min-width: 72px;
  max-width: 110px;
  flex: 1 1 auto;
  padding: 3px clamp(5px, 0.8vw, 8px);
  gap: 2px;
  box-sizing: border-box;
}

.mp-gauge .energy-percent {
  font-size: clamp(9px, 1.8vw, 12px);
}

.mp-gauge .hud-label {
  font-size: clamp(7.5px, 1.3vw, 9.5px);
}

/* ==========================================================================
   RESPONSIVE MULTIPLAYER COCKPIT HUD (MOBILE LANDSCAPE, TABLET & COMPACT SCREENS)
   Triggers whenever viewport is constrained horizontally (<= 1100px) OR
   vertically (<= 560px), which captures ALL mobile phones in landscape & portrait.
   Organizes left & right pilot pods into dual-tier cockpits:
   - Row 1: Pilot badge (Name + YOU/CO-PILOT + Lives)
   - Row 2: Equal-width mini gauges (Ammo + Shield)
   ========================================================================== */
@media (max-width: 1100px), (max-height: 560px) {
  #hud.multiplayer-active {
    padding: max(4px, env(safe-area-inset-top, 4px)) max(6px, env(safe-area-inset-right, 6px)) 2px max(6px, env(safe-area-inset-left, 6px));
    justify-content: center;
  }

  #hud.multiplayer-active #hudMultiplayer {
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    gap: clamp(6px, 1.4vw, 16px);
    padding: 0;
    box-sizing: border-box;
    position: static;
  }

  /* Anchored Utility Controls */
  .mp-hud-right {
    position: absolute;
    right: max(6px, env(safe-area-inset-right, 6px));
    top: max(4px, env(safe-area-inset-top, 4px));
    gap: 3px;
    z-index: 25;
  }

  .mp-hud-right .hud-btn {
    padding: 2px 4px;
    font-size: 10px;
    min-width: 23px;
    height: 23px;
  }

  /* P2 Left Wing: Modular Console (Badge on Top, Dual Mini Gauges Below) */
  .hud-mp-player.hud-mp-p2 {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 2px 4px;
    min-width: 0;
    max-width: 100%;
    justify-items: center;
    align-items: center;
  }

  .hud-mp-p2 .mp-player-badge {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    padding: 3px clamp(4px, 0.8vw, 8px) 5px;
    gap: 2px;
  }

  .hud-mp-p2 #p2EnergyHud {
    grid-column: 1 / 2;
    grid-row: 2;
    width: 100%;
    max-width: 120px;
    box-sizing: border-box;
    padding: 2px 4px;
    gap: 1px;
    min-width: 0;
  }

  .hud-mp-p2 #p2ShieldHud {
    grid-column: 2 / 3;
    grid-row: 2;
    width: 100%;
    max-width: 120px;
    box-sizing: border-box;
    padding: 2px 4px;
    gap: 1px;
    min-width: 0;
  }

  /* Center Cockpit: Shared Team Score & High Score */
  .hud-mp-center {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    padding: 0;
    justify-self: center;
  }

  .hud-mp-center .score-container {
    padding: 2px clamp(5px, 1vw, 8px);
    gap: clamp(4px, 0.8vw, 8px);
  }

  .hud-mp-center .score-divider {
    height: 14px;
  }

  .hud-mp-center .hud-label {
    font-size: clamp(6.5px, 1.1vw, 8px);
    letter-spacing: 0.3px;
  }

  .hud-mp-center .hud-value {
    font-size: clamp(12.5px, 2vw, 16px);
  }

  .online-status-badge {
    padding: 1px 4px;
    font-size: 7.5px;
    margin-top: 1px;
  }

  /* P1 Right Wing: Modular Console (Badge on Top, Dual Mini Gauges Below) */
  .hud-mp-player.hud-mp-p1 {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 2px 4px;
    min-width: 0;
    max-width: 100%;
    justify-items: center;
    align-items: center;
  }

  /* Reset order for grid layout on mobile */
  .hud-mp-p1 .mp-player-badge {
    order: unset;
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    padding: 3px clamp(4px, 0.8vw, 8px) 5px;
    gap: 2px;
  }

  .hud-mp-p1 #p1ShieldHud {
    order: unset;
    grid-column: 1 / 2;
    grid-row: 2;
    width: 100%;
    max-width: 120px;
    box-sizing: border-box;
    padding: 2px 4px;
    gap: 1px;
    min-width: 0;
  }

  .hud-mp-p1 #p1EnergyHud {
    order: unset;
    grid-column: 2 / 3;
    grid-row: 2;
    width: 100%;
    max-width: 120px;
    box-sizing: border-box;
    padding: 2px 4px;
    gap: 1px;
    min-width: 0;
  }

  /* Mini Gauges Layout */
  .mp-gauge {
    min-width: 0;
    padding: 2px 4px;
    box-sizing: border-box;
  }

  .mp-gauge .hud-label {
    font-size: clamp(6.5px, 1vw, 8px);
    letter-spacing: 0.2px;
  }

  .mp-gauge .energy-percent {
    font-size: clamp(7.5px, 1.2vw, 9.5px);
  }

  .mp-gauge .energy-bar-track {
    height: 3.5px;
  }

  .mp-tag {
    font-size: clamp(8px, 1.4vw, 10.5px);
    letter-spacing: 0.4px;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
  }

  .p1-lives svg, .p2-lives svg {
    width: 8px;
    height: 10px;
  }

  .mp-player-badge .life-icon {
    width: 8px;
    height: 10px;
  }

  .lives-icons {
    gap: 4px;
  }
}

/* Specific optimizations for portrait mode on narrow phones */
@media (max-width: 540px) and (orientation: portrait) {
  #hud.multiplayer-active #hudMultiplayer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 4px 6px !important;
    padding-right: clamp(4px, 1vw, 8px) !important;
    padding-left: clamp(4px, 1vw, 8px) !important;
  }

  .hud-mp-center {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    justify-self: center !important;
  }

  .hud-mp-player.hud-mp-p2 {
    grid-column: 1 / 2 !important;
    grid-row: 2 !important;
  }

  .hud-mp-player.hud-mp-p1 {
    grid-column: 2 / 3 !important;
    grid-row: 2 !important;
  }

  .mp-hud-right {
    position: absolute !important;
    right: max(6px, env(safe-area-inset-right, 6px)) !important;
    top: max(4px, env(safe-area-inset-top, 4px)) !important;
  }
}

.hud-left {
  display: flex;
  align-items: center;
  flex-shrink: 1;
  min-width: 0;
}

.hud-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5vw, 16px);
  flex-shrink: 1;
  min-width: 0;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 10px);
  flex-shrink: 0;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 30, 0.45);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  padding: 4px clamp(6px, 1.2vw, 12px);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5), inset 0 0 8px rgba(56, 189, 248, 0.08);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-sizing: border-box;
}

.score-container {
  flex-direction: row;
  align-items: center;
  gap: clamp(6px, 1.2vw, 14px);
  padding: 4px clamp(6px, 1.5vw, 14px);
}

.score-substat {
  display: flex;
  flex-direction: column;
}

.score-divider {
  width: 1px;
  height: 24px;
  background: rgba(56, 189, 248, 0.25);
}

.hud-label {
  font-size: clamp(8px, 1.8vw, 11px);
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--font-display);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.hud-value {
  font-size: clamp(15px, 3vw, 22px);
  font-weight: 800;
  color: var(--neon-yellow);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.6), 0 2px 4px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

.lives-container {
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex-shrink: 0;
  padding: 4px clamp(5px, 1vw, 10px);
}

.lives-icons {
  display: flex;
  gap: clamp(4px, 1vw, 8px);
  margin-top: 2px;
}

.life-icon {
  display: inline-block;
  width: clamp(12px, 2.5vw, 16px);
  height: clamp(15px, 3vw, 20px);
  filter: drop-shadow(0 0 6px #00f0ff);
  transition: opacity 0.2s ease, transform 0.2s ease;
  vertical-align: middle;
}

.life-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.life-icon polygon {
  fill: #00f0ff;
}

.life-icon:not(.active) {
  opacity: 0.12;
  filter: none;
  transform: scale(0.8);
}

.life-icon:not(.active) polygon {
  fill: #475569;
}

/* ==========================================================================
   ENERGY / BATTERY / SHIELD HUD
   ========================================================================== */
.energy-container {
  min-width: 0;
  max-width: 150px;
  flex: 1 1 auto;
  justify-content: center;
  gap: 3px;
  padding: 4px clamp(6px, 1.5vw, 12px);
}

.energy-container.shield-mode {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2), inset 0 0 8px rgba(56, 189, 248, 0.1);
}

.energy-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  width: 100%;
}

.energy-percent {
  font-size: clamp(11px, 2.2vw, 15px);
  font-weight: 900;
  font-family: var(--font-mono);
  color: #4ade80;
  letter-spacing: 0.5px;
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.7), 0 2px 4px rgba(0, 0, 0, 0.9);
  transition: color 0.2s ease, text-shadow 0.2s ease;
  white-space: nowrap;
}

.energy-percent.warning {
  color: #facc15;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.7), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.energy-percent.depleted {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.8), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.energy-percent.in-debt {
  color: #ff0055;
  text-shadow: 0 0 12px rgba(255, 0, 85, 0.9), 0 2px 4px rgba(0, 0, 0, 0.9);
  animation: energyBlink 0.25s infinite alternate;
}

.energy-percent.shield-mode {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.8), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.energy-percent.shield-mode.ready {
  color: #00f0ff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 1), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.energy-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(74, 222, 128, 0.5);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7);
  transition: border-color 0.2s ease;
}

.energy-bar-track::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.22);
  pointer-events: none;
  z-index: 2;
}

.energy-bar-track.warning {
  border-color: rgba(250, 204, 21, 0.6);
}

.energy-bar-track.depleted {
  border-color: rgba(239, 68, 68, 0.7);
}

.energy-bar-track.in-debt {
  border-color: rgba(255, 0, 85, 0.8);
  box-shadow: 0 0 8px rgba(255, 0, 85, 0.4), inset 0 1px 4px rgba(0, 0, 0, 0.7);
}

.energy-bar-track.shield-mode {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.3), inset 0 1px 4px rgba(0, 0, 0, 0.7);
}

.energy-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #15803d, #22c55e, #4ade80);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.9);
  transition: width 0.08s linear, background 0.2s ease, box-shadow 0.2s ease;
}

.energy-bar-fill.warning {
  background: linear-gradient(90deg, #ca8a04, #eab308, #facc15);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.9);
}

.energy-bar-fill.depleted {
  background: linear-gradient(90deg, #b91c1c, #dc2626, #ef4444);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.9);
  animation: energyBlink 0.3s infinite alternate;
}

.energy-bar-fill.in-debt {
  background: linear-gradient(90deg, #880022, #cc0033, #ff0055);
  box-shadow: 0 0 14px rgba(255, 0, 85, 0.9);
  animation: energyBlink 0.2s infinite alternate;
}

.energy-bar-fill.shield-mode {
  background: linear-gradient(90deg, #0284c7, #0ea5e9, #38bdf8);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.9);
}

.energy-bar-fill.shield-mode.ready {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8, #00f0ff);
  box-shadow: 0 0 14px rgba(0, 240, 255, 1);
}

@keyframes energyBlink {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.energy-container.hidden, .shield-container.hidden {
  display: none !important;
}

.hud-btn {
  pointer-events: auto;
  background: rgba(10, 15, 30, 0.4);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--neon-yellow);
  font-family: var(--font-mono);
  font-size: clamp(12px, 2.5vw, 16px);
  font-weight: bold;
  padding: 6px clamp(8px, 1.5vw, 14px);
  border-radius: var(--radius-sm);
  cursor: pointer;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  box-sizing: border-box;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--neon-cyan);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

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

/* ==========================================================================
   TOUCH & MOBILE ON-SCREEN CONTROLS
   ========================================================================== */
#touchControls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 10;
  pointer-events: none;
  background: transparent;
}

.touch-group-left {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: auto;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.touch-rot-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.touch-group-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
  box-sizing: border-box;
  margin: 0;
}

:root {
  --ctrl-btn-size: 72px;
}

.ctrl-btn {
  width: var(--ctrl-btn-size);
  height: var(--ctrl-btn-size);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.28);
  border: 2px solid rgba(56, 189, 248, 0.45);
  color: var(--neon-cyan);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  position: relative;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.ctrl-btn:active, .ctrl-btn.pressed {
  background: rgba(56, 189, 248, 0.35);
  border-color: var(--neon-cyan-bright);
  color: #fff;
  transform: scale(0.92);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.ctrl-btn.action-btn {
  width: calc(var(--ctrl-btn-size) * 1.06);
  height: calc(var(--ctrl-btn-size) * 1.06);
  border-radius: calc(var(--ctrl-btn-size) * 0.26);
}

.ctrl-btn.shield-btn {
  width: 90%;
  max-width: 100%;
  min-width: 0;
  height: 46px;
  border-radius: 9px;
  border-color: rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.45);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25), 0 2px 6px rgba(0, 0, 0, 0.4);
  padding: 0 10px;
  align-self: center;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0 auto;
}

.shield-btn-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.shield-btn-content svg {
  flex-shrink: 0;
}

.shield-btn-content .btn-subtext {
  margin-top: 0;
  font-size: clamp(8px, 2.2vw, 11px);
  font-weight: 800;
  letter-spacing: 0.8px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.ctrl-btn.shield-btn:active, .ctrl-btn.shield-btn.pressed {
  background: rgba(56, 189, 248, 0.4);
  border-color: #00f0ff;
  color: #fff;
  transform: scale(0.96);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.8);
}

.ctrl-btn.shield-btn.in-debt {
  border-color: rgba(239, 68, 68, 0.5);
  color: #ef4444;
  opacity: 0.6;
}

.ctrl-btn.shield-btn.uncharged {
  border-color: rgba(148, 163, 184, 0.35);
  color: rgba(148, 163, 184, 0.6);
  opacity: 0.55;
}

.loop-arrow-svg {
  width: 70%;
  height: 70%;
  display: block;
}

.ctrl-btn.fire-btn {
  border-color: rgba(244, 63, 94, 0.45);
  color: var(--neon-red);
}

.ctrl-btn.fire-btn:active, .ctrl-btn.fire-btn.pressed {
  background: rgba(244, 63, 94, 0.4);
  border-color: #ff3366;
  color: #fff;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.7);
}

.btn-subtext {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ==========================================================================
   GLASSMODAL & OVERLAYS
   ========================================================================== */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px var(--panel-glow);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.menu-card, .modal-card {
  width: 90%;
  max-width: 480px;
  padding: 36px 32px;
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

/* ==========================================================================
   START SCREEN & LOGO
   ========================================================================== */
.logo-wrapper {
  margin-bottom: 28px;
}

.ship-preview-glow {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, transparent 70%);
}

.floating-ship {
  width: 56px;
  height: 56px;
  object-fit: contain;
  animation: floatShip 3s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
}

@keyframes floatShip {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(4deg);
  }
}

.game-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 20%, var(--neon-cyan) 60%, var(--neon-yellow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
  margin-bottom: 6px;
}

.game-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

.menu-github-link {
  color: var(--neon-cyan);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.menu-github-link:hover {
  color: #ffffff;
  text-shadow: 0 0 8px var(--neon-cyan-bright);
}

/* ==========================================================================
   BUTTONS & NAVIGATION
   ========================================================================== */
.menu-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.menu-btn {
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
}

.primary-btn {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.4);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(14, 165, 233, 0.6);
}

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

.multiplayer-menu-btn {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4) 0%, rgba(56, 189, 248, 0.4) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(56, 189, 248, 0.6) !important;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35), 0 0 15px rgba(239, 68, 68, 0.25) !important;
}

.multiplayer-menu-btn:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.6) 0%, rgba(56, 189, 248, 0.6) 100%) !important;
  box-shadow: 0 6px 28px rgba(56, 189, 248, 0.6), 0 0 20px rgba(239, 68, 68, 0.4) !important;
  transform: translateY(-2px);
}

.secondary-btn {
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.2);
}

.secondary-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan-bright);
  transform: translateY(-2px);
}

.desktop-hints {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.5;
}

.desktop-hints b {
  color: var(--neon-yellow);
}

/* ==========================================================================
   SETTINGS MODAL
   ========================================================================== */
.modal-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  margin-bottom: 24px;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.setting-group {
  margin-bottom: 22px;
  text-align: left;
}

.setting-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

/* ==========================================================================
   HULL COLOR STUDIO & COLOR PICKER
   ========================================================================== */
.ship-color-studio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-studio-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.color-studio-subtext {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.color-target-pill-group {
  display: flex;
  gap: 8px;
  background: rgba(10, 15, 30, 0.6);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.color-target-pill {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.color-target-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.color-target-pill.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.og-fleet-section,
.custom-palette-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.og-fleet-label,
.custom-palette-label {
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.ship-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ship-option {
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-mono);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  position: relative;
}

.ship-option img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.ship-option:hover img {
  transform: scale(1.08);
}

.ship-option-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ship-option-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-option-badge {
  font-size: 9px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  width: fit-content;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.ship-option:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(30, 41, 59, 0.8);
  transform: translateY(-1px);
}

.ship-option.active {
  border-color: var(--neon-cyan);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}

.ship-option.active .ship-option-badge {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

@media (max-width: 600px) {
  .ship-selector {
    grid-template-columns: 1fr;
  }
}

.color-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 600px) {
  .color-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.color-preset-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.color-preset-chip:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.color-preset-chip.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.preset-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 6px currentColor;
}

.preset-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-color-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.08);
}

.custom-color-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-color-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  cursor: pointer;
}

.color-wheel-icon {
  font-size: 14px;
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-color-picker-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-color-picker-input:hover {
  transform: scale(1.1);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.custom-color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.custom-color-picker-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-hex-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(10, 15, 30, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 3px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.color-preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(148, 163, 184, 0.2);
  flex-shrink: 0;
}

.color-preview-ship-wrap {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 30, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.color-preview-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

.color-preview-details {
  display: flex;
  flex-direction: column;
}

.color-preview-role {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.color-preview-title {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 800;
  color: #f8fafc;
}

.match-laser-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(10, 15, 30, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 4px;
}

.toggle-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-label-wrap .setting-subtext {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Online Lobby Color Studio */
.online-color-studio {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(10, 16, 32, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: inset 0 0 16px rgba(56, 189, 248, 0.05);
}

.online-color-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.online-color-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.online-color-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.8px;
}

.online-color-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.online-ship-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.online-ship-preview-frame {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(10, 15, 30, 0.8) 75%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.2);
  position: relative;
  overflow: hidden;
}

.online-ship-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.online-ship-preview-card:hover .online-ship-img {
  transform: scale(1.1) rotate(-3deg);
}

.online-ship-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.online-ship-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-ship-role-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.online-ship-color-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-ship-color-desc {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-presets-section {
  display: flex;
  flex-direction: column;
}

.online-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 520px) {
  .online-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.online-preset-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  text-align: left;
}

.online-preset-chip:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}

.online-preset-chip.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
  transform: scale(1.02);
}

.online-custom-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.55);
  border: 1px dashed rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-top: 2px;
}

.online-custom-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Tab 3 Mini Header Color Picker */
.player-box-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-color-picker-wrap {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  vertical-align: middle;
}

.mini-header-color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  padding: 0;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
}

.mini-header-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
.mini-header-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.power-mode-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.power-mode-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.power-mode-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(30, 41, 59, 0.7);
  transform: translateY(-1px);
}

.power-mode-card.active {
  border-color: var(--neon-cyan);
  background: rgba(56, 189, 248, 0.14);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}

.power-mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.power-mode-title {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
}

.power-mode-card.active .power-mode-title {
  color: var(--neon-cyan-bright);
}

.power-mode-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
  letter-spacing: 0.5px;
}

.power-mode-badge.dual {
  background: rgba(0, 240, 255, 0.15);
  color: #00f0ff;
  border-color: rgba(0, 240, 255, 0.35);
}

.power-mode-badge.shield {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.power-mode-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle-row .setting-label {
  margin-bottom: 0;
}

.custom-toggle {
  width: 44px;
  height: 24px;
  accent-color: var(--neon-cyan);
  cursor: pointer;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.setting-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-yellow);
}

.custom-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(56, 189, 248, 0.2);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

.custom-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}

/* ==========================================================================
   SETTINGS TABS & FULLY CUSTOMIZABLE CONTROLS
   ========================================================================== */
.settings-card {
  max-width: 580px !important;
  width: 95% !important;
}

.settings-tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  padding-bottom: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.settings-tab-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-tab-btn:hover {
  color: #fff;
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.15);
}

.settings-tab-btn.active {
  color: var(--neon-cyan-bright);
  border-color: var(--neon-cyan);
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.settings-tab-pane {
  display: none;
}

.settings-tab-pane.active {
  display: block;
  animation: tabFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.controls-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  text-align: left;
}

.preset-select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 200px;
}

.preset-dropdown {
  width: 100%;
  cursor: pointer;
}

.reset-controls-btn {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fca5a5;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.reset-controls-btn:hover {
  background: rgba(244, 63, 94, 0.3);
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
  transform: translateY(-1px);
}

.controls-hint-text {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.4;
}

.controls-hint-text kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  padding: 1px 5px;
  color: #fff;
  font-size: 10px;
}

.key-binder-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.solo-binder-grid {
  max-width: 440px;
  margin: 0 auto;
}

.key-binder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.7);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}

.binder-action-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
}

.keycap-btn {
  min-width: 84px;
  padding: 6px 14px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  color: #00f0ff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
  user-select: none;
}

.keycap-btn:hover {
  border-color: #00f0ff;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.keycap-btn.listening {
  background: rgba(250, 204, 21, 0.25) !important;
  border-color: #facc15 !important;
  color: #facc15 !important;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.6) !important;
  animation: pulseListening 1.2s infinite ease-in-out;
}

@keyframes pulseListening {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 22px rgba(250, 204, 21, 0.85);
  }
}

.keycap-btn.p1-btn {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.45);
}

.keycap-btn.p1-btn:hover {
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
}

.keycap-btn.p2-btn {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.45);
}

.keycap-btn.p2-btn:hover {
  border-color: #00f0ff;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.5);
}

.keycap-btn.conflict {
  border-color: #f59e0b !important;
  color: #fbbf24 !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5) !important;
}

.controls-mp-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
  text-align: left;
}

.player-controls-box {
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.p1-controls-box {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.p2-controls-box {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

.player-box-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.player-box-title {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.p1-header .player-box-title {
  color: #f87171;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.p2-header .player-box-title {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.player-box-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.controls-conflict-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

@media (max-width: 600px) {
  .controls-mp-columns {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .settings-tabs-nav {
    gap: 4px;
  }
  .settings-tab-btn {
    padding: 6px 10px;
    font-size: 10px;
  }
}

/* ==========================================================================
   INSTRUCTIONS & CREDITS
   ========================================================================== */
.instructions-content, .credits-content {
  text-align: left;
  margin-bottom: 24px;
}

.original-quote {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--neon-yellow);
  background: rgba(250, 204, 21, 0.08);
  border-left: 3px solid var(--neon-yellow);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  line-height: 1.5;
}

.controls-guide {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 600px) {
  .controls-guide {
    grid-template-columns: 1fr 1fr;
  }
}

.guide-col h3 {
  font-size: 13px;
  color: var(--neon-cyan);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.guide-col ul {
  list-style: none;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.guide-col ul b {
  color: var(--text-primary);
}

.scoring-tip {
  font-size: 12px;
  color: #cbd5e1;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.credit-badge {
  text-align: center;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.credit-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 12px;
  border: 2px solid var(--neon-cyan);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.6);
  background-color: #0f172a;
}

.author-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.github-handle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--neon-cyan);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  transition: all 0.2s ease;
}

.github-handle:hover {
  background: rgba(56, 189, 248, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

.kofi-wrapper {
  margin-top: 14px;
}

.kofi-custom-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #13c3ff, #0284c7);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
}

.kofi-custom-btn:hover {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.55);
  transform: translateY(-2px);
  color: #ffffff;
}

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

.history-note {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.history-subnote {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   GAME OVER MODAL
   ========================================================================== */
.game-over-title {
  color: var(--neon-red);
  text-shadow: 0 0 20px rgba(244, 63, 94, 0.6);
  font-size: 28px;
}

.high-score-banner {
  background: linear-gradient(90deg, transparent, rgba(250, 204, 21, 0.2), transparent);
  color: var(--neon-yellow);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 8px;
  margin-bottom: 20px;
  border-top: 1px solid rgba(250, 204, 21, 0.4);
  border-bottom: 1px solid rgba(250, 204, 21, 0.4);
  animation: pulseGlow 1.5s infinite;
}

.high-score-banner.hidden {
  display: none;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; text-shadow: 0 0 10px rgba(250, 204, 21, 0.8); }
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.results-stats.mp-results-stats {
  margin-top: -12px;
  margin-bottom: 24px;
}

.p1-result-box {
  border-color: rgba(239, 68, 68, 0.35) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

.p2-result-box {
  border-color: rgba(56, 189, 248, 0.35) !important;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
}

.result-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.result-number {
  font-size: 28px;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--neon-yellow);
}

/* ==========================================================================
   RESPONSIVENESS & TOUCH VISIBILITY
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
  /* On desktop devices by default, show subtle touch controls or hide per setting */
  #touchControls.auto-hide {
    opacity: 0.4;
    transition: opacity 0.3s ease;
  }
  #touchControls.auto-hide:hover {
    opacity: 1;
  }
}

#touchControls.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  #hud {
    padding: max(6px, env(safe-area-inset-top, 6px)) max(8px, env(safe-area-inset-right, 8px)) 4px max(8px, env(safe-area-inset-left, 8px));
    gap: 4px;
  }
  .hud-stat {
    padding: 3px 6px;
  }
  .score-container {
    gap: 6px;
    padding: 3px 6px;
  }
  .score-divider {
    height: 18px;
  }
  .hud-label {
    font-size: 8px;
    letter-spacing: 0.5px;
  }
  .hud-value {
    font-size: 14px;
  }
  .lives-container {
    min-width: 0;
    padding: 3px 5px;
  }
  .energy-container {
    min-width: 0;
    max-width: 95px;
    padding: 3px 6px;
  }
  .energy-percent {
    font-size: 11px;
  }
  .energy-bar-track {
    height: 6px;
  }
  .life-icon {
    width: 12px;
    height: 15px;
  }
  .hud-btn {
    padding: 5px 8px;
    font-size: 12px;
  }
  .hud-right {
    gap: 4px;
  }
  #touchControls {
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
    padding-top: 0;
    padding-bottom: 0;
  }
  .touch-group-left {
    gap: 8px;
    align-items: center;
  }
  .touch-rot-row, .touch-group-right {
    gap: 8px;
  }
  .ctrl-btn {
    width: var(--ctrl-btn-size);
    height: var(--ctrl-btn-size);
    max-width: 82px;
    max-height: 82px;
  }
  .ctrl-btn.shield-btn {
    width: 90%;
    max-width: 100%;
    min-width: 0;
    height: 40px;
    border-radius: 8px;
    padding: 0 6px;
    align-self: center;
    margin: 0 auto;
  }
  .shield-btn-content {
    gap: 5px;
  }
  .shield-btn-content svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }
  .shield-btn-content .btn-subtext {
    font-size: clamp(7.5px, 2.2vw, 9.5px);
    letter-spacing: 0.4px;
    overflow: visible;
    text-overflow: clip;
  }
  .ctrl-btn.action-btn {
    width: calc(var(--ctrl-btn-size) * 1.05);
    height: calc(var(--ctrl-btn-size) * 1.05);
    max-width: 86px;
    max-height: 86px;
    border-radius: 16px;
  }
  .btn-subtext {
    font-size: 8px;
  }
  .menu-card, .modal-card {
    padding: 22px 18px;
    max-height: 88vh;
  }
  .game-title {
    font-size: 20px;
  }
}

@media (max-width: 400px) {
  .hud-center {
    gap: 4px;
  }
  .energy-container {
    max-width: 82px;
    padding: 2px 4px;
  }
  .energy-percent {
    font-size: 10px;
  }
  .power-mode-title {
    font-size: 10.5px;
  }
  .power-mode-badge {
    font-size: 9px;
    padding: 1px 5px;
  }
}

/* ==========================================================================
   REINFORCEMENT LEARNING & AI AUTOPILOT HUD STYLES
   ========================================================================== */

/* RL Menu Action Buttons */
.rl-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  letter-spacing: 1.5px;
  font-size: 12.5px;
}

.rl-trained-btn {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2) 0%, rgba(14, 116, 144, 0.3) 100%);
  border-color: rgba(6, 182, 212, 0.5);
  color: #67e8f9;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

.rl-trained-btn:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.4) 0%, rgba(14, 116, 144, 0.5) 100%);
  border-color: #22d3ee;
  color: #ffffff;
  box-shadow: 0 0 25px rgba(34, 211, 238, 0.45);
  transform: translateY(-2px);
}

.rl-train-btn {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2) 0%, rgba(126, 34, 206, 0.3) 100%);
  border-color: rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.rl-train-btn:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.4) 0%, rgba(126, 34, 206, 0.5) 100%);
  border-color: #c084fc;
  color: #ffffff;
  box-shadow: 0 0 25px rgba(192, 132, 252, 0.45);
  transform: translateY(-2px);
}

/* ==========================================================================
   COMPACT AI AUTOPILOT PILL & RL TRAINING TOOLBAR (NON-INTRUSIVE)
   ========================================================================== */

/* AI Autopilot Compact Pill Widget */
.ai-compact-pill {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-compact-pill.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
}

.ai-pill-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(56, 189, 248, 0.2);
  font-family: var(--font-mono);
  font-size: 11px;
}

.ai-pill-badge {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--neon-cyan-bright);
}

.ai-pill-status {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.ai-pill-sep {
  color: rgba(255, 255, 255, 0.25);
  font-size: 10px;
}

.ai-pill-metric {
  color: var(--text-muted);
  font-size: 10.5px;
}

.ai-pill-metric b {
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
}

/* Hoverable Neural State Tooltip */
.ai-tooltip-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: help;
  user-select: none;
}

.ai-telemetry-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(10, 15, 30, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 15px rgba(56, 189, 248, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.ai-tooltip-trigger:hover .ai-telemetry-tooltip,
.ai-tooltip-trigger:focus .ai-telemetry-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.tooltip-title {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--neon-cyan-bright);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tooltip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 10px;
}

.tooltip-item span {
  color: var(--text-muted);
}

.tooltip-item b {
  color: #ffffff;
  font-family: var(--font-mono);
}

.ai-pill-exit {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 2px;
}

.ai-pill-exit:hover {
  background: rgba(244, 63, 94, 0.45);
  color: #fff;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
}

/* Compact RL Training Toolbar */
.rl-compact-hud {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.rl-compact-hud.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
}

.rl-compact-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 12px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.90);
  border: 1px solid rgba(192, 132, 252, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(168, 85, 247, 0.25);
  font-family: var(--font-mono);
}

.rl-compact-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rl-compact-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #c084fc;
}

.rl-compact-stat {
  font-size: 10.5px;
  color: var(--text-muted);
}

.rl-compact-stat b {
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
}

.rl-compact-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rl-speed-btn-group {
  display: flex;
  gap: 4px;
}

.rl-speed-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rl-speed-btn:hover {
  border-color: #c084fc;
  color: #ffffff;
}

.rl-speed-btn.active {
  background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
  border-color: #c084fc;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.ai-btn-sm {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-btn-sm:hover {
  background: rgba(148, 163, 184, 0.35);
  border-color: #ffffff;
}

.ai-exit-btn {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-exit-btn:hover {
  background: rgba(244, 63, 94, 0.45);
  color: #fff;
  box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
}

/* Pulse animation indicator */
.ai-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  animation: aiPulse 1.5s infinite;
}

.ai-pulse-dot.cyan {
  background: #00f0ff;
  box-shadow: 0 0 6px #00f0ff;
}

.ai-pulse-dot.purple {
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
}

@keyframes aiPulse {
  0% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.6; }
}

@media (max-width: 600px) {
  .ai-compact-pill {
    top: 54px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 96vw;
  }
  .rl-compact-hud {
    top: 54px;
    width: 96vw;
  }
  .rl-compact-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
  }
}

/* ==========================================================================
   ONLINE MULTIPLAYER STYLES
   ========================================================================== */
.online-menu-btn {
  background: linear-gradient(135deg, #0284c7 0%, #6366f1 50%, #8b5cf6 100%);
  border-color: rgba(147, 51, 234, 0.6);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
  color: #ffffff;
  position: relative;
  overflow: hidden;
}

.online-menu-btn:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #4f46e5 50%, #9333ea 100%);
  box-shadow: 0 6px 26px rgba(129, 140, 248, 0.65);
  transform: translateY(-2px);
}

.online-lobby-card {
  max-width: 540px;
  width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 26px;
}

/* Pilot Callsign Bar (Codenames style) */
.online-pilot-bar {
  background: rgba(10, 16, 32, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pilot-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.pilot-label-row .setting-label {
  margin: 0;
}

.pilot-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #38bdf8;
  opacity: 0.85;
}

.pilot-input-wrap {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  transition: all 0.2s ease;
}

.pilot-input-wrap:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
}

.pilot-input-icon {
  font-size: 18px;
  margin-right: 10px;
  user-select: none;
}

.pilot-name-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: font-size 0.15s ease, letter-spacing 0.15s ease;
}

.pilot-name-input::placeholder {
  color: #64748b;
  font-weight: normal;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* Tabs: Host vs Join (Segmented Cyberpunk Pill Control) */
.online-tabs-nav {
  display: flex;
  background: rgba(10, 16, 32, 0.85);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  margin-bottom: 20px;
  gap: 6px;
}

.online-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #94a3b8;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  outline: none;
}

.online-tab-btn:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.online-tab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.28) 0%, rgba(99, 102, 241, 0.35) 100%);
  border: 1px solid #38bdf8;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35), inset 0 0 10px rgba(56, 189, 248, 0.15);
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

.online-tab-btn .tab-icon {
  font-size: 15px;
  line-height: 1;
}

.online-tab-btn.active .tab-icon {
  filter: drop-shadow(0 0 6px #38bdf8);
}

.online-tab-pane {
  display: none;
}

.online-tab-pane.active {
  display: block;
}

/* Mission Crew Manifest Box */
.crew-manifest-box {
  background: rgba(10, 15, 30, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 14px 0 18px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.crew-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.crew-status-dot {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

.crew-status-dot.waiting {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.crew-status-dot.ready {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.crew-roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .crew-roster {
    grid-template-columns: 1fr;
  }
}

.crew-member {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-width: 0;
  transition: all 0.3s ease;
}

.crew-member.host {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.1);
}

.crew-member.guest {
  border-color: rgba(56, 189, 248, 0.2);
}

.crew-member.guest.connected {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
  background: rgba(15, 23, 42, 0.85);
}

.crew-member-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.crew-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.crew-avatar {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.crew-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crew-role-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crew-title {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #94a3b8;
  white-space: nowrap;
}

.crew-ship-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.crew-ship-badge.red {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.crew-ship-badge.blue {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.crew-name-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
}

.crew-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.8px;
  width: 100%;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
  transition: font-size 0.15s ease, letter-spacing 0.15s ease;
}

.crew-name.waiting {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: normal;
  white-space: nowrap;
}

.crew-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.crew-badge.connected {
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: #4ade80;
}

.crew-badge.waiting {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.35);
  color: #facc15;
  animation: radarGlow 1.8s infinite;
}

.crew-badge.ready-badge {
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid rgba(74, 222, 128, 0.65);
  color: #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.45);
  animation: readyPulse 1.4s ease-in-out infinite alternate;
}

.crew-badge.not-ready-badge {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.online-room-box {
  background: rgba(10, 15, 30, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.online-code-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.online-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.online-room-code {
  font-family: var(--font-mono);
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--neon-cyan);
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.8);
  user-select: all;
}

.online-code-actions {
  display: flex;
  gap: 8px;
}

.online-copy-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.online-copy-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.copy-toast {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #4ade80;
  margin-top: 8px;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
  transition: opacity 0.3s ease;
}

.online-subtext {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

.online-role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.online-role-card {
  background: rgba(15, 23, 42, 0.65);
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: var(--font-display);
}

.online-role-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(15, 23, 42, 0.85);
}

.online-role-card.active {
  border-color: var(--neon-cyan);
  background: rgba(14, 165, 233, 0.15);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.role-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.role-dot.red {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.role-dot.blue {
  background: #00f0ff;
  box-shadow: 0 0 8px #00f0ff;
}

.role-title {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
}

.role-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
  max-width: 100%;
  transition: font-size 0.15s ease;
}

.online-status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 16px 0;
}

.radar-scan-box {
  width: 32px;
  height: 32px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.radar-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
  position: relative;
}

.radar-pulse::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid #38bdf8;
  animation: radarRipple 1.6s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.radar-pulse.connected {
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
}

.radar-pulse.connected::after {
  border-color: #22c55e;
}

.radar-pulse.error {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

.radar-pulse.error::after {
  border-color: #ef4444;
}

@keyframes radarRipple {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

.online-status-info {
  flex: 1;
  text-align: left;
}

.online-status-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
  word-break: break-word;
  transition: font-size 0.15s ease, letter-spacing 0.15s ease;
}

.online-status-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

.online-modal-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.menu-btn.disabled, .menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.5);
  box-shadow: none;
}

.online-join-box {
  background: rgba(10, 15, 30, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  margin-bottom: 16px;
}

.join-input-wrapper {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.join-code-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s ease;
}

.join-code-input:focus {
  border-color: var(--neon-cyan-bright);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.join-submit-btn {
  width: auto;
  padding: 10px 20px;
  font-size: 12px;
  flex-shrink: 0;
}

.online-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(74, 222, 128, 0.5);
  border-radius: 12px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #e2e8f0;
  margin-top: 4px;
  transition: all 0.25s ease;
}

.online-status-badge .online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  transition: all 0.25s ease;
}

/* ==========================================================================
   2-PLAYER ONLINE CO-OP PAUSE BANNER
   High-visibility synchronized mission pause indicator
   ========================================================================== */
.pause-modal-card {
  max-width: 520px;
}

.pause-online-banner {
  margin: 0 0 20px 0;
  padding: 16px 18px;
  border-radius: 12px;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: pauseBannerPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pauseBannerPop {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Paused by the other player (Remote Pause Alert) */
.pause-online-banner.by-peer {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(220, 38, 38, 0.12) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.65);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.25), inset 0 0 15px rgba(245, 158, 11, 0.1);
}

.pause-online-banner.by-peer .pause-online-dot {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
  animation: beaconAmberPulse 1.2s infinite ease-in-out;
}

.pause-online-banner.by-peer .pause-online-badge {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
}

.pause-online-banner.by-peer .pause-online-title {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.pause-online-banner.by-peer .pause-online-pulse-text {
  color: #fbbf24;
}

/* Paused by the local player (You Paused) */
.pause-online-banner.by-you {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.16) 0%, rgba(59, 130, 246, 0.12) 100%);
  border: 1.5px solid rgba(6, 182, 212, 0.65);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.25), inset 0 0 15px rgba(6, 182, 212, 0.1);
}

.pause-online-banner.by-you .pause-online-dot {
  background: #06b6d4;
  box-shadow: 0 0 10px #06b6d4;
  animation: beaconCyanPulse 1.2s infinite ease-in-out;
}

.pause-online-banner.by-you .pause-online-badge {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.6);
  color: #bae6fd;
}

.pause-online-banner.by-you .pause-online-title {
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.pause-online-banner.by-you .pause-online-pulse-text {
  color: #38bdf8;
}

.pause-online-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pause-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes beaconAmberPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 6px #f59e0b, 0 0 14px rgba(245, 158, 11, 0.6);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.75;
    box-shadow: 0 0 12px #f59e0b, 0 0 22px rgba(245, 158, 11, 0.9);
  }
}

@keyframes beaconCyanPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 6px #06b6d4, 0 0 14px rgba(6, 182, 212, 0.6);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.75;
    box-shadow: 0 0 12px #06b6d4, 0 0 22px rgba(6, 182, 212, 0.9);
  }
}

.pause-online-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid;
  text-transform: uppercase;
}

.pause-online-role-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  text-transform: uppercase;
}

.pause-online-role-badge.red {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.15);
}

.pause-online-role-badge.blue {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.15);
}

.pause-online-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
  line-height: 1.3;
  margin-bottom: 6px;
  word-break: break-word;
}

.pause-online-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.5;
  margin: 0 0 10px 0;
}

.pause-online-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  font-size: 11px;
}

.pause-online-pulse-text {
  font-weight: 700;
  letter-spacing: 1px;
  animation: pulseOpacity 1.6s infinite ease-in-out;
  white-space: nowrap;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.pause-online-action-hint {
  color: var(--text-muted);
  font-size: 10.5px;
  text-align: right;
}

/* Online Status Badge Paused State in HUD */
.online-status-badge.is-paused {
  background: rgba(245, 158, 11, 0.25) !important;
  border-color: #f59e0b !important;
}

.online-status-badge.is-paused .online-dot {
  background: #f59e0b !important;
  box-shadow: 0 0 8px #f59e0b !important;
  animation: beaconAmberPulse 1s infinite !important;
}

/* Ready Up Button Active/Ready State */
.menu-btn.active-ready {
  background: linear-gradient(135deg, #15803d, #22c55e) !important;
  border-color: #4ade80 !important;
  color: #ffffff !important;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.5) !important;
}

@keyframes readyPulse {
  from {
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.3);
    transform: scale(1);
  }
  to {
    box-shadow: 0 0 14px rgba(74, 222, 128, 0.65);
    transform: scale(1.03);
  }
}

/* Online Lobby Countdown Overlay (Fortnite Style) */
.online-lobby-card {
  position: relative;
}

.online-countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.countdown-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 16, 32, 0.92);
  backdrop-filter: blur(8px);
}

.countdown-badge {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #38bdf8;
  border-radius: var(--radius-lg);
  padding: 24px 36px;
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.45);
  text-align: center;
}

.countdown-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.3);
  border-top-color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
  animation: countdownRingSpin 1s linear infinite;
}

@keyframes countdownRingSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.countdown-number {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 900;
  color: #38bdf8;
  text-shadow: 0 0 16px #38bdf8;
  animation: countdownDigitPulse 1s ease-in-out infinite alternate;
}

@keyframes countdownDigitPulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

.countdown-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 1px;
}

.countdown-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Online Rematch Squadron Box (Game Over Screen) */
.online-rematch-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

.rematch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rematch-title {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 1px;
}

.rematch-count-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.rematch-roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rematch-pilot-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(10, 16, 32, 0.65);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.rematch-pilot-role {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.rematch-pilot-name {
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
}

.rematch-status-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 4px;
  padding: 3px 6px;
  text-align: center;
  margin-top: 4px;
}

.rematch-status-badge.waiting {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.rematch-status-badge.ready {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.6);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.35);
}

.rematch-countdown-notice {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 800;
  color: #22c55e;
  text-shadow: 0 0 10px #22c55e;
  text-align: center;
  padding: 4px;
  letter-spacing: 0.8px;
  animation: readyPulse 1s ease-in-out infinite alternate;
}

/* Responsive Multiplayer HUD Compact Mode (COOP-03) */
@media (max-width: 768px) {
  #hud.multiplayer-active #hudMultiplayer {
    padding-right: 76px;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: space-between;
    width: 100%;
  }

  #hud.multiplayer-active .hud-mp-player {
    gap: 3px;
    flex-shrink: 1;
  }

  #hud.multiplayer-active .mp-player-badge {
    padding: 2px 5px 3px;
  }

  #hud.multiplayer-active .energy-hud {
    padding: 3px 5px;
    min-width: 48px;
  }

  #hud.multiplayer-active .energy-bar-track {
    width: 38px;
  }
}

