html, body { margin: 0; height: 100%; overflow: hidden; background: #03040a; }
canvas { display: block; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 36px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(5,10,20,0.9), rgba(5,10,20,0.6));
  border-bottom: 1px solid rgba(80,160,255,0.35);
  color: #9fe8ff;
  font: 12px/1 monospace;
  pointer-events: none;
  text-shadow: 0 0 6px #0af;
  z-index: 10;
}
.top-left, .top-right {
  display: flex; align-items: center; gap: 10px;
}
.top-center { flex: 1; text-align: center; }

/* Кнопка выхода в лобби: под верхней строкой в левом углу, подписана
   словами — чтобы было понятно без догадок. Второй тап подтверждает. */
#lobbyBtn {
  position: fixed;
  top: 36px;
  left: 8px;
  z-index: 40;
  /* кнопка вне верхней строки, но оставляем явно: pointer-events наследуется,
     а у соседних слоёв HUD он отключён */
  pointer-events: auto;
  padding: 6px 11px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #a9c8e4;
  background: rgba(14, 26, 42, 0.74);
  border: 1px solid rgba(120, 170, 210, 0.28);
  border-radius: 6px;
  opacity: 0.78;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#lobbyBtn:hover { opacity: 1; }
#lobbyBtn.armed {
  opacity: 1;
  color: #ffe0dc;
  background: rgba(120, 36, 36, 0.9);
  border-color: rgba(255, 130, 120, 0.6);
  animation: lobbyPulse 0.9s ease-in-out infinite;
}
@keyframes lobbyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 130, 120, 0.5); }
  55%      { box-shadow: 0 0 0 7px rgba(255, 130, 120, 0); }
}
#lobbyBtn[hidden] { display: none; }
.stat { white-space: nowrap; }
.stat b { color: #fff; }
.stat.dim { opacity: 0.42; font-size: 11px; }

/* Команда игрока в командных режимах: небольшой цветной ярлык */
.stat-team {
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid rgba(120, 170, 210, 0.25);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stat-team b { font-weight: 600; }

.toggle-icon {
  pointer-events: auto;
  cursor: pointer;
  font-size: 13px;
}

.toggle-icon.off { opacity: 0.35; }

.lang-select {
  pointer-events: auto;
  background: rgba(80, 160, 255, 0.12);
  border: 1px solid rgba(80, 160, 255, 0.35);
  border-radius: 3px;
  color: #9fe8ff;
  font: 11px monospace;
  padding: 1px 3px;
  cursor: pointer;
  outline: none;
}

.lang-select:hover { background: rgba(80, 160, 255, 0.24); }
.lang-select option { background: #0a1220; color: #cfe8ff; }
.bar-wrap {
  width: 80px; height: 8px;
  background: rgba(80,160,255,0.15);
  border: 1px solid rgba(80,160,255,0.35);
  border-radius: 4px;
  overflow: hidden;
}
.bar { height: 100%; width: 0%; transition: width 0.15s linear; }
.hp-bar { background: linear-gradient(90deg, #ff4060, #ff8080); }
.energy-bar { background: linear-gradient(90deg, #39c0ff, #9affd0); }
.status { color: #9affd0; font-weight: bold; }
.shield-bar { background: linear-gradient(90deg, #a060ff, #c080ff); }
#bottombar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 32px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(0deg, rgba(5,10,20,0.9), rgba(5,10,20,0.6));
  border-top: 1px solid rgba(80,160,255,0.35);
  color: #9fe8ff;
  font: 12px/1 monospace;
  pointer-events: none;
  text-shadow: 0 0 6px #0af;
  z-index: 10;
}
.bottom-left, .bottom-right { display: flex; align-items: center; gap: 10px; }
.bottom-center { flex: 1; text-align: center; }
.hint { color: #6a8; font-size: 11px; }

#rightpanel {
  position: fixed; right: 12px; top: 48px;
  width: 220px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  color: #c0d8ff;
  font: 11px/1.4 monospace;
  pointer-events: none;
  text-shadow: 0 0 6px #0af;
  z-index: 10;
  scrollbar-width: thin;
  scrollbar-color: rgba(80, 160, 255, 0.3) transparent;
}

#rightpanel::-webkit-scrollbar { width: 4px; }
#rightpanel::-webkit-scrollbar-thumb {
  background: rgba(80, 160, 255, 0.3);
  border-radius: 2px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

/* Счёт по звёздам под картой: четыре команды в одну строку */
.team-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.3;
  color: #a9c6e2;
}
.team-scores[hidden] { display: none; }
.team-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.team-score .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 4px currentColor;
}
.team-score b {
  color: #eaf6ff;
  font-weight: 600;
  min-width: 1ch;
}
.team-score.mine { opacity: 1; }
.team-score:not(.mine) { opacity: 0.72; }

/* чат забирает свободную высоту, остальное — по содержимому */
.panel-section.panel-grow {
  flex: 1 1 auto;
  min-height: 116px;
}

.panel-toggle {
  pointer-events: auto;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  cursor: pointer;
  color: #9fe8ff;
  font: bold 11px monospace;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-shadow: 0 0 6px #0af;
}

.panel-toggle:hover { color: #d8f6ff; }

.chevron {
  font-size: 9px;
  color: #6ab0d8;
  transition: transform 0.15s ease;
}

.panel-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
}

.panel-body[hidden] { display: none; }
.panel-title {
  display: flex; justify-content: space-between; align-items: center;
  color: #9fe8ff; font-weight: bold; margin-bottom: 0;
  font-size: 11px;
}
#minimap {
  display: block; width: 220px; height: 220px;
  border: 1px solid rgba(80,160,255,0.35);
  background: rgba(5,10,20,0.7);
}
#leaderboard {
  background: rgba(5,10,20,0.7);
  border: 1px solid rgba(80,160,255,0.25);
  border-radius: 4px;
  padding: 6px 8px;
  min-height: 100px;
}
#leaderboard .lb-row {
  display: flex; justify-content: space-between;
  font-size: 10px; line-height: 1.5;
}
#leaderboard .lb-row.me { color: #9affd0; }

.toggle-btn {
  pointer-events: auto;
  background: rgba(80,160,255,0.15);
  border: 1px solid rgba(80,160,255,0.4);
  color: #9fe8ff;
  font: 10px monospace;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.toggle-btn:hover { background: rgba(80,160,255,0.3); }
.toggle-btn.off { color: #6a8; border-color: rgba(80,160,255,0.2); }

/* ---- СЛАЙДЕРЫ ГРОМКОСТИ ---- */
.volume-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px;
  pointer-events: auto;
}
.volume-row span:first-child {
  font-size: 10px;
  color: #9fe8ff;
  min-width: 40px;
}
.volume-row span:last-child {
  font-size: 10px;
  color: #c0d8ff;
  min-width: 32px;
  text-align: right;
}
.volume-row input[type="range"] {
  flex: 1;
  width: 100%;
  max-width: 110px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(80,160,255,0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px; height: 10px;
  background: #39c0ff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px #0af;
}
.volume-row input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px;
  background: #39c0ff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px #0af;
}

/* ---- НАЗВАНИЕ ТРЕКА + УПРАВЛЕНИЕ ---- */
.track-row {
  margin-top: 8px;
  pointer-events: auto;
}
#trackTitle {
  font-size: 10px;
  color: #9fe8ff;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  pointer-events: auto;
}
.track-btn {
  background: rgba(80,160,255,0.15);
  border: 1px solid rgba(80,160,255,0.4);
  color: #9fe8ff;
  font: 12px monospace;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  min-width: 28px;
  text-align: center;
}
.track-btn:hover {
  background: rgba(80,160,255,0.3);
}
.download-btn {
  pointer-events: auto;
  background: rgba(80,160,255,0.15);
  border: 1px solid rgba(80,160,255,0.4);
  color: #9fe8ff;
  font: 10px monospace;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}
.download-btn:hover {
  background: rgba(80,160,255,0.3);
}

/* ================= МОДАЛЬНОЕ ОКНО ПРИВЕТСТВИЯ ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px;
  background: radial-gradient(900px 520px at 50% 35%, rgba(18, 54, 96, 0.55), rgba(3, 4, 10, 0.86));
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
  opacity: 0;
  visibility: hidden;
  /* visibility переключается мгновенно при открытии (иначе поле нельзя сфокусировать),
     а при закрытии — с задержкой, чтобы успел проиграть фейд */
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease, visibility 0s;
}

.modal-box {
  position: relative;
  box-sizing: border-box;
  width: min(440px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 26px 26px 20px;
  border: 1px solid rgba(80, 160, 255, 0.42);
  border-radius: 16px;
  background: linear-gradient(168deg, rgba(14, 26, 46, 0.97), rgba(6, 10, 22, 0.98));
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(3, 8, 18, 0.9),
    0 0 60px rgba(0, 130, 255, 0.12);
  color: #b6cdea;
  font: 12.5px/1.55 Consolas, monospace;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.modal-overlay.open .modal-box {
  transform: none;
}

/* светящаяся полоса по верхней кромке */
.modal-box::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 12%;
  width: 76%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(57, 192, 255, 0.9), transparent);
  box-shadow: 0 0 8px rgba(57, 192, 255, 0.8);
}

.modal-box::-webkit-scrollbar { width: 6px; }
.modal-box::-webkit-scrollbar-thumb {
  background: rgba(80, 160, 255, 0.35);
  border-radius: 3px;
}

.modal-box h1 {
  margin: 0 0 12px;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 1px;
  color: #e6f7ff;
  text-shadow: 0 0 18px rgba(57, 192, 255, 0.5);
}

.modal-box h3 {
  margin: 16px 0 6px;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #7fd4ff;
  opacity: 0.9;
}

.modal-box p { margin: 0 0 6px; color: #a6c0e0; }
.modal-box ul { margin: 0; padding-left: 18px; }
.modal-box li { margin: 3px 0; }
.modal-box li b { color: #eafaff; font-weight: 600; }

.modal-input-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ---- ЛОББИ: КАРТОЧКИ РЕЖИМОВ ---- */
.mode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-family: inherit;
  color: #cfe4f7;
  background: rgba(18, 34, 54, 0.7);
  border: 1px solid rgba(110, 170, 220, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mode-card:hover {
  border-color: rgba(130, 200, 240, 0.55);
  background: rgba(24, 46, 70, 0.85);
}

.mode-card.selected {
  border-color: rgba(150, 220, 255, 0.85);
  background: rgba(30, 58, 88, 0.9);
  box-shadow: 0 0 0 1px rgba(150, 220, 255, 0.35) inset;
}

.mode-card.down {
  opacity: 0.45;
  cursor: not-allowed;
}

.mode-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mode-card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mode-card-online {
  font-size: 11px;
  color: #8fb4d4;
  white-space: nowrap;
}

.mode-card-desc {
  font-size: 12px;
  line-height: 1.35;
  color: #9db8d3;
}

#nameInput {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid rgba(80, 160, 255, 0.5);
  border-radius: 9px;
  background: rgba(3, 8, 18, 0.92);
  color: #e8f7ff;
  font: 13px/1 Consolas, monospace;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#nameInput::placeholder { color: rgba(150, 190, 235, 0.4); }

#nameInput:focus {
  border-color: #39c0ff;
  box-shadow: 0 0 0 3px rgba(57, 192, 255, 0.16), 0 0 18px rgba(57, 192, 255, 0.22);
}

#nameInput.invalid {
  border-color: #ff4d6a;
  box-shadow: 0 0 0 3px rgba(255, 77, 106, 0.16);
  animation: modal-shake 0.3s ease;}

#startBtn {
  flex: 0 0 auto;
  padding: 11px 20px;
  border: 1px solid rgba(57, 192, 255, 0.6);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(57, 192, 255, 0.3), rgba(18, 84, 150, 0.38));
  color: #eafaff;
  font: 12px/1 Consolas, monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

#startBtn:hover {
  background: linear-gradient(180deg, rgba(57, 192, 255, 0.45), rgba(18, 84, 150, 0.5));
  box-shadow: 0 0 20px rgba(57, 192, 255, 0.3);
}

#startBtn:active { transform: translateY(1px); }

#startBtn:focus-visible {
  outline: 2px solid #39c0ff;
  outline-offset: 2px;
}

.modal-error {
  min-height: 15px;
  margin-top: 8px;
  color: #ff8296;
  font-size: 11px;
}

@keyframes modal-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (max-width: 560px) {
  .modal-overlay { padding: 14px; }
  .modal-box { padding: 20px 18px 16px; }
  .modal-input-row { flex-direction: column; }
  #startBtn { width: 100%; }
}

/* кнопка панели: нужна только на узких экранах */
.panel-toggle-btn {
  display: none;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(80, 160, 255, 0.12);
  border: 1px solid rgba(80, 160, 255, 0.35);
  border-radius: 3px;
  color: #9fe8ff;
  font: 12px monospace;
  padding: 1px 6px;
}

.panel-toggle-btn[aria-expanded="true"] {
  background: rgba(80, 160, 255, 0.3);
  color: #fff;
}

/* ---- Ноутбуки и экраны 1280: всё чуть плотнее, чтобы хватало места ---- */
@media (max-width: 1366px) and (min-width: 901px) {
  #topbar { height: 32px; padding: 0 8px; font-size: 11px; gap: 8px; }
  .top-left, .top-right { gap: 8px; }
  .bar-wrap { width: 64px; height: 7px; }
  #rightpanel { width: 200px; }
  #minimap { width: 200px; height: 200px; }
  #bottombar { height: 28px; padding: 0 8px; font-size: 11px; }
  .hint { font-size: 10px; }
}

/* ---- Телефон: панель выдвигается поверх игры, клавишные подсказки не нужны ---- */
/* Ловим и узкие экраны, и любые тач-устройства: телефон в альбомной
   ориентации шире 760px, но играть на нём всё равно надо без панелей */
@media (max-width: 900px), ((hover: none) and (pointer: coarse)) {
  .panel-toggle-btn { display: inline-block; }

  /* нижний худ на телефоне только мешает: координаты и скорость не нужны */
  #bottombar { display: none; }

  /* шапка: остаются уровень и полоски, всё словесное прячем */
  #topbar {
    padding: 0 6px;
    gap: 5px;
    font-size: 10px;
    height: 30px;
  }
  .stat-hp, .stat-shield, .stat-energy, .stat-parts,
  .stat-fps, .stat-ping, .stat-sound, .stat-music, .stat-bots {
    display: none;
  }
  .top-left { gap: 5px; }
  .top-right { gap: 5px; }
  .bar-wrap { width: 44px; height: 7px; }
  .stat-level { font-size: 11px; }
  .lang-select { padding: 0 2px; }

  /* в портрете для статуса орбиты нет места — оставляем только ремонт */
  #status { display: none; }
  .top-center { min-width: 0; overflow: hidden; }
  #repairHint {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #rightpanel {
    display: none;
    max-height: calc(100dvh - 90px);
    background: rgba(4, 8, 16, 0.94);
    border: 1px solid rgba(80, 160, 255, 0.25);
    border-radius: 6px;
    padding: 8px;
  }

  #rightpanel.open { display: flex; }

  #minimap { width: 164px; height: 164px; }

  .bottom-center { display: none; }
  .bottom-left, .bottom-right { gap: 8px; }

  /* окно приветствия не должно вылезать за экран в альбомной ориентации */
  .modal-overlay { padding: 10px; }
  .modal-box {
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    padding: 16px 16px 12px;
  }
  .modal-box p, .modal-box li { font-size: 12px; }
}

