/* STARDRIFT — Copyright (c) 2026 Qoo Studio (ehsan-14041). All Rights Reserved.
   Proprietary and confidential. See LICENSE and TERMS.md. */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "SF Mono", ui-monospace, "Menlo", "Consolas", "Roboto Mono", monospace;
  color: #aee9ff;
  cursor: crosshair;
  /* nothing in the app is meant to be selected — a long-press on Android otherwise
     pops the selection magnifier over the WebGL canvas and stalls the frame loop */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

input, textarea { -webkit-user-select: text; user-select: text; }   /* typing still needs a caret */

#scene { display: block; width: 100vw; height: 100vh; }

/* subtle cinematic vignette over the scene (below the HUD, no blur — GPU-cheap) */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 58%, rgba(2, 6, 14, 0.42) 100%);
}
body.lite #vignette { display: none; }   /* keep TVs as light as possible */

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

.panel {
  position: absolute;
  padding: 11px 15px;
  background: linear-gradient(160deg, rgba(14, 30, 48, 0.5), rgba(6, 15, 26, 0.44));
  border: 1px solid rgba(120, 205, 255, 0.28);
  border-radius: 9px;
  backdrop-filter: blur(4px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(160, 225, 255, 0.09);
  letter-spacing: 1px;
}
.panel::before {   /* a hairline light sweep along the top edge */
  content: ""; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(150, 225, 255, 0.55), transparent);
}

/* HUD elements glide in once the sky has loaded (one-time, CSS only) */
@keyframes hudIn { from { opacity: 0; } to { opacity: 1; } }
body.ready .panel        { animation: hudIn 0.7s ease both; }
body.ready .panel.top-right { animation-delay: 0.12s; }
body.ready #search       { animation: hudIn 0.7s ease 0.24s both; }
body.ready #dock, body.ready #btnMenu, body.ready #btnConst { animation: hudIn 0.7s ease 0.34s both; }

.top-left  { top: 18px; left: 18px; }
.top-right { top: 18px; right: 18px; text-align: right; min-width: 180px; }
/* on phones the two corner panels share one 130px-tall top band; hard caps mean
   long Persian names / extra info lines can never grow into the row below */
body.touch .panel.top-left,
body.touch .panel.top-right { max-width: 46vw; max-height: 118px; overflow: hidden; }
body.touch .panel.top-right .big { font-size: 19px; white-space: normal; word-break: break-word; }
body.touch .infolines div { white-space: normal; }

