:root {
  --bg: #0b0e14;
  --panel: #141a25;
  --panel-2: #1b2230;
  --line: #26303f;
  --text: #e6ecf5;
  --muted: #8695ad;
  --accent: #4ea8ff;
  --danger: #ff6b6b;
  --ok: #5ddc7a;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

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

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.hud-top {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.pill {
  background: rgba(20, 26, 37, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--muted);
  backdrop-filter: blur(6px);
}

.pill b {
  color: var(--text);
  letter-spacing: 0.12em;
  margin-left: 4px;
}

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  text-align: center;
}

.bars {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
}

.bar {
  flex: 1;
  text-align: left;
}

.bar-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  margin-top: 3px;
  background: rgba(38, 48, 63, 0.85);
  border-radius: 999px;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ok);
  border-radius: 999px;
  transition: width 0.09s linear, background-color 0.2s;
}

.bar-track.reload i {
  background: var(--accent);
}

.hint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
}

#killfeed {
  position: absolute;
  top: 56px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  font-size: 12px;
}

.kill-entry {
  background: rgba(20, 26, 37, 0.85);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  animation: slideIn 0.18s ease-out;
}

.kill-entry .who {
  font-weight: 600;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
}

#respawn {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 14, 20, 0.55);
  backdrop-filter: blur(2px);
}

.respawn-title {
  font-size: 22px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--danger);
}

.respawn-timer {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#scoreboard {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 340px;
  background: rgba(20, 26, 37, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
}

#scoreboard h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

#chat {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: min(340px, 46vw);
}

#chat-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  font-size: 12px;
}

.chat-line {
  background: rgba(20, 26, 37, 0.78);
  border-radius: 7px;
  padding: 3px 9px;
  align-self: flex-start;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.chat-line .who {
  font-weight: 600;
}

#chat-input {
  pointer-events: auto;
  width: 100%;
}

/* ---------- Формы ---------- */

input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  width: 100%;
}

input:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: #5d6b82;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}

button:hover {
  background: #232c3d;
  border-color: #35425a;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 650;
  width: 100%;
}

button.primary:hover {
  background: #6ab6ff;
  border-color: #6ab6ff;
}

button.ghost {
  width: 100%;
  background: transparent;
  color: var(--muted);
}

/* ---------- Меню ---------- */

#menu,
#disconnected {
  position: fixed;
  inset: 0;
  display: flex;
  /* Не align-items: center: когда карточка выше экрана (а с полной таблицей
     рекордов так и происходит), флекс-центрирование срезает её верх и до него
     нельзя доскроллить. Прижимаем к началу, а центрирует margin: auto — он
     работает только при наличии свободного места. */
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, #16203047, #0b0e14 70%), var(--bg);
  overflow: auto;
  z-index: 10;
}

.menu-card {
  margin: auto;
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.menu-card.narrow {
  text-align: center;
}

.menu-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 20px;
}

.field {
  display: block;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 11px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.row input {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
}

.row button {
  flex: 0 0 auto;
}

.error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb3b3;
  font-size: 13px;
}

/* ---------- Таблицы ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(38, 48, 63, 0.45);
}

td:not(:first-child),
th:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Числовые колонки выравниваются вправо, а текстовые — нет: в таблице рекордов
   имя стоит вторым после номера, а в игровом счёте вторым идёт корпус, и
   прижатый вправо текст читается как сбитая вёрстка. */
.board td:nth-child(2),
.board th:nth-child(2),
#scoreboard td:nth-child(2),
#scoreboard th:nth-child(2) {
  text-align: left;
}

tr:last-child td {
  border-bottom: none;
}

.board {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.board h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: baseline;
}

.you {
  color: var(--accent);
}

/* ---------- Выбиралки ---------- */

.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 14px 0 6px;
}

.field-label .muted {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.75;
}

.hull-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hull-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 8px;
  text-align: left;
  line-height: 1.25;
}

.hull-name {
  font-weight: 600;
  font-size: 13px;
}

.hull-hint {
  font-size: 10px;
  color: var(--muted);
}

.hull-card.selected,
.chip.selected {
  border-color: var(--accent);
  background: rgba(78, 168, 255, 0.13);
}

.hull-card.selected .hull-name {
  color: var(--accent);
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* Выбиралки задают свой отступ сверху через .field-label, но снизу его нет —
   без этого цветовые кружки упирались прямо в кнопку «Играть». */
#play-btn {
  margin-top: 18px;
}

/* Правило по соседству, а не по идентификатору: любые две кнопки, стоящие
   в карточке стопкой, разделяются сами. Пока отступ навешивался поштучно,
   каждая следующая добавленная кнопка снова слипалась с предыдущей. */
.menu-card > button + button {
  margin-top: 8px;
}

.color-dot {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4) inset;
}

.color-dot:hover {
  transform: scale(1.08);
}

.color-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 7px 13px;
  font-size: 13px;
}

.create-panel {
  margin-top: 6px;
  padding: 4px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(27, 34, 48, 0.5);
}

.create-panel .primary {
  margin-top: 14px;
}

.invite-banner {
  margin-bottom: 14px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(78, 168, 255, 0.12);
  border: 1px solid rgba(78, 168, 255, 0.35);
  font-size: 13px;
}

.invite-banner b {
  letter-spacing: 0.16em;
}

/* ---------- Меню паузы ---------- */

#pause {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  background: rgba(11, 14, 20, 0.72);
  backdrop-filter: blur(4px);
  overflow: auto;
  z-index: 20;
}

.pause-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pause-head h2 {
  margin: 0;
  font-size: 20px;
}

.small {
  font-size: 11px;
}

.invite-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
}

.invite-box .field-label {
  margin: 0 0 2px;
}

.room-code-big {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1.1;
}

/* Селектор с элементом — иначе width: 100% из button.ghost окажется
   специфичнее и кнопка вылезет за край карточки. */
button.small-btn {
  width: auto;
  padding: 8px 12px;
  font-size: 12px;
  flex: 0 0 auto;
}

.section-split {
  height: 1px;
  background: var(--line);
  margin: 18px 0 4px;
}

#host-settings.locked {
  opacity: 0.55;
}

#host-settings button:disabled {
  cursor: not-allowed;
}

.pause-actions {
  margin-top: 20px;
}

.pause-actions button {
  flex: 1;
}

/* ---------- Тост ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(27, 34, 48, 0.96);
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.18s ease-out;
  pointer-events: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

@media (max-width: 560px) {
  .hint {
    display: none;
  }
  #chat {
    width: 60vw;
  }
  .hull-row {
    grid-template-columns: 1fr;
  }
  .invite-box {
    flex-direction: column;
    align-items: stretch;
  }
}