/* ================= ПЛАШКА ПЕРЕЗАПУСКА СЕРВЕРА ================= */
.restart-notice {  position: fixed;
  left: 12px;
  bottom: 44px;
  z-index: 60;
  display: none;
  padding: 5px 12px;
  border: 1px solid rgba(255, 190, 90, 0.5);
  border-radius: 4px;
  background: rgba(30, 18, 6, 0.85);
  color: #ffd08a;
  font: 11px/1.4 monospace;
  text-shadow: 0 0 6px rgba(255, 160, 40, 0.5);
  pointer-events: none;
}

.restart-notice.open { display: block; }

@media (max-width: 900px), ((hover: none) and (pointer: coarse)) {
  .restart-notice { bottom: 70px; left: 8px; font-size: 10px; }
}

/* ================= ОКНО ОБНОВЛЕНИЯ КЛИЕНТА ================= */
.update-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 14, 0.93);
  backdrop-filter: blur(3px);
}

.update-overlay.open { display: flex; }

.update-box {
  max-width: 340px;
  padding: 26px 30px;
  text-align: center;
  background: rgba(8, 14, 26, 0.96);
  border: 1px solid rgba(80, 160, 255, 0.4);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(40, 120, 255, 0.25);
  color: #c0d8ff;
  font: 13px/1.5 monospace;
}

