:root {
  --space: #0e1322;
  --panel: rgba(18, 24, 40, .82);
  --panel-solid: #151c2e;
  --panel-2: rgba(255, 255, 255, .05);
  --line: rgba(255, 255, 255, .09);
  --ink: #edf0f6;
  --muted: #8a94aa;
  --accent: #ff8a4c;       /* spacesuit orange */
  --accent-ink: #1b1209;
  --tech: #4fd1c5;         /* belts, drones, readouts */
  --warn: #ff6b6b;
  --alien: #7dffb0;
  --r: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--space);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button { touch-action: manipulation; }
body.building #game { cursor: crosshair; }

.hidden { display: none !important; }

/* Dark visor glass, with a thin bright edge along the top. */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top-color: rgba(255, 255, 255, .16);
  border-radius: var(--r);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

/* ---------- left HUD ---------- */
.hud-left {
  position: fixed; top: 16px; left: 16px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px; width: 270px;
}
.hud-main { padding: 14px 16px 12px; }
.credits { display: flex; align-items: baseline; gap: 8px; }
.mb-icon { color: var(--accent); font-size: 16px; transform: translateY(-3px); }
#hud-credits { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .1em; }

.bag { margin-top: 10px; }
.bag-head {
  display: flex; justify-content: space-between;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600;
}
#hud-bag-text { color: var(--ink); font-variant-numeric: tabular-nums; }
.bagbar {
  position: relative; height: 12px; margin-top: 6px;
  background: rgba(255, 255, 255, .07); border-radius: 3px; overflow: hidden;
}
.bagbar .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: var(--tech); transition: width .15s linear, background .3s;
}
.bagbar .fill.full { background: var(--accent); animation: blink 1s infinite; }
/* Segment cut-outs, like an oxygen gauge. */
.bagbar::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 10px, var(--panel-solid) 10px 12px);
}
@keyframes blink { 50% { opacity: .55; } }

.mini-stats {
  display: flex; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.mini-stats b { color: var(--ink); font-weight: 700; margin-left: 3px; }

.mission {
  padding: 10px 14px; text-align: left; font-size: 14px; font-weight: 500;
  display: flex; flex-direction: column; gap: 3px;
}
.mission .count { font-size: 10px; letter-spacing: .16em; color: var(--accent); font-weight: 700; text-transform: uppercase; }
.mission.done { animation: flash .6s ease; }
@keyframes flash { 0% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 138, 76, .35); } 100% { } }

.broom-chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  font-size: 13px; font-weight: 600; text-align: left;
}
.broom-chip #broom-state { flex: 1; }
.broom-chip.up { border-color: rgba(79, 209, 197, .5); color: var(--tech); }
.broom-chip.up .b-ico { transform: rotate(-35deg); }
.b-ico { display: inline-block; transition: transform .2s; }

