.hud-overlay {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
  z-index: 20;
}

.hud-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 55%),
    rgba(13, 17, 25, 0.86);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft), var(--inner-light);
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 0 22px var(--glow-accent);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.15em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.stat {
  position: relative;
  min-width: 84px;
  padding: 6px 10px 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--surface-2), rgba(17, 21, 31, 0.86));
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(111, 211, 230, 0.35), transparent);
}

.stat span,
.stat-head {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-icon {
  flex: 0 0 auto;
  opacity: 0.9;
}

.stat strong {
  display: block;
  margin-top: 1px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.stat[data-tone="good"] strong {
  color: var(--good);
}

.stat[data-tone="warn"] strong {
  color: var(--warn);
}

.stat[data-tone="bad"] strong {
  color: var(--bad);
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 54px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
}

.clock strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.conn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.conn[data-state="online"] {
  border-color: rgba(143, 224, 138, 0.28);
  color: var(--good);
}

.conn[data-state="online"]::before {
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
}

.conn[data-state="offline"] {
  border-color: rgba(255, 138, 112, 0.32);
  color: var(--bad);
}

.conn[data-state="offline"]::before {
  background: var(--bad);
}

.conn[data-state="connecting"] {
  border-color: rgba(245, 211, 107, 0.28);
  color: var(--warn);
}

.conn[data-state="connecting"]::before {
  background: var(--warn);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.hud-menu {
  display: flex;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.hud-btn:hover:not(:disabled) {
  border-color: rgba(111, 211, 230, 0.55);
  background: var(--surface-3);
  color: var(--text);
}

.hud-btn:disabled {
  opacity: 0.45;
}

.hud-btn kbd {
  font-size: 0.68em;
}

.hud-btn-icon {
  display: grid;
  place-items: center;
  width: 32px;
  padding: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 100%);
  pointer-events: none;
}

.objective {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: rgba(13, 17, 25, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
}

.objective-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.objective-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.objective p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.4;
}

.mission-hud {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(183, 156, 255, 0.3);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, rgba(183, 156, 255, 0.1), transparent 60%),
    rgba(13, 17, 25, 0.84);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  text-align: left;
  pointer-events: auto;
  transition: border-color 140ms ease, transform 140ms ease;
}

.mission-hud[data-warn="true"] {
  border-color: rgba(245, 211, 107, 0.45);
}

.mission-hud[hidden] {
  display: none;
}

.mission-hud:hover {
  border-color: rgba(183, 156, 255, 0.62);
  transform: translateY(-1px);
}

.mission-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mission-hud-kicker {
  color: var(--accent-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mission-hud-progress {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

.mission-hud strong {
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-hud-step {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-hud-bar {
  display: block;
  height: 4px;
  margin: 3px 0 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.mission-hud-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px rgba(183, 156, 255, 0.35);
  transition: width 260ms ease;
}

.mission-hud-meta {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interact {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(245, 211, 107, 0.6);
  border-radius: 999px;
  background: rgba(13, 17, 25, 0.94);
  box-shadow: 0 0 26px rgba(245, 211, 107, 0.16);
  color: var(--text);
  font-size: 13px;
  z-index: 16;
  animation: interact-in 160ms ease both;
  transition: border-color 140ms ease, background 140ms ease;
}

.interact:hover {
  border-color: rgba(245, 211, 107, 0.92);
  background: rgba(23, 28, 40, 0.98);
}

.interact[hidden] {
  display: none;
}

@keyframes interact-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 1120px) {
  .brand-sub {
    display: none;
  }

  .stat {
    min-width: 70px;
  }

  .stat strong {
    font-size: 13px;
  }
}

@media (max-width: 1024px) {
  .hud-top {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .stats {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .stat {
    flex: 1;
    min-width: 0;
  }

  .hud-menu {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .hud-overlay {
    top: calc(8px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    gap: 8px;
  }

  .hud-top {
    gap: 7px 8px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .brand {
    margin-right: auto;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 13px;
  }

  .brand strong {
    overflow: hidden;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .clock,
  .brand-sub {
    display: none;
  }

  .conn {
    padding: 4px 8px;
    font-size: 10px;
  }

  .hud-menu {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }

  .hud-btn {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .hud-btn kbd {
    display: none;
  }

  .hud-btn-icon {
    min-width: 34px;
    width: 34px;
  }

  .stats {
    order: 4;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .stat {
    padding: 5px 6px;
  }

  .stat span {
    overflow: hidden;
    font-size: 8.5px;
    letter-spacing: 0.05em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stat strong {
    font-size: 11px;
  }

  .hud-left {
    width: 100%;
  }

  .objective {
    padding: 10px 12px;
  }

  .objective p {
    font-size: 12px;
  }

  .mission-hud {
    padding: 10px 12px;
  }

  .interact {
    bottom: calc(154px + var(--safe-bottom));
    min-height: 44px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 460px) {
  .hud-menu {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 6px;
  }

  .hud-btn {
    justify-content: center;
  }
}

@media (hover: none), (pointer: coarse) {
  .hud-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .hud-btn-icon {
    width: 44px;
  }

  .interact {
    bottom: calc(154px + var(--safe-bottom));
    min-height: 44px;
  }
}

@media (hover: none) and (max-width: 480px), (pointer: coarse) and (max-width: 480px) {
  .hud-menu {
    display: none;
  }
}

@media (max-height: 560px) {
  .objective {
    display: none;
  }
}
