/* Space Discoverer — HUD & chrome */
@font-face {
  font-family: 'Orbitron';
  src: url('../assets/fonts/orbitron-var.woff2') format('woff2');
  font-weight: 400 900; font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/rajdhani-500.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/rajdhani-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../assets/fonts/rajdhani-700.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --hud: #8fe8ff;
  --hud-dim: rgba(143, 232, 255, 0.55);
  --hud-line: rgba(143, 232, 255, 0.22);
  --panel: rgba(5, 12, 20, 0.52);
  --warn: #ffb26b;
  --danger: #ff5f6b;
  --ok: #7dffc8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #000; }
body {
  font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  color: var(--hud);
  user-select: none;
  -webkit-user-select: none;
}
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
body:not(.steering) canvas#scene { cursor: default; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  padding: 10px 14px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(143, 232, 255, 0.03);
}

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: none; }
#hud.hudless > *:not(#toasts) { opacity: 0 !important; transition: opacity 0.3s; }
#labels { z-index: 1; }
#topleft, #topright, #bottom, #hintStrip, #fps { position: absolute; z-index: 5; }

/* ---------- top left: location ---------- */
#topleft { position: absolute; top: 18px; left: 18px; display: flex; flex-direction: column; gap: 8px; }
#locRegion {
  font-family: 'Orbitron'; font-weight: 700; font-size: 15px; letter-spacing: 0.28em; color: #d9f6ff;
  text-shadow: 0 0 12px rgba(143, 232, 255, 0.5);
}
#locSub { font-size: 13px; letter-spacing: 0.22em; color: var(--hud-dim); margin-top: 3px; }
#discPanel { font-size: 12px; letter-spacing: 0.24em; color: var(--hud-dim); padding: 6px 14px; }
#discCount { color: var(--ok); font-weight: 700; margin-left: 6px; }

/* ---------- top right: target ---------- */
#topright { position: absolute; top: 18px; right: 18px; width: 308px; }
#tgtPanel { border-top: 2px solid rgba(143, 232, 255, 0.5); }
#tgtHeader { display: flex; justify-content: space-between; align-items: baseline; }
#tgtName {
  font-family: 'Orbitron'; font-weight: 700; font-size: 16px; letter-spacing: 0.18em; color: #eafbff;
  text-shadow: 0 0 14px rgba(143, 232, 255, 0.55);
}
#tgtKind { font-size: 10px; letter-spacing: 0.3em; color: var(--hud-dim); }
#tgtRows { margin-top: 8px; }
#tgtRows .row { display: flex; justify-content: space-between; font-size: 13px; letter-spacing: 0.14em; padding: 1.5px 0; }
#tgtRows .row span:first-child { color: var(--hud-dim); font-size: 11px; letter-spacing: 0.24em; }
#tgtRows .row span:last-child { color: #d9f6ff; font-weight: 600; font-variant-numeric: tabular-nums; }
#tgtPanel.empty #tgtRows, #tgtPanel.empty #scanWrap { display: none; }
#scanWrap { margin-top: 9px; position: relative; height: 18px; }
#scanWrap::before {
  content: ''; position: absolute; inset: 0; border: 1px solid var(--hud-line); border-radius: 2px;
}
#scanBar {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, rgba(125, 255, 200, 0.15), rgba(125, 255, 200, 0.55));
  transition: width 0.15s linear;
}
#scanLabel {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; letter-spacing: 0.3em; color: #d9f6ff;
}
#tgtFacts { margin-top: 8px; }
.frow { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 1.5px 0; }
.frow span:first-child { color: var(--hud-dim); font-size: 10px; letter-spacing: 0.22em; white-space: nowrap; }
.frow span:last-child { color: #cdeeff; text-align: right; letter-spacing: 0.06em; }
.blurb {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--hud-line);
  font-size: 12.5px; line-height: 1.45; color: rgba(205, 238, 255, 0.82); letter-spacing: 0.04em;
}
#tgtHint { margin-top: 9px; font-size: 10px; letter-spacing: 0.24em; color: rgba(143, 232, 255, 0.42); }