.label {
  font-size: 10px;
  color: #5a86a0;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.big {
  font-size: 30px;
  font-weight: 700;
  color: #eaf8ff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;   /* numbers keep an even width, no jitter */
  text-shadow: 0 0 14px rgba(120, 210, 255, 0.55), 0 0 2px rgba(180, 235, 255, 0.6);
}
.unit { font-size: 11px; color: #6fa8c4; }
/* thin throttle bar under the velocity readout (scaleX'd from JS — compositor-only) */
#speedBar {
  margin-top: 7px; height: 3px; border-radius: 2px;
  background: rgba(90, 160, 210, 0.18);
  overflow: hidden;
}
#speedBar i {
  display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #3f9fe0, #8fe0ff);
  box-shadow: 0 0 8px rgba(110, 205, 255, 0.55);
  transform: scaleX(0); transform-origin: left center;
  transition: transform 0.15s linear;
}
.infolines { font-size: 11px; color: #8fb6cc; line-height: 1.55; }
.infolines div { white-space: nowrap; }
/* AI ship's computer narration — sits under the scan lines, wraps to a few lines */
.narration {
  font-size: 11px; line-height: 1.5; color: #bfe6ff; max-width: 240px;
  margin-top: 8px; white-space: normal; font-style: italic;
  border-top: 1px solid rgba(110,200,255,0.18); padding-top: 7px;
  min-height: 0; opacity: 0; transition: opacity .35s ease;
}
.narration.show { opacity: 1; }
.narration.thinking { color: #6fa8c4; font-style: italic; }
.narration.show::after {   /* ship-computer console cursor */
  content: "▍"; margin-left: 2px; color: #7dc8ff;
  animation: cblink 1.1s steps(2) infinite;
}
@keyframes cblink { 50% { opacity: 0; } }
body.lite .narration.show::after { animation: none; }   /* no idle animation on TVs */
/* On touch, lift the narration out of the top-right panel (which would otherwise
   grow into the ✦-lines and mute buttons) and show it as a centred caption above
   the on-screen controls. */
body.touch .narration {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: auto; bottom: 220px;
  width: 62vw; max-width: 62vw; margin: 0;
  padding: 7px 12px; border-top: none; border-radius: 8px;
  background: rgba(6, 16, 26, 0.62);
  text-align: center; font-size: 10px; line-height: 1.45;
}
body.touch .narration:not(.show) { display: none; }
.mid  { font-size: 18px; font-weight: 600; color: #cdecff; }
.sep  { height: 1px; background: rgba(110,200,255,0.2); margin: 8px 0; }

/* ---- category legend ---- */
#legend {
  position: fixed;
  left: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 8px 11px;
  background: rgba(8, 20, 32, 0.35);
  border: 1px solid rgba(110, 200, 255, 0.2);
  border-radius: 6px;
  pointer-events: none;
}
body.touch #legend { display: none; }       /* the joystick lives here on phones */

/* ---- direction markers ---- */
#markers { position: absolute; inset: 0; }
.marker {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #8fd6ff;
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(0, 8, 16, 0.95);
}
.marker .sym { font-size: 12px; line-height: 1; color: #6fc8ff; }
.marker .dist { color: #5f8aa3; font-size: 10px; }
.marker.home { color: #ffd27a; }
.marker.home .sym { color: #ffd27a; }
.marker.poi { color: #d59bff; }
.marker.poi .sym { color: #d59bff; }
.marker.deep { color: #b89bff; }
.marker.deep .sym { color: #d8c0ff; }
.marker.comet { color: #aef0ff; }
.marker.comet .sym { color: #d6faff; }
.marker.exo { color: #9fffc0; }
.marker.exo .sym { color: #c8ffd8; }

/* names of nearby catalogued stars (appear as you fly through a constellation) */
#starLabels { position: absolute; inset: 0; }
.starLabel {
  position: absolute;
  transform: translate(-50%, -150%);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: #add6f0;
  white-space: nowrap;
  text-shadow: 0 0 5px rgba(0, 8, 16, 0.95);
  pointer-events: none;
  display: none;
}
.marker.off { color: #6fb6d8; }       /* dimmer when off-screen */
.marker.off .sym { color: #ffae5c; }   /* but a warm edge arrow */

.bottom {
  /* stacked above the epoch slider — the bottom edge belongs to legend/slider/dock,
     each in its own horizontal band, so none of the four can collide */
  bottom: 116px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #7fb4cf;
  white-space: nowrap;
}
.bottom b { color: #d6f4ff; }
.bottom .dim { color: #466; }

/* ---- center reticle: a soft double ring with breathing ticks ---- */
#reticle {
  position: absolute;
  top: 50%; left: 50%;
  width: 38px; height: 38px;
  margin: -19px 0 0 -19px;
  border: 1px solid rgba(130, 215, 255, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(90, 180, 255, 0.25), inset 0 0 8px rgba(90, 180, 255, 0.15);
}
#reticle::before, #reticle::after {
  content: "";
  position: absolute;
  background: rgba(140, 220, 255, 0.75);
  border-radius: 1px;
}
#reticle::before { top: 50%; left: -11px; width: 8px; height: 1px; box-shadow: 32px 0 rgba(140,220,255,0.75); }
#reticle::after  { left: 50%; top: -11px; height: 8px; width: 1px;  box-shadow: 0 32px rgba(140,220,255,0.75); }

/* ---- heading (prograde) marker: shows the direction you're actually moving ---- */
#heading {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: #7dff9e;
  font-size: 22px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(40, 255, 120, 0.6);
  pointer-events: none;
}

/* ---- utility dock -------------------------------------------------------
   One container owns every utility button, so their layout is a single flex/
   grid decision instead of nine hand-placed fixed positions (which is what
   caused the old overlaps). Desktop: a row in the bottom-right corner.
   Phones: hidden behind ☰, opens as a 2-column popover grid (see below). */
#dock {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 6;
  display: flex;
  gap: 9px;
}
#dock button {
  position: relative;              /* anchors the PRO star badge */
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: #a9d9f5;
  font-family: inherit;
  font-size: 13px; letter-spacing: 0.5px; line-height: 1;   /* the EN/فا text button */
  border: 1px solid rgba(110, 200, 255, 0.3);
  border-radius: 13px;             /* soft square: calmer, more legible than circles */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* crisp line icons — one visual family instead of mixed-color emoji */
.ic {
  width: 21px; height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
#btnMute.muted { opacity: 0.55; }
/* speaker icon: waves when sound is on, a cross when muted (CSS swap, no JS text) */
#btnMute .ic-snd .x { display: none; }
#btnMute.muted .ic-snd .w { display: none; }
#btnMute.muted .ic-snd .x { display: block; }
#btnMissions.hasnew { border-color: #7dff9e; box-shadow: 0 0 10px rgba(125,255,158,0.5); }
#btnCoop.linked { border-color: #7dff9e; box-shadow: 0 0 10px rgba(125,255,158,0.5); }

/* ---- fly-together (multiplayer) panel ---- */
#coop {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  display: none;
  width: 300px; max-width: 90vw;
  background: rgba(8, 20, 32, 0.95);
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 10px;
  padding: 14px 16px 16px;
  backdrop-filter: blur(5px);
}
#coop.show { display: block; }
#coop .chead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: 3px; color: #7dc8ff; margin-bottom: 12px; }
#coop .cclose { cursor: pointer; color: #6fa8c4; font-size: 15px; }
#coop .crow, #coop .crow2 { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
#coop .crow span { font-size: 11px; color: #7a97a8; }
#coop .cor { font-size: 11px; color: #5a86a0; }
#coop input { flex: 1; min-width: 0; font-family: inherit; font-size: 13px; color: #dff2ff; background: rgba(20,36,52,0.7); border: 1px solid rgba(110,200,255,0.25); border-radius: 6px; padding: 6px 8px; }
#coop #coopCode { text-transform: uppercase; letter-spacing: 2px; max-width: 92px; }
#coop button { font-family: inherit; font-size: 12px; color: #06131f; background: #7dc8ff; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
#coop button:hover { background: #9fd8ff; }
#coop .cstatus { font-size: 11px; color: #9fd0e8; margin: 6px 0 8px; min-height: 14px; }
#coop .chost { font-size: 11px; color: #7dff9e; line-height: 1.5; margin-bottom: 8px; word-break: break-all; }
#coop .chost b { color: #dff2ff; }
#coop .chost .clink { color: #9fe8ff; font-weight: 400; }
#coop .chost .cdim { color: #6f97ad; font-size: 10px; }
#coop .chost .ccopy { font-size: 11px; padding: 2px 8px; margin-left: 4px; vertical-align: middle; }
#coop .chost:empty { display: none; }
#coop .cqr { display: none; width: 140px; height: 140px; margin: 4px auto 8px; border-radius: 6px; background: #fff; padding: 6px; image-rendering: pixelated; }
#coop .cchat { height: 110px; overflow-y: auto; font-size: 12px; line-height: 1.5; color: #bfe0ff; background: rgba(4,12,20,0.5); border-radius: 6px; padding: 6px 8px; margin-bottom: 8px; }
#coop .cchat .who { color: #7dc8ff; }
#coop .cchat .who.me { color: #7dff9e; }
#coop .cchatrow #chatSend { padding: 6px 12px; }
#coop .cemoji { font-size: 20px; letter-spacing: 4px; cursor: pointer; user-select: none; }
#coop .cemoji span { cursor: pointer; }

/* ---- collapsible button menu (touch only) ---- */
/* On phones the utility dock hides behind a ☰ toggle; opening it shows a compact
   2-column popover grid pinned under the ☰ — a fixed footprint that can't run
   into the thrust cluster the way the old full-height column did. */
#btnMenu { display: none; }
body.touch #btnMenu {
  display: flex; align-items: center; justify-content: center;
  position: fixed; right: 12px; top: 148px; z-index: 8;
  width: 44px; height: 44px; color: #cdecff;
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 13px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
/* burger ↔ ✕ swap is pure CSS off body.menu-open */
#btnMenu .ic-close { display: none; }
body.menu-open #btnMenu .ic-open { display: none; }
body.menu-open #btnMenu .ic-close { display: block; }
body.touch.menu-open #btnMenu { color: #7dc8ff; border-color: #7dc8ff; }
body.touch #dock { display: none; }
body.touch.menu-open #dock {
  display: grid;
  grid-template-columns: repeat(2, 46px);
  gap: 9px;
  right: 12px; top: 200px; bottom: auto; left: auto;
  padding: 10px;
  background: rgba(8, 20, 32, 0.88);
  border: 1px solid rgba(110, 200, 255, 0.3);
  border-radius: 15px;
  backdrop-filter: blur(5px);
  animation: hudIn 0.18s ease both;
}
body.touch.menu-open #dock button { width: 46px; height: 46px; }

#missions {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  display: none;
  min-width: 280px; max-width: 88vw;
  background: rgba(8, 20, 32, 0.94);
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 10px;
  padding: 14px 20px 16px;
  backdrop-filter: blur(5px);
}
#missions.show { display: block; }
#missions .mhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: 3px; color: #7dc8ff; margin-bottom: 10px; }
#missions .mclose { cursor: pointer; color: #6fa8c4; font-size: 15px; }
#missions .mrow { display: flex; justify-content: space-between; gap: 18px; font-size: 12px; color: #bfe0ff; padding: 5px 0; }
#missions .mrow.done { color: #7dff9e; }
#missions .mrow .mick { min-width: 18px; }
#missions .mrow .mprog { color: #8fb6cc; }
#missions .mnote { margin-top: 10px; font-size: 10px; color: #5a86a0; text-align: center; }

#filterPanel {
  position: fixed;
  right: 18px; top: 152px;
  z-index: 9;
  display: none;
  width: 230px;
  background: rgba(8, 20, 32, 0.94);
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 10px;
  padding: 12px 16px 14px;
  backdrop-filter: blur(5px);
}
#filterPanel.show { display: block; }
/* phones: align with the ☰ popover position so it opens clear of the top row */
body.touch #filterPanel { top: 200px; right: 12px; }
#filterPanel .fhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: 3px; color: #7dc8ff; }
#filterPanel .fclose { cursor: pointer; color: #6fa8c4; }
#filterPanel .fsec { font-size: 10px; letter-spacing: 1.5px; color: #5a86a0; text-transform: uppercase; margin: 11px 0 5px; }
#filterPanel .flayers { display: flex; flex-direction: column; gap: 3px; }
#filterPanel label { font-size: 12px; color: #bfe0ff; display: flex; align-items: center; gap: 6px; cursor: pointer; }
#filterPanel input[type=checkbox] { accent-color: #6fc8ff; }
#filterPanel input[type=range] { width: 100%; accent-color: #6fc8ff; }
#fClasses { display: flex; gap: 4px; }
#fClasses .chip { flex: 1; font-family: inherit; font-size: 12px; color: #7a97a8; background: rgba(20,36,52,0.6); border: 1px solid rgba(110,200,255,0.2); border-radius: 5px; padding: 4px 0; cursor: pointer; }
#fClasses .chip.on { color: #06131f; background: #7dc8ff; border-color: #7dc8ff; font-weight: 700; }

/* ---- cinematic / screenshot mode ---- */

#journal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  display: none;
  min-width: 300px;
  background: rgba(8, 20, 32, 0.94);
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 10px;
  padding: 14px 20px 16px;
  backdrop-filter: blur(5px);
}
#journal.show { display: block; }
#journal .jhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: 3px; color: #7dc8ff; margin-bottom: 10px; }
#journal .jclose { cursor: pointer; color: #6fa8c4; font-size: 15px; }
#journal .jrow { display: flex; justify-content: space-between; gap: 18px; font-size: 12px; color: #bfe0ff; padding: 4px 0; }
#journal .jrow .jn { color: #8fb6cc; }
#journal .jrow .jpct { color: #7dff9e; min-width: 40px; text-align: right; }
#journal .jtotal { border-top: 1px solid rgba(110, 200, 255, 0.2); margin-top: 8px; padding-top: 8px; color: #d6f4ff; }
#journal .jreset { margin-top: 10px; font-size: 11px; color: #5a86a0; cursor: pointer; text-align: center; }
#journal .jreset:hover { color: #9fd0e8; }

#cineBar {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  z-index: 8;
  display: none;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(8, 20, 32, 0.8);
  border: 1px solid rgba(110, 200, 255, 0.3);
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #cdecff;
  backdrop-filter: blur(4px);
  max-width: 96vw;
  flex-wrap: wrap;
  justify-content: center;
}
body.cinematic #cineBar { display: flex; }
body.cinematic #hud, body.cinematic #minimap, body.cinematic #timePanel,
body.cinematic #search, body.cinematic #legend, body.cinematic #dock,
body.cinematic #btnMenu, body.cinematic #toast, body.cinematic #travel,
body.cinematic #touch, body.cinematic #journal,
body.cinematic #filterPanel { display: none !important; }
#cineBar .lbl { color: #7dc8ff; letter-spacing: 2px; }
#cineBar label { display: flex; align-items: center; gap: 5px; }
#cineBar input[type=range] { width: 88px; accent-color: #6fc8ff; }
#cineBar select { font-family: inherit; color: #cdecff; background: rgba(8,20,32,0.8); border: 1px solid rgba(110,200,255,0.3); border-radius: 5px; padding: 2px 4px; }
#cineBar button { font-family: inherit; color: #cdecff; background: rgba(60,130,200,0.4); border: 1px solid rgba(110,200,255,0.35); border-radius: 6px; padding: 6px 11px; cursor: pointer; }
#cineBar button:hover { background: rgba(80,150,220,0.55); }
#cineBar .hint { color: #7dff9e; opacity: 0.75; }

/* ---- Historical Sky time slider ---- */
#timePanel {
  position: fixed;
  left: 50%; bottom: 54px;
  transform: translateX(-50%);
  z-index: 6;
  width: 340px; max-width: 82vw;
  text-align: center;
  background: rgba(8, 20, 32, 0.4);
  border: 1px solid rgba(110, 200, 255, 0.2);
  border-radius: 8px;
  padding: 7px 12px 5px;
}
#epochSlider { width: 100%; accent-color: #6fc8ff; cursor: pointer; }
#epochLabel { margin-top: 2px; font-size: 12px; letter-spacing: 1.5px; color: #9fd0e8; }
body.touch #timePanel { display: none; }

/* ---- minimap (top-down radar) ---- */
#minimap {
  position: fixed;
  right: 18px; top: 152px;
  z-index: 6;
  pointer-events: none;
  border-radius: 50%;
  border: 1px solid rgba(120, 205, 255, 0.22);
  box-shadow: 0 0 16px rgba(60, 150, 230, 0.15), inset 0 0 12px rgba(80, 170, 255, 0.08);
}
body.touch #minimap { display: none; }

/* ---- search + auto-travel ---- */
#search {
  position: fixed;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  width: 300px; max-width: 70vw;
}
/* on phones the corner panels fill the top row — search drops into the ☰ row,
   ending before the buttons start so nothing can sit on top of it */
body.touch #search {
  top: 148px; left: 12px; transform: none;
  width: auto; max-width: none; right: 176px;
}
#searchInput {
  width: 100%;
  padding: 8px 15px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #cdecff;
  background: linear-gradient(180deg, rgba(16, 34, 52, 0.6), rgba(8, 18, 30, 0.62));
  border: 1px solid rgba(120, 205, 255, 0.32);
  border-radius: 999px;                          /* pill */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(170, 225, 255, 0.08);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#searchInput:focus {
  border-color: rgba(140, 230, 255, 0.75);
  box-shadow: 0 0 14px rgba(90, 190, 255, 0.3), inset 0 1px 0 rgba(170, 225, 255, 0.1);
}
#searchResults {
  margin-top: 4px;
  display: none;
  background: rgba(8, 20, 32, 0.92);
  border: 1px solid rgba(110, 200, 255, 0.25);
  border-radius: 8px;
  overflow: hidden;
}
#searchResults.show { display: block; }
#searchResults .row {
  padding: 7px 13px;
  font-size: 12px;
  color: #bfe0ff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#searchResults .row:hover { background: rgba(60, 130, 200, 0.4); color: #fff; }

#travel {
  position: fixed;
  top: 58px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #7dff9e;
  text-shadow: 0 0 8px rgba(40, 255, 120, 0.5);
  pointer-events: none;
  display: none;
}
#travel.show { display: block; }

/* ---- arrival toast ---- */
#toast {
  position: fixed;
  top: 16%; left: 50%;
  transform: translate(-50%, -8px);
  padding: 10px 22px;
  font-size: 15px;
  letter-spacing: 3px;
  color: #d6f4ff;
  background: rgba(8, 20, 32, 0.4);
  border: 1px solid rgba(120, 210, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(3px);
  text-shadow: 0 0 12px rgba(120, 210, 255, 0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
/* on phones the top strip is full of panels — drop arrival toasts below the search */
body.touch #toast { top: 216px; font-size: 13px; letter-spacing: 2px; max-width: 86vw; }

/* ---- loader: a small branded splash ---- */
#loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, #071120 0%, #010409 70%);
  color: #6fa8c4;
  font-size: 14px;
  letter-spacing: 3px;
  z-index: 10;
  transition: opacity 0.8s ease;
  text-align: center;
}
#loader.hidden { opacity: 0; pointer-events: none; }

/* ---- first-run onboarding ---- */
#onboard {
  position: fixed; inset: 0; z-index: 11;
  display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(4,10,20,0.55), rgba(2,5,11,0.82));
  backdrop-filter: blur(2px);
}
#onboard.show { display: flex; animation: hudIn 0.5s ease both; }
.obcard {
  width: 340px; max-width: 88vw;
  background: linear-gradient(160deg, rgba(16,34,54,0.96), rgba(8,18,32,0.96));
  border: 1px solid rgba(120,205,255,0.35);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(160,225,255,0.12);
  padding: 22px 22px 20px;
  text-align: center;
}
.obtitle { font-size: 19px; font-weight: 700; color: #eaf8ff; letter-spacing: 1px;
  text-shadow: 0 0 16px rgba(120,210,255,0.5); margin-bottom: 18px; }
.obstep { display: flex; align-items: center; gap: 12px; text-align: left;
  font-size: 13px; color: #cfeaff; line-height: 1.4; margin: 12px 4px; }
.obicon { font-size: 22px; flex: 0 0 26px; text-align: center; }
.obbtn {
  margin-top: 20px; width: 100%; padding: 12px;
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: 1px;
  color: #06131f; border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #8fe0ff, #4aa8ec);
  box-shadow: 0 0 18px rgba(90,190,255,0.4);
}
.obbtn:active { transform: translateY(1px); }
body.rtl .obstep { text-align: right; flex-direction: row-reverse; }

/* ---- Pro upsell ---- */
#pro {
  position: fixed; inset: 0; z-index: 12; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(4,10,20,0.6), rgba(2,5,11,0.86));
  backdrop-filter: blur(2px);
}
#pro.show { display: flex; animation: hudIn 0.4s ease both; }
.procard {
  width: 330px; max-width: 88vw; text-align: center;
  background: linear-gradient(160deg, rgba(18,38,60,0.97), rgba(9,20,36,0.97));
  border: 1px solid rgba(150,225,255,0.4); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55), inset 0 1px 0 rgba(170,230,255,0.14);
  padding: 24px 22px 18px;
}
.probadge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 2px;
  color: #06131f; background: linear-gradient(90deg,#ffd27a,#ffb84a);
  padding: 4px 12px; border-radius: 999px; box-shadow: 0 0 16px rgba(255,200,110,0.5);
}
.protitle { font-size: 20px; font-weight: 700; color: #eaf8ff; margin: 14px 0 8px;
  text-shadow: 0 0 16px rgba(120,210,255,0.5); }
