*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cyan: #00ffff;
  --bg: #020b18;
  --panel: rgba(0, 15, 35, 0.88);
  --border: rgba(0, 255, 255, 0.2);
  --text: #88ccdd;
  --label: #336677;
  --amber: #ffcc44; /* warm complement to cyan — used for subtitles and descriptive text */
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Courier New', monospace;
  color: var(--text);
}

#canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%; height: 100%;
  cursor: none;
}

/* ── Aim circle — projected onto 3D aim target by JS ── */
#crosshair {
  position: fixed;
  top: 0; left: 0;                  /* JS sets left/top each frame  */
  transform: translate(-50%, -50%); /* keeps circle centered on point */
  pointer-events: none;
  z-index: 20;
  border: 2px solid rgba(0, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3), inset 0 0 6px rgba(0, 255, 255, 0.08);
  width: 44px; height: 44px;
  transition: width 0.06s ease, height 0.06s ease, border-color 0.12s;
}
#crosshair::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  background: rgba(0, 255, 255, 0.9);
  border-radius: 50%;
}

/* ── Turret heading dot — desired aim point the turret traverses toward ── */
#turret-dot {
  position: fixed;
  top: 0; left: 0;                  /* JS positions each frame */
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 19;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* ── HUD ── */
#hud {
  position: absolute;
  top: 38px; left: 20px; /* below top status bar */
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-block {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 12px;
  min-width: 170px;
}

.hud-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--label);
  margin-bottom: 5px;
}

.hud-lives {
  font-size: 22px;
  color: #ffdd00;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 220, 0, 0.6);
}

#health-track {
  background: rgba(0,255,255,0.08);
  height: 5px;
  border: 1px solid var(--border);
}
#health-bar {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  transition: width 0.15s, background 0.3s;
}

#score, #wave-num {
  font-size: 26px;
  color: var(--cyan);
  letter-spacing: 2px;
}

#active-tactic {
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 2px;
  transition: color 0.4s;
}
.tactic-desc {
  font-size: 9px;
  letter-spacing: 1px;
  color: #557788;
  line-height: 1.5;
  margin-bottom: 4px;
}

.nn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 2px;
}
.nn-row span { width: 38px; color: var(--label); }
.nn-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.nn-bar {
  height: 100%;
  transition: width 0.7s ease, background 0.4s;
  width: 25%;
}

/* ── Wave message ── */
#wave-msg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  letter-spacing: 8px;
  color: var(--cyan);
  text-align: center;
  text-shadow: 0 0 24px var(--cyan);
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
#wave-msg.hidden { opacity: 0; }

/* ── Hit marker ── */
#hit-marker {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 25;
  width: 20px; height: 20px;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}
#hit-marker.active { opacity: 1; }
#hit-marker.kill { width: 28px; height: 28px; }
#hit-marker::before, #hit-marker::after {
  content: '';
  position: absolute;
  background: #ffffff;
  transition: background 0.08s;
}
#hit-marker.kill::before, #hit-marker.kill::after {
  background: #ff8800;
}
#hit-marker::before {
  top: 50%; left: 0;
  width: 100%; height: 2px;
  margin-top: -1px;
}
#hit-marker::after {
  top: 0; left: 50%;
  width: 2px; height: 100%;
  margin-left: -1px;
}


/* ── MG ammo ── */
#mg-ammo-val {
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--cyan);
  transition: color 0.2s;
}

/* ── Damage flash ── */
#damage-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: transparent;
  transition: background 0.05s;
}
#damage-flash.active { background: rgba(255,30,30,0.18); }

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(2, 11, 24, 0.92);
  pointer-events: all;
  overflow-y: auto;
  padding: 20px 0;
  z-index: 50; /* stay above mobile-controls overlay on iPad */
}
.screen.hidden { display: none; }

.screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  margin: auto;
}

h1 {
  font-size: 72px;
  letter-spacing: 18px;
  color: var(--cyan);
  text-shadow: 0 0 30px var(--cyan), 0 0 80px rgba(0,255,255,0.25);
}

.subtitle {
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255, 204, 68, 0.35);
}

.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px 28px;
  text-align: left;
}
.ctrl-key  { font-size: 11px; letter-spacing: 2px; color: var(--cyan); }
.ctrl-desc { font-size: 11px; color: var(--text); }