.update-box h2 {
  margin: 0 0 10px;
  font-size: 16px;
  color: #9fe8ff;
  letter-spacing: 0.5px;
}

.update-box p { margin: 0; color: #a8c4e8; }

/* Окно простоя: затемняем слабо, чтобы было видно, что происходит в космосе.
   Игрок ещё в игре, и карта перед глазами помогает понять обстановку. */
#afkOverlay {
  background: rgba(3, 6, 14, 0.42);
  backdrop-filter: blur(1px);
}

#afkOverlay .update-box {
  padding: 20px 26px;
}

/* ================= ОБУЧЕНИЕ ПЕРВОГО ЗАХОДА ================= */
.tutorial-banner {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(12px);
  z-index: 90;
  display: none;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100vw - 32px));
  padding: 14px 18px;
  background: rgba(8, 14, 26, 0.86);
  border: 1px solid rgba(90, 200, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 0 28px rgba(40, 120, 255, 0.18);
  color: #d6e8ff;
  font: 13px/1.45 monospace;
  pointer-events: none;
}

.tutorial-banner.open {
  display: flex;
  animation: tutorial-in 0.25s ease-out forwards;
}

@keyframes tutorial-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tutorial-text { color: #bfe4ff; }

.tutorial-hint {
  font-weight: bold;
  color: #8ef0c8;
  min-height: 0;
}

.tutorial-bar {
  height: 4px;
  background: rgba(80, 160, 255, 0.18);
  border-radius: 2px;
  overflow: hidden;
}

.tutorial-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #39c0ff, #8ef0c8);
  transition: width 0.15s linear;
}