/* ---------- bottom center: flight ---------- */
#bottom { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); text-align: center; }
#speedCluster { min-width: 300px; padding: 10px 22px 12px; }
#spdRow { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
#spdVal {
  font-family: 'Orbitron'; font-size: 30px; font-weight: 700; color: #eafbff;
  text-shadow: 0 0 16px rgba(143, 232, 255, 0.6); font-variant-numeric: tabular-nums;
}
#spdUnit { font-size: 13px; letter-spacing: 0.3em; color: var(--hud-dim); }
.bar { height: 4px; background: rgba(143, 232, 255, 0.10); margin-top: 7px; border-radius: 2px; overflow: hidden; }
#thrFill { height: 100%; width: 0%; background: linear-gradient(90deg, #3fa8c8, #8fe8ff); transition: width 0.1s; }
.bar.boost { height: 3px; margin-top: 4px; }
#boostFill { height: 100%; width: 100%; background: rgba(255, 178, 107, 0.55); transition: width 0.15s; }
#boostFill.hot { background: #ffb26b; box-shadow: 0 0 10px rgba(255, 178, 107, 0.8); }
#modeRow { display: flex; justify-content: center; gap: 18px; margin-top: 7px; font-size: 10px; letter-spacing: 0.3em; }
#flightMode { color: #d9f6ff; font-weight: 700; }
#flightMode.warp { color: var(--warn); text-shadow: 0 0 12px rgba(255, 178, 107, 0.7); }
#assistTag { color: var(--ok); }
#assistTag.off { color: var(--warn); }
#camTag { color: var(--hud-dim); }
#warpState {
  margin-top: 8px; font-size: 12px; letter-spacing: 0.34em; color: var(--warn);
  text-shadow: 0 0 14px rgba(255, 178, 107, 0.6); opacity: 0; transition: opacity 0.3s;
}

#hintStrip {
  position: absolute; bottom: 22px; left: 22px; font-size: 10px; letter-spacing: 0.26em;
  color: rgba(143, 232, 255, 0.4);
}
#fps { position: absolute; bottom: 22px; right: 22px; font-size: 10px; letter-spacing: 0.2em; color: rgba(143, 232, 255, 0.35); font-variant-numeric: tabular-nums; }

/* ---------- center: crosshair, steering ---------- */
#crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.ch-c { width: 5px; height: 5px; border: 1px solid rgba(143, 232, 255, 0.8); border-radius: 50%; box-shadow: 0 0 8px rgba(143, 232, 255, 0.5); }
#steerRing {
  position: absolute; left: 50%; top: 50%; width: 29.4vh; height: 29.4vh;
  transform: translate(-50%, -50%); border: 1px dashed rgba(143, 232, 255, 0.10); border-radius: 50%;
}
#steerDot { position: absolute; top: 0; left: 0; width: 8px; height: 8px; margin: -4px; }
#steerDot::after {
  content: ''; display: block; width: 8px; height: 8px; border: 1.5px solid rgba(143, 232, 255, 0.85);
  transform: rotate(45deg); box-shadow: 0 0 10px rgba(143, 232, 255, 0.6);
}
#engageHint {
  position: absolute; left: 50%; top: 58%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: 0.4em; color: rgba(143, 232, 255, 0.5);
  opacity: 0; transition: opacity 0.4s;
}
#engageHint.show { opacity: 1; animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- reticle / target arrow ---------- */
#reticle {
  position: absolute; top: 0; left: 0; display: none; margin: 0;
  translate: -50% -50%; pointer-events: none;
}
#reticle .c { position: absolute; width: 12px; height: 12px; border: 1.5px solid rgba(143, 232, 255, 0.9); filter: drop-shadow(0 0 6px rgba(143, 232, 255, 0.7)); }
#reticle .c.tl { top: 0; left: 0; border-right: none; border-bottom: none; }
#reticle .c.tr { top: 0; right: 0; border-left: none; border-bottom: none; }
#reticle .c.bl { bottom: 0; left: 0; border-right: none; border-top: none; }
#reticle .c.br { bottom: 0; right: 0; border-left: none; border-top: none; }
#retDist {
  position: absolute; top: 100%; left: 50%; transform: translate(-50%, 6px);
  font-size: 10px; letter-spacing: 0.3em; color: rgba(143, 232, 255, 0.75); white-space: nowrap;
}
#tarrow {
  position: absolute; top: 0; left: 0; display: none; width: 0; height: 0; margin: -8px 0 0 -8px;
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 14px solid rgba(143, 232, 255, 0.85);
  filter: drop-shadow(0 0 8px rgba(143, 232, 255, 0.7));
}