button {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  letter-spacing: 6px;
  padding: 12px 36px;
  cursor: pointer;
  pointer-events: all;
  transition: background 0.2s, box-shadow 0.2s;
  margin-top: 8px;
}
button:hover {
  background: rgba(0,255,255,0.08);
  box-shadow: 0 0 24px rgba(0,255,255,0.3);
}

/* ── Game-over panel — right-side cinematic layout ── */
#game-over-screen {
  position: fixed;
  inset: auto;
  right: 0;
  top: 0;
  width: 500px;
  height: 100vh;
  background: linear-gradient(90deg, transparent 0%, rgba(2, 11, 24, 0.97) 25%);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
#game-over-screen .screen-content {
  width: 440px;
  padding: 40px 32px 40px 28px;
  align-items: flex-start;
  text-align: left;
  margin: auto 0;
}
#game-over-screen h1 {
  font-size: 52px;
  letter-spacing: 10px;
}

#final-score   { font-size: 52px; color: var(--cyan); letter-spacing: 4px; }
#waves-survived { font-size: 36px; color: var(--cyan); letter-spacing: 2px; }

#ai-insight {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px 20px;
  width: 100%;
  box-sizing: border-box;
}
#ai-insight-text {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.7;
}
.ai-state-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}
.ai-state-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  opacity: 0.55;
  flex: 1;
  text-align: left;
}
.ai-tactic-pill {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan);
  background: rgba(0,220,200,0.08);
  border: 1px solid rgba(0,220,200,0.25);
  padding: 2px 8px;
}
.ai-tactic-pct {
  font-size: 10px;
  opacity: 0.6;
  min-width: 30px;
}
.ai-note {
  margin-top: 12px;
  font-size: 11px;
  opacity: 0.7;
  line-height: 1.6;
}

/* ── Heading indicator — always visible at bottom-right ── */
#heading-overlay {
  position: fixed;
  bottom: 20px; right: 20px;
  background: rgba(0,15,35,0.78);
  border: 1px solid rgba(0,255,255,0.3);
  padding: 6px 12px 8px;
  text-align: center;
  pointer-events: none;
  z-index: 20;
}
#heading-canvas {
  display: block;
  margin: 4px auto 0;
  width: 80px; height: 80px;
  opacity: 0.92;
}

/* ── Hit feedback (directional damage text) ── */
#hit-feedback {
  position: fixed;
  top: calc(50% - 70px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 3px;
  font-family: 'Courier New', monospace;
  pointer-events: none;
  z-index: 22;
  opacity: 0;
  transition: opacity 0.4s ease-out;
  text-shadow: 0 0 8px currentColor;
  white-space: nowrap;
}

/* ── Component damage panel ── */
#component-panel { min-width: 170px; }
.comp-row {
  font-size: 10px;
  letter-spacing: 2px;
  color: #ff4444;
  text-shadow: 0 0 8px rgba(255,68,68,0.6);
  margin-top: 4px;
  animation: comp-pulse 1.2s ease-in-out infinite;
}
@keyframes comp-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Inline audio controls (start screen + pause screen) ── */
.audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 16px;
}
.inline-mute {
  padding: 3px 10px;
  font-size: 14px;
  letter-spacing: 0;
  margin-top: 0;
  min-width: 34px;
}
.audio-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--label);
}
.inline-vol {
  width: 130px;
  accent-color: var(--cyan);
  cursor: pointer;
}

/* ── Upgrade tier badge ── */
.upg-tier {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--label);
}