.tutorial-skip {
  align-self: flex-end;
  pointer-events: auto;
  background: transparent;
  border: 1px solid rgba(120, 180, 240, 0.35);
  border-radius: 6px;
  color: #9fc2e8;
  font: 12px monospace;
  padding: 4px 10px;
  cursor: pointer;
}

.tutorial-skip:hover {
  color: #d6ecff;
  border-color: rgba(140, 220, 255, 0.7);
}

.update-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid rgba(80, 160, 255, 0.2);
  border-top-color: #39c0ff;
  border-radius: 50%;
  animation: update-spin 0.9s linear infinite;
}

@keyframes update-spin {
  to { transform: rotate(360deg); }
}

#updateReload {
  margin-top: 16px;
  padding: 6px 18px;
  font: 12px monospace;
}

/* ================= ВЕРСИЯ И ИСТОРИЯ ИЗМЕНЕНИЙ ================= */
.bottom-right { gap: 14px; }

.version-tag {
  pointer-events: auto;
  cursor: pointer;
  padding: 1px 7px;
  border: 1px solid rgba(80, 160, 255, 0.35);
  border-radius: 3px;
  background: rgba(80, 160, 255, 0.12);
  color: #7fd4ff;
  font: 11px/1.4 monospace;
  letter-spacing: 0.5px;
}

