@import url('https://fonts.googleapis.com/css2?family=Michroma&family=JetBrains+Mono:wght@300;400;500;700&family=Space+Grotesk:wght@400;500;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Accessibility: visible keyboard focus, and calm everything for users who
   prefer reduced motion (the 3D render loop is JS rAF, unaffected). */
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:root {
  --bg: #05060d;
  --ink: #d6e3ff;
  --dim: #7e8db0;
  --accent: #7df9ff;
  --warn: #ff5577;
  --gold: #ffcc55;
  --green: #66ffaa;
  --panel: rgba(10, 14, 28, 0.78);
  --border: rgba(125, 249, 255, 0.25);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #000; color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  cursor: none;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) and (pointer: coarse) {
  html, body { cursor: default; }
  #cursor { display: none !important; }
}

#canvas-wrap { position: fixed; inset: 0; }
canvas { display: block; }

#cursor {
  position: fixed; width: 24px; height: 24px;
  pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
#cursor::before, #cursor::after {
  content: ''; position: absolute; background: var(--accent);
}
#cursor::before { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-0.5px); }
#cursor::after  { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-0.5px); }

body.ptr-locked, body.ptr-locked * { cursor: none !important; }
body.ptr-locked #cursor { display: none; }

/* Hide the custom crosshair whenever a UI panel that uses the real OS cursor
   is showing (boot, modal/terminal, directory, system map, engage overlay) —
   otherwise the crosshair and the OS cursor both appear and compete. */
body.not-started #cursor,
body.modal-open #cursor,
body:has(#modal-backdrop.visible) #cursor,
body:has(#directory.visible) #cursor,
body:has(#system-map.visible) #cursor,
body:has(#ptr-overlay.visible) #cursor { display: none; }

/* Cinematic mode — hide every HUD layer for clean screenshots / video.
   Toggle with H. The 3D scene, scanlines, and vignette stay visible. */
body.hud-hidden .hud,
body.hud-hidden #keybinds,
body.hud-hidden #minimap,
body.hud-hidden #planet-info,
body.hud-hidden #target-lock,
body.hud-hidden #worldspace,
body.hud-hidden #free-cam-hud,
body.hud-hidden #debug-hud {
  display: none !important;
}

.hud {
  position: fixed; z-index: 10;
  pointer-events: none;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); transition: opacity 0.3s;
}
body.not-started .hud { opacity: 0; }
body.modal-open .hud { opacity: 0.3; }
.hud .label { color: var(--dim); }
.hud .val { color: var(--accent); }

#top-left {
  top: calc(18px + var(--safe-t)); left: calc(22px + var(--safe-l));
  display: flex; flex-direction: column; gap: 4px;
}
#top-left .title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 19px; letter-spacing: 0.1em;
  color: var(--ink); margin-bottom: 6px;
}
#top-left .title .dot {
  display: inline-block; width: 7px; height: 7px;
  background: var(--accent); border-radius: 50%;
  margin-right: 8px; transform: translateY(-2px);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#top-right {
  top: calc(18px + var(--safe-t)); right: calc(22px + var(--safe-r));
  text-align: right;
  display: flex; flex-direction: column; gap: 4px;
  font-variant-numeric: tabular-nums;
}

#bottom-left {
  bottom: calc(18px + var(--safe-b)); left: calc(22px + var(--safe-l));
  display: flex; flex-direction: column; gap: 2px;
  min-width: 220px;
}
#bottom-left .row { display: flex; justify-content: space-between; gap: 12px; }
.bar {
  width: 100%; height: 2px;
  background: rgba(125, 249, 255, 0.15);
  margin-top: 2px; margin-bottom: 6px;
  position: relative; overflow: hidden;
}
.bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent); width: 0%;
  transition: width 0.15s linear;
}

#keybinds {
  position: fixed;
  bottom: calc(8px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  z-index: 10; pointer-events: none;
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.05em; text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.3s;
}
body.not-started #keybinds { opacity: 0; }
body.modal-open #keybinds { opacity: 0.3; }
#keybinds kbd {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 1px 4px; margin: 0 1px;
  color: var(--ink); font-family: inherit;
  font-size: 9px; border-radius: 2px;
  background: rgba(125, 249, 255, 0.05);
}
#keybinds .sep { color: rgba(90, 106, 138, 0.4); margin: 0 6px; }

/* Free-cam mode indicator (bottom, above the keybinds row) */
#free-cam-hud {
  position: fixed;
  bottom: calc(28px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  z-index: 12; pointer-events: none;
  font-size: 10px; letter-spacing: 0.18em;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(255, 204, 85, 0.5);
  opacity: 0; transition: opacity 0.15s;
}
#free-cam-hud.visible { opacity: 1; }

/* Minimap */
#minimap {
  position: fixed;
  bottom: calc(18px + var(--safe-b));
  right: calc(22px + var(--safe-r));
  z-index: 10;
  width: 180px; height: 180px;
  pointer-events: none;
  transition: opacity 0.3s;
}
body.not-started #minimap { opacity: 0; }
body.modal-open #minimap { opacity: 0.3; }
#minimap-canvas {
  width: 100%; height: 100%; display: block;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(10, 14, 28, 0.7) 0%, rgba(10, 14, 28, 0.85) 100%);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(125, 249, 255, 0.08);
}
#minimap-label {
  position: absolute; top: -16px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px; letter-spacing: 0.2em;
  color: var(--dim); text-transform: uppercase;
  white-space: nowrap;
}
#minimap-scale {
  position: absolute; bottom: -16px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px; letter-spacing: 0.15em;
  color: var(--dim); text-transform: uppercase;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

@media (hover: none) and (pointer: coarse) {
  #keybinds { display: none; }
  #minimap {
    width: 120px; height: 120px;
    bottom: auto;
    top: calc(150px + var(--safe-t));
    right: calc(15px + var(--safe-r));
  }
}

#target-lock {
  position: fixed; pointer-events: none; z-index: 6;
  width: 120px; height: 120px;
  transform: translate(-50%, -50%);
  display: none; opacity: 0; transition: opacity 0.2s;
}
#target-lock.active { display: block; opacity: 1; }
#target-lock svg { width: 100%; height: 100%; }
body.modal-open #target-lock { display: none; }

#planet-info {
  position: fixed; z-index: 7;
  top: 50%; right: calc(24px + var(--safe-r));
  transform: translate(40px, -50%);
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 14px 16px;
  width: 320px; max-width: 36vw;
  font-size: 11px; line-height: 1.5;
  opacity: 0; pointer-events: none;
  box-shadow: 0 0 40px rgba(125, 249, 255, 0.08);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
#planet-info.visible { opacity: 1; transform: translate(0, -50%); }
body.modal-open #planet-info, body.hud-hidden #planet-info { opacity: 0; }
@media (hover: none) and (pointer: coarse) {
  #planet-info { right: 12px; width: 280px; max-width: 70vw; }
}
#planet-info .pi-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
#planet-info .pi-desig {
  margin-top: 12px; padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--dim); text-transform: uppercase;
  letter-spacing: 0.12em; font-size: 9px;
}
#planet-info .status {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid currentColor;
  font-size: 9px; letter-spacing: 0.1em;
}
#planet-info .status.vacant { color: var(--green); }
#planet-info .status.owned  { color: var(--gold); }
#planet-info .desc {
  color: var(--ink); margin-top: 6px;
  text-transform: none; letter-spacing: 0;
}
/* Enriched claimed-planet content: logo + name + category + pitch + url. */
#planet-info .pi-saas { display: flex; gap: 10px; align-items: center; }
#planet-info .pi-logo {
  flex: 0 0 40px; width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#planet-info .pi-logo img { width: 100%; height: 100%; object-fit: contain; }
#planet-info .pi-logo.mono {
  font-family: 'Michroma', monospace; font-size: 14px;
  color: #04060d; background: var(--cat);
}
#planet-info .pi-saas-info { flex: 1; min-width: 0; }
#planet-info .pi-saas-name {
  font-family: 'Michroma', monospace; font-size: 13px;
  letter-spacing: 0.04em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#planet-info .pi-saas-sub {
  margin-top: 3px; display: flex; align-items: center; gap: 6px;
  font-size: 9px; letter-spacing: 0.08em; color: var(--dim);
  text-transform: uppercase;
}
#planet-info .pi-cat {
  color: var(--cat); border: 1px solid currentColor; padding: 1px 5px;
  font-size: 8px; letter-spacing: 0.12em;
}
#planet-info .pi-cat:empty { display: none; }
#planet-info .pi-pitch {
  margin-top: 8px; font-size: 12px; line-height: 1.5; color: var(--ink);
}
#planet-info .pi-url {
  margin-top: 6px; font-size: 10px; letter-spacing: 0.06em;
  color: var(--accent);
}
#planet-info .action {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 10px; letter-spacing: 0.12em;
  animation: pulse 1.6s ease-in-out infinite;
}

