/* VOID BASTION — holographic UI.
   Mobile-first. The game canvas fills the viewport and every panel floats over
   it, so the fight stays visible while you shop. */

:root {
  --bg:        #04050b;
  --cyan:      #4df0ff;
  --cyan-dim:  #1b7f8f;
  --magenta:   #ff3b6b;
  --gold:      #ffc94d;
  --violet:    #b06bff;
  --green:     #3ef5a0;
  --text:      #d7ecf5;
  --text-dim:  #7c96a6;
  --panel:     rgba(8, 16, 30, 0.90);
  --panel-solid: #070d1a;
  --line:      rgba(77, 240, 255, 0.22);
  --line-soft: rgba(77, 240, 255, 0.10);
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);
  /* The upgrade panel is permanent furniture, not a popup. Its height is a
     variable because both the panel and the ability row above it depend on it. */
  --panel-h: clamp(184px, 34vh, 330px);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

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

/* Several elements here are toggled with the `hidden` attribute but also carry
   a class that sets `display`. An author `display` rule beats the UA stylesheet's
   `[hidden] { display: none }`, so without this those elements stay visible —
   which once left an empty, opaque #bootError covering the entire game. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#scene, #overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* Dragging the ship must not also scroll or zoom the page. */
#scene { touch-action: none; }
#overlay { pointer-events: none; }

/* Faint CRT scanlines tie the neon together and hide banding in the bloom. */
#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.13) 3px, rgba(0,0,0,0.13) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.3;
}

/* ── top HUD ──────────────────────────────────────────────────── */

#hud {
  /* A framed bar rather than text floating over the playfield. Without an
     edge the readouts read as debug overlay, not as instrumentation. */
  background: linear-gradient(180deg, rgba(6,9,16,.92) 0%, rgba(6,9,16,.66) 68%, rgba(6,9,16,0) 100%);
  border-bottom: 1px solid rgba(90,140,200,.16);
  box-shadow: 0 6px 18px -10px rgba(0,0,0,.9);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: calc(var(--safe-t) + 6px) 9px 7px;
  background: linear-gradient(to bottom, rgba(4,6,14,0.94) 55%, rgba(4,6,14,0));
  pointer-events: none;
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
  letter-spacing: 0.06em;
}
.stat strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--text-dim); font-size: 10px; }
.stat.wave strong { color: var(--cyan); text-shadow: 0 0 12px rgba(77,240,255,0.6); }
.phase-dots {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}
.phase-dots i {
  width: 9px; height: 3px;
  border-radius: 2px;
  background: rgba(140, 170, 190, 0.28);
}
.phase-dots i.done { background: var(--cyan); box-shadow: 0 0 5px var(--cyan); }
.phase-dots i.boss { width: 13px; background: var(--magenta); box-shadow: 0 0 6px var(--magenta); }

.zone {
  display: flex;
  flex-direction: column;
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--violet);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 116px;
}
.stat.coins { margin-left: auto; }
.stat.coins strong { color: var(--gold); text-shadow: 0 0 12px rgba(255,201,77,0.45); }
.stat.cores strong { color: var(--violet); text-shadow: 0 0 12px rgba(176,107,255,0.45); }

.pip { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pip-coin { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.pip-core {
  background: var(--violet);
  box-shadow: 0 0 8px var(--violet);
  border-radius: 2px;
  transform: rotate(45deg);
}

.boss-tag {
  margin-left: 4px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--magenta);
  border-radius: 3px;
  animation: bosspulse 0.9s ease-in-out infinite;
}
@keyframes bosspulse { 50% { opacity: 0.45; } }

.chip {
  pointer-events: auto;
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(10, 24, 40, 0.85);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.chip:active { background: rgba(77, 240, 255, 0.2); }
.chip.off { color: var(--text-dim); border-color: rgba(124,150,166,0.25); }

/* ── abilities ────────────────────────────────────────────────── */

#abilities {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + var(--panel-h) + 10px);
  z-index: 9;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  pointer-events: none;
}
.ability {
  pointer-events: auto;
  position: relative;
  width: 52px; height: 50px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 18, 32, 0.9);
  color: var(--cyan);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ability .ab-glyph { font-size: 20px; line-height: 1; }
.ability .ab-name { font-size: 7.5px; letter-spacing: 0.04em; color: var(--text-dim); }
.ability .ab-cd {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dim);
}
.ability.ready { box-shadow: 0 0 16px rgba(77,240,255,0.35); border-color: var(--cyan); }
.ability.ready:active { transform: scale(0.94); }
.ability.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(255,201,77,0.6); }