.version-tag:hover {
  background: rgba(80, 160, 255, 0.28);
  border-color: rgba(80, 160, 255, 0.6);
  box-shadow: 0 0 12px rgba(57, 192, 255, 0.35);
}

.version-tag:focus-visible {
  outline: 2px solid #39c0ff;
  outline-offset: 2px;
}

.changelog-box {
  width: min(520px, 100%);
}

.changelog-list {
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
}

.changelog-list::-webkit-scrollbar { width: 6px; }
.changelog-list::-webkit-scrollbar-thumb {
  background: rgba(80, 160, 255, 0.35);
  border-radius: 3px;
}

.changelog-entry {
  padding: 12px 0;
  border-bottom: 1px solid rgba(80, 160, 255, 0.14);
}

.changelog-entry:first-child { padding-top: 2px; }
.changelog-entry:last-child { border-bottom: none; }

.changelog-version {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #e6f7ff;
}

.changelog-date {
  font-size: 10px;
  letter-spacing: 0;
  color: rgba(150, 190, 235, 0.55);
}

.changelog-entry ul {
  margin: 0;
  padding-left: 17px;
}

.changelog-entry li {
  margin: 3px 0;
  font-size: 12px;
  line-height: 1.45;
  color: #a6c0e0;
}

#changelogClose {
  margin-left: auto;
  padding: 9px 20px;
  border: 1px solid rgba(57, 192, 255, 0.5);
  border-radius: 9px;
  background: rgba(57, 192, 255, 0.14);
  color: #eafaff;
  font: 12px/1 Consolas, monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