#ptr-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 80; display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
}
#ptr-overlay.visible { display: flex; }
@media (hover: none) and (pointer: coarse) {
  #ptr-overlay { display: none !important; }
}
.ptr-msg { text-align: center; color: var(--ink);
  font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; }
.ptr-msg .ptr-icon { font-size: 48px; color: var(--accent); margin-bottom: 16px; }
.ptr-msg .ptr-sub { margin-top: 8px; font-size: 10px; color: var(--dim); letter-spacing: 0.18em; }

/* Pause menu — injected into #ptr-overlay (the backdrop stays click-to-resume). */
#ptr-overlay.pause-menu { cursor: pointer; }
.pm-panel {
  width: min(330px, 86vw); cursor: default;
  background: linear-gradient(180deg, rgba(10,14,28,0.97), rgba(6,8,15,0.97));
  border: 1px solid var(--border); box-shadow: 0 0 80px rgba(125,249,255,0.18);
  padding: 22px 22px 18px;
}
.pm-title {
  text-align: center; color: var(--accent); font-size: 13px;
  letter-spacing: 0.24em; text-transform: uppercase; margin-bottom: 18px;
}
.pm-items { display: flex; flex-direction: column; gap: 8px; }
.pm-item {
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  font-family: inherit; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 11px 14px; cursor: pointer; text-align: left; transition: all 0.12s;
}
.pm-item:hover { background: var(--accent); color: #04060d; border-color: var(--accent); }
.pm-item[hidden] { display: none; }
.pm-primary { border-color: var(--accent); color: var(--accent); }
.pm-muted { color: var(--dim); }
.pm-muted:hover { background: var(--dim); border-color: var(--dim); color: #04060d; }
.pm-keys {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 9px; letter-spacing: 0.06em; color: var(--dim); line-height: 2; text-align: center;
}
.pm-keys kbd {
  font-family: inherit; font-size: 9px; color: var(--ink);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; margin: 0 1px;
}
.pm-keys span { margin: 0 5px; color: rgba(125,249,255,0.3); }

/* Dock transition caption — diegetic line shown during descent / ascent. */
#dock-overlay {
  position: fixed; top: 34%; left: 50%;
  transform: translateX(-50%);
  z-index: 96; pointer-events: none;
  text-align: center;
  display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transition: opacity 0.3s ease-out;
}
#dock-overlay.visible { opacity: 1; }
#dock-overlay .dock-label {
  font-family: 'Michroma', monospace;
  font-size: 13px; letter-spacing: 0.32em;
  color: var(--accent);
  text-shadow: 0 0 16px rgba(125, 249, 255, 0.5);
}
#dock-overlay .dock-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.2em; color: var(--ink);
}

/* Modal — reframed as a "surface terminal". Backdrop kept light so the
   cinematic planet framing stays visible behind; the panel rises into view. */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 4, 10, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100; display: none;
  align-items: center; justify-content: flex-end;   /* terminal docks to the right */
  cursor: default;
  padding: env(safe-area-inset-top) calc(3vw + env(safe-area-inset-right)) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#modal-backdrop.visible { display: flex; }
/* Decoration tab: drop the view-dimming so the planet reads clearly while editing. */
#modal-backdrop.deco-clear { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
#modal {
  background: linear-gradient(180deg, rgba(10,14,28,0.97) 0%, rgba(6,8,15,0.97) 100%);
  border: 1px solid var(--border);
  padding: 36px 40px 32px;
  width: min(560px, 94vw);
  max-height: 88vh; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;                 /* hide the scrollbar (still scrolls) */
  position: relative;
  box-shadow: 0 0 80px rgba(125, 249, 255, 0.18);
}
#modal::-webkit-scrollbar { display: none; }
#modal .feedback-list { scrollbar-width: none; }
#modal .feedback-list::-webkit-scrollbar { display: none; }
/* Terminal slides in from the right (the planet stays visible on the left). */
#modal-backdrop.visible #modal { animation: terminal-slide 0.4s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes terminal-slide {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
@media (max-width: 640px) {
  #modal-backdrop { justify-content: center; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
}

/* ── Incoming-transmission viewscreen ──────────────────────────────────────
   Sits in the space left of the docked panel (above the backdrop dim so it
   reads crisp), shows a planet's homepage capture in a CRT frame. Visual only
   (pointer-events: none). Hidden when there's no room beside the panel.
   The image URL is passed in as the --tx-src CSS variable. */
#transmission {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  right: calc(min(560px, 94vw) + 6vw);    /* stop short of the right-docked panel */
  z-index: 101;                            /* above #modal-backdrop (100) */
  display: flex; align-items: center; justify-content: center;
  padding: 4vh 3vw;
  pointer-events: none;
  /* No directional entrance — the box powers on in place (see .tx-frame),
     and the whole sequence starts ~0.5s after landing. */
  animation: tx-in 0.15s ease 0.5s both;
}
@media (max-width: 900px) { #transmission { display: none; } }
@keyframes tx-in { from { opacity: 0; } to { opacity: 1; } }

.tx-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; width: min(100%, 760px); }
.tx-label {
  font: 12px 'JetBrains Mono', monospace; letter-spacing: 0.22em; color: var(--accent);
  text-shadow: 0 0 10px rgba(125,249,255,0.7); padding-left: 2px;
}

.tx-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1280 / 800;
  max-height: 78vh;
  border-radius: 16px;
  overflow: hidden;                  /* contain the boot-phase screen tearing */
  background: #04060c;
  border: 1px solid rgba(125, 249, 255, 0.35);
  box-shadow: 0 0 60px rgba(125, 249, 255, 0.18), inset 0 0 0 7px #070a12, inset 0 0 0 8px rgba(125,249,255,0.12);
}
.tx-screen { position: absolute; inset: 8px; border-radius: 10px; overflow: hidden; background: #000; }
.tx-img {
  position: absolute; inset: 0;
  background-image: var(--tx-src); background-size: cover; background-position: top center;
  transform-origin: center;
}
/* Colour-fringe ghost (a second copy of the image), flashed during glitches. */
.tx-chroma {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background-image: var(--tx-src); background-size: cover; background-position: top center;
}
/* Bright horizontal tracking band, jumps during glitches. */
.tx-tracking {
  position: absolute; left: 0; right: 0; height: 9px; top: 30%; opacity: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.85), rgba(125,249,255,0.5), transparent);
  filter: blur(0.4px);
}
/* scanlines (a touch stronger now) */
.tx-lines { position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px); }
/* CRT vignette + slight tint */
.tx-vignette { position: absolute; inset: 0; pointer-events: none; border-radius: 10px;
  box-shadow: inset 0 0 90px rgba(0,0,0,0.6); background: radial-gradient(120% 120% at 50% 50%, transparent 58%, rgba(125,249,255,0.06)); }
/* boiling static */
.tx-noise { position: absolute; inset: -20%; pointer-events: none; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: tx-boil 0.8s steps(5) infinite; }
/* slow rolling bar (idle) */
.tx-roll { position: absolute; left: 0; right: 0; height: 26%; top: -26%; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.05) 45%, rgba(125,249,255,0.07) 55%, transparent);
  animation: tx-rolling 6s linear infinite; }
/* beam sweep (boot only) */
.tx-scan { position: absolute; left: 0; right: 0; height: 16%; top: -16%; opacity: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(125,249,255,0.35), rgba(255,255,255,0.7), rgba(125,249,255,0.35), transparent); }

/* Click-through to the founder's site. Inert during the beam-in (so the arrival
   isn't interrupted), active once the screen settles: hover darkens it and
   reveals a VISIT pill. #transmission itself is pointer-events:none, so the
   anchor re-enables just this region. */
