/* Вояджер-1 — интерфейс миссии */
:root {
  --bg-0: #03050b;
  --bg-1: #071021;
  --ink: #eaf4ff;
  --ink-dim: #9db2c9;
  --ink-faint: #6f849b;
  --cyan: #7ee8ff;
  --cyan-soft: rgba(126, 232, 255, 0.16);
  --warm: #ffd9a3;
  --line: rgba(160, 200, 235, 0.16);
  --panel: rgba(7, 13, 24, 0.62);
  --panel-solid: rgba(7, 13, 24, 0.9);
  --ok: #6ee7a8;
  --warn: #f0b46a;
  --radius: 14px;
  --pad: clamp(10px, 2.2vw, 22px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 780px at 72% 4%, rgba(38, 60, 112, 0.55) 0%, rgba(9, 15, 32, 0.2) 45%, transparent 70%),
    radial-gradient(900px 700px at 12% 92%, rgba(84, 40, 102, 0.32) 0%, transparent 65%),
    var(--bg-0);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

/* ---------- сцена / HUD ---------- */
.app {
  position: fixed;
  inset: 0;
}

.hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  z-index: 5;
}

.hud > * {
  pointer-events: none;
}

.hud button,
.hud .panel,
.hud .readout,
.hud .brand,
.hud .status {
  pointer-events: auto;
}

.hud__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  max-width: min(56vw, 420px);
}

.brand__kicker {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.brand h1 {
  margin: 0;
  font-size: clamp(19px, 3.4vw, 30px);
  line-height: 1.05;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.65);
}

.brand__sub {
  margin: 3px 0 0;
  font-size: clamp(11px, 1.6vw, 13px);
  color: var(--ink-dim);
}

.status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}

.clock {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-dim);
  background: rgba(4, 8, 16, 0.45);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
}

.clock__time {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.clock__zone {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.dsn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-dim);
  background: rgba(4, 8, 16, 0.45);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  max-width: 100%;
}

.dsn__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5c6f83;
  box-shadow: 0 0 0 3px rgba(92, 111, 131, 0.18);
  flex: 0 0 auto;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.dsn.is-on {
  color: #cfeee0;
}

.dsn.is-on .dsn__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(110, 231, 168, 0.18), 0 0 12px rgba(110, 231, 168, 0.7);
}

/* ---------- нижний блок ---------- */
.hud__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.readout {
  width: min(330px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px 12px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.readout__label {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.readout__value {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

.readout__au {
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: #fff;
}

.readout__unit {
  font-size: 13px;
  color: var(--cyan);
}

.readout__km {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.readout__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(160, 200, 235, 0.12);
}

.readout__grid div {
  min-width: 0;
}

.readout__grid dt {
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout__grid dd {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout__grid .is-muted {
  color: var(--ink-dim);
}

/* ---------- док управления ---------- */
.dock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.dock__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.dock__label {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 2px;
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(5, 10, 19, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.seg__btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 8px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.seg__btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.seg__btn[aria-pressed="true"] {
  color: #f2fdff;
  background: var(--cyan-soft);
  border-color: rgba(126, 232, 255, 0.4);
  box-shadow: inset 0 0 0 1px rgba(126, 232, 255, 0.08);
}

.seg__btn--action {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

.seg__btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.seg__btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.hint {
  margin: 0;
  font-size: 10.5px;
  color: var(--ink-faint);
  text-align: right;
  max-width: 100%;
}

/* ---------- всплывающая подсказка ---------- */
.tip {
  position: fixed;
  z-index: 30;
  max-width: min(280px, calc(100vw - 24px));
  padding: 10px 12px 11px;
  border-radius: 12px;
  border: 1px solid rgba(126, 232, 255, 0.3);
  background: rgba(6, 13, 25, 0.94);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  transform: translate(-50%, -112%);
  transition: opacity 0.12s ease;
}

.tip__title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
}

.tip__meta {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.tip__note {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: var(--ink-dim);
}

/* ---------- загрузка / ошибка ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(700px 500px at 50% 45%, rgba(18, 33, 60, 0.92), rgba(3, 5, 11, 0.96) 70%);
  transition: opacity 0.5s ease;
}

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

.loader__ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(126, 232, 255, 0.25);
  border-top-color: var(--cyan);
  animation: spin 1.1s linear infinite;
}

.loader__text {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}

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

.banner {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 25;
  max-width: calc(100vw - 28px);
  padding: 8px 14px;
  font-size: 11.5px;
  color: #ffe2bd;
  background: rgba(44, 26, 10, 0.86);
  border: 1px solid rgba(240, 180, 106, 0.4);
  border-radius: 999px;
  text-align: center;
}

/* ---------- инвайт-гейт ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 500px at 50% 35%, rgba(28, 43, 76, 0.5), transparent 70%),
    var(--bg-0);
}

.gate__card {
  width: min(430px, 100%);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.gate__mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1px solid rgba(126, 232, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  font-size: 17px;
  letter-spacing: 0.06em;
}

.gate__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.gate__text {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.6;
}

.gate__brand {
  margin: 0 0 14px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.noscript {
  padding: 24px;
  color: var(--ink);
  font-family: inherit;
}

/* ---------- мобильный ---------- */
@media (max-width: 760px) {
  .hud__top {
    gap: 8px;
  }

  .brand__kicker {
    display: none;
  }

  .status {
    gap: 6px;
  }

  .clock {
    font-size: 11px;
    padding: 4px 9px;
  }

  .dsn {
    font-size: 10.5px;
    padding: 4px 9px;
  }

  .hud__bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
  }

  .readout {
    width: 100%;
    padding: 10px 12px 9px;
    order: 2;
  }

  .readout__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px 10px;
    margin-top: 8px;
    padding-top: 8px;
  }

  .readout__grid dd {
    font-size: 11.5px;
  }

  .readout__au {
    font-size: 24px;
  }

  .dock {
    align-items: stretch;
    order: 1;
    gap: 6px;
  }

  .dock__row {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1px;
  }

  .dock__row::-webkit-scrollbar {
    display: none;
  }

  .dock__label {
    display: none;
  }

  .seg {
    flex: 0 0 auto;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .readout {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .seg__btn {
    padding: 10px 12px;
    font-size: 12px;
    min-height: 38px;
  }

  .hint {
    display: none;
  }
}

@media (max-width: 400px) {
  .readout__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readout__grid div:nth-child(n + 3) {
    display: none;
  }

  .readout {
    padding: 9px 12px 8px;
  }

  .readout__au {
    font-size: 22px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand__sub {
    font-size: 10.5px;
  }

  .clock__date {
    display: none;
  }

  .dsn__text {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .seg {
    padding: 2px;
  }

  .seg__btn {
    padding: 8px 4px;
    font-size: 10px;
    min-height: 32px;
    letter-spacing: 0;
  }

  .dock__row {
    gap: 4px;
  }

  .dock {
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader__ring {
    animation: none;
  }

  .seg__btn,
  .dsn__dot,
  .tip {
    transition: none;
  }
}