#changelogClose:hover {
  background: rgba(57, 192, 255, 0.28);
  box-shadow: 0 0 18px rgba(57, 192, 255, 0.3);
}

/* ================= ТАЧ-УПРАВЛЕНИЕ ================= */
.touch-stick {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 30;
  pointer-events: none;
}

.touch-stick-base,
.touch-stick-knob {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.touch-stick-base {
  width: 124px;
  height: 124px;
  border: 2px solid rgba(80, 160, 255, 0.45);
  background: radial-gradient(circle, rgba(20, 50, 90, 0.28), rgba(10, 20, 40, 0.06));
  box-shadow: 0 0 24px rgba(57, 192, 255, 0.18);
}

.touch-stick-knob {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(120, 210, 255, 0.75);
  background: radial-gradient(circle at 35% 30%, rgba(120, 220, 255, 0.55), rgba(20, 80, 140, 0.4));
  box-shadow: 0 0 18px rgba(57, 192, 255, 0.45);
  transition: transform 0.04s linear;
}

.touch-fire {
  position: fixed;
  right: 18px;
  bottom: 16px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255, 140, 120, 0.55);
  background: radial-gradient(circle, rgba(120, 30, 20, 0.35), rgba(40, 10, 10, 0.25));
  color: #ffd0c0;
  font: 12px/1 Consolas, monospace;
  letter-spacing: 1px;
  z-index: 31;
  pointer-events: none;   /* касания ловим на документе, кнопка — индикатор */
  opacity: 0.65;
  transition: transform 0.08s, background 0.08s, opacity 0.08s;
}

.touch-fire.active {
  transform: scale(0.94);
  background: radial-gradient(circle, rgba(255, 90, 60, 0.5), rgba(120, 20, 10, 0.35));
  opacity: 1;
}

/* ================= ЧАТ ================= */
.chat-log {
  flex: 1 1 auto;
  min-height: 84px;
  overflow-y: auto;
  padding: 6px 8px;
  background: rgba(5, 10, 20, 0.7);
  border: 1px solid rgba(80, 160, 255, 0.25);
  border-radius: 4px;
  font: 10px/1.45 Consolas, monospace;
  color: #c0d8ff;
  pointer-events: auto;
}

.chat-log::-webkit-scrollbar { width: 5px; }
.chat-log::-webkit-scrollbar-thumb {
  background: rgba(80, 160, 255, 0.35);
  border-radius: 3px;
}

.chat-row {
  margin-bottom: 2px;
  word-break: break-word;
}

.chat-author { font-weight: bold; }
.chat-text { color: #d8e8ff; }

.chat-form {
  margin-top: 4px;
  pointer-events: auto;
}

#chatInput {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 7px;
  background: rgba(3, 8, 18, 0.9);
  border: 1px solid rgba(80, 160, 255, 0.35);
  border-radius: 4px;
  color: #e8f7ff;
  font: 10px/1.3 Consolas, monospace;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#chatInput::placeholder { color: rgba(150, 190, 235, 0.35); }

#chatInput:focus {
  border-color: #39c0ff;
  box-shadow: 0 0 0 2px rgba(57, 192, 255, 0.15);
}

/* ================= РЕМОНТ НА АСТЕРОИДЕ ================= */
.repair-hint {
  display: inline-block;
  margin-left: 12px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 220, 120, 0.55);
  border-radius: 4px;
  background: rgba(60, 45, 10, 0.45);
  color: #ffe8a8;
  font: 11px/1.6 monospace;
  pointer-events: auto;
  cursor: pointer;
  animation: repair-pulse 1.6s ease-in-out infinite;
}

@keyframes repair-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

.repair-bar {
  display: inline-block;
  position: relative;
  margin-left: 12px;
  width: 180px;
  height: 16px;
  border: 1px solid rgba(255, 200, 90, 0.5);
  border-radius: 4px;
  background: rgba(20, 16, 8, 0.7);
  overflow: hidden;
  vertical-align: middle;
}

.repair-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255, 190, 60, 0.75), rgba(255, 235, 150, 0.9));
  transition: width 0.1s linear;
}

.repair-bar-text {
  position: relative;
  display: block;
  text-align: center;
  color: #fff4d0;
  font: 10px/16px monospace;
  letter-spacing: 1px;
}