.tx-visit {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
/* Active once the screen settles — captures clicks so a stray click on the
   viewscreen never falls through to the backdrop and dismisses the panel.
   The plain <div> variant (no URL) just swallows; only the <a> reacts. */
#transmission:not(.tx-booting) .tx-visit { pointer-events: auto; }
a.tx-visit { cursor: pointer; background: rgba(2,4,10,0); transition: background 0.2s ease; }
a.tx-visit:hover { background: rgba(2,4,10,0.5); }
.tx-visit-label {
  opacity: 0; transform: translateY(4px); transition: opacity 0.2s ease, transform 0.2s ease;
  font: 14px 'JetBrains Mono', monospace; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); text-shadow: 0 0 12px rgba(125,249,255,0.6);
  border: 1px solid rgba(125,249,255,0.6); padding: 10px 18px; background: rgba(4,8,14,0.6);
}
a.tx-visit:hover .tx-visit-label { opacity: 1; transform: translateY(0); }

/* CRT power-off — frame collapses to a bright horizontal line, then to a centre
   dot, and fades. Played when leaving the detail panel for the Decoration tab. */
.tx-off .tx-frame { transform-origin: center; animation: tx-poweroff 0.46s cubic-bezier(0.4, 0, 0.6, 1) forwards; }
.tx-off .tx-label { animation: tx-off-label 0.18s ease forwards; }
@keyframes tx-poweroff {
  0%   { transform: scaleY(1) scaleX(1);     filter: brightness(1.1); }
  48%  { transform: scaleY(0.018) scaleX(1); filter: brightness(2.6); }
  78%  { transform: scaleY(0.018) scaleX(0.35); filter: brightness(3.2); }
  100% { transform: scaleY(0.018) scaleX(0); filter: brightness(3.6); opacity: 0; }
}
@keyframes tx-off-label { to { opacity: 0; } }

/* Boot: ~0.55s of static "tuning in", then the image resolves out of bright
   desaturated noise with a beam sweep + glitch jitters. */
/* Timeline (after the 0.5s start delay): 0.4s CRT power-on → 0.4s ragged tear →
   image beam-in at 1.3s. */
.tx-booting .tx-img { animation: tx-resolve 1.25s cubic-bezier(0.2,0.7,0.2,1) 1.3s both; }
/* Box "comes on air": CRT power-on (bright line expands to the rectangle, 0.4s)
   then the outline tears/goes ragged (animated clip-path, 0.4s), resolving to a
   clean rect just before the image resolves. */
.tx-booting .tx-frame { transform-origin: center; animation: tx-box-onair 0.8s linear 0.5s both; }
.tx-booting .tx-tracking {
  top: 0; height: 100%; opacity: 0.55; filter: none;
  background: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,255,255,0.12) 7px 8px, transparent 8px 20px);
  animation: tx-boot-bars 0.8s steps(12) 0.5s both;
}
.tx-booting .tx-noise { opacity: 0.42; animation: tx-boil 0.35s steps(8) infinite; }
.tx-booting .tx-scan { animation: tx-sweep 1.25s ease-out 1.3s both; }

/* Idle: subtle flicker + occasional chroma/tracking glitch bursts. */
#transmission:not(.tx-booting) .tx-screen   { animation: tx-flicker 6.5s ease-in-out infinite; }
#transmission:not(.tx-booting) .tx-img      { animation: tx-img-idle 5.5s ease-in-out infinite; }
#transmission:not(.tx-booting) .tx-chroma   { animation: tx-chroma 5.5s ease-in-out infinite; }
#transmission:not(.tx-booting) .tx-tracking { animation: tx-track 5.5s linear infinite; }

@keyframes tx-resolve {
  0%   { clip-path: inset(0 0 100% 0); filter: brightness(2.4) contrast(0.3) saturate(0) blur(3px); transform: scale(1.05); }
  18%  { clip-path: inset(0 0 0 0);    filter: brightness(1.7) contrast(0.6) saturate(0.3) blur(1.5px); transform: scale(1.03); }
  100% { clip-path: inset(0 0 0 0);    filter: none; transform: scale(1); }
}
@keyframes tx-sweep {
  0% { top: -16%; opacity: 0.9; } 85% { opacity: 0.9; } 100% { top: 116%; opacity: 0; }
}
/* Box on-air: CRT power-on (scaleY from a bright line) then ragged/torn edges
   (clip-path mid-edge points bitten inward, decaying) settling to a clean rect.
   Corners stay fixed; the vertical edges tear. */
@keyframes tx-box-onair {
  /* Power-on (scaleY line→rect) and the ragged tear run CONCURRENTLY: the edges
     are torn from the very first frame and decay to a clean rect as the box
     powers up. 3 points per vertical edge, deepest bite ~20% early. */
  0%   { transform: scaleY(0.04); filter: brightness(2.6) saturate(0);
         clip-path: polygon(0% 0%,100% 0%,82% 25%,100% 50%,86% 75%,100% 100%,0% 100%,14% 75%,0% 50%,18% 25%); }
  16%  { transform: scaleY(0.92); filter: brightness(2.0) saturate(0.4);
         clip-path: polygon(0% 0%,100% 0%,100% 25%,80% 50%,96% 75%,100% 100%,0% 100%,8% 75%,20% 50%,4% 25%); }
  30%  { transform: scaleY(1.05); filter: brightness(1.6);
         clip-path: polygon(0% 0%,100% 0%,88% 25%,97% 50%,84% 75%,100% 100%,0% 100%,16% 75%,5% 50%,12% 25%); }
  44%  { transform: scaleY(1); filter: brightness(1.25);
         clip-path: polygon(0% 0%,100% 0%,96% 25%,90% 50%,98% 75%,100% 100%,0% 100%,6% 75%,11% 50%,3% 25%); }
  60%  { clip-path: polygon(0% 0%,100% 0%,98% 25%,95% 50%,96% 75%,100% 100%,0% 100%,3% 75%,7% 50%,5% 25%); }
  76%  { clip-path: polygon(0% 0%,100% 0%,99% 25%,98% 50%,99% 75%,100% 100%,0% 100%,2% 75%,3% 50%,1% 25%); }
  90%  { clip-path: polygon(0% 0%,100% 0%,100% 25%,99% 50%,100% 75%,100% 100%,0% 100%,0% 75%,1% 50%,0% 25%); }
  100% { transform: scaleY(1); filter: none;
         clip-path: polygon(0% 0%,100% 0%,100% 25%,100% 50%,100% 75%,100% 100%,0% 100%,0% 75%,0% 50%,0% 25%); }
}
/* Boot tracking bars: juddering bright bands that fade out before the image. */
@keyframes tx-boot-bars {
  0%   { opacity: 0.6; background-position-y: 0; }
  50%  { opacity: 0.4; background-position-y: -120px; }
  100% { opacity: 0; background-position-y: -260px; }
}
@keyframes tx-boil { to { background-position: 140px 140px; } }
@keyframes tx-rolling { to { top: 116%; } }
@keyframes tx-flicker { 0%,92%,100% { opacity: 1; } 93% { opacity: 0.94; } 96% { opacity: 0.98; } 98% { opacity: 0.93; } }
/* Two short glitch bursts per loop (~60% and ~85%), gentle. */
@keyframes tx-img-idle {
  0%,57%,100% { transform: translateX(0) skewX(0); }
  59% { transform: translateX(-3px) skewX(-0.4deg); }
  60.5% { transform: translateX(3px) skewX(0.5deg); }
  62% { transform: translateX(0) skewX(0); }
  84% { transform: translateX(2px); }
  86% { transform: translateX(0); }
}
@keyframes tx-chroma {
  0%,58%,100% { opacity: 0; transform: translateX(0); filter: none; }
  60% { opacity: 0.4; transform: translateX(5px); filter: hue-rotate(-45deg) saturate(2.2) brightness(1.1); }
  62.5% { opacity: 0.28; transform: translateX(-4px); filter: hue-rotate(50deg) saturate(2.2); }
  65% { opacity: 0; transform: translateX(0); }
  84% { opacity: 0.34; transform: translateX(-5px); filter: hue-rotate(60deg) saturate(2.2); }
  87% { opacity: 0; }
}
@keyframes tx-track {
  0%,58%,100% { opacity: 0; top: 22%; }
  60% { opacity: 0.6; top: 32%; }
  62% { opacity: 0.45; top: 56%; }
  64% { opacity: 0; top: 72%; }
  85% { opacity: 0.55; top: 46%; }
  87% { opacity: 0; top: 60%; }
}
@media (prefers-reduced-motion: reduce) {
  #transmission, .tx-booting .tx-img, .tx-booting .tx-frame, .tx-booting .tx-scan,
  .tx-booting .tx-tracking, .tx-noise, .tx-roll,
  #transmission:not(.tx-booting) .tx-screen, #transmission:not(.tx-booting) .tx-img,
  #transmission:not(.tx-booting) .tx-chroma, #transmission:not(.tx-booting) .tx-tracking { animation: none; }
  .tx-booting .tx-img { clip-path: none; filter: none; }
  .tx-noise { opacity: 0.05; }
}

