:root {
  color-scheme: dark;
  --hud-bg: rgba(5, 12, 24, 0.68);
  --hud-border: rgba(122, 194, 255, 0.34);
  --hud-text: #eef7ff;
  --hud-muted: #9ab4ce;
  --panel-shadow: 0 24px 50px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(45, 80, 132, 0.28), transparent 42%),
    radial-gradient(circle at bottom, rgba(8, 18, 40, 0.72), transparent 38%),
    #02050d;
  color: var(--hud-text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  letter-spacing: 0.02em;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    var(--panel-shadow);
  backdrop-filter: blur(12px);
}

.panel-title,
.panel-subtitle {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--hud-muted);
}

.panel-subtitle {
  font-size: 0.7rem;
  color: #c9d9eb;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.status-panel {
  top: 18px;
  left: 18px;
  width: min(300px, calc(100vw - 36px));
  padding: 16px;
}

.target-panel {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 40px));
  padding: 16px;
}

.radar-panel {
  top: 18px;
  right: 18px;
  width: min(280px, calc(100vw - 36px));
  padding: 14px 16px 16px;
}

.controls-panel {
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  padding: 16px 18px;
}

.inventory-panel {
  left: 18px;
  bottom: 18px;
  width: min(300px, calc(100vw - 36px));
  padding: 16px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
}

.hull-fill {
  background: linear-gradient(90deg, #ff9b65, #ff4c56);
}

.shield-fill {
  background: linear-gradient(90deg, #79e6ff, #2b8cff);
}

.energy-fill {
  background: linear-gradient(90deg, #7dffb8, #28b86f);
}

.boost-fill {
  background: linear-gradient(90deg, #ffe27c, #ffae38);
}

.target-fill {
  background: linear-gradient(90deg, #8bf6ff, #3bb3ff);
}

.summary-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin-top: 18px;
  font-size: 0.92rem;
}

.summary-grid span:nth-child(odd) {
  color: var(--hud-muted);
  font-weight: 700;
}

.warning-text {
  margin-top: 14px;
  min-height: 1.2rem;
  color: #9bc8e5;
  font-size: 0.92rem;
}

.warning-hot {
  color: #ffb56d;
}

.target-lock {
  min-height: 1em;
  font-size: 0.72rem;
  color: #8bf6ff;
  letter-spacing: 0.16em;
}

.target-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.target-meta {
  margin-top: 6px;
  color: #d3e7fb;
}

.target-extra {
  margin-top: 6px;
  min-height: 2.7rem;
  color: var(--hud-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.controls-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin-top: 10px;
  font-size: 0.92rem;
}

.controls-grid span:nth-child(odd) {
  color: #d7ebff;
  font-weight: 700;
}

.controls-grid span:nth-child(even) {
  color: var(--hud-muted);
}

#radar-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  margin-top: 6px;
  border-radius: 50%;
  border: 1px solid rgba(120, 198, 255, 0.2);
  background: radial-gradient(circle, rgba(10, 19, 36, 0.85), rgba(4, 9, 20, 0.98));
}

.radar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--hud-muted);
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

.legend-player::before {
  background: #8bf6ff;
}

.legend-station::before {
  background: #5cb7ff;
}

.legend-enemy::before {
  background: #ff6a5f;
}

.legend-asteroid::before {
  background: #ffd171;
}

.legend-nav::before {
  background: #ffe76f;
}

.inventory-meta {
  margin-top: 10px;
  color: #d3e7fb;
}

.compact-grid {
  margin-top: 10px;
}

.inventory-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.inventory-note {
  margin-top: 14px;
  color: var(--hud-muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.message-strip,
.prompt {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--hud-border);
  background: rgba(6, 15, 30, 0.76);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
  text-align: center;
}

.message-strip {
  top: 106px;
  min-width: min(500px, calc(100vw - 40px));
}

.prompt {
  bottom: 22px;
  max-width: min(660px, calc(100vw - 40px));
}

.hidden {
  display: none;
}

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(97, 214, 255, 0.18);
}

#reticle::before,
#reticle::after {
  content: "";
  position: absolute;
  background: rgba(235, 246, 255, 0.86);
}

#reticle::before {
  width: 2px;
  height: 12px;
  top: 3px;
  left: 8px;
}

#reticle::after {
  width: 12px;
  height: 2px;
  top: 8px;
  left: 3px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 5, 13, 0.28);
  transition: opacity 180ms ease, visibility 180ms ease;
  pointer-events: auto;
}

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