.prodesc { font-size: 13px; color: #bfe0ff; line-height: 1.5; }
.promsg { font-size: 12px; color: #ffcf7a; min-height: 16px; margin-top: 10px; }
#pro .obbtn { margin-top: 16px; }
.prolink { margin-top: 12px; background: none; border: none; color: #6f97ad;
  font-family: inherit; font-size: 12px; cursor: pointer; }
.prolink:hover { color: #9fd0e8; }
/* a tiny PRO badge on the coop button once entitled */
#btnCoop.pro::after { content: "★"; position: absolute; top: -3px; right: -3px;
  font-size: 11px; color: #ffd27a; text-shadow: 0 0 6px rgba(255,200,110,0.8); }

/* language toggle in the filters panel */
#filterPanel .flang { display: flex; gap: 6px; }
#filterPanel .flang button {
  flex: 1; font-family: inherit; font-size: 12px; padding: 5px 0; cursor: pointer;
  color: #7a97a8; background: rgba(20,36,52,0.6);
  border: 1px solid rgba(110,200,255,0.2); border-radius: 6px;
}
#filterPanel .flang button.on { color: #06131f; background: #7dc8ff; border-color: #7dc8ff; font-weight: 700; }

#loader .ltitle {
  font-size: 34px; font-weight: 700; letter-spacing: 10px; color: #eaf8ff;
  text-shadow: 0 0 24px rgba(120, 210, 255, 0.65), 0 0 3px rgba(200, 240, 255, 0.8);
  animation: lglow 2.4s ease-in-out infinite;
}
#loader .lsub { margin-top: 12px; font-size: 12px; letter-spacing: 4px; color: #5f8aa4; }
#loader .lbar {
  width: 180px; height: 2px; margin: 22px auto 0; border-radius: 2px;
  background: rgba(90, 160, 210, 0.18); overflow: hidden;
}
#loader .lbar i {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #8fe0ff, transparent);
  animation: lscan 1.4s ease-in-out infinite;
}
@keyframes lglow { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
@keyframes lscan { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ---- touch controls (only shown when body.touch) ---- */
#scene { touch-action: none; }      /* stop browser gestures stealing drags */

#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
body.touch #touch { display: block; }
body.touch #help  { display: none; }   /* keyboard hints are useless on touch */

#touch > * { pointer-events: auto; }

.tbtn {
  font-family: inherit;
  color: #cdeeff;
  background: linear-gradient(180deg, rgba(20, 44, 66, 0.6), rgba(8, 20, 34, 0.62));
  border: 1px solid rgba(120, 205, 255, 0.42);
  border-radius: 14px;
  letter-spacing: 1px;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(180, 230, 255, 0.12);
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}
.tbtn.pressed, .tbtn:active {
  background: linear-gradient(180deg, rgba(80, 175, 245, 0.7), rgba(40, 115, 195, 0.72));
  color: #fff;
  box-shadow: inset 0 0 16px rgba(140, 220, 255, 0.5), 0 0 14px rgba(90, 190, 255, 0.4);
  transform: translateY(1px);
}

/* left joystick — a glowing orb in a guide ring */
#joyBase {
  position: absolute;
  left: 22px; bottom: 26px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 44%, rgba(46, 96, 146, 0.34), rgba(7, 17, 29, 0.5) 72%);
  border: 1px solid rgba(120, 205, 255, 0.34);
  box-shadow: 0 0 24px rgba(60, 150, 230, 0.18), inset 0 0 20px rgba(80, 170, 255, 0.12);
  touch-action: none;
}
#joyBase::before {          /* faint inner guide ring */
  content: ""; position: absolute; inset: 15px; border-radius: 50%;
  border: 1px dashed rgba(130, 205, 255, 0.2);
}
#joyThumb {
  position: absolute;
  left: 50%; top: 50%;
  width: 58px; height: 58px;
  margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 34%, #d6efff, #5aa8ec 58%, #2c6fb0 100%);
  border: 1px solid rgba(200, 235, 255, 0.85);
  box-shadow: 0 0 16px rgba(95, 190, 255, 0.55), inset 0 2px 7px rgba(255, 255, 255, 0.4), inset 0 -3px 8px rgba(10, 40, 70, 0.5);
}