#modal::before {
  content: ''; position: absolute;
  top: -1px; left: -1px;
  width: 24px; height: 24px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}
#modal::after {
  content: ''; position: absolute;
  bottom: -1px; right: -1px;
  width: 24px; height: 24px;
  border-bottom: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}
#modal-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none;
  color: var(--dim); font-size: 16px; cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; z-index: 2;
}
#modal-close:hover { color: var(--ink); }
#modal h2 {
  font-family: 'Michroma', monospace;
  font-size: 22px; letter-spacing: 0.18em;
  margin-bottom: 4px; color: var(--ink);
}
#modal .planet-coords {
  color: var(--dim); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 20px;
}
#modal .planet-coords .desig {
  font-family: 'Michroma', monospace; letter-spacing: 0.18em; opacity: 0.65;
}
#modal h2.scanning { color: var(--dim); }
#modal label {
  display: block; color: var(--dim);
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 6px; margin-top: 24px;
}
#modal .founding-as {
  margin-top: 12px;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim);
}
#modal .founding-as span { color: var(--accent); }
#modal input, #modal textarea, #modal select {
  width: 100%;
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 10px 12px;
  font-family: inherit; font-size: 13px;
  outline: none; transition: border-color 0.2s;
  border-radius: 0; -webkit-appearance: none; appearance: none;
}
#modal select {
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%),
                    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}
#modal select option { background: #0a0e1c; color: var(--ink); }
#modal input:focus, #modal textarea:focus, #modal select:focus { border-color: var(--accent); }
#modal textarea { resize: vertical; min-height: 80px; }
/* The locked call sign shown inline on the LEAVE FEEDBACK label. */
#modal label .fb-as { color: var(--accent); }
/* Shown in place of the composer when feedback requires sign-in. */
#modal .fb-gate {
  margin-top: 14px; padding: 12px 14px; font-size: 12px; line-height: 1.5;
  color: var(--dim); border: 1px dashed var(--border); background: rgba(125, 249, 255, 0.03);
}
/* Decoration tab — owner-only live world customisation */
#modal .deco-tabs { display: flex; gap: 6px; margin: 14px 0 4px; border-bottom: 1px solid var(--border); }
#modal .deco-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--dim); cursor: pointer; font-family: inherit; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; padding: 8px 12px;
}
#modal .deco-tab:hover { color: var(--ink); background: transparent; }
#modal .deco-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
#modal .deco-intro { font-size: 12px; color: var(--dim); line-height: 1.5; margin: 16px 0; }
#modal .deco-row { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
#modal .deco-label { flex: 1; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#modal .deco-label b { color: var(--accent); font-weight: 600; }
#modal .deco-row input[type="color"] {
  width: 46px; height: 30px; padding: 0; border: 1px solid var(--border);
  background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none;
}
#modal .deco-row input[type="range"] { -webkit-appearance: auto; appearance: auto; flex: 1.5; accent-color: var(--accent); cursor: pointer; }
#modal .deco-reset {
  background: transparent; border: 1px solid var(--border); color: var(--dim); cursor: pointer;
  font-family: inherit; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; padding: 6px 10px;
}
#modal .deco-reset:hover { color: var(--ink); border-color: var(--accent); background: transparent; }
#modal .deco-check {
  display: flex; align-items: center; gap: 9px; margin: 14px 0; cursor: pointer;
  font-size: 13px; letter-spacing: 0.04em; text-transform: none; color: var(--ink);
}
#modal .deco-check input { -webkit-appearance: auto; appearance: auto; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto; }
#modal .btns { display: flex; gap: 10px; margin-top: 30px; }
#modal button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 12px 20px;
  font-family: inherit; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s;
}
/* Only the action rows split evenly — not inline buttons like the per-comment
   upvote, which should size to their content. */
#modal .btns button { flex: 1; }
#modal button:hover, #modal button:active {
  background: var(--accent); color: #000; border-color: var(--accent);
}
#modal button.secondary:hover, #modal button.secondary:active {
  background: var(--dim); color: #000; border-color: var(--dim);
}
#modal button:disabled { opacity: 0.4; cursor: not-allowed; }
#modal button:disabled:hover { background: transparent; color: var(--ink); border-color: var(--border); }
#modal .info-block {
  background: rgba(125, 249, 255, 0.04);
  border-left: 2px solid var(--accent);
  padding: 12px 14px; margin: 16px 0;
  font-size: 12px; line-height: 1.6;
}
#modal .info-block .owner {
  color: var(--gold); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 4px;
}
#modal .claim-head { display: flex; gap: 12px; align-items: center; }
#modal .claim-logo {
  flex: 0 0 48px; width: 48px; height: 48px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#modal .claim-logo img { width: 100%; height: 100%; object-fit: contain; }
#modal .claim-logo.mono {
  font-family: 'Michroma', monospace; font-size: 16px;
  color: #04060d; background: var(--gold);
}
#modal .claim-header-text { flex: 1; min-width: 0; }

/* Reworked claimed-planet panel header + CTAs. */
#modal .claim-header { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
#modal .claim-header h2 { margin: 0 0 5px; }
#modal .claim-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#modal .claim-tier {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gold); border: 1px solid rgba(255, 204, 85, 0.5); padding: 2px 8px;
}
/* Founder now sits on its own line beneath the tag row. */
#modal .claim-founder { display: block; margin-top: 6px; font-size: 12px; color: var(--dim); letter-spacing: 0.06em; }
#modal .claim-pitch { font-size: 13px; line-height: 1.6; color: var(--ink); margin: 6px 0 16px; }
#modal .claim-desc { font-size: 12px; line-height: 1.6; color: var(--dim); margin: 0 0 18px; }
#modal .claim-video {
  display: inline-block; margin: 0 0 12px; color: var(--gold); font-size: 12px;
  letter-spacing: 0.06em; text-decoration: none;
}
#modal .claim-video:hover { text-decoration: underline; }
#modal .claim-shots { display: flex; gap: 8px; margin: 0 0 14px; }
#modal .claim-shots img {
  width: calc(50% - 4px); max-height: 120px; object-fit: cover;
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.4);
}
#modal .claim-cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
#modal .claim-visit {
  flex: 1; min-width: 160px; text-align: center; text-decoration: none;
  background: var(--accent); color: #04060d; padding: 10px 16px;
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; transition: box-shadow 0.15s;
}
#modal .claim-visit:hover { box-shadow: 0 0 20px var(--accent); }
#modal .claim-fullpage {
  text-align: center; text-decoration: none; border: 1px solid var(--accent); color: var(--accent);
  padding: 10px 16px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; transition: background 0.15s;
}
#modal .claim-fullpage:hover { background: rgba(125, 249, 255, 0.12); }

/* Logo upload row in the edit form. */
#modal .logo-edit { display: flex; gap: 12px; align-items: center; margin-top: 4px; }
#modal .logo-edit-preview {
  flex: 0 0 56px; width: 56px; height: 56px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#modal .logo-edit-preview img { width: 100%; height: 100%; object-fit: contain; }
#modal .logo-edit-preview.mono {
  font-family: 'Michroma', monospace; font-size: 18px;
  color: #04060d; background: var(--gold);
}
#modal .logo-edit-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#modal .logo-edit-controls input[type=file] {
  font-family: inherit; font-size: 11px; color: var(--dim);
  border: none; background: none; padding: 0;
}
#modal .logo-edit-controls input[type=file]::file-selector-button {
  font-family: inherit; font-size: 10px; letter-spacing: 0.08em;
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  padding: 4px 10px; margin-right: 8px; cursor: pointer;
}
#modal .logo-edit-hint { font-size: 11px; letter-spacing: 0.08em; color: var(--dim); }
#modal #e-logo-upload { flex: 0; align-self: flex-start; padding: 6px 14px; }
#modal .owner-actions {
  margin: 8px 0 16px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
}
#modal .owner-actions .btns { margin-top: 6px; }

