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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #88aacc;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  color: #eef;
}

#canvas-wrap {
  position: fixed;
  inset: 0;
}

#canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Settings button + panel ── */
#settings-wrap {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 30;
  user-select: none;
}

#settings-btn {
  background: rgba(10, 18, 32, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.35);
  color: rgba(200, 220, 255, 0.85);
  font-family: 'Courier New', Courier, monospace;
  font-size: 18px;
  line-height: 1;
  width: 34px;
  height: 34px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
#settings-btn:hover {
  background: rgba(30, 50, 90, 0.85);
  border-color: rgba(100, 160, 255, 0.65);
}

#settings-panel {
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  width: min(600px, calc(100vw - 24px));
  background: rgba(8, 14, 28, 0.92);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 4px;
  padding: 10px 18px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
#settings-panel.settings-open {
  display: block;
}

/* ── Settings tabs ── */
.sp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(100, 160, 255, 0.20);
  margin-bottom: 14px;
}
.sp-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 6px 12px 8px;
  color: rgba(140, 170, 230, 0.50);
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}
.sp-tab:hover { color: rgba(180, 210, 255, 0.80); }
.sp-tab.sp-tab-active {
  color: rgba(190, 215, 255, 0.95);
  border-bottom-color: rgba(100, 160, 255, 0.75);
}
.sp-pane { display: none; }
.sp-pane.sp-pane-active { display: block; }

/* .settings-title replaced by .sp-tabs */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.settings-label {
  font-size: 14px;
  color: rgba(220, 235, 255, 0.90);
  letter-spacing: 0.04em;
}

.settings-sub { padding-left: 14px; }
.settings-sub-header { margin-bottom: 0; padding-bottom: 0; }

/* Difficulty slider */
.settings-diff {
  padding: 5px 0 2px;
  border-top: 1px solid rgba(100, 160, 255, 0.10);
  margin-top: 4px;
}

#diff-slider {
  display: block;
  width: 100%;
  margin: 5px 0 3px;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(60, 100, 200, 0.40);
  outline: none;
  cursor: pointer;
}
#diff-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: rgba(140, 185, 255, 0.88);
  cursor: pointer;
  border: 1px solid rgba(100, 160, 255, 0.55);
}
#diff-slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: rgba(140, 185, 255, 0.88);
  cursor: pointer;
  border: 1px solid rgba(100, 160, 255, 0.55);
}

.diff-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(150, 180, 255, 0.55);
  letter-spacing: 0.04em;
  user-select: none;
}

.settings-select {
  display: block;
  width: 100%;
  margin: 5px 0 3px;
  background: rgba(0, 20, 60, 0.85);
  color: rgba(150, 180, 255, 0.90);
  border: 1px solid rgba(100, 160, 255, 0.40);
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* Changelog */
.cl-details {
  margin-top: 10px;
  border-top: 1px solid rgba(100, 160, 255, 0.15);
  padding-top: 8px;
}
.cl-summary {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(100, 160, 255, 0.55);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.cl-summary::-webkit-details-marker { display: none; }
.cl-summary::after {
  content: ' +';
  color: rgba(100, 160, 255, 0.40);
}
.cl-details[open] .cl-summary::after { content: ' -'; }
.cl-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}
.cl-entry {
  font-size: 13px;
  color: rgba(190, 210, 245, 0.80);
  line-height: 1.6;
}
.cl-entry code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: rgba(140, 210, 255, 0.90);
  background: rgba(0, 20, 50, 0.50);
  padding: 1px 4px;
  border-radius: 2px;
  white-space: pre;
}
.cl-tag {
  color: rgba(100, 160, 255, 0.75);
  font-weight: bold;
  margin-right: 4px;
}
.setup-list {
  margin: 4px 0 2px 18px;
  padding: 0;
}
.setup-list li {
  margin-bottom: 3px;
}
.setup-pre {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: rgba(140, 210, 255, 0.90);
  background: rgba(0, 20, 50, 0.55);
  border-left: 2px solid rgba(80, 140, 220, 0.40);
  padding: 6px 10px;
  margin: 6px 0 4px 0;
  border-radius: 3px;
  white-space: pre;
  overflow-x: auto;
}