/* right thrust cluster */
#thrustPad {
  position: absolute;
  right: 22px; bottom: 26px;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
#thrustPad .tbtn { width: 104px; height: 50px; }
#thrustPad .big  { height: 64px; font-size: 15px; font-weight: 700;
  background: linear-gradient(180deg, rgba(46, 128, 196, 0.6), rgba(22, 74, 134, 0.64));
  border-color: rgba(150, 235, 255, 0.8); color: #eaf8ff;
  box-shadow: 0 0 18px rgba(80, 200, 255, 0.32), inset 0 0 14px rgba(130, 225, 255, 0.16);
  text-shadow: 0 0 10px rgba(160, 235, 255, 0.6); }

/* roll buttons, bottom centre */
#rollPad {
  position: absolute;
  left: 50%; bottom: 30px; transform: translateX(-50%);
  display: flex; gap: 26px;
}
#rollPad .tbtn { width: 58px; height: 58px; border-radius: 50%; font-size: 22px; }

/* sits in one row with ☰ — same height, same top, no way to collide */
#btnConst.corner {
  position: absolute;
  right: 64px; top: 148px;
  height: 44px; padding: 0 14px;
  border-radius: 13px;
}

/* ---- shared polish for the utility buttons (overrides their flat bg) ---- */
#dock button, #btnMenu, #btnConst {
  background: linear-gradient(180deg, rgba(18, 38, 58, 0.62), rgba(8, 18, 30, 0.64));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(170, 225, 255, 0.1);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.06s ease, color 0.15s ease;
}
#dock button:active, #btnMenu:active, #btnConst:active { transform: translateY(1px); }
#dock button:hover, #btnMenu:hover {
  color: #dff2ff;
  border-color: rgba(140, 220, 255, 0.6); box-shadow: 0 0 14px rgba(90, 190, 255, 0.28);
}