.overlay-card,
.menu-card,
.map-card {
  max-width: 560px;
  width: min(560px, calc(100vw - 36px));
  padding: 22px 24px;
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(22, 42, 76, 0.84), rgba(5, 12, 24, 0.94));
  border: 1px solid rgba(120, 198, 255, 0.3);
  box-shadow: 0 28px 65px rgba(0, 0, 0, 0.34);
  text-align: center;
}

.map-card {
  max-width: 1160px;
  width: min(1160px, calc(100vw - 36px));
  text-align: left;
}

.overlay-title,
.menu-title {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
}

.overlay-body,
.menu-subtitle {
  margin-top: 10px;
  color: #c9d9eb;
  line-height: 1.5;
}

.menu-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  margin-top: 20px;
  text-align: left;
}

.menu-grid span:nth-child(odd) {
  color: var(--hud-muted);
  font-weight: 700;
}

.menu-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.menu-actions button {
  border: 1px solid rgba(120, 198, 255, 0.26);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: #eef7ff;
  background: linear-gradient(180deg, rgba(37, 84, 144, 0.78), rgba(18, 47, 88, 0.88));
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.menu-actions button:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(52, 102, 167, 0.9), rgba(25, 60, 109, 0.95));
}

.menu-actions button.secondary {
  background: rgba(11, 25, 48, 0.78);
}

.menu-log {
  margin-top: 18px;
  min-height: 1.4rem;
  color: #9fd2ff;
}

.map-top-actions {
  display: flex;
  gap: 10px;
}

.map-tabs {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.map-tab,
.map-button {
  pointer-events: auto;
  border: 1px solid rgba(120, 198, 255, 0.26);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  color: #eef7ff;
  background: linear-gradient(180deg, rgba(37, 84, 144, 0.78), rgba(18, 47, 88, 0.88));
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.map-tab:hover,
.map-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, rgba(52, 102, 167, 0.9), rgba(25, 60, 109, 0.95));
}

.map-tab.active {
  background: linear-gradient(180deg, rgba(77, 153, 220, 0.92), rgba(32, 86, 148, 0.96));
}

.map-button.active {
  background: linear-gradient(180deg, rgba(77, 153, 220, 0.92), rgba(32, 86, 148, 0.96));
}

.map-button.secondary {
  background: rgba(11, 25, 48, 0.78);
}

.map-panel {
  margin-top: 18px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.galaxy-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
}

#system-map-canvas {
  width: 100%;
  height: auto;
  border-radius: 20px;
  border: 1px solid rgba(120, 198, 255, 0.18);
  background:
    radial-gradient(circle at center, rgba(18, 37, 68, 0.45), rgba(4, 9, 20, 0.94)),
    rgba(5, 12, 24, 0.85);
  cursor: pointer;
}

.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}

.map-nav-status,
.map-note {
  color: #c9d9eb;
  line-height: 1.5;
}

.map-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.map-list button {
  text-align: left;
}

.map-entry-title {
  display: block;
  font-weight: 700;
}

.map-entry-meta {
  display: block;
  margin-top: 4px;
  color: #c9d9eb;
  font-size: 0.86rem;
}

.galaxy-placeholder {
  min-height: 420px;
  border-radius: 20px;
  border: 1px solid rgba(120, 198, 255, 0.18);
  background:
    radial-gradient(circle at center, rgba(48, 78, 132, 0.28), transparent 38%),
    radial-gradient(circle at 30% 35%, rgba(140, 184, 255, 0.14), transparent 24%),
    rgba(4, 9, 20, 0.94);
  padding: 22px;
}

@media (max-width: 1080px) {
  .target-panel {
    top: auto;
    bottom: 178px;
  }

  .message-strip {
    top: 18px;
  }
}

@media (max-width: 920px) {
  #hud {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
  }

  .status-panel,
  .target-panel,
  .radar-panel,
  .controls-panel,
  .inventory-panel {
    position: static;
    width: auto;
    transform: none;
    margin: 6px 0;
  }

  .message-strip {
    top: auto;
    bottom: 108px;
  }

  .map-layout,
  .galaxy-layout {
    grid-template-columns: 1fr;
  }

  .map-top-actions,
  .map-tabs {
    flex-wrap: wrap;
  }
}