/* ── Active buff display ── */
#buff-panel { min-width: 140px; }
.buff-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 2px;
}
.buff-name  { color: #00ccff; }
.buff-timer { color: var(--cyan); font-size: 11px; }

/* ── Upgrade picker ── */
.upg-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 20px;
}
.upg-stat {
  font-size: 18px;
  color: var(--cyan);
  letter-spacing: 2px;
  margin-right: 8px;
}
.upg-grid {
  display: flex;
  gap: 12px;
}
.upg-card {
  flex: 1;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 22px 18px;
  cursor: pointer;
  pointer-events: all;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.upg-card:hover {
  background: rgba(0, 255, 255, 0.10);
  border-color: rgba(0, 255, 255, 0.7);
  box-shadow: 0 0 22px rgba(0, 255, 255, 0.22);
}
.upg-tag  { font-size: 8px; letter-spacing: 2px; padding: 2px 7px; border: 1px solid; display: inline-block; margin-bottom: 2px; }
.upg-name { font-size: 12px; letter-spacing: 3px; color: var(--cyan); }
.upg-desc { font-size: 11px; letter-spacing: 1px; color: var(--text); line-height: 1.6; }

/* ── Pause screen ── */
#pause-screen .shop-stats { gap: 10px; }
#pause-screen .sstat-row  { font-size: 12px; letter-spacing: 2px; }

/* ── Shop ── */
.shop-stats {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 20px;
  width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sstat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  letter-spacing: 2px;
}
.sstat-label {
  width: 60px;
  color: var(--label);
}
.sstat-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(0,255,255,0.08);
  border: 1px solid var(--border);
}
.sstat-bar {
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  transition: width 0.3s;
  width: 100%;
}
.sstat-val {
  min-width: 70px;
  text-align: right;
  color: var(--cyan);
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 420px;
  max-height: 50vh;
  overflow-y: auto;
}
.shop-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  pointer-events: all;
}
.shop-item:hover {
  background: rgba(0, 255, 255, 0.07);
  border-color: rgba(0, 255, 255, 0.5);
}
.shop-item--disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.shop-item--disabled:hover {
  background: var(--panel);
  border-color: var(--border);
}
.shop-name { font-size: 12px; letter-spacing: 3px; color: var(--cyan); }
.shop-desc { font-size: 10px; letter-spacing: 1px; color: var(--text); }
.shop-cost { font-size: 11px; letter-spacing: 2px; color: #ffdd00; white-space: nowrap; }

/* ── Top status bar (desktop + mobile) ── */
#mob-status {
  display: flex; /* always visible */
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 7px 14px;
  background: rgba(2,11,24,0.78);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

/* Desktop-only items in the top bar */
.desk-only { display: inline; }

/* Desktop HUD key hint — right side of top status bar */
.hud-key-hint {
  margin-left: auto;
  font-size: 8px;
  letter-spacing: 2px;
  color: rgba(0,255,255,0.35);
  white-space: nowrap;
}
.hud-key-hint.hidden { display: none; }
#mob-hp-track {
  flex: 0 0 100px;
  height: 5px;
  background: rgba(0,255,255,0.08);
  border: 1px solid var(--border);
}
#mob-hp-bar {
  height: 100%;
  width: 100%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  transition: width 0.15s, background 0.3s;
}
#mob-score-val, #mob-wave-val {
  font-size: 17px;
  color: var(--cyan);
  letter-spacing: 1px;
}
.mob-sep { color: var(--border); font-size: 14px; }
.mob-lbl { font-size: 9px; letter-spacing: 2px; color: var(--label); }
.mob-buff-chip {
  font-size: 9px;
  letter-spacing: 2px;
  color: #00ccff;
  background: rgba(0,180,255,0.12);
  border: 1px solid rgba(0,180,255,0.35);
  padding: 1px 6px;
  white-space: nowrap;
  animation: buff-pulse 1.8s ease-in-out infinite;
}
.mob-buff-chip.hidden { display: none; }
@keyframes buff-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Mobile touch controls ── */
#mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#mobile-controls.hidden { display: none; }

/* HUD hidden state (mobile toggle) */
.hud-hidden { display: none !important; }

#joy-zone {
  position: absolute;
  bottom: 28px;
  left: 20px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 2px solid rgba(0,255,255,0.25);
  background: rgba(0,15,35,0.45);
  pointer-events: all;
  touch-action: none;
}
#joy-thumb {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0,255,255,0.35);
  border: 2px solid var(--cyan);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0,255,255,0.3);
}
#right-touch-zone {
  position: absolute;
  left: 50%;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: all;
  touch-action: none;
  z-index: 8;
}