/* ---------- right HUD ---------- */
.hud-right {
  position: fixed; top: 16px; right: 16px; z-index: 5;
  display: flex; gap: 8px; align-items: stretch;
}
.sector-chip {
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
}
.sector-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd27a; box-shadow: 0 0 8px #ffd27a; }
.sector-chip.dark .dot { background: #7f93ff; box-shadow: 0 0 8px #7f93ff; }
.icon-btns { display: flex; padding: 4px; gap: 2px; }
.icon-btns button {
  border: 0; background: transparent; width: 34px; height: 30px; border-radius: 8px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.icon-btns button:hover, .icon-btns button.on { background: var(--panel-2); color: var(--ink); }

/* ---------- action button (drive / park / cancel) ---------- */
.action-btn {
  position: fixed; right: 182px; bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  font-size: 15px; font-weight: 700; color: var(--accent-ink);
  background: var(--accent); border-color: rgba(255, 255, 255, .25);
}
.action-btn .key { color: rgba(27, 18, 9, .6); border-color: rgba(27, 18, 9, .25); }

/* Touch screens: no keyboard hints. */
body.touch .key, body.touch .t-key { display: none; }
body.touch .tool { grid-template-columns: 1fr; }

/* ---------- station panel ---------- */
.station-panel {
  position: fixed; right: 16px; top: 64px; width: 330px; z-index: 6; padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 200px); overflow-y: auto;
}
.sp-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sp-head h3 { margin: 2px 0 0; font-size: 17px; font-weight: 700; }
.station-panel .stats dd.ok { color: var(--tech); }
.station-panel .stats dd.warn { color: #ffb37a; }
.sp-mods { display: flex; flex-direction: column; gap: 8px; }
.sp-mod {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center;
  padding: 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
}
.sp-mod img { width: 48px; height: 48px; object-fit: contain; }
.sp-mod b { display: block; font-size: 13px; }
.sp-mod span { display: block; font-size: 11px; color: var(--muted); line-height: 1.35; }
.sp-mod button {
  border: 0; border-radius: 8px; padding: 8px 10px; font-weight: 700; font-size: 12px;
  background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
.sp-mod button:disabled { background: rgba(255, 255, 255, .07); color: var(--muted); cursor: not-allowed; }
.sp-full { margin: 0; font-size: 12px; color: var(--tech); }
.lab-parts { font-size: 13px; font-weight: 600; color: var(--alien); }
.lab-list { display: flex; flex-direction: column; gap: 8px; }
.lab-item {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
}
.lab-item b { display: block; font-size: 13px; }
.lab-item span { display: block; font-size: 11px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.lab-item .tier-bar { margin-top: 6px; }
.lab-item.done { opacity: .7; }
.lab-item button {
  border: 0; border-radius: 8px; padding: 8px 10px; font-weight: 700; font-size: 12px; white-space: nowrap;
  background: var(--alien); color: #0b1a12;
}
.lab-item button:disabled { background: rgba(255, 255, 255, .07); color: var(--muted); cursor: not-allowed; }
.lab-done { font-size: 12px; font-weight: 700; color: var(--alien); }

/* ---------- account ---------- */
.account-chip {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.account-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.account-chip.signed .dot { background: var(--tech); box-shadow: 0 0 8px var(--tech); }
.account-chip.error .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.account-chip:hover { border-color: rgba(79, 209, 197, .5); }
.auth-card label { display: block; margin-top: 12px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.auth-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink);
  font: 500 16px "Space Grotesk", sans-serif; outline: none;
}
.auth-card input:focus { border-color: var(--tech); }
.auth-tabs { display: flex; gap: 4px; margin-top: 14px; padding: 3px; background: var(--panel-2); border-radius: 9px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.auth-tabs button.on { background: rgba(255, 255, 255, .09); color: var(--ink); }
.auth-error { min-height: 18px; margin-top: 10px; font-size: 13px; color: var(--warn); }
.auth-note { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 4px 0 16px; }
.auth-actions { display: flex; justify-content: flex-end; gap: 8px; }
.auth-actions .primary { float: none; }
.auth-actions .ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 9px; padding: 11px 16px; font-weight: 600; }
.auth-actions button:disabled { opacity: .5; cursor: wait; }
.auth-newgame {
  display: block; margin: 14px auto 0; border: 0; background: none; padding: 4px 8px;
  font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.auth-newgame:hover { color: var(--ink); }
.auth-newgame.confirm { color: var(--warn); text-decoration: none; }

/* ---------- toasts / prompt ---------- */
#toasts {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 6; pointer-events: none;
}
.toast {
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  border-radius: 8px; padding: 8px 14px 8px 12px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in .25s ease;
}
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.alien { color: var(--alien); border-color: rgba(125, 255, 176, .3); }
.toast.alien::before { background: var(--alien); box-shadow: 0 0 8px var(--alien); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.prompt {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 138, 76, .95); color: var(--accent-ink); border-radius: 6px;
  padding: 7px 14px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; z-index: 4;
  pointer-events: none;
}

/* ---------- bottom controls ---------- */
.dock-btn {
  position: fixed; left: 16px; bottom: 16px; z-index: 4;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-size: 15px; font-weight: 600;
}
.dock-btn:hover { border-color: rgba(255, 138, 76, .5); }
.dock-btn .ico { color: var(--accent); font-size: 18px; }
.key, .t-key {
  font-size: 10px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

.buildbar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; gap: 4px; padding: 5px;
}
.tool {
  border: 1px solid transparent; background: transparent; border-radius: 9px;
  padding: 7px 12px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center;
  min-width: 140px; text-align: left;
}
.tool .t-key { grid-row: span 2; }
.tool:hover { background: var(--panel-2); }
.tool.on { background: rgba(79, 209, 197, .14); border-color: rgba(79, 209, 197, .5); }
.tool:disabled { opacity: .35; cursor: not-allowed; }
.t-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.t-cost { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Round radar; the top-down map inside is turned to match the isometric view. */
.radar {
  position: fixed; right: 16px; bottom: 16px; width: 150px; height: 150px; z-index: 4;
  border-radius: 50%; overflow: hidden; background: #0b1020;
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
#minimap {
  position: absolute; left: 50%; top: 50%; width: 140px; height: 140px;
  transform: translate(-50%, -50%) scaleY(.5) rotate(45deg) scale(1.35);
  image-rendering: pixelated; opacity: .9;
}
.radar-ring {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle, transparent 0 33%, rgba(79, 209, 197, .18) 33.5% 34%, transparent 34.5% 66%, rgba(79, 209, 197, .18) 66.5% 67%, transparent 67.5%),
    conic-gradient(from 0deg, rgba(79, 209, 197, .22), transparent 18%);
  animation: sweep 4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.eyebrow { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.modal h2 { margin: 2px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }

/* ---------- tier progress (HUD + store) ---------- */
.tier-badge {
  display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 6px;
  border-radius: 5px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
}
.tier-badge.locked { background: rgba(255, 255, 255, .1); color: var(--muted); }
.tier-bar { position: relative; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.tier-bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--accent), #ffd27a); transition: width .3s; }
.tier-mini { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.tier-mini .tier-bar { flex: 1; }
.tier-text { margin-top: 5px; font-size: 11px; color: var(--muted); }
.tier-text b { color: var(--ink); font-weight: 600; }

/* ---------- store ---------- */
.store {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center;
  background: rgba(5, 8, 16, .55); backdrop-filter: blur(3px);
}
.store-card {
  width: min(1060px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel-solid); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.store-head { display: flex; align-items: center; gap: 22px; padding: 18px 22px 12px; }
/* Close button pinned to the card's top-right corner, whatever the header holds. */
.store-card { position: relative; }
.store-head { padding-right: 64px; }
#store-close { position: absolute; top: 14px; right: 14px; }
.store-title h2 { margin: 2px 0 0; font-size: 24px; font-weight: 700; }
.tier-box { flex: 1; max-width: 360px; margin-left: auto; }
.tier-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.tier-sub { font-size: 11px; color: var(--muted); margin-top: 5px; }
.store-credits { display: flex; align-items: baseline; gap: 6px; }
.store-credits #store-credits { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.close { border: 0; background: var(--panel-2); width: 32px; height: 32px; border-radius: 8px; font-size: 18px; line-height: 1; flex: none; }

.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.store-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 330px; }
.grid {
  overflow-y: auto; padding: 16px 18px; display: grid; gap: 10px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.item {
  position: relative; border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px;
  padding: 10px 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.item:hover { border-color: rgba(255, 255, 255, .22); }
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.item img {
  width: 100%; aspect-ratio: 1.35; object-fit: contain; border-radius: 8px;
  background: radial-gradient(circle at 50% 60%, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02) 70%);
}
.item.locked img { filter: grayscale(1) brightness(.55); }
.item .i-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.item .i-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.item .i-meta .ok { color: var(--tech); font-weight: 600; }
.item .i-meta .price { color: var(--ink); font-weight: 600; }
.item .i-meta .price.short { color: var(--warn); }
.item .lock { position: absolute; top: 14px; right: 14px; font-size: 13px; }
.item .pips { display: flex; gap: 3px; }
.pip { width: 8px; height: 8px; border-radius: 2px; background: rgba(255, 255, 255, .12); transform: rotate(45deg) scale(.75); }
.pip.on { background: var(--accent); }

.preview { border-left: 1px solid var(--line); padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.preview .big {
  width: 100%; aspect-ratio: 1.3; object-fit: contain; border-radius: 12px;
  background: radial-gradient(circle at 50% 62%, rgba(255, 138, 76, .12), rgba(255, 255, 255, .02) 70%);
}
.preview.locked .big { filter: grayscale(1) brightness(.6); }
.preview h3 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.preview .desc { margin: 0; font-size: 13px; color: #c9cfdb; line-height: 1.5; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 12px; }
.stats dt { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 600; align-self: center; }
.stats dd { margin: 0; font-weight: 600; }
.stats .up { color: var(--tech); }
.actions { display: flex; gap: 8px; margin-top: auto; }
.actions button {
  flex: 1; border: 0; border-radius: 10px; padding: 12px 14px; font-weight: 700; font-size: 14px;
  background: var(--accent); color: var(--accent-ink);
}
.actions button.ghost { background: transparent; color: var(--tech); border: 1px solid rgba(79, 209, 197, .5); }
.actions button:disabled { background: rgba(255, 255, 255, .07); color: var(--muted); border-color: transparent; cursor: not-allowed; }
.why { font-size: 12px; color: var(--muted); line-height: 1.4; }
.why b { color: var(--accent); }
.dock-note { margin: 0; padding: 8px 22px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.dock-note.ok { color: var(--tech); font-weight: 600; }
.dock-note.away { background: rgba(255, 138, 76, .14); color: #ffb37a; font-weight: 600; }

/* ---------- debug console (` key) ---------- */
.debug {
  position: fixed; top: 0; left: 16px; right: 16px; height: min(46vh, 420px); z-index: 10;
  display: flex; flex-direction: column;
  background: rgba(8, 11, 20, .94); border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 12px 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  animation: drop .15s ease-out;
}
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }
.debug-head { display: flex; align-items: center; gap: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.debug-title { color: var(--accent); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.debug-stats { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.debug .close { width: 26px; height: 26px; font-size: 15px; }
.debug-actions { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.debug-actions button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); border-radius: 6px;
  padding: 3px 9px; font: inherit; font-size: 11px;
}
.debug-actions button:hover { border-color: var(--tech); color: var(--tech); }
.debug-log { flex: 1; overflow-y: auto; padding: 8px 12px; }
.debug-log div { white-space: pre-wrap; word-break: break-word; }
.debug-log .cmd { color: var(--ink); }
.debug-log .cmd::before { content: "› "; color: var(--accent); }
.debug-log .ok { color: var(--tech); }
.debug-log .err { color: var(--warn); }
.debug-log .info { color: var(--muted); }
.debug-input { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.debug-input span { color: var(--accent); font-weight: 700; }
.debug-input input { flex: 1; background: transparent; border: 0; outline: 0; color: var(--ink); font: inherit; font-size: 13px; }
.debug-overlay {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: none;
  background: rgba(8, 11, 20, .8); color: var(--tech); border-radius: 6px; padding: 4px 10px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(5, 8, 16, .55); z-index: 9;
  display: grid; place-items: center; backdrop-filter: blur(3px);
}
.modal-card {
  width: min(460px, calc(100vw - 32px)); background: var(--panel-solid); border: 1px solid var(--line);
  border-top: 3px solid var(--accent); border-radius: 14px;
  padding: 24px 26px 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.modal.alien .modal-card { border-top-color: var(--alien); background: #0f1a1c; color: #d6f5e4; }
.modal.alien .eyebrow { color: var(--alien); }
.modal.alien .primary { background: var(--alien); color: #0b1a12; }
#modal-body { font-size: 15px; line-height: 1.55; margin: 12px 0 18px; color: #c9cfdb; }
#modal-body p { margin: 0 0 10px; }
#modal-body a { color: var(--tech); }
#modal-body kbd {
  display: inline-block; min-width: 22px; text-align: center; padding: 1px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--panel-2); color: var(--ink); font: 700 11px "Space Grotesk", sans-serif;
}
.primary {
  border: 0; border-radius: 9px; padding: 11px 18px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 14px; float: right;
}
.modal-card::after { content: ""; display: block; clear: both; }

@media (max-width: 900px) {
  .hud-left { width: 220px; }
  .sector-chip { display: none; }
  .store-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .preview {
    border-left: 0; border-top: 1px solid var(--line); max-height: 300px;
    display: grid; grid-template-columns: 120px 1fr; column-gap: 14px; align-content: start;
  }
  .preview .big { grid-row: span 3; width: 120px; }
  .preview > :not(.big) { grid-column: 2; }
  .tier-box { display: none; }
  .radar { display: none; }
  .tool { min-width: 0; }
  /* Stack the build bar above the upgrades button instead of overlapping it. */
  .buildbar { bottom: 78px; left: 16px; transform: none; }
  .prompt { bottom: 150px; }
}

/* ---------- phones: a compact HUD that keeps the moon visible ---------- */
@media (max-width: 700px), (max-height: 520px) {
  .hud-left {
    top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
    width: 196px; gap: 6px;
  }
  .hud-main { padding: 9px 11px 8px; }
  #hud-credits { font-size: 22px; }
  .bag { margin-top: 6px; }
  .bagbar { height: 9px; }
  .tier-mini { margin-top: 7px; }
  .tier-text { font-size: 10px; }
  .mini-stats { display: none; }
  .mission { padding: 7px 11px; font-size: 12px; }
  .broom-chip { padding: 6px 10px; font-size: 12px; }
  .hud-right {
    top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); gap: 6px;
    flex-direction: column; align-items: flex-end;
  }
  .account-chip { padding: 7px 10px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
  .icon-btns button { width: 30px; height: 28px; }
  .dock-btn {
    left: max(8px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom));
    padding: 10px 14px; font-size: 14px;
  }
  .action-btn { right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); padding: 12px 20px; }
  .buildbar {
    left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px); transform: none;
  }
  .tool { flex: 1; min-width: 0; padding: 6px 8px; }
  .t-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .t-cost { font-size: 10px; }
  .prompt {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 58px); max-width: calc(100vw - 24px);
    white-space: normal; text-align: center; font-size: 11px;
  }
  .buildbar:not(.hidden) ~ .prompt { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 112px); }
  #toasts { top: max(8px, env(safe-area-inset-top)); width: calc(100vw - 24px); }
  .toast { font-size: 12px; }
  .store-card { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .station-panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 54px); max-height: 55vh; }
  .store-head { padding: 12px 14px 8px; gap: 12px; }
  .store-title h2 { font-size: 18px; }
}
/* Phone held sideways: little height, so keep the left column short. */
@media (max-height: 520px) {
  .tier-text, .bag-head { display: none; }
  .bag { margin-top: 4px; }
  .preview { max-height: 46vh; }
}