/* Share row */
#modal .share-row {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 6px;
}
#modal .share-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--accent); cursor: pointer;
  font-family: inherit; font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; padding: 5px 12px;
  transition: all 0.12s; flex: 0 0 auto;
}
#modal .share-btn:hover { background: var(--accent); color: #04060d; border-color: var(--accent); }
#modal .share-page {
  border: 1px solid var(--border); color: var(--gold);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 5px 12px; flex: 0 0 auto; transition: all 0.12s;
}
#modal .share-page:hover { background: var(--gold); color: #04060d; border-color: var(--gold); text-decoration: none; }
#modal .share-hint { font-size: 11px; letter-spacing: 0.08em; color: var(--dim); text-transform: uppercase; }
#modal .upvote-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; }
/* Stacked vote widget: arrow over a larger count, in its own header corner. */
#modal .upvote-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  cursor: pointer; font-family: inherit; line-height: 1;
  width: 56px; padding: 9px 0; transition: all 0.12s; flex: 0 0 auto;
  align-self: flex-start;   /* pin to the top of the header, aligned with the title */
  margin-right: 34px;       /* clear the absolutely-positioned ✕ close button in the corner */
}
#modal .upvote-btn .uv-arrow { font-size: 13px; }
#modal .upvote-btn .uv-count { font-size: 19px; font-weight: 600; letter-spacing: 0.03em; }
#modal .upvote-btn:hover { background: rgba(125, 249, 255, 0.12); }
#modal .upvote-btn.voted { background: var(--accent); color: #04060d; border-color: var(--accent); }
#modal .upvote-label { font-size: 11px; letter-spacing: 0.08em; color: var(--dim); text-transform: uppercase; }
#modal .share-hint.copied { color: var(--green); }

/* Founder stats dashboard */
#modal .founder-stats { margin-top: 10px; }
#modal .founder-stats .fs-loading { font-size: 10px; color: var(--dim); letter-spacing: 0.1em; }
#modal .founder-stats .fs-title {
  font-size: 11px; letter-spacing: 0.16em; color: var(--gold);
  text-transform: uppercase; margin-bottom: 6px;
}
#modal .fs-tiles { display: flex; gap: 6px; flex-wrap: wrap; }
#modal .fs-tile {
  flex: 1; min-width: 52px; text-align: center;
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border); padding: 6px 4px;
}
#modal .fs-num { font-family: 'Michroma', monospace; font-size: 16px; color: var(--accent); font-variant-numeric: tabular-nums; }
#modal .fs-label { font-size: 9px; letter-spacing: 0.12em; color: var(--dim); margin-top: 3px; }
#modal .fs-spark-label { font-size: 10px; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; margin: 10px 0 4px; }
#modal .fs-spark { display: flex; align-items: flex-end; gap: 4px; height: 38px; }
#modal .fs-bar { flex: 1; background: linear-gradient(180deg, var(--accent), rgba(125,249,255,0.25)); min-height: 4px; }
#modal .fs-spark-empty { font-size: 10px; color: var(--dim); }
#modal .feedback-list { margin-top: 8px; }
#modal .feedback-more {
  display: inline-block; margin: 6px 0 2px;
  font-size: 11px; letter-spacing: 0.06em; color: var(--accent);
}
#modal .feedback-more:hover { text-decoration: underline; }
#modal .feedback-item {
  border-left: 1px solid var(--border);
  padding: 6px 10px; margin-bottom: 6px;
  font-size: 11px; line-height: 1.5;
}
#modal .feedback-item .from {
  color: var(--dim); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 8px;
}
#modal .feedback-item .from .reply-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: inherit; font-size: 10px;
  letter-spacing: 0.14em;
  padding: 1px 6px; cursor: pointer;
  transition: all 0.12s;
}
#modal .feedback-item .from .reply-btn:hover {
  color: var(--gold); border-color: var(--gold);
}
#modal .feedback-item .from .vote-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: inherit; font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 7px; cursor: pointer;
  transition: all 0.12s;
}
#modal .feedback-item .from .vote-btn:hover { color: var(--accent); border-color: var(--accent); }
#modal .feedback-item .from .vote-btn.voted { color: var(--green); border-color: var(--green); cursor: default; }
#modal .feedback-item .from .vote-count { font-variant-numeric: tabular-nums; }
#modal .feedback-reply {
  margin-top: 8px; padding: 6px 10px;
  border-left: 2px solid var(--gold);
  background: rgba(255, 204, 85, 0.04);
  font-size: 11px; line-height: 1.5;
}
#modal .feedback-reply .from {
  color: var(--gold); font-size: 9px;
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 2px;
}
#modal .reply-form {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 2px dashed var(--gold);
}
#modal .reply-form textarea {
  min-height: 50px; font-size: 12px;
}
#modal .reply-form .btns { margin-top: 8px; }
#modal .url { color: var(--accent); text-decoration: none; word-break: break-all; }
#modal .url:hover { text-decoration: underline; }
#modal .err {
  color: var(--warn); font-size: 11px; margin-top: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
#modal .token-note {
  margin-top: 20px; padding: 10px 12px;
  background: rgba(255, 204, 85, 0.06);
  border-left: 2px solid var(--gold);
  font-size: 10px; line-height: 1.6;
  color: var(--ink); letter-spacing: 0.06em;
}
#modal .token-note code {
  display: block;
  background: rgba(0,0,0,0.4);
  padding: 6px 8px;
  margin-top: 4px;
  font-family: inherit; font-size: 11px;
  color: var(--gold); word-break: break-all;
  /* Override the global user-select:none so the token can be selected/copied. */
  -webkit-user-select: all; user-select: all;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
#modal .token-note code:hover { border-color: var(--gold); }
#modal .token-note .token-copy-hint {
  display: inline-block;
  margin-top: 5px;
  font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim);
}
#modal .token-note .token-copy-hint.copied { color: var(--green); }

/* Boot */
#boot {
  position: fixed; inset: 0;
  z-index: 200; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: safe center;   /* scroll, don't clip, on short viewports */
  cursor: default; transition: opacity 0.6s;
  padding: 20px;
  background:
    radial-gradient(ellipse 70% 50% at 22% 28%, rgba(96, 64, 200, 0.32) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 78% 72%, rgba(40, 120, 210, 0.28) 0%, transparent 60%),
    radial-gradient(ellipse 45% 40% at 55% 22%, rgba(190, 70, 150, 0.16) 0%, transparent 65%),
    radial-gradient(ellipse at 50% 60%, #060a18 0%, #02030a 75%);
}
#boot.gone { opacity: 0; pointer-events: none; }

/* Distant sun glow at the horizon line. */
#boot::before {
  content: '';
  position: absolute;
  left: 50%; top: 78%;
  width: 540px; height: 540px;
  margin: -270px 0 0 -270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(125, 249, 255, 0.18) 0%, rgba(125, 249, 255, 0.05) 30%, transparent 65%);
  pointer-events: none;
  filter: blur(2px);
}

/* Faint horizon line under the sun glow. */
#boot::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 78%;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(125, 249, 255, 0.18) 50%, transparent 100%);
  pointer-events: none;
}

/* Star layers — pseudo-elements on dedicated wrappers so we can animate
   each independently for slow parallax drift. */
.boot-stars {
  position: absolute; inset: -10% -10%;
  pointer-events: none;
  background-repeat: repeat;
}
.boot-stars.far {
  background-image:
    radial-gradient(1px 1px at 12px 34px,  rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(1px 1px at 80px 120px, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(1px 1px at 160px 60px, rgba(200,220,255,0.40), transparent 60%),
    radial-gradient(1px 1px at 220px 180px,rgba(255,255,255,0.30), transparent 60%),
    radial-gradient(1px 1px at 40px 220px, rgba(180,200,255,0.35), transparent 60%),
    radial-gradient(1px 1px at 280px 90px, rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(1px 1px at 350px 250px,rgba(200,220,255,0.30), transparent 60%),
    radial-gradient(1px 1px at 110px 290px,rgba(255,255,255,0.30), transparent 60%);
  background-size: 400px 320px;
  animation: boot-drift-far 180s linear infinite;
  opacity: 0.7;
}
.boot-stars.near {
  background-image:
    radial-gradient(1.5px 1.5px at 60px 70px,  rgba(255,255,255,0.85), transparent 55%),
    radial-gradient(1.5px 1.5px at 180px 140px,rgba(180,220,255,0.75), transparent 55%),
    radial-gradient(2px 2px at 320px 60px,     rgba(255,255,255,0.95), transparent 55%),
    radial-gradient(1px 1px at 240px 240px,    rgba(255,210,180,0.70), transparent 55%),
    radial-gradient(2px 2px at 90px 280px,     rgba(180,210,255,0.85), transparent 55%),
    radial-gradient(1.5px 1.5px at 400px 180px,rgba(255,255,255,0.80), transparent 55%);
  background-size: 480px 380px;
  animation: boot-drift-near 90s linear infinite;
}
@keyframes boot-drift-far {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-400px, -160px, 0); }
}
@keyframes boot-drift-near {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(480px, 190px, 0); }
}