/* Bottom-right mobile buttons */
#btn-fpv-mob, #btn-hud-mob, #btn-reload-mob {
  position: absolute;
  width: 110px;
  background: rgba(0,10,30,0.72);
  border: 1px solid rgba(0,255,255,0.45);
  color: var(--cyan);
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: all;
  z-index: 15;
  bottom: 0;
  height: 48px;
  font-size: 10px;
  opacity: 0.85;
}
#btn-fpv-mob    { right: 260px; }
#btn-reload-mob { right: 140px; color: #ffee44; border-color: rgba(255,238,68,0.45); }
#btn-hud-mob    { right: 20px; }

/* Active state for toggle buttons */
.mob-btn-active {
  background: rgba(0,255,255,0.16) !important;
  border-color: var(--cyan) !important;
  box-shadow: 0 0 14px rgba(0,255,255,0.28);
  opacity: 1 !important;
}

/* ── Score popup ── */
.score-popup {
  position: absolute;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffff44;
  text-shadow: 0 0 10px #ffaa00, 0 0 20px #ff8800;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 25;
  animation: scoreFloat 1.2s ease-out forwards;
  white-space: nowrap;
}
@keyframes scoreFloat {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0px); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-70px); }
}

/* ── Main menu ── */
.menu-btns {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.menu-btns button { width: 220px; }

.btn-secondary {
  border-color: rgba(0, 255, 255, 0.4);
  color: rgba(0, 255, 255, 0.7);
  font-size: 12px;
  letter-spacing: 5px;
  padding: 10px 36px;
}
.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,255,255,0.06);
  box-shadow: 0 0 16px rgba(0,255,255,0.2);
}

.btn-back {
  font-size: 11px;
  letter-spacing: 4px;
  border-color: rgba(0,255,255,0.3);
  color: rgba(0,255,255,0.6);
  padding: 8px 24px;
  margin-top: 16px;
}
.btn-back:hover { color: var(--cyan); border-color: var(--cyan); }

.panel-title {
  font-size: 18px;
  letter-spacing: 8px;
  color: var(--amber);
  margin-bottom: 16px;
  text-shadow: 0 0 12px rgba(255,204,68,0.3);
}

.menu-sub-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 320px;
}
.menu-sub-panel.hidden { display: none; }

/* ── Upgrade log (pause screen) ── */
.upgrade-log {
  width: 400px;
  max-height: 160px;
  overflow-y: auto;
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(0,200,255,0.15);
  text-align: left;
}
.upgrade-log-title {
  font-size: 9px;
  letter-spacing: 3px;
  color: rgba(0,200,255,0.6);
  margin-bottom: 6px;
}
.upgrade-log-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.75);
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.upgrade-log-row:last-child { border-bottom: none; }
.upgrade-log-src {
  font-size: 8px;
  letter-spacing: 2px;
  margin-right: 8px;
  opacity: 0.5;
  flex-shrink: 0;
}
.upgrade-log-tag {
  font-size: 8px;
  letter-spacing: 1px;
  opacity: 0.55;
  flex-shrink: 0;
}
.upgrade-log.hidden { display: none; }

/* ── How to Play ── */
#menu-howto-panel {
  max-width: 520px;
  width: 90vw;
}
.howto-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 8px;
  text-align: left;
}
.howto-section { border-left: 2px solid rgba(0,200,255,0.25); padding-left: 12px; }
.howto-title {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--cyan);
  margin-bottom: 5px;
}
.howto-sections p {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin: 3px 0;
  line-height: 1.6;
  letter-spacing: 0.5px;
}
.howto-sections strong { color: rgba(255,255,255,0.95); }
.howto-list {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin: 4px 0 4px 14px;
  padding: 0;
  line-height: 1.7;
  letter-spacing: 0.5px;
}
.howto-list li { margin-bottom: 2px; }
.howto-list strong { color: rgba(255,255,255,0.95); }

/* ── Leaderboard ── */
#leaderboard-entries {
  min-width: 380px;
  max-width: 480px;
}
.lb-empty {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--label);
  padding: 20px;
  text-align: center;
}
.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 5px;
  font-size: 11px;
  letter-spacing: 2px;
}
.lb-row.lb-top {
  border-color: var(--amber);
  box-shadow: 0 0 14px rgba(255,204,68,0.15);
}
.lb-rank  { color: var(--label); font-size: 10px; }
.lb-top .lb-rank { color: var(--amber); font-size: 13px; }
.lb-score { color: var(--cyan); font-size: 16px; letter-spacing: 1px; }
.lb-top .lb-score { color: var(--amber); }
.lb-detail { color: var(--text); font-size: 10px; white-space: nowrap; }
.lb-date   { color: var(--label); font-size: 9px; white-space: nowrap; }