/* Toggle switch */
.toggle-wrap {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(60, 80, 120, 0.60);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 20px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: rgba(140, 180, 255, 0.70);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-wrap input:checked + .toggle-slider {
  background: rgba(40, 100, 220, 0.75);
  border-color: rgba(100, 160, 255, 0.60);
}
.toggle-wrap input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: rgba(180, 210, 255, 0.95);
}

/* ── HUD overlay ── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  user-select: none;
}

#hud-topleft {
  position: absolute;
  top: 52px; left: 14px;  /* pushed down to clear the settings button */
  display: flex;
  flex-direction: column;
  gap: 3px;
}


#hud-bottomleft {
  position: absolute;
  bottom: 8px; left: 8px;
}

.hud-label {
  color: #CCDDCC;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

.hud-val {
  color: #E8F0E8;
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

#hud-title {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 0.18em;
  color: rgba(255,255,220,0.80);
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  text-transform: uppercase;
}

#hud-phase {
  font-size: 13px;
  letter-spacing: 0.10em;
  color: rgba(200,215,255,0.45);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Two-panel HUD info box ── */
.hud-info-container {
  display: flex;
  gap: 1px;
}

.hud-info-left,
.hud-info-right {
  background: rgba(0, 0, 0, 0.80);
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #CCDDCC;
  border: 1px solid rgba(100, 200, 100, 0.20);
}

.hil-mode {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(100, 160, 255, 0.60);
  margin-bottom: 2px;
}

.hil-name {
  font-size: 16px;
  font-weight: bold;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  line-height: 1.2;
}

.hil-faction {
  font-size: 11px;
  color: #88AA88;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* Advanced block (speed / heading / pos) — hidden by default */
.hil-adv-block {
  display: none;
  margin-top: 4px;
  margin-bottom: 4px;
}
.hud-info-left.adv .hil-adv-block { display: block; }

.hil-kv {
  display: flex;
  gap: 8px;
}
.hil-key {
  color: rgba(180, 200, 255, 0.55);
  min-width: 72px;
  letter-spacing: 0.04em;
}
.hil-val { color: #88FF88; }

/* Status section */
.hil-status {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.hil-hp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Reload indicator: hidden in basic, shown in advanced */
.hil-ready {
  font-size: 13px;
  color: rgba(120, 255, 120, 0.85);
  display: none;
}
.hud-info-left.adv .hil-ready { display: inline; }

/* Speed damage state indicator */
.hil-speed-state {
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

/* Consumables: column in basic, row in advanced */
.hil-consumables {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hud-info-left.adv .hil-consumables {
  flex-direction: row;
  gap: 14px;
}

/* Right panel — controls reference */
.hud-info-right {
  min-width: 175px;
}
.hir-row {
  display: flex;
  gap: 10px;
}
.hir-key {
  color: #88FF88;
  font-weight: bold;
  min-width: 50px;
  display: inline-block;
}
.hir-action { color: #88AA88; }

/* ── Hit indicator ── */
#hud-hit-indicator {
  position: fixed;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: 'Courier New', Courier, monospace;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none;
  user-select: none;
  z-index: 15;
  opacity: 0;
  white-space: nowrap;
}

/* ── Menu warning (above overlay, tank selection) ── */
#menu-warn {
  position: fixed;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'Courier New', Courier, monospace;
  color: rgba(255, 80, 60, 0.95);
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none;
  user-select: none;
  z-index: 25;
  display: none;
  white-space: nowrap;
}

/* ── Encounter message ── */
#hud-encounter {
  position: fixed;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'Courier New', Courier, monospace;
  color: rgba(180, 220, 255, 0.90);
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none;
  user-select: none;
  z-index: 15;
  opacity: 0;
  white-space: nowrap;
}

/* ── Obliterator customise label ── */
.ts-customise-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(120, 180, 255, 0.60);
  text-align: center;
  margin-bottom: 4px;
}

/* ── Mercenary stat adjust buttons (Obliterator) ── */
.merc-adj {
  background: rgba(60, 80, 110, 0.85);
  border: 1px solid rgba(120, 180, 255, 0.35);
  color: rgba(200, 225, 255, 0.95);
  font-size: 13px;
  font-family: 'Courier New', Courier, monospace;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
  pointer-events: auto;
}
.merc-adj:hover {
  background: rgba(80, 120, 180, 0.95);
  border-color: rgba(150, 200, 255, 0.6);
}

/* ── Edge-of-map warning ── */
#hud-edge-warning {
  display: none;
  position: fixed;
  top: 33%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 60, 60, 0.92);
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  pointer-events: none;
  user-select: none;
  z-index: 15;
  animation: blink 0.9s ease-in-out infinite;
}

/* ── Overlay controls list ── */
#overlay-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 4px;
  text-align: left;
  min-width: 260px;
  pointer-events: auto;
}