.boot-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 44px 56px 36px;
  max-width: 560px;
  background: linear-gradient(180deg, rgba(8, 12, 26, 0.55) 0%, rgba(4, 6, 14, 0.35) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(125, 249, 255, 0.08);
}
.boot-content::before,
.boot-content::after {
  content: ''; position: absolute;
  width: 28px; height: 28px;
  pointer-events: none;
}
.boot-content::before {
  top: -1px; left: -1px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}
.boot-content::after {
  bottom: -1px; right: -1px;
  border-bottom: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}

#boot .boot-logo {
  width: min(540px, 82vw); height: auto;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 26px rgba(125, 249, 255, 0.25));
}
#boot .tag {
  color: var(--dim);
  font-size: clamp(9px, 1.6vw, 11px);
  letter-spacing: 0.32em; text-transform: uppercase;
  margin-bottom: 36px;
  display: flex; align-items: center; gap: 12px;
}
#boot .tag::before,
#boot .tag::after {
  content: '';
  height: 1px; width: 32px;
  background: linear-gradient(90deg, transparent, var(--dim), transparent);
}
#boot .handle-row {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  margin-bottom: 22px;
}
/* Deep-link launch state: while we resolve auth for a ?planet visitor, mask the
   form with a loading line so a signed-in pilot never sees the boot controls
   flash before being warped in. */
#boot .boot-launching { display: none; }
#boot.launching .handle-row,
#boot.launching .start,
#boot.launching .boot-account,
#boot.launching .hint { display: none; }
#boot.launching .boot-launching {
  display: block; text-align: center;
  color: var(--dim); font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  animation: boot-pulse 1.4s ease-in-out infinite;
}
@keyframes boot-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
#boot .handle-row label {
  color: var(--dim); font-size: 9px;
  letter-spacing: 0.22em; text-transform: uppercase;
}
#boot .handle-row input {
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 10px 14px;
  font-family: inherit; font-size: 12px;
  letter-spacing: 0.12em; text-align: center;
  width: 240px; max-width: 60vw;
  border-radius: 0; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
#boot .handle-row input:focus {
  border-color: var(--accent);
  background: rgba(125, 249, 255, 0.08);
  box-shadow: 0 0 12px rgba(125, 249, 255, 0.18);
}
#boot .start {
  position: relative;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 14px 42px;
  font-family: inherit; font-size: 12px;
  letter-spacing: 0.22em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  border-radius: 0;
  box-shadow: 0 0 0 rgba(125, 249, 255, 0);
}
#boot .start:hover, #boot .start:active {
  background: var(--accent); color: #000;
  box-shadow: 0 0 40px var(--accent);
}
/* Sign-in / signed-in row beneath the start button. */
#boot .boot-account {
  margin-top: 18px;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  min-height: 20px;
}
#boot .boot-google {
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 20px;
  font-family: inherit; font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer; transition: all 0.18s;
}
#boot .boot-google:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(125, 249, 255, 0.08);
}
#boot .boot-acct-hint {
  color: var(--dim); font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
}
#boot .boot-acct-warn {
  color: var(--gold); font-size: 10px;
  letter-spacing: 0.08em; margin-top: 4px;
}
#boot .boot-acct-name {
  color: var(--accent); font-size: 10px;
  letter-spacing: 0.16em; text-transform: uppercase;
}
#boot .boot-link {
  background: none; border: none;
  color: var(--dim); font-family: inherit;
  font-size: 10px; letter-spacing: 0.12em;
  cursor: pointer; text-decoration: underline;
}
#boot .boot-link:hover { color: var(--accent); }

#boot .hint {
  margin-top: 28px;
  color: var(--dim); font-size: 10px;
  line-height: 1.9; text-align: center;
  letter-spacing: 0.08em; max-width: 540px;
}
#boot .hint .kb-grp {
  color: var(--accent); font-weight: 700;
  font-size: 9px; letter-spacing: 0.2em;
  margin-right: 7px;
}
/* Desktop: aligned two-column key -> action grid */
#boot .hint .kb-cols { display: flex; justify-content: center; gap: 46px; margin-top: 18px; text-align: left; }
#boot .hint .kb-col { display: flex; flex-direction: column; gap: 6px; }
#boot .hint .kb-head {
  color: var(--accent); font-weight: 700; font-size: 9px;
  letter-spacing: 0.2em; margin-bottom: 9px;
}
#boot .hint .kb-row { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; }
#boot .hint .kb-key { display: inline-flex; align-items: center; gap: 1px; }
#boot .hint kbd {
  display: inline-block;
  border: 1px solid var(--border);
  padding: 1px 5px;
  color: var(--ink); font-family: inherit;
  font-size: 10px; margin: 0 1px;
  background: rgba(125, 249, 255, 0.04);
}

#scanlines {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(125, 249, 255, 0.015) 2px,
    rgba(125, 249, 255, 0.015) 3px
  );
  mix-blend-mode: screen;
}
#vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 49;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
}

/* Boost vignette — tightens the edges when SHIFT is held. Opacity driven
   from JS each frame so it eases in/out with the boost input. */
#boost-vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 51;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,0.85) 100%);
  opacity: 0;
  transition: opacity 0.18s ease-out;
}

/* Heat vignette — warm orange glow that builds as the ship gets close to
   the sun. Opacity driven from JS based on distance. Subtle pulse for life. */
#heat-vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 52;
  background: radial-gradient(ellipse at center, transparent 25%, rgba(255, 90, 20, 0.7) 95%);
  opacity: 0;
  mix-blend-mode: screen;
  animation: heat-pulse 1.6s ease-in-out infinite;
}
@keyframes heat-pulse {
  0%, 100% { filter: brightness(0.9); }
  50%      { filter: brightness(1.15); }
}

/* Touch */
#touch-ui {
  display: none; position: fixed; inset: 0;
  z-index: 20; pointer-events: none;
}
@media (hover: none) and (pointer: coarse) {
  #touch-ui { display: block; }
  body.not-started #touch-ui { display: none; }
  body.modal-open #touch-ui { display: none; }
}

.joystick {
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: radial-gradient(circle at center, rgba(125, 249, 255, 0.05), rgba(125, 249, 255, 0.02));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto; touch-action: none;
}
.joystick::before {
  content: ''; position: absolute;
  inset: 30%;
  border: 1px dashed rgba(125, 249, 255, 0.15);
  border-radius: 50%;
}
.joystick-knob {
  position: absolute; top: 50%; left: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(125, 249, 255, 0.6), rgba(125, 249, 255, 0.2));
  border: 1px solid var(--accent);
  box-shadow: 0 0 20px rgba(125, 249, 255, 0.4);
  pointer-events: none;
  transition: transform 0.05s linear;
}
.joystick.active .joystick-knob { box-shadow: 0 0 30px rgba(125, 249, 255, 0.8); }
.joystick-label {
  position: absolute; bottom: -22px;
  left: 0; right: 0; text-align: center;
  font-size: 9px; letter-spacing: 0.2em;
  color: var(--dim); text-transform: uppercase;
}
#joy-left  { bottom: calc(40px + var(--safe-b)); left: calc(30px + var(--safe-l)); }
#joy-right { bottom: calc(40px + var(--safe-b)); right: calc(30px + var(--safe-r)); }

.touch-btn {
  position: absolute;
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.6);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  pointer-events: auto; cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: all 0.1s;
}
.touch-btn:active {
  background: var(--accent); color: #000;
  border-color: var(--accent);
  transform: scale(0.95);
}
.touch-btn.primary {
  border-color: var(--gold); color: var(--gold);
  font-size: 18px;
}
.touch-btn.primary:active { background: var(--gold); color: #000; }
#btn-boost  { bottom: calc(200px + var(--safe-b)); left: calc(40px + var(--safe-l)); }
#btn-brake  { bottom: calc(200px + var(--safe-b)); right: calc(40px + var(--safe-r)); }
#btn-interact {
  top: 50%; right: calc(20px + var(--safe-r));
  margin-top: -35px;
  display: none;
  width: 80px; height: 80px;
}
#btn-interact.visible { display: block; }

#btn-emote, #btn-map {
  display: none;
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.6);
  color: var(--accent);
  font-size: 22px;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#btn-emote { top: calc(220px + var(--safe-t)); left: calc(20px + var(--safe-l)); }