/* ── Hull selection ── */
.hull-grid {
  display: flex;
  gap: 16px;
  margin: 20px 0 28px;
  flex-wrap: wrap;
  justify-content: center;
}
.hull-choice {
  border: 1px solid rgba(0,255,255,0.2);
  background: rgba(0,15,35,0.75);
  padding: 20px 16px;
  min-width: 180px;
  max-width: 200px;
  cursor: pointer;
  pointer-events: all;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}
.hull-choice:hover {
  border-color: rgba(0,255,255,0.6);
  background: rgba(0,30,60,0.9);
}
.hull-choice.selected {
  border-color: var(--cyan);
  background: rgba(0,40,70,0.95);
  box-shadow: 0 0 18px rgba(0,255,255,0.25);
}
.hull-name {
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  margin-bottom: 4px;
}
.hull-role {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--amber);
  margin-bottom: 14px;
}
.hull-stats { margin-bottom: 12px; }
.hstat {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(0,255,255,0.08);
  color: #88ccdd;
}
.hull-desc {
  font-size: 11px;
  color: #aabbcc;
  letter-spacing: 1px;
  line-height: 1.6;
}

/* ── Hull card per-type colour coding ── */
.hull-choice[data-hull="vanguard"] .hull-name { color: #00ffff; text-shadow: 0 0 10px #00ffff; }
.hull-choice[data-hull="blitzer"]  .hull-name { color: #88ff00; text-shadow: 0 0 10px #88ff00; }
.hull-choice[data-hull="bastion"]  .hull-name { color: #ff5500; text-shadow: 0 0 10px #ff5500; }
.hull-choice[data-hull="vanguard"] .hull-role { color: #00ccdd; }
.hull-choice[data-hull="blitzer"]  .hull-role { color: #66cc00; }
.hull-choice[data-hull="bastion"]  .hull-role { color: #cc4400; }
.hull-choice[data-hull="vanguard"].selected { border-color: #00ffff; box-shadow: 0 0 22px rgba(0,255,255,0.3); }
.hull-choice[data-hull="blitzer"].selected  { border-color: #88ff00; box-shadow: 0 0 22px rgba(136,255,0,0.3); background: rgba(10,30,0,0.95); }
.hull-choice[data-hull="bastion"].selected  { border-color: #ff5500; box-shadow: 0 0 22px rgba(255,85,0,0.3);  background: rgba(30,10,0,0.95); }
.hull-choice[data-hull="blitzer"]:hover     { border-color: rgba(136,255,0,0.6); background: rgba(5,20,0,0.9); }
.hull-choice[data-hull="bastion"]:hover     { border-color: rgba(255,85,0,0.6);  background: rgba(20,5,0,0.9); }
.hull-choice[data-hull="phantom"]  .hull-name { color: #cc44ff; text-shadow: 0 0 10px #cc44ff; }
.hull-choice[data-hull="ironclad"] .hull-name { color: #ffcc00; text-shadow: 0 0 10px #ffcc00; }
.hull-choice[data-hull="phantom"]  .hull-role { color: #aa33dd; }
.hull-choice[data-hull="ironclad"] .hull-role { color: #ddaa00; }
.hull-choice[data-hull="phantom"].selected  { border-color: #cc44ff; box-shadow: 0 0 22px rgba(204,68,255,0.3);  background: rgba(20,0,30,0.95); }
.hull-choice[data-hull="ironclad"].selected { border-color: #ffcc00; box-shadow: 0 0 22px rgba(255,204,0,0.3);   background: rgba(30,25,0,0.95); }
.hull-choice[data-hull="phantom"]:hover     { border-color: rgba(204,68,255,0.6); background: rgba(15,0,25,0.9); }
.hull-choice[data-hull="ironclad"]:hover    { border-color: rgba(255,204,0,0.6);  background: rgba(25,20,0,0.9); }
.hull-choice[data-hull="reaper"]   .hull-name { color: #dd0033; text-shadow: 0 0 10px #dd0033; }
.hull-choice[data-hull="viper"]    .hull-name { color: #00ffaa; text-shadow: 0 0 10px #00ffaa; }
.hull-choice[data-hull="specter"]  .hull-name { color: #4488ff; text-shadow: 0 0 10px #4488ff; }
.hull-choice[data-hull="colossus"] .hull-name { color: #ff9900; text-shadow: 0 0 10px #ff9900; }
.hull-choice[data-hull="reaper"]   .hull-role { color: #aa0022; }
.hull-choice[data-hull="viper"]    .hull-role { color: #00cc88; }
.hull-choice[data-hull="specter"]  .hull-role { color: #3366cc; }
.hull-choice[data-hull="colossus"] .hull-role { color: #cc7700; }
.hull-choice[data-hull="reaper"].selected   { border-color: #dd0033; box-shadow: 0 0 22px rgba(221,0,51,0.3);   background: rgba(25,0,5,0.95); }
.hull-choice[data-hull="viper"].selected    { border-color: #00ffaa; box-shadow: 0 0 22px rgba(0,255,170,0.3);  background: rgba(0,25,15,0.95); }
.hull-choice[data-hull="specter"].selected  { border-color: #4488ff; box-shadow: 0 0 22px rgba(68,136,255,0.3); background: rgba(0,10,30,0.95); }
.hull-choice[data-hull="colossus"].selected { border-color: #ff9900; box-shadow: 0 0 22px rgba(255,153,0,0.3);  background: rgba(28,18,0,0.95); }
.hull-choice[data-hull="reaper"]:hover      { border-color: rgba(221,0,51,0.6);   background: rgba(20,0,4,0.9); }
.hull-choice[data-hull="viper"]:hover       { border-color: rgba(0,255,170,0.6);  background: rgba(0,20,12,0.9); }
.hull-choice[data-hull="specter"]:hover     { border-color: rgba(68,136,255,0.6); background: rgba(0,8,25,0.9); }
.hull-choice[data-hull="colossus"]:hover    { border-color: rgba(255,153,0,0.6);  background: rgba(22,14,0,0.9); }

/* ── Hull confirm button — fixed so it's always in thumb reach ── */
#btn-hull-confirm {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  box-shadow: 0 0 32px rgba(2,11,24,0.95), 0 0 18px rgba(0,255,255,0.2);
  white-space: nowrap;
}
#hull-select-screen .screen-content { padding-bottom: 88px; }

/* ── Classified archives section ── */
.hull-archives {
  width: 100%;
  max-width: 700px;
  margin: 8px 0 24px;
}
.hull-archives-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  border-top: 1px solid rgba(120,50,0,0.35);
  padding-top: 14px;
}
.hull-archives-badge {
  background: rgba(80,20,0,0.8);
  border: 1px solid rgba(180,60,0,0.6);
  color: #cc4400;
  padding: 3px 10px;
  font-size: 9px;
  letter-spacing: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.hull-archives-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: #664422;
}
.hull-archives-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
/* Compact cards inside archives — show name/role/cost only */
.hull-archives-grid .hull-choice {
  min-width: 130px;
  max-width: 150px;
  padding: 14px 12px 12px;
}
.hull-archives-grid .hull-choice .hull-stats,
.hull-archives-grid .hull-choice .hull-desc { display: none; }
.hull-archives-grid .hull-choice .hull-name { font-size: 14px; letter-spacing: 3px; }
.hull-archives-grid .hull-choice .hull-role { font-size: 9px; letter-spacing: 2px; margin-bottom: 10px; }

/* ── Locked hull cards ── */
.hull-choice.hull-locked {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.hull-lock-info {
  margin-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 10px;
}
.hull-cp-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #ffaa00;
  margin-bottom: 6px;
}
.hull-cp-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-bottom: 5px;
}
.hull-cp-bar-fill {
  height: 100%;
  background: #ffaa00;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.hull-cp-progress {
  font-size: 10px;
  color: #777;
  letter-spacing: 1px;
}

/* ── CP header on hull select ── */
.hull-select-cp-row {
  font-size: 11px;
  letter-spacing: 3px;
  color: #ffaa00;
  margin-bottom: 6px;
}
.hull-select-cp-val {
  color: #ffdd44;
  font-size: 15px;
}

/* ── Game over CP section ── */
#go-cp-section {
  margin: 14px 0 6px;
  padding: 14px 18px;
  border: 1px solid rgba(255,170,0,0.3);
  background: rgba(20,14,0,0.7);
  width: 100%;
  box-sizing: border-box;
}
.go-cp-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 2px;
  color: #aabbcc;
  padding: 3px 0;
}
.go-cp-val { color: #ffdd44; }
#go-cp-next { margin-top: 10px; }
.cp-next-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #ffaa44;
  margin-bottom: 5px;
}
.cp-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-bottom: 4px;
}
.cp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff8800, #ffcc00);
  border-radius: 2px;
}
.cp-next-cost {
  font-size: 10px;
  color: #777;
  letter-spacing: 1px;
  text-align: right;
}
.cp-unlock-banner {
  display: block;
  font-size: 14px;
  letter-spacing: 4px;
  color: #ffdd00;
  text-shadow: 0 0 20px #ffaa00, 0 0 40px #ff8800;
  text-align: center;
  padding: 8px 0;
  animation: cpUnlockPulse 0.9s ease-in-out infinite alternate;
}
@keyframes cpUnlockPulse {
  from { opacity: 0.75; text-shadow: 0 0 20px #ffaa00; }
  to   { opacity: 1.0;  text-shadow: 0 0 30px #ffaa00, 0 0 60px #ff8800; }
}
.cp-all-done {
  font-size: 11px;
  letter-spacing: 3px;
  color: #00ffaa;
  text-align: center;
  padding: 6px 0;
}

/* ── Wave standby indicator ── */
#wave-standby {
  position: fixed;
  bottom: 75px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--label);
  pointer-events: none;
  z-index: 15;
  animation: standby-blink 1.2s ease-in-out infinite;
  white-space: nowrap;
}
#wave-standby.hidden { display: none; }
@keyframes standby-blink {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 0.15; }
}

/* ── Settings panel sections ── */
.settings-section {
  width: 100%;
  margin-top: 4px;
}
.settings-section-title {
  font-size: 8px;
  letter-spacing: 3px;
  color: var(--label);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
  margin-top: 4px;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.settings-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text);
  min-width: 110px;
}
.preset-btn {
  font-size: 9px;
  letter-spacing: 3px;
  padding: 4px 12px;
  margin-top: 0;
  border-color: rgba(0,255,255,0.3);
  color: rgba(0,255,255,0.55);
}
.preset-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,255,255,0.08);
  box-shadow: 0 0 10px rgba(0,255,255,0.15);
}
.preset-btn.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,255,255,0.10);
  box-shadow: 0 0 10px rgba(0,255,255,0.2);
}

/* ── In-game controls hint ── */
#controls-hint {
  position: absolute;
  bottom: 140px; right: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px 14px;
  pointer-events: all;
  z-index: 15;
  min-width: 220px;
}
#controls-hint.hidden { display: none; }
.hint-header {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--label);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hint-close {
  cursor: pointer;
  color: rgba(0,255,255,0.5);
  font-size: 12px;
  padding: 0 2px;
  transition: color 0.15s;
}
.hint-close:hover { color: var(--cyan); }
.hint-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 1px;
  margin-bottom: 3px;
}
.hint-key { color: var(--cyan); }
.hint-row span:last-child { color: var(--text); }

/* ── Left-side fire buttons (above joystick for left-thumb firing) ── */
#btn-fire-cannon-l, #btn-fire-mg-l {
  position: absolute;
  width: 62px;
  height: 52px;
  bottom: 170px;
  background: rgba(0,10,30,0.72);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: 'Courier New', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 0 8px rgba(0,255,255,0.12);
  z-index: 15;
}
#btn-fire-cannon-l { left: 20px; }
#btn-fire-mg-l     { left: 88px; }

/* ── Mobile pause button — top-right ── */
#btn-pause-mob {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 48px;
  height: 36px;
  background: rgba(0,15,35,0.75);
  border: 1px solid rgba(0,255,255,0.3);
  color: var(--cyan);
  font-size: 16px;
  letter-spacing: 2px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  pointer-events: all;
  touch-action: manipulation;
  z-index: 30;
}


/* ── Low-HP danger vignette ── */
#low-hp-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(200,0,0,0.6) 100%);
  opacity: 0;
}
/* Heartbeat double-pulse at <25% HP */
#low-hp-vignette.active {
  animation: heartbeat 1.6s ease-in-out infinite;
}
/* Frantic pulse at <12% HP */
#low-hp-vignette.lhp-critical {
  animation: heartbeat 0.75s ease-in-out infinite;
  background: radial-gradient(ellipse at center, transparent 44%, rgba(220,0,0,0.72) 100%);
}
@keyframes heartbeat {
  0%, 100% { opacity: 0.35; }
  12%      { opacity: 0.72; }
  26%      { opacity: 0.35; }
  38%      { opacity: 0.92; }
  55%, 90% { opacity: 0.35; }
}

/* ── Boss HP bar ── */
#boss-bar-container {
  position: fixed;
  top: 40px; left: 50%;
  transform: translateX(-50%);
  width: min(520px, 72vw);
  text-align: center;
  pointer-events: none;
  z-index: 20;
}
#boss-bar-container.hidden { display: none; }
#boss-bar-label {
  color: #ff4400;
  font-size: 10px;
  letter-spacing: 4px;
  margin-bottom: 5px;
  text-shadow: 0 0 12px rgba(255,68,0,0.9);
}
/* Critical: label flashes */
#boss-bar-container.boss-critical #boss-bar-label {
  animation: boss-label-flash 0.55s ease-in-out infinite;
  color: #ff1100;
}
@keyframes boss-label-flash {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
#boss-bar-track {
  position: relative;
  overflow: hidden;
  width: 100%; height: 12px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,68,0,0.5);
  box-shadow: 0 0 18px rgba(255,68,0,0.25);
}
/* Scan-line shimmer sweeping left→right */
#boss-bar-track::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -30%; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255,200,150,0.28), transparent);
  animation: boss-scan 2.8s linear infinite;
  pointer-events: none;
}
@keyframes boss-scan { to { left: 110%; } }
#boss-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #bb1100, #ff5500, #ff7700);
  box-shadow: 0 0 10px rgba(255,80,0,0.8);
  transition: width 0.12s linear;
}
/* Critical: bar turns blood-red */
#boss-bar-container.boss-critical #boss-bar-fill {
  background: linear-gradient(90deg, #ff0000, #ff3300);
  box-shadow: 0 0 14px rgba(255,0,0,0.95);
  animation: boss-fill-pulse 0.55s ease-in-out infinite;
}
@keyframes boss-fill-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.6); }
}
#boss-bar-hp-text {
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255,110,30,0.65);
  margin-top: 4px;
}