.ctrl-row {
  display: flex;
  gap: 10px;
  font-size: 15px;
  color: rgba(200, 220, 255, 0.65);
  letter-spacing: 0.04em;
}

.ctrl-key {
  min-width: 110px;
  text-align: right;
  color: rgba(255, 240, 160, 0.80);
  font-weight: bold;
}

.ctrl-desc {
  color: rgba(190, 210, 255, 0.60);
}

.ctrl-tip {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(160, 185, 255, 0.42);
  letter-spacing: 0.05em;
  text-align: center;
}

/* ── Tank selection (menu overlay) ── */
.ts-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  margin-bottom: 4px;
}
.ts-arrow {
  background: rgba(60, 80, 110, 0.85);
  border: 1px solid rgba(120, 180, 255, 0.35);
  color: rgba(200, 225, 255, 0.95);
  font-size: 15px;
  font-family: 'Courier New', Courier, monospace;
  width: 28px;
  height: 28px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
  pointer-events: auto;
  user-select: none;
}
.ts-arrow:hover:not(:disabled) {
  background: rgba(80, 120, 180, 0.95);
  border-color: rgba(150, 200, 255, 0.6);
}
.ts-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}
.ts-name {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: rgba(255, 248, 200, 0.95);
  text-transform: uppercase;
  min-width: 310px;
  text-align: center;
}
.ts-faction {
  font-size: 13px;
  color: rgba(180, 210, 180, 0.60);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 10px;
}
.ts-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 340px;
}
.ts-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}
.ts-label {
  min-width: 90px;
  text-align: right;
  color: rgba(180, 200, 255, 0.55);
  letter-spacing: 0.05em;
}
.ts-bar {
  color: rgba(120, 200, 120, 0.82);
  letter-spacing: 0.04em;
  font-size: 14px;
}
.ts-val {
  color: rgba(255, 240, 160, 0.90);
  width: 82px;
  flex-shrink: 0;
  font-size: 16px;
}
.merc-adj-pair {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  width: 50px;
  justify-content: flex-end;
}
.ts-counter {
  text-align: center;
  font-size: 14px;
  color: rgba(160, 180, 255, 0.65);
  margin-top: 8px;
  letter-spacing: 0.08em;
}

/* ── Game state overlay ── */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 8vh;
  gap: 10px;
  pointer-events: none;
  user-select: none;
  z-index: 20;
  transition: opacity 0.25s ease;
}

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

.overlay-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.78);
}

#overlay-title {
  font-size: 54px;
  font-weight: bold;
  letter-spacing: 0.22em;
  color: rgba(255, 248, 200, 0.95);
  text-shadow: 0 3px 12px rgba(0,0,0,0.9);
  text-transform: uppercase;
}

#overlay-sub {
  font-size: 18px;
  letter-spacing: 0.12em;
  color: rgba(200, 220, 255, 0.70);
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