#btn-map   { top: calc(140px + var(--safe-t)); left: calc(20px + var(--safe-l)); }
@media (hover: none) and (pointer: coarse) {
  body:not(.not-started):not(.modal-open) #btn-emote,
  body:not(.not-started):not(.modal-open) #btn-map { display: block; }
  body.emote-open #btn-interact { display: none !important; }
}

/* System map (was galaxy map) */
#system-map {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 90;
  display: none;
  align-items: center; justify-content: center;
  cursor: default;
}
#system-map.visible { display: flex; }
#system-map-canvas { display: block; cursor: pointer; touch-action: none; }
#system-map-overlay {
  position: absolute; top: 30px; left: 50%;
  transform: translateX(-50%);
  text-align: center; color: var(--ink);
  pointer-events: none;
}
#system-map-overlay h2 {
  font-family: 'Michroma', monospace;
  font-size: 18px; letter-spacing: 0.3em;
  margin-bottom: 4px;
}
#system-map-overlay .sub {
  font-size: 10px; letter-spacing: 0.2em;
  color: var(--dim); text-transform: uppercase;
}
#system-map-close {
  position: absolute; top: 24px; right: 28px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 14px;
  font-family: inherit; font-size: 10px;
  letter-spacing: 0.2em; cursor: pointer;
  pointer-events: auto;
}
#system-map-close:hover { background: var(--accent); color: #000; border-color: var(--accent); }
#system-map-info {
  position: absolute; bottom: 30px;
  left: 50%; transform: translateX(-50%);
  color: var(--ink); text-align: center;
  font-size: 11px; letter-spacing: 0.15em;
  pointer-events: none; min-height: 60px;
}
#system-map-info .sys-name {
  font-family: 'Michroma', monospace;
  font-size: 16px; letter-spacing: 0.3em;
  margin-bottom: 4px; color: var(--accent);
}
#system-map-info .sys-meta {
  font-size: 9px; letter-spacing: 0.2em;
  color: var(--dim); text-transform: uppercase;
}
#system-map-info .sys-pitch {
  margin-top: 6px; font-size: 11px; line-height: 1.4;
  color: var(--ink); max-width: 360px;
  margin-left: auto; margin-right: auto;
}
#system-map-info .warp-btn {
  margin-top: 14px;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 10px 24px;
  font-family: inherit; font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  cursor: pointer; pointer-events: auto;
  transition: all 0.15s;
}
#system-map-info .warp-btn:hover, #system-map-info .warp-btn:active {
  background: var(--gold); color: #000;
  box-shadow: 0 0 30px var(--gold);
}
#system-map-info .warp-btn.disabled {
  border-color: var(--dim); color: var(--dim);
  cursor: default; pointer-events: none;
}

/* Category filter / legend chips along the top of the system map. */
#system-map-categories {
  position: absolute;
  top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 3;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  max-width: 80vw;
  pointer-events: auto;
}
.sysmap-cat-chip {
  --chip: #7df9ff;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(10, 14, 28, 0.72);
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.sysmap-cat-chip:hover { color: var(--ink); border-color: var(--chip); }
.sysmap-cat-chip.active {
  color: #04060d; background: var(--chip); border-color: var(--chip);
}
.sysmap-cat-chip .chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--chip);
  box-shadow: 0 0 6px var(--chip);
}
.sysmap-cat-chip.active .chip-dot { background: #04060d; box-shadow: none; }
.sysmap-cat-chip .chip-count {
  opacity: 0.65; font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  #system-map-categories { display: none; }
}

/* Side panels flanking the system map. Discovery (trending / recent / log)
   sits on the left in #system-map-intel; the rankings (top founders / pirate
   hunters) mirror it on the right in #system-map-leaderboards. Both share the
   .intel-panel layout + section styling. */
.intel-panel {
  position: absolute;
  top: 90px;
  width: 240px;
  display: flex; flex-direction: column;
  gap: 18px;
  pointer-events: auto;
  color: var(--ink);
}
#system-map-intel { left: 28px; }
#system-map-leaderboards { right: 28px; }
.intel-panel .intel-section {
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 10px 12px;
  position: relative;
}
.intel-panel .intel-section::before {
  content: ''; position: absolute;
  top: -1px; left: -1px;
  width: 14px; height: 14px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
}
.intel-panel .intel-title {
  font-family: 'Michroma', monospace;
  font-size: 10px; letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex; align-items: baseline; gap: 8px;
}
.intel-panel .intel-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px; color: var(--dim);
  letter-spacing: 0.12em;
}
.intel-panel .intel-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(125, 249, 255, 0.06);
  cursor: pointer;
  transition: color 0.12s;
}
.intel-panel .intel-row:last-child { border-bottom: none; }
.intel-panel .intel-row:hover .intel-name { color: var(--gold); }
.intel-panel .intel-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
/* Ranking rows (founders / pirate hunters) — not navigable, rank in the
   dot's slot. */
.intel-panel .intel-rank-row { cursor: default; }
.intel-panel .intel-rank-row:hover .intel-name { color: var(--ink); }
.intel-panel .intel-rank {
  flex-shrink: 0;
  width: 14px; text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--accent);
  letter-spacing: 0;
}
.intel-panel .intel-name {
  font-size: 11px; color: var(--ink);
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.intel-panel .intel-meta {
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.intel-panel .intel-loading,
.intel-panel .intel-empty {
  font-size: 10px; color: var(--dim);
  letter-spacing: 0.1em;
  padding: 6px 0;
}

@media (max-width: 900px) {
  .intel-panel { display: none; }
}

/* SaaS Directory — full-screen browsable list/grid of claimed planets. */
#directory {
  position: fixed; inset: 0;
  background: rgba(2, 4, 10, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 95;
  display: none;
  flex-direction: column;
  cursor: default;
  padding: calc(24px + var(--safe-t)) calc(28px + var(--safe-r)) 0 calc(28px + var(--safe-l));
}
#directory.visible { display: flex; }
#directory .dir-header, #founder-panel .dir-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
#directory .dir-header h2, #founder-panel .dir-header h2 {
  font-family: 'Michroma', monospace;
  font-size: 18px; letter-spacing: 0.28em;
  color: var(--ink);
}
#directory .dir-count, #founder-panel .dir-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.15em;
  color: var(--dim); margin-left: 12px;
}
.founder-head-actions { display: flex; align-items: center; gap: 8px; }
#directory-close, #founder-close, .founder-head-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--ink); padding: 8px 14px;
  font-family: inherit; font-size: 10px; letter-spacing: 0.2em;
  cursor: pointer;
}
#directory-close:hover, #founder-close:hover, .founder-head-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }

/* Founder dashboard — mirrors the directory overlay; lists the signed-in
   founder's own planets as cards. */
#founder-panel {
  position: fixed; inset: 0;
  background: rgba(2, 4, 10, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 95;
  display: none;
  flex-direction: column;
  cursor: default;
  padding: calc(24px + var(--safe-t)) calc(28px + var(--safe-r)) 0 calc(28px + var(--safe-l));
}
#founder-panel.visible { display: flex; }
#founder-body {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding-bottom: 24px;
  align-content: start;
}
.founder-empty {
  color: var(--dim); font-size: 12px; letter-spacing: 0.06em;
  line-height: 1.7; padding: 20px 4px; grid-column: 1 / -1;
}
.founder-card {
  border: 1px solid var(--border);
  background: rgba(10, 14, 28, 0.6);
  padding: 14px 16px;
  display: flex; justify-content: space-between; gap: 12px;
}
.founder-card .fc-name {
  font-family: 'Michroma', monospace;
  font-size: 14px; letter-spacing: 0.06em; color: var(--ink);
  margin-bottom: 6px;
}
.founder-card .fc-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
}
.founder-card .fc-tier  { color: var(--accent); }
.founder-card .fc-score { color: var(--gold); }
.founder-card .fc-cat   { color: var(--dim); }
.founder-card .fc-pitch {
  margin-top: 8px; font-size: 11px; line-height: 1.5; color: var(--dim);
}
.founder-card .fc-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.founder-card .fc-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--ink); padding: 6px 12px;
  font-family: inherit; font-size: 9px; letter-spacing: 0.16em;
  cursor: pointer; transition: all 0.15s;
}
.founder-card .fc-btn:hover { border-color: var(--accent); color: var(--accent); }