/* ── upgrade drawer ───────────────────────────────────────────── */

.drawer {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 12;
  height: calc(var(--panel-h) + var(--safe-b));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.75);
  padding-bottom: var(--safe-b);
}

.tabs { display: flex; gap: 4px; padding: 8px 10px 0; flex: none; }
.tab {
  flex: 1;
  padding: 8px 4px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }

.buy-mode {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 3px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  flex: none;
}
.qty {
  padding: 3px 9px;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.qty.active { color: var(--cyan); border-color: var(--line); background: rgba(77,240,255,0.1); }

.upgrade-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 8px 12px;
  /* Two per row on phones: an upgrade card only needs to say name, level,
     current value and price, and halving the rows means twice as much of the
     tree is reachable without scrolling. */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-content: start;
}

.up {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 8px 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.up-main { min-width: 0; }
.up-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.up-name {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Pip colours mirror js/game/game.js COLORS for each weapon system. */
.w-pip {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: middle;
}
.w-laser   { background: #5ee0f5; box-shadow: 0 0 6px #5ee0f5; }
.w-missile { background: #ffa33d; box-shadow: 0 0 6px #ffa33d; }
.w-flak    { background: #ffcf4d; box-shadow: 0 0 6px #ffcf4d; }
.w-arc     { background: #a98cff; box-shadow: 0 0 6px #a98cff; }
.w-wing    { background: #4ff0ad; box-shadow: 0 0 6px #4ff0ad; }

.up-lv {
  flex: none;
  min-width: 20px;
  padding: 1px 5px;
  font-size: 9.5px;
  font-weight: 700;
  text-align: center;
  color: var(--cyan);
  background: rgba(77, 240, 255, 0.13);
  border-radius: 3px;
}
.up-lv.is-max { color: var(--gold); background: rgba(255, 201, 77, 0.15); }
.up-desc { display: none; font-size: 10px; color: var(--text-dim); }
.up-val {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 11px;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
.up-val > span { overflow: hidden; text-overflow: ellipsis; }
.v-label {
  flex: none;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.85;
}
.v-now   { color: var(--text-dim); }
.v-arrow { color: var(--cyan); opacity: 0.8; flex: none; }
.v-next  { color: var(--green); font-weight: 700; }
.up-sub  { font-size: 9px; color: var(--text-dim); }

/* Mastery line on weapon cards: what the system does now, and what depth buys. */
.up-mastery {
  font-size: 8.5px;
  line-height: 1.3;
  color: var(--text-dim);
  white-space: normal;
}
.up-mastery b {
  color: var(--gold);
  margin-right: 3px;
}
.up-mastery em {
  font-style: normal;
  opacity: 0.65;
}

/* The price doubles as the button face, so affordability is unmistakable. */
.up-buy {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-top: 1px;
  padding: 5px 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
}
.up-cost {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #6a5a3a;
}
.up-qty { font-size: 9px; opacity: 0.75; }

.up.afford { border-color: rgba(77, 240, 255, 0.4); }
.up.afford .up-buy {
  background: linear-gradient(180deg, #6ff6ff, #22c2d8);
  box-shadow: 0 0 12px rgba(77, 240, 255, 0.3);
}
.up.afford .up-cost, .up.afford .up-qty { color: #041018; }
.up.afford:active { transform: scale(0.97); }
.up.poor { opacity: 0.72; }
.up.maxed {
  opacity: 0.55;
  border-color: rgba(255, 201, 77, 0.28);
  cursor: default;
}
.up.maxed .up-buy { background: rgba(255, 255, 255, 0.03); }
.up.maxed .up-cost { color: var(--gold); }

/* ── modals ───────────────────────────────────────────────────── */

.modal-root { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 4, 10, 0.82); backdrop-filter: blur(6px); }
.modal {
  position: relative;
  width: min(480px, calc(100vw - 20px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 18px calc(18px + var(--safe-b));
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(77, 240, 255, 0.14), 0 24px 60px rgba(0,0,0,0.7);
  animation: modalin 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalin { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.modal h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(77,240,255,0.5);
  margin-bottom: 8px;
}
.modal h2.danger { color: var(--magenta); text-shadow: 0 0 18px rgba(255,59,107,0.5); }
.lab-heading {
  font-size: 11px; letter-spacing: 0.16em; color: var(--violet);
  margin: 18px 0 4px;
}
.modal-sub { font-size: 11px; line-height: 1.55; color: var(--text-dim); margin-bottom: 12px; }
.hint { font-size: 10.5px; line-height: 1.5; color: var(--text-dim); margin: 10px 0 4px; }
.c-core { color: var(--violet); }
.c-coin { color: var(--gold); }

.core-banner {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--violet);
  background: rgba(176, 107, 255, 0.1);
  border: 1px solid rgba(176, 107, 255, 0.3);
  border-radius: 7px;
}
.core-banner strong { font-size: 17px; font-variant-numeric: tabular-nums; }

.lab-list {
  /* Same two-up card grid as the upgrade panel. The Lab is the other place the
     player spends most of their time, so it should not read as a different app. */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

/* Lab cards keep the upgrade card's shape and swap cyan for violet, so "this
   is permanent" is legible at a glance without reading a word. */
.lab-list .up.lab {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 9px 7px;
  border-radius: 8px;
}
.lab-list .up.lab .up-desc { display: none; }
/* Research names run longer than upgrade names ("Market Analysis" vs "Rail
   Coil"), so they get a touch less type and a tighter badge to stay unclipped
   in a half-width card. */
.lab-list .up.lab .up-name { font-size: 10.5px; letter-spacing: -0.01em; }
.lab-list .up.lab .up-lv { font-size: 9px; padding: 1px 4px; min-width: 0; }
.lab-list .up.lab .up-lv {
  color: var(--violet);
  background: rgba(176, 107, 255, 0.16);
}
.lab-list .up.lab .up-lv.is-max { color: var(--gold); background: rgba(255, 201, 77, 0.15); }
.lab-list .up.lab .v-arrow { color: var(--violet); }

.lab-list .up.lab .up-buy {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  margin-top: 2px;
  padding: 5px 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}
.lab-list .up.lab .up-cost { font-size: 12px; font-weight: 700; color: #6a5a7a; }
.lab-list .up.lab .up-qty { font-size: 9px; color: #6a5a7a; opacity: 0.9; }

.lab-list .up.lab.afford { border-color: rgba(176, 107, 255, 0.45); }
.lab-list .up.lab.afford .up-buy {
  background: linear-gradient(180deg, #c79cff, #8b4bd8);
  box-shadow: 0 0 12px rgba(176, 107, 255, 0.35);
}
.lab-list .up.lab.afford .up-cost,
.lab-list .up.lab.afford .up-qty { color: #14051f; }
.lab-list .up.lab.afford:active { transform: scale(0.97); }
.lab-list .up.lab.poor { opacity: 0.66; }
.lab-list .up.lab.maxed {
  opacity: 0.55;
  border-color: rgba(255, 201, 77, 0.28);
  cursor: default;
}
.lab-list .up.lab.maxed .up-buy { background: rgba(255, 255, 255, 0.03); }
.lab-list .up.lab.maxed .up-cost { color: var(--gold); }
/* An owned ability has nothing to buy — the OWNED badge already says so, and an
   empty button just invites a tap that does nothing. */
.lab-list .up.ability-card.maxed .up-buy { display: none; }

/* Ability cards carry a glyph and a sentence, so they get the full width. */
.lab-list .up.ability-card { grid-column: 1 / -1; }
.lab-list .up.ability-card .up-val {
  white-space: normal;
  color: var(--text);
  font-size: 10.5px;
}
.ab-mark {
  display: inline-block;
  min-width: 17px;
  color: var(--violet);
  font-size: 12px;
}

.ascend-figure {
  display: flex; align-items: center; justify-content: space-around; gap: 8px;
  padding: 14px 8px;
  margin: 4px 0;
  background: rgba(255,255,255,0.035);
  border-radius: 9px;
}
.ascend-figure > div { text-align: center; }
.ascend-figure span { display: block; font-size: 8.5px; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 4px; }
.ascend-figure strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.ascend-figure .arrow { font-size: 18px; color: var(--text-dim); }

.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  flex: 1;
  padding: 12px 14px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cyan);
}
.btn.primary {
  background: linear-gradient(180deg, #6ff6ff, #22c2d8);
  color: #041018;
  border: none;
  box-shadow: 0 0 22px rgba(77,240,255,0.35);
}
.btn.ghost { color: var(--text-dim); border-color: rgba(124,150,166,0.28); }
.btn.danger-ghost { color: var(--magenta); border-color: rgba(255,59,107,0.35); }
.btn:active { transform: scale(0.98); }
.modal > .btn { margin-top: 12px; width: 100%; }

.menu-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.menu-stats div {
  padding: 8px 10px;
  background: rgba(255,255,255,0.035);
  border-radius: 6px;
}
.menu-stats span { display: block; font-size: 8.5px; letter-spacing: 0.09em; color: var(--text-dim); }
.menu-stats b { font-size: 14px; font-variant-numeric: tabular-nums; }
.menu-actions { display: flex; flex-direction: column; gap: 7px; }
.menu-actions .btn { width: 100%; }

.help-list { padding-left: 16px; display: flex; flex-direction: column; gap: 9px; }
.help-list li { font-size: 11.5px; line-height: 1.55; color: var(--text-dim); }
.help-list b { color: var(--text); }
kbd {
  padding: 1px 4px; font-size: 10px; border-radius: 3px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18);
}

/* ── toasts ───────────────────────────────────────────────────── */

/* Level card: the run's chapter heading. Big, brief, and out of the way. */
.level-card {
  padding: 12px 20px 11px;
  text-align: center;
  color: var(--text);
  background: rgba(6, 14, 26, 0.94);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: 9px;
  box-shadow: 0 0 34px rgba(77, 240, 255, 0.22);
  animation: toastin 0.35s cubic-bezier(0.22,1,0.36,1), toastout 0.5s ease 3.0s forwards;
}
.level-card .lc-lvl {
  font-size: 9px; letter-spacing: 0.24em; color: var(--text-dim);
}
.level-card .lc-name {
  font-size: 16px; font-weight: 700; letter-spacing: 0.14em;
  color: var(--cyan); text-shadow: 0 0 16px rgba(77,240,255,0.5);
  margin: 3px 0 5px;
}
.level-card .lc-boss {
  font-size: 10px; letter-spacing: 0.1em; color: var(--magenta);
}
.level-card .lc-tell { font-size: 9.5px; color: var(--text-dim); margin-top: 3px; }
.level-card .lc-refit {
  display: inline-block; margin-top: 6px; padding: 2px 7px;
  font-size: 8.5px; letter-spacing: 0.12em; color: var(--gold);
  background: rgba(255, 201, 77, 0.12);
  border: 1px solid rgba(255, 201, 77, 0.3); border-radius: 3px;
}

/* ── home screen ──────────────────────────────────────────────── */

.home {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(circle at 50% 22%, rgba(77,240,255,0.10), transparent 58%),
    rgba(3, 6, 13, 0.97);
  backdrop-filter: blur(3px);
}
.home-inner {
  width: min(440px, 100%);
  margin: auto;
  text-align: center;
  animation: modalin 0.3s cubic-bezier(0.22,1,0.36,1);
}
.home-mark {
  font-size: 34px;
  color: var(--cyan);
  text-shadow: 0 0 26px rgba(77,240,255,0.75);
  line-height: 1;
}
.home-title {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--cyan);
  text-shadow: 0 0 26px rgba(77,240,255,0.5);
}
.home-sub {
  margin: 6px 0 16px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.diff-list { display: flex; flex-direction: column; gap: 7px; text-align: left; }
.diff {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid var(--cyan-dim);
  border-radius: 8px;
  cursor: pointer;
}
.diff.sel {
  border-left-color: var(--cyan);
  border-color: rgba(77,240,255,0.45);
  background: rgba(77,240,255,0.09);
  box-shadow: 0 0 20px rgba(77,240,255,0.16);
}
.diff.locked { opacity: 0.45; cursor: not-allowed; border-left-color: rgba(124,150,166,0.3); }
.diff-name {
  font-size: 13px; font-weight: 700; letter-spacing: 0.13em; color: var(--text);
}
.diff.sel .diff-name { color: var(--cyan); }
.diff-blurb { font-size: 9.5px; color: var(--text-dim); margin-top: 2px; }
.diff-meta { font-size: 9.5px; color: var(--green); margin-top: 3px; font-variant-numeric: tabular-nums; }
.diff-req { font-size: 9.5px; color: var(--gold); margin-top: 3px; }
.diff-core {
  text-align: right; white-space: nowrap;
  font-size: 15px; font-weight: 700; color: var(--violet);
  font-variant-numeric: tabular-nums;
}
.diff-core span { display: block; font-size: 8px; letter-spacing: 0.1em; color: var(--text-dim); }
.diff-lock { font-size: 15px; color: var(--text-dim); }

.home-stats {
  display: flex; justify-content: center; gap: 18px;
  margin: 16px 0 12px;
  font-size: 10px; letter-spacing: 0.08em; color: var(--text-dim);
}
.home-stats b { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.home .btn { width: 100%; margin-top: 8px; }

#toasts {
  position: fixed;
  top: calc(var(--safe-t) + 74px);
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
  background: rgba(6, 16, 30, 0.94);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 0 26px rgba(77, 240, 255, 0.28);
  animation: toastin 0.3s cubic-bezier(0.22,1,0.36,1), toastout 0.4s ease 2.1s forwards;
}
.toast.gold { color: var(--gold); border-color: rgba(255,201,77,0.4); box-shadow: 0 0 26px rgba(255,201,77,0.3); }
.toast.violet { color: var(--violet); border-color: rgba(176,107,255,0.4); box-shadow: 0 0 26px rgba(176,107,255,0.3); }
.toast.danger { color: var(--magenta); border-color: rgba(255,59,107,0.4); box-shadow: 0 0 26px rgba(255,59,107,0.3); }
.toast.big { font-size: 15px; padding: 12px 22px; }
@keyframes toastin { from { opacity: 0; transform: translateY(-12px) scale(0.95); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-10px); } }

.load-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  width: min(300px, 62vw);
  z-index: 60;
  pointer-events: none;
  transition: opacity .45s ease;
}
.load-bar.done { opacity: 0; }
.load-bar-label {
  display: flex;
  justify-content: space-between;
  font: 600 9px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .14em;
  color: #6f8bb0;
  margin-bottom: 5px;
}
.load-bar-track {
  height: 2px;
  background: rgba(120, 170, 230, .16);
  border-radius: 2px;
  overflow: hidden;
}
.load-bar-track > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2f7fd0, #4df0ff);
  box-shadow: 0 0 8px rgba(77, 240, 255, .7);
  transition: width .18s linear;
}

.boot-error {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 30px; text-align: center;
  background: var(--bg); color: var(--magenta);
  font-size: 13px; line-height: 1.6;
}

/* ── desktop: drawer becomes a permanent side column ──────────── */

@media (min-width: 860px) and (orientation: landscape) {
  #hud {
  /* A framed bar rather than text floating over the playfield. Without an
     edge the readouts read as debug overlay, not as instrumentation. */
  background: linear-gradient(180deg, rgba(6,9,16,.92) 0%, rgba(6,9,16,.66) 68%, rgba(6,9,16,0) 100%);
  border-bottom: 1px solid rgba(90,140,200,.16);
  box-shadow: 0 6px 18px -10px rgba(0,0,0,.9); padding: 12px 14px 10px; max-width: calc(100% - 350px); }
  #abilities { right: 340px; bottom: 22px; }
  .drawer {
    top: 0; bottom: 0; left: auto;
    width: 330px;
    height: auto;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--line);
    box-shadow: -14px 0 44px rgba(0,0,0,0.6);
    padding-bottom: 0;
  }
  .tabs { padding-top: 14px; }
  /* The right-hand column is only ~330px wide — two cards would be cramped, and
     there is vertical room to spare, so desktop goes back to one wide row each
     with the description shown. */
  #upgradeList {
    grid-template-columns: 1fr;
    padding: 4px 10px 16px;
  }
  #upgradeList .up {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
  }
  #upgradeList .up-desc { display: block; }
  #upgradeList .up-name { white-space: normal; }
  #upgradeList .up-buy { min-width: 74px; margin-top: 0; padding: 6px 8px; }
  .stat strong { font-size: 19px; }
  .bar { height: 15px; }
  .bar span { line-height: 15px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  #scanlines { display: none; }
}