/* ================= ЭКРАННЫЕ ЭФФЕКТЫ ================= */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%,
    rgba(0, 0, 0, 0) 42%,
    rgba(140, 20, 30, 0.45) 78%,
    rgba(110, 10, 20, 0.75) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

#flash {
  position: fixed;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(190, 240, 255, 0.55), rgba(120, 200, 255, 0.1));
  opacity: 0;
  transition: opacity 0.45s ease;
}

/* На невысоких экранах ужимаем панель, иначе чат и звук не помещаются */
@media (max-height: 720px) {
  #minimap { width: 168px; height: 168px; }
  #leaderboard { min-height: 54px; }
  .panel-section.panel-grow { min-height: 92px; }
  .chat-log { min-height: 64px; }
  .volume-row { margin-top: 2px; }
  .track-row { margin-top: 4px; }
}
/* ссылка на политику конфиденциальности в окне приветствия */
.modal-legal {
  margin-top: 10px;
  text-align: center;
  font: 11px monospace;
}
.modal-legal a {
  color: #6f9cc4;
  text-decoration: none;
  border-bottom: 1px dotted rgba(111, 156, 196, 0.5);
}
.modal-legal a:hover { color: #9fe8ff; }

/* вкладки таблицы лидеров: онлайн / сегодня / всё время */
.lb-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 4px;
  pointer-events: auto;
}
.lb-tab {
  flex: 1;
  padding: 3px 2px;
  background: rgba(80, 160, 255, 0.08);
  border: 1px solid rgba(80, 160, 255, 0.22);
  border-radius: 3px;
  color: #7fa8c8;
  font: 10px monospace;
  cursor: pointer;
}
.lb-tab:hover { background: rgba(80, 160, 255, 0.18); }
.lb-tab.active {
  background: rgba(80, 160, 255, 0.28);
  border-color: rgba(120, 200, 255, 0.6);
  color: #d8f6ff;
}
.lb-empty {
  color: #6f8aa8;
  font-size: 10px;
  padding: 2px 0;
}

/* Числа в шапке не должны двигать вёрстку: фиксируем ширину под самое
   длинное значение и выравниваем по правому краю. Иначе при ремонте
   дробный HP (0.3 / 1) шире, чем целый (1 / 1), и панель дёргается. */
#hp, #shield, #energy, #parts {
  display: inline-block;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#hp { min-width: 9.5ch; }
#shield, #energy { min-width: 10ch; }
#parts { min-width: 8ch; }

/* ---- СПЕКТАТОР (режим захвата) ---- */
.spectator-bar {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  z-index: 65;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border: 1px solid rgba(120, 180, 230, 0.35);
  border-radius: 8px;
  background: rgba(8, 16, 28, 0.78);
  color: #cfe4f7;
  font-size: 13px;
  letter-spacing: 0.02em;
  pointer-events: auto;
}
.spectator-bar[hidden] { display: none; }
.spectator-bar button { font-size: 13px; padding: 5px 12px; }
/* ---- ОТЛАДОЧНЫЙ ОВЕРЛЕЙ ПРОИЗВОДИТЕЛЬНОСТИ ---- */
/* Включается по ?debug=1, F3 или тройному тапу в левом верхнем углу.
   Лежит поверх HUD, но не мешает игре кликами: кнопки забирают только себя. */
.perf-debug {
  position: fixed;
  top: 44px;
  left: 8px;
  z-index: 90;
  max-width: calc(100vw - 16px);
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid rgba(120, 200, 255, 0.45);
  border-radius: 6px;
  background: rgba(4, 10, 18, 0.86);
  color: #b9e6ff;
  font: 11px/1.45 Consolas, ui-monospace, monospace;
  text-shadow: 0 0 4px rgba(0, 160, 255, 0.35);
  pointer-events: none;
}
.perf-debug[hidden] { display: none; }
.perf-debug-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  pointer-events: auto;
}
.perf-debug-title {
  flex: 1;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #7fe3ff;
}
.perf-debug-btn {
  padding: 1px 7px;
  border: 1px solid rgba(120, 200, 255, 0.45);
  border-radius: 4px;
  background: rgba(20, 50, 80, 0.7);
  color: #cfefff;
  font: inherit;
  cursor: pointer;
}
.perf-debug-btn:hover { background: rgba(40, 90, 130, 0.85); }
.perf-debug-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}
.perf-debug-hint {
  margin-top: 5px;
  color: #5f8aa8;
  font-size: 10px;
}