/* ---------- labels ---------- */
#labels { position: absolute; inset: 0; }
.label {
  position: absolute; top: 0; left: 0; display: none; pointer-events: auto; cursor: pointer;
  text-align: center; translate: -50% -130%;
  transition: opacity 0.25s;
}
.label .ln {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.26em; color: #d9f6ff;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9), 0 0 10px rgba(143, 232, 255, 0.35);
}
.label .ld { display: block; font-size: 9.5px; letter-spacing: 0.18em; color: rgba(143, 232, 255, 0.5); font-variant-numeric: tabular-nums; }
.label::after {
  content: ''; display: block; width: 1px; height: 10px; margin: 2px auto 0;
  background: linear-gradient(rgba(143, 232, 255, 0.5), transparent);
}
.label.current .ln { color: #fff; }
.label.disc .ln::after { content: ' ✓'; color: var(--ok); font-size: 9px; }
.label:hover .ln { color: #ffffff; }

/* ---------- alerts / toasts ---------- */
#alerts { position: absolute; top: 16%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.alert {
  font-family: 'Orbitron'; font-size: 13px; font-weight: 700; letter-spacing: 0.34em; color: #d9f6ff;
  padding: 8px 22px; border: 1px solid var(--hud-line); background: var(--panel);
  border-radius: 2px; text-shadow: 0 0 12px rgba(143, 232, 255, 0.6);
}
.alert.warn { color: var(--warn); border-color: rgba(255, 178, 107, 0.4); text-shadow: 0 0 12px rgba(255, 178, 107, 0.6); }
.alert.danger { color: var(--danger); border-color: rgba(255, 95, 107, 0.5); text-shadow: 0 0 12px rgba(255, 95, 107, 0.7); animation: pulse 0.7s infinite; }
#toasts { position: absolute; bottom: 96px; right: 22px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  font-size: 12px; letter-spacing: 0.22em; color: #d9f6ff; padding: 8px 16px;
  background: var(--panel); border: 1px solid var(--hud-line); border-left: 3px solid var(--ok);
  border-radius: 2px; opacity: 0; transform: translateX(20px); transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.in { opacity: 1; transform: none; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 12, 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.overlay.hidden { display: none; }
.overlay .obox { display: flex; gap: 28px; align-items: flex-start; max-width: 94vw; max-height: 90vh; }

#mapCanvas { border: 1px solid var(--hud-line); border-radius: 4px; background: rgba(4, 10, 18, 0.6); }
#mapSide { width: 300px; max-height: 74vh; overflow-y: auto; padding-right: 6px; }
#mapSide h2, .overlay h2 {
  font-family: 'Orbitron'; font-size: 15px; font-weight: 700; letter-spacing: 0.3em; color: #eafbff; margin-bottom: 12px;
}
.mgroup { font-size: 10px; letter-spacing: 0.32em; color: var(--hud-dim); margin: 14px 0 6px; }
.mitem {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px; cursor: pointer;
  border: 1px solid transparent; border-radius: 2px; pointer-events: auto;
}
.mitem:hover { border-color: var(--hud-line); background: rgba(143, 232, 255, 0.06); }
.mdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.mname { font-size: 13px; letter-spacing: 0.16em; color: #d9f6ff; flex: 1; }
.mdist { font-size: 11px; color: var(--hud-dim); font-variant-numeric: tabular-nums; }
.mcheck { width: 14px; color: var(--ok); font-size: 11px; }
.okey { font-size: 10px; letter-spacing: 0.24em; color: var(--hud-dim); margin-top: 14px; }
#mapSide::-webkit-scrollbar { width: 4px; }
#mapSide::-webkit-scrollbar-thumb { background: rgba(143, 232, 255, 0.25); }

/* help */
#helpBox { width: 720px; max-width: 92vw; }
.hcols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 40px; margin-top: 8px; }
.hrow { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid rgba(143, 232, 255, 0.08); }
.hrow b {
  font-weight: 600; color: #eafbff; background: rgba(143, 232, 255, 0.1); border: 1px solid var(--hud-line);
  border-radius: 3px; padding: 0 8px; font-size: 11.5px; letter-spacing: 0.12em; min-width: 46px; text-align: center;
}
.hrow span { color: rgba(205, 238, 255, 0.8); letter-spacing: 0.1em; }
.htip { margin-top: 14px; font-size: 12px; line-height: 1.6; color: rgba(143, 232, 255, 0.55); letter-spacing: 0.08em; }

/* ---------- start screen ---------- */
#start {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
  background: radial-gradient(120% 90% at 50% 20%, rgba(10, 24, 40, 0.55), rgba(0, 2, 6, 0.92)), #000;
  transition: opacity 1.3s ease; overflow: hidden;
}
#start.gone { opacity: 0; pointer-events: none; }
#start::before {
  content: ''; position: absolute; inset: -50%;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 30%, rgba(255,255,255,0.9), transparent 60%),
    radial-gradient(1px 1px at 34% 68%, rgba(190,220,255,0.8), transparent 60%),
    radial-gradient(1.6px 1.6px at 56% 22%, rgba(255,255,255,0.95), transparent 60%),
    radial-gradient(1px 1px at 72% 50%, rgba(255,230,200,0.8), transparent 60%),
    radial-gradient(1.2px 1.2px at 88% 76%, rgba(190,220,255,0.85), transparent 60%),
    radial-gradient(1px 1px at 22% 84%, rgba(255,255,255,0.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 44% 44%, rgba(255,255,255,0.8), transparent 60%),
    radial-gradient(1px 1px at 66% 88%, rgba(190,220,255,0.75), transparent 60%),
    radial-gradient(1.1px 1.1px at 80% 12%, rgba(255,255,255,0.85), transparent 60%);
  background-size: 480px 480px;
  animation: drift 90s linear infinite;
}
@keyframes drift { to { transform: translate3d(240px, 120px, 0); } }
#startInner { position: relative; text-align: center; max-width: 680px; padding: 0 24px; }
#title {
  font-family: 'Orbitron'; font-weight: 800; font-size: clamp(34px, 6vw, 62px);
  letter-spacing: 0.34em; color: #eafbff; text-indent: 0.34em;
  text-shadow: 0 0 30px rgba(143, 232, 255, 0.55), 0 0 90px rgba(80, 160, 255, 0.35);
}
#subtitle { margin-top: 14px; font-size: 13px; letter-spacing: 0.5em; color: rgba(143, 232, 255, 0.6); text-indent: 0.5em; }
#startProgress { margin: 44px auto 10px; width: 340px; height: 2px; background: rgba(143, 232, 255, 0.12); position: relative; }
#startBar { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, #3fa8c8, #8fe8ff); box-shadow: 0 0 12px rgba(143, 232, 255, 0.8); transition: width 0.3s; }
#startLabel { font-size: 10px; letter-spacing: 0.34em; color: rgba(143, 232, 255, 0.5); }
#launchBtn {
  margin-top: 36px; font-family: 'Orbitron'; font-size: 16px; font-weight: 700; letter-spacing: 0.42em; text-indent: 0.42em;
  color: rgba(143, 232, 255, 0.35); background: transparent; border: 1px solid rgba(143, 232, 255, 0.2);
  padding: 15px 52px; border-radius: 2px; cursor: default; transition: all 0.4s;
}
#launchBtn.ready {
  color: #06131c; background: #8fe8ff; border-color: #8fe8ff; cursor: pointer;
  box-shadow: 0 0 34px rgba(143, 232, 255, 0.55);
}
#launchBtn.ready:hover { background: #c2f4ff; box-shadow: 0 0 54px rgba(143, 232, 255, 0.85); }
#startKeys { margin-top: 40px; display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; }
#startKeys div { font-size: 10.5px; letter-spacing: 0.22em; color: rgba(143, 232, 255, 0.45); }
#startKeys b { color: rgba(234, 251, 255, 0.85); font-weight: 600; }
#startCredit { position: absolute; bottom: 20px; width: 100%; text-align: center; font-size: 9.5px; letter-spacing: 0.26em; color: rgba(143, 232, 255, 0.25); }

/* error */
#errorOverlay .ebox { max-width: 520px; text-align: center; }
#errorOverlay h2 { color: var(--danger); }
#errorOverlay .emsg { font-size: 14px; line-height: 1.6; color: rgba(255, 210, 214, 0.85); }