/* ── Training mode banner ── */
#training-banner {
  position: fixed;
  top: 38px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 20, 5, 0.88);
  border: 1px solid rgba(0, 255, 100, 0.35);
  padding: 5px 14px;
  pointer-events: all;
  z-index: 20;
  font-size: 10px;
  letter-spacing: 3px;
  color: #00ff88;
  white-space: nowrap;
}
#training-banner.hidden { display: none; }
.training-exit-hint { opacity: 0.6; font-size: 9px; letter-spacing: 2px; }

@media (max-width: 600px) {
  #hud { gap: 5px; max-height: calc(100vh - 275px); overflow-y: auto; }
  .hud-block { padding: 5px 8px; min-width: 130px; }
  /* AI protocol is too dense for mobile — hide it from the toggle HUD */
  #nn-panel { display: none; }
  h1 { font-size: 48px; letter-spacing: 10px; }
  .upg-grid { flex-direction: column; }
  .shop-grid { max-height: 45vh; }
  /* Push boss bar below mobile status strip; narrower on small screens */
  #boss-bar-container { top: 38px; width: min(300px, 58vw); }
  /* Heading overlay: move above the bottom buttons instead of hiding */
  #heading-overlay { bottom: 52px; right: 20px; padding: 4px 8px 5px; }
  #heading-canvas { width: 60px; height: 60px; }
  /* Controls hint: show at top-center on mobile */
  #controls-hint { bottom: auto; top: 44px; right: auto; left: 50%; transform: translateX(-50%); min-width: 260px; }
  /* Desk-only items hidden on mobile */
  .desk-only { display: none !important; }
}