/* HUD account line (top-left): opens the dashboard / starts sign-in. */
.account-line { margin-top: 6px; font-size: 10px; letter-spacing: 0.1em; }
.account-line .account-name {
  color: var(--accent); cursor: pointer;
}
.account-line .account-name:hover { text-shadow: 0 0 8px var(--accent); }
.account-line .account-signin {
  color: var(--dim); cursor: pointer; text-decoration: underline;
}
.account-line .account-signin:hover { color: var(--accent); }
.dir-controls { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
#dir-search {
  flex: 1; min-width: 200px;
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 12px;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  outline: none;
}
#dir-search:focus { border-color: var(--accent); }
#dir-sort {
  background: rgba(125, 249, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 9px 12px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  outline: none; cursor: pointer; -webkit-appearance: none; appearance: none;
}
#dir-sort option { background: #0a0e1c; }
#dir-categories {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 16px;
}
.dir-chip {
  --chip: #7df9ff;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(10, 14, 28, 0.72);
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.dir-chip:hover { color: var(--ink); border-color: var(--chip); }
.dir-chip.active { color: #04060d; background: var(--chip); border-color: var(--chip); }
.dir-chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip); box-shadow: 0 0 6px var(--chip); }
.dir-chip.active .chip-dot { background: #04060d; box-shadow: none; }
.dir-chip .chip-count { opacity: 0.65; font-variant-numeric: tabular-nums; }

#dir-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  padding-bottom: 24px;
  align-content: start;
}
.dir-empty {
  grid-column: 1 / -1;
  color: var(--dim); font-size: 13px; text-align: center;
  padding: 60px 20px;
}
.dir-card {
  --cat: #ffcc55;
  display: flex; gap: 12px; text-align: left;
  background: rgba(10, 14, 28, 0.6);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat);
  padding: 12px;
  cursor: pointer; font-family: inherit;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.dir-card:hover { background: rgba(125, 249, 255, 0.06); transform: translateY(-1px); }
.dir-logo {
  flex: 0 0 52px; width: 52px; height: 52px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.dir-logo img { width: 100%; height: 100%; object-fit: contain; }
.dir-logo.mono {
  font-family: 'Michroma', monospace;
  font-size: 18px; letter-spacing: 0.04em;
  color: #04060d; background: var(--cat);
}
.dir-body { flex: 1; min-width: 0; }
.dir-name {
  font-family: 'Michroma', monospace;
  font-size: 13px; letter-spacing: 0.06em;
  color: var(--ink); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dir-meta { display: flex; gap: 8px; margin-bottom: 5px; }
.dir-cat {
  font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--cat); border: 1px solid currentColor; padding: 1px 6px;
}
.dir-tier {
  font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim);
  display: inline-flex; align-items: center;
}
.dir-pitch {
  font-size: 11px; line-height: 1.4; color: var(--ink);
  margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dir-pitch em { color: var(--dim); }
.dir-owner {
  font-size: 9px; letter-spacing: 0.08em; color: var(--dim);
  text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: center;
}
.dir-owner .dir-score {
  color: var(--accent); font-variant-numeric: tabular-nums;
}

/* Warp overlay */
#warp-overlay {
  position: fixed; inset: 0;
  z-index: 150; pointer-events: none;
  display: none; background: black; overflow: hidden;
}
#warp-overlay.visible { display: block; }
#warp-overlay .warp-msg {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Michroma', monospace;
  font-size: 18px; letter-spacing: 0.3em;
  color: var(--accent); text-align: center;
  text-shadow: 0 0 20px var(--accent);
  opacity: 0;
  animation: warp-msg-pulse 1.5s ease-out;
}
@keyframes warp-msg-pulse {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}
#warp-overlay .warp-msg .sub {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.2em;
  color: var(--ink); margin-top: 8px;
}

/* Emote wheel */
#emote-wheel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  width: 280px; height: 280px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-out, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#emote-wheel.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.emote-slot {
  position: absolute;
  top: 50%; left: 50%;
  width: 60px; height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: rgba(10, 14, 28, 0.85);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; cursor: pointer;
  transition: all 0.1s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}
.emote-slot:hover, .emote-slot.hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.2);
  box-shadow: 0 0 30px var(--accent);
}
#emote-wheel-center {
  position: absolute;
  top: 50%; left: 50%;
  width: 70px; height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 50%;
  background: rgba(125, 249, 255, 0.08);
  border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.15em; text-transform: uppercase;
  pointer-events: none;
}

/* Starfox-style dialogue stack — anchored at the bottom-left; the bottom
   edge is fixed so the stack grows UPWARD as new messages arrive (newest at
   the bottom). Each message slides in from the left. Colour is set inline
   per-message (the sender's colour) and drives avatar/name/borders via
   currentColor. */
#dialogue-stack {
  position: fixed;
  left: calc(28px + var(--safe-l));
  bottom: calc(90px + var(--safe-b));
  z-index: 70;
  width: 380px; max-width: 70vw;
  display: flex; flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
body.hud-hidden #dialogue-stack { display: none; }
.dialogue-msg {
  display: flex;
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.25s ease-out,
              transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.dialogue-msg.visible { opacity: 1; transform: translateX(0); }
.dialogue-msg.leaving { opacity: 0; transform: translateX(-20px); }
.dialogue-msg .dialogue-avatar {
  flex: 0 0 56px;
  width: 56px; height: 56px;
  background: rgba(5, 10, 22, 0.92);
  border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  padding: 9px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.5);
}
.dialogue-msg .dialogue-body {
  flex: 1; min-width: 0;
  background: rgba(5, 10, 22, 0.92);
  border: 2px solid currentColor;
  border-left: none;
  padding: 7px 12px 9px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.5);
}
.dialogue-msg .dialogue-name {
  font-family: 'Michroma', monospace;
  font-size: 10px; letter-spacing: 0.14em;
  color: currentColor;
  text-transform: uppercase;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dialogue-msg .dialogue-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.45;
  color: var(--ink);
  letter-spacing: 0.02em;
  min-height: 1.45em;
  word-break: break-word;
}
/* Blinking caret while typewriting. */
.dialogue-msg.typing .dialogue-text::after {
  content: '▌';
  color: currentColor;
  animation: dlg-caret 0.7s steps(1) infinite;
}
@keyframes dlg-caret { 50% { opacity: 0; } }

/* Chat input bar — slides up from the bottom centre when composing. */
#chat-input-bar {
  position: fixed;
  left: 50%; bottom: calc(40px + var(--safe-b));
  transform: translate(-50%, 30px);
  z-index: 71;
  width: 520px; max-width: 86vw;
  display: none; align-items: center; gap: 10px;
  background: rgba(5, 10, 22, 0.9);
  border: 1px solid var(--accent);
  padding: 8px 12px;
  box-shadow: 0 0 30px rgba(125, 249, 255, 0.18);
  opacity: 0;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
#chat-input-bar.visible { display: flex; opacity: 1; transform: translate(-50%, 0); }
#chat-input-bar .chat-input-label {
  font-family: 'Michroma', monospace;
  font-size: 10px; letter-spacing: 0.18em;
  color: var(--accent); flex: 0 0 auto;
}
#chat-input-bar input {
  flex: 1; min-width: 0;
  background: transparent;
  border: none; outline: none;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; letter-spacing: 0.02em;
}
#chat-input-bar .chat-input-hint {
  flex: 0 0 auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px; letter-spacing: 0.1em;
  color: var(--dim); text-transform: uppercase;
}
@media (hover: none) and (pointer: coarse) {
  #chat-input-bar .chat-input-hint { display: none; }
}

/* Pilot tags */
.pilot-tag {
  position: fixed; pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -100%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  white-space: nowrap;
  transition: opacity 0.2s;
  text-align: center;
}
.pilot-tag.distant { opacity: 0.4; font-size: 9px; }
.pilot-tag .name {
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Off-screen direction marker for remote pilots. Colour is inherited from
   the `color` style on the element; the SVG triangle uses currentColor. */
.pilot-direction {
  position: fixed; pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
  transition: opacity 0.15s;
}
.pilot-direction svg { display: block; }

.emote-bubble {
  position: fixed; pointer-events: none;
  z-index: 6;
  transform: translate(-50%, -100%);
  font-size: 32px;
  text-align: center;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.8));
  animation: emote-pop 3s ease-out forwards;
}
@keyframes emote-pop {
  0%   { opacity: 0; transform: translate(-50%, -80%) scale(0.5); }
  10%  { opacity: 1; transform: translate(-50%, -120%) scale(1.2); }
  20%  { transform: translate(-50%, -110%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.9); }
}