#overlay-score {
  font-size: 20px;
  letter-spacing: 0.10em;
  color: rgba(255, 240, 140, 0.90);
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  margin-top: 8px;
}

#overlay-hint {
  font-size: 16px;
  letter-spacing: 0.14em;
  color: rgba(220, 235, 255, 0.90);
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  margin-top: 14px;
  padding: 8px 24px;
  background: rgba(0, 0, 0, 0.60);
  border-radius: 3px;
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.3; }
}

/* ── Target acquisition HUD ── */
#hud-target {
  position: fixed;
  top: 78px;
  left: 14px;
  display: none;
  pointer-events: none;
  user-select: none;
}

#hud-target-name {
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 0.10em;
  color: rgba(255, 125, 95, 0.92);
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
  text-transform: uppercase;
}

#hud-target-bar {
  font-size: 14px;
  color: rgba(215, 185, 165, 0.72);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.80);
  margin-top: 2px;
}

/* ── Damage flash ── */
#hud-damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
  z-index: 22;
  background: radial-gradient(
    ellipse at center,
    transparent 35%,
    rgba(200, 20, 20, 0.70) 100%
  );
  opacity: 0;
}
#hud-damage-flash.flash-active {
  animation: damageFlash 0.50s ease-out forwards;
}
@keyframes damageFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Gun-sight overlay ── */
#hud-sight {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  z-index: 25;
  /* Circular periscope vignette — black outside the scope circle */
  background: radial-gradient(
    circle closest-side at center,
    transparent 78%,
    rgba(0, 0, 0, 0.97) 80%
  );
}

.sight-svg {
  width: 75vmin;
  height: 75vmin;
  overflow: visible;
  position: absolute;
}

.sight-svg line {
  stroke: rgba(195, 230, 160, 0.72);
  stroke-width: 0.7;
  stroke-linecap: square;
}

.sight-text {
  font-family: 'Courier New', Courier, monospace;
  font-size: 6px;
  fill: rgba(195, 230, 160, 0.55);
}

/* ── Minimap ── */
#hud-lives-icons {
  position: fixed;
  bottom: 232px;   /* 14px margin + 210px minimap + 8px gap */
  right: 14px;
  width: 210px;
  height: 44px;
  pointer-events: none;
  user-select: none;
  z-index: 10;
}

#minimap {
  position: fixed;
  bottom: 14px;
  right: 14px;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(80, 140, 80, 0.35);
  border-radius: 3px;
  pointer-events: none;
  user-select: none;
  z-index: 10;
  image-rendering: pixelated;
}

/* ── Settings controls reference ── */
.settings-ctrl-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(100, 160, 255, 0.70);
  margin: 8px 0 5px;
  padding-top: 8px;
  border-top: 1px solid rgba(100, 160, 255, 0.12);
}
.settings-ctrl-ref {
  font-size: 13px;
  color: rgba(200, 220, 255, 0.75);
  line-height: 1.6;
  letter-spacing: 0.03em;
}
.settings-ctrl-ref kbd {
  display: inline-block;
  background: rgba(60, 90, 160, 0.50);
  border: 1px solid rgba(100, 160, 255, 0.35);
  border-radius: 3px;
  padding: 0 5px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: rgba(255, 240, 160, 0.90);
  min-width: 1.4em;
  text-align: center;
}

/* ── Menu START button ── */
.menu-start-btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 12px 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: rgba(200, 240, 200, 0.95);
  background: rgba(30, 80, 30, 0.55);
  border: 2px solid rgba(120, 220, 120, 0.60);
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.menu-start-btn:hover {
  background: rgba(40, 120, 40, 0.75);
  border-color: rgba(160, 255, 160, 0.90);
  color: rgba(220, 255, 220, 1.0);
}

/* ── Combined menu: 2-column tank + mode layout ── */
.menu-combined {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.menu-col {
  display: flex;
  flex-direction: column;
}
.menu-section-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(100, 160, 255, 0.50);
  margin-bottom: 8px;
}