/* lite build (smart TVs / weak GPUs): drop the blur to keep the HUD cheap */
body.lite .panel, body.lite #toast, body.lite #journal, body.lite #missions,
body.lite #coop, body.lite #filterPanel, body.lite #search input { backdrop-filter: none; }

/* ---- small-screen HUD scaling ---- */
@media (max-width: 680px) {
  .panel { padding: 7px 10px; }
  .big   { font-size: 22px; }
  .mid   { font-size: 15px; }
  .label { font-size: 9px; letter-spacing: 1.5px; }
  .top-right { min-width: 130px; }
  .marker { font-size: 10px; }
  body.touch .marker .dist { display: none; }   /* cut clutter on phones */
  #heading { font-size: 18px; }
  /* phones: a horizontal roll row runs into the joystick — stack it as a slim
     column in the free strip between the joystick and the thrust cluster */
  body.touch #rollPad { flex-direction: column; gap: 10px; bottom: 26px; }
  body.touch #rollPad .tbtn { width: 52px; height: 52px; font-size: 20px; }
}

/* ---- narrow / phone-width layout (applies even without touch, so a narrow
   desktop window gets the clean layout too, not just touch devices) ---- */
@media (max-width: 560px) {
  #help, #legend, #timePanel, #minimap { display: none; }
  #search { top: 148px; left: 12px; transform: none; width: auto; max-width: none; right: 12px; }
  /* a narrow non-touch window still shows the full dock — let it wrap upward */
  #dock { flex-wrap: wrap; justify-content: flex-end; max-width: 216px; }
}

/* ---- phone LANDSCAPE: the short height breaks the vertical button column, so
   lay the utility buttons out as a horizontal row across the free top-centre
   strip (between the two panels) and drop the narration to a bottom caption. --- */
@media (orientation: landscape) and (max-height: 500px) {
  #help, #legend, #timePanel, #minimap { display: none; }
  /* narrow the nearest-body panel so the top-centre strip has room */
  .panel.top-right { max-width: 150px; min-width: 0; }
  .panel.top-right .big { font-size: 16px; white-space: normal; }
  body.touch #btnMenu { top: 8px; left: 50%; right: auto; margin-left: -22px; }
  body.touch #btnConst.corner { top: 8px; right: auto; left: 50%; margin-left: 34px; }
  /* search fills the gap between the velocity panel and the ☰, never touching either */
  body.touch #search { top: 8px; left: 195px; right: auto; width: calc(50vw - 224px); }
  /* the dock popover becomes a centred 4×2 grid in the strip below the panels */
  body.touch.menu-open #dock {
    grid-template-columns: repeat(4, 46px);
    top: 148px; right: auto; left: 50%; transform: translateX(-50%);
  }
  body.touch .narration { bottom: 6px; width: 70vw; max-width: 70vw; }
}