/* ── Faction / Army selection ── */
.faction-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 130px;
  margin: 4px 0;
}
.faction-opt {
  padding: 9px 14px;
  border: 1px solid rgba(100, 160, 255, 0.15);
  border-radius: 4px;
  background: rgba(5, 10, 22, 0.40);
  pointer-events: auto;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
}
.faction-opt:hover {
  border-color: rgba(100, 160, 255, 0.35);
  background: rgba(12, 25, 55, 0.50);
}
.faction-selected {
  border-color: rgba(100, 200, 120, 0.60);
  background: rgba(10, 40, 20, 0.60);
}
.faction-name {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.10em;
  color: rgba(200, 240, 200, 0.80);
  text-transform: uppercase;
}
.faction-selected .faction-name {
  color: rgba(160, 255, 160, 1.0);
}

/* ── Mode selection ── */
.mode-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 380px;
  margin: 4px 0;
}
.mode-opt {
  padding: 10px 14px;
  border: 1px solid rgba(100, 160, 255, 0.15);
  border-radius: 4px;
  background: rgba(5, 10, 22, 0.40);
  pointer-events: auto;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.mode-opt:hover {
  border-color: rgba(100, 160, 255, 0.35);
  background: rgba(12, 25, 55, 0.50);
}
.mode-selected {
  border-color: rgba(100, 160, 255, 0.55);
  background: rgba(20, 40, 80, 0.55);
}
.mode-name {
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 0.10em;
  color: rgba(255, 248, 200, 0.80);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.mode-selected .mode-name {
  color: rgba(255, 255, 180, 1.0);
}
.mode-sel-arrow {
  font-size: 11px;
  vertical-align: middle;
}
.mode-desc {
  font-size: 13px;
  color: rgba(180, 200, 255, 0.65);
  letter-spacing: 0.04em;
}
.mode-selected .mode-desc {
  color: rgba(210, 230, 255, 0.85);
}

/* ── Purchase screen ── */
.purchase-screen {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 480px;
  max-width: 580px;
  width: 100%;
}
.purchase-info {
  background: rgba(20, 35, 65, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.22);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  color: rgba(190, 215, 255, 0.80);
  line-height: 1.55;
  letter-spacing: 0.03em;
}
.purchase-info-title {
  font-weight: bold;
  color: rgba(255, 230, 100, 0.90);
  letter-spacing: 0.12em;
  font-size: 11px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.purchase-budget {
  font-size: 14px;
  color: rgba(200, 220, 255, 0.70);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.budget-ok   { color: rgba(100, 220, 100, 0.90); }
.budget-over { color: rgba(255, 100, 80,  0.90); }
.purchase-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.purchase-faction-header {
  padding: 6px 10px 2px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(180, 160, 100, 0.55);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(180, 160, 100, 0.15);
  margin-top: 4px;
}
.purchase-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(100, 160, 255, 0.12);
  border-radius: 3px;
  font-size: 13px;
  background: rgba(5, 10, 22, 0.35);
}
.purchase-selected {
  border-color: rgba(100, 160, 255, 0.50);
  background: rgba(20, 40, 80, 0.50);
}
.pur-name {
  min-width: 130px;
  color: rgba(255, 248, 200, 0.85);
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pur-stats {
  flex: 1;
  color: rgba(160, 200, 160, 0.62);
  font-size: 11px;
  letter-spacing: 0.02em;
  font-family: 'Courier New', Courier, monospace;
}
.pur-cost {
  min-width: 60px;
  text-align: right;
  color: rgba(255, 220, 100, 0.75);
  font-size: 12px;
}
.pur-qty {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 72px;
  justify-content: center;
}
.pur-count {
  min-width: 18px;
  text-align: center;
  color: rgba(200, 220, 255, 0.90);
  font-size: 15px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
}
.pur-adj {
  background: rgba(30, 50, 90, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 2px;
  color: rgba(180, 210, 255, 0.90);
  font-size: 13px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: auto;
  font-family: 'Courier New', Courier, monospace;
}
.pur-adj:hover:not(:disabled) { background: rgba(50, 80, 150, 0.85); }
.pur-adj:disabled { opacity: 0.25; cursor: default; }
.purchase-row { cursor: pointer; }
.purchase-row:hover { background: rgba(15, 30, 60, 0.55); }
.pur-start-btn {
  align-self: center;
  margin-top: 6px;
  padding: 8px 32px;
  background: rgba(30, 60, 110, 0.80);
  border: 1px solid rgba(100, 160, 255, 0.45);
  border-radius: 3px;
  color: rgba(200, 225, 255, 0.95);
  font-size: 15px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: 'Courier New', Courier, monospace;
}
.pur-start-btn:hover:not(:disabled) { background: rgba(50, 100, 180, 0.90); }
.pur-start-btn:disabled { opacity: 0.30; cursor: default; }
.purchase-hint {
  font-size: 12px;
  color: rgba(160, 185, 255, 0.42);
  letter-spacing: 0.05em;
  text-align: center;
  margin-top: 4px;
}
.purchase-error {
  font-size: 13px;
  color: rgba(255, 100, 80, 0.85);
  letter-spacing: 0.06em;
  text-align: center;
  animation: blink 0.9s ease-in-out infinite;
}

/* ── LAN peer name tags (dynamically created per peer) ── */
.lan-nametag {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: none;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(255, 160, 80, 0.90);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  white-space: nowrap;
  line-height: 1.4;
}
.lan-nametag .nt-hp {
  display: block;
  width: 48px;
  height: 4px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,160,80,0.4);
  margin: 2px auto 0;
  position: relative;
}
.lan-nametag .nt-hp-fill {
  position: absolute;
  top: 0; left: 0; height: 100%;
  background: rgba(255, 120, 40, 0.85);
  transition: width 0.2s;
}
.lan-nametag .nt-name {
  display: block;
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: 1px;
}

/* ── LAN lobby ── */
.lan-lobby {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 400px;
  margin: 0 auto;
  pointer-events: auto;
  user-select: text;
}
.lan-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lan-section-title {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(180, 210, 255, 0.70);
  text-transform: uppercase;
}
.lan-desc {
  font-size: 12px;
  color: rgba(200, 200, 200, 0.55);
  line-height: 1.5;
}
.lan-desc code {
  color: rgba(180, 255, 180, 0.75);
  font-family: 'Courier New', monospace;
}
.lan-join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lan-input {
  flex: 1;
  background: rgba(10, 15, 30, 0.80);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 3px;
  color: rgba(200, 230, 255, 0.90);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
}
.lan-input:focus { border-color: rgba(100, 160, 255, 0.70); }
.lan-btn {
  background: rgba(30, 60, 120, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.40);
  border-radius: 3px;
  color: rgba(180, 220, 255, 0.90);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.10em;
  padding: 6px 14px;
  cursor: pointer;
  text-transform: uppercase;
}
.lan-btn:hover { background: rgba(50, 90, 160, 0.80); }
.lan-btn-danger {
  background: rgba(100, 25, 25, 0.70);
  border-color: rgba(255, 90, 70, 0.40);
  color: rgba(255, 175, 165, 0.90);
}
.lan-btn-danger:hover { background: rgba(150, 40, 35, 0.80); }
.lan-online-col { min-width: 200px; gap: 0; }
.lan-divider {
  text-align: center;
  font-size: 11px;
  color: rgba(150, 150, 150, 0.40);
  letter-spacing: 0.10em;
}
.lan-status {
  font-size: 12px;
  color: rgba(180, 255, 180, 0.75);
  letter-spacing: 0.06em;
  min-height: 18px;
}
.lan-back {
  margin-top: 4px;
}
.lan-back-btn {
  background: none;
  border: none;
  color: rgba(160, 160, 160, 0.55);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  padding: 0;
}
.lan-back-btn:hover { color: rgba(200, 200, 200, 0.80); }
.lan-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.lan-name-label {
  font-size: 11px;
  color: rgba(160, 190, 230, 0.60);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.lan-name-input { max-width: 140px; }
.lan-code-input {
  width: 65px;
  flex: 0 0 65px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 13px;
  text-align: center;
}
.scan-code {
  display: inline-block;
  background: rgba(80, 200, 120, 0.18);
  border: 1px solid rgba(80, 200, 120, 0.35);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: rgba(140, 230, 160, 0.95);
  margin-left: 6px;
}
.lan-btn-sm { font-size: 11px; padding: 5px 10px; }
.lan-btn:disabled { opacity: 0.45; cursor: default; }
.lan-scan-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.lan-scan-status {
  font-size: 11px;
  color: rgba(160, 200, 255, 0.65);
  letter-spacing: 0.05em;
}
.lan-scan-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.lan-scan-result {
  background: rgba(20, 40, 80, 0.60);
  border: 1px solid rgba(100, 160, 255, 0.25);
  border-radius: 3px;
  color: rgba(160, 200, 255, 0.75);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  text-align: left;
}
.lan-scan-result:hover { background: rgba(40, 70, 140, 0.70); color: rgba(200, 230, 255, 0.95); }
.lan-scan-result-ready {
  border-color: rgba(80, 200, 120, 0.40);
  color: rgba(140, 230, 160, 0.90);
}
.lan-scan-result-ready:hover { background: rgba(20, 60, 30, 0.70); }
.scan-info {
  font-size: 10px;
  color: rgba(160, 200, 160, 0.60);
  margin-left: 8px;
}
.lan-team-sel {
  background: rgba(10, 15, 30, 0.80);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 3px;
  color: rgba(200, 230, 255, 0.85);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
}
.lan-host-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lan-btn-disabled { opacity: 0.38; cursor: default; }
/* Waiting room */
.lan-waiting-room {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(10, 20, 40, 0.60);
  border: 1px solid rgba(100, 160, 255, 0.20);
  border-radius: 4px;
  padding: 12px 14px;
}
.lan-waiting-title {
  font-size: 12px;
  letter-spacing: 0.10em;
  color: rgba(180, 210, 255, 0.75);
  text-transform: uppercase;
}
.lan-waiting-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lan-waiting-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(200, 220, 255, 0.80);
}
.lan-waiting-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lan-waiting-name { flex: 1; }
.lan-waiting-team { font-size: 10px; letter-spacing: 0.06em; }

/* ── Squad HUD (top-centre) ── */
#hud-squad {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  letter-spacing: 0.10em;
  color: rgba(120, 200, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
}

/* ── Tank name flash (below squad icons, on tank switch) ── */
#hud-tank-name-flash {
  position: fixed;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 24px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  font-family: 'Courier New', Courier, monospace;
  color: rgba(140, 210, 255, 0.95);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  pointer-events: none;
  user-select: none;
  z-index: 10;
  opacity: 0;
  white-space: nowrap;
}

/* ── Objective HUD (below squad HUD) ── */
#hud-objective {
  position: fixed;
  top: 42px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 220, 80, 0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  user-select: none;
  z-index: 26;
  white-space: nowrap;
}

/* ── Tank selection preview ── */
#tank-preview {
  display: none;
  width: 220px;
  height: 160px;
  border: 2px solid rgba(120, 220, 120, 0.60);
  border-radius: 4px;
  margin: 10px auto 0;
  background: transparent;
  transition: border-color 0.2s;
}
#tank-preview.faction-american { border-color: rgba(120, 220, 120, 0.65); }
#tank-preview.faction-russian  { border-color: rgba(220, 80,  80,  0.65); }
#tank-preview.faction-german   { border-color: rgba(220, 200, 60,  0.65); }
#tank-preview.faction-mercenary{ border-color: rgba(80,  160, 255, 0.65); }

/* ── Merc editor ── */
.merc-edit-btn {
  display: block;
  margin: 5px 0 0 auto;
  padding: 3px 14px;
  width: 54px;        /* aligns with merc-adj-pair width */
  box-sizing: border-box;
  background: rgba(60, 100, 180, 0.55);
  border: 1px solid rgba(100, 160, 255, 0.50);
  border-radius: 3px;
  color: rgba(180, 215, 255, 0.95);
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s;
}
.merc-edit-btn:hover { background: rgba(80, 130, 220, 0.75); }

.me-panel {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  background: rgba(8, 14, 28, 0.96);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 4px;
  overflow: hidden;
}
.me-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(20, 35, 65, 0.80);
  border-bottom: 1px solid rgba(100, 160, 255, 0.20);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(180, 210, 255, 0.90);
}
.me-close {
  background: none;
  border: none;
  color: rgba(180, 210, 255, 0.70);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  pointer-events: auto;
}
.me-close:hover { color: rgba(255, 100, 80, 0.90); }
.me-body {
  padding: 10px 14px 12px;
}
.me-section-name {
  margin-bottom: 8px;
}
.me-section-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(120, 170, 255, 0.70);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.me-name-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(15, 25, 50, 0.80);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 3px;
  color: rgba(200, 225, 255, 0.95);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
  pointer-events: auto;
}
.me-name-input:focus { border-color: rgba(100, 160, 255, 0.65); }
.me-cols {
  display: flex;
  gap: 16px;
}
.me-col {
  flex: 1;
  min-width: 0;
}
.me-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.me-label {
  flex: 1;
  font-size: 11px;
  color: rgba(190, 215, 255, 0.80);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-val {
  font-size: 11px;
  color: rgba(220, 240, 255, 0.95);
  min-width: 38px;
  text-align: center;
}
.me-adj, .me-vis {
  background: rgba(30, 50, 90, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 2px;
  color: rgba(180, 210, 255, 0.90);
  font-size: 13px;
  line-height: 1;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: auto;
}
.me-adj:hover, .me-vis:hover { background: rgba(50, 80, 150, 0.85); }
.me-footer {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}
.me-btn {
  padding: 5px 16px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid;
  pointer-events: auto;
}
.me-btn-reset {
  background: rgba(60, 30, 30, 0.65);
  border-color: rgba(200, 80, 60, 0.40);
  color: rgba(255, 160, 140, 0.90);
}
.me-btn-reset:hover { background: rgba(90, 40, 40, 0.80); }
.me-btn-done {
  background: rgba(30, 60, 120, 0.70);
  border-color: rgba(100, 160, 255, 0.45);
  color: rgba(180, 215, 255, 0.95);
}
.me-btn-done:hover { background: rgba(50, 90, 170, 0.85); }

/* ── Debug panel (right-edge, shown during gameplay) ── */
#debug-panel {
  display: none;
  position: fixed;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 240px;
  background: rgba(8, 14, 28, 0.92);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 4px;
  overflow: hidden;
  z-index: 30;
  pointer-events: auto;
}
#debug-panel.dbg-visible { display: block; }
.dbg-title {
  padding: 6px 10px;
  background: rgba(20, 35, 65, 0.90);
  border-bottom: 1px solid rgba(100, 160, 255, 0.20);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(180, 210, 255, 0.90);
  font-family: 'Courier New', Courier, monospace;
}
.dbg-section {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(120, 170, 255, 0.70);
  text-transform: uppercase;
  padding: 5px 8px 2px;
}
.dbg-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
}
.dbg-label {
  flex: 1;
  font-size: 13px;
  color: rgba(190, 215, 255, 0.80);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Courier New', Courier, monospace;
}
.dbg-val {
  font-size: 13px;
  color: rgba(220, 240, 255, 0.95);
  min-width: 36px;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
}
.dbg-adj {
  background: rgba(30, 50, 90, 0.70);
  border: 1px solid rgba(100, 160, 255, 0.30);
  border-radius: 2px;
  color: rgba(180, 210, 255, 0.90);
  font-size: 14px;
  line-height: 1;
  width: 22px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  pointer-events: auto;
}
.dbg-adj:hover { background: rgba(50, 80, 150, 0.85); }

