:root {
  --bg: #05070e;
  /* every panel, popup and the header share one frosted-glass look */
  --panel: rgba(8, 12, 24, 0.72);
  --blur: blur(18px) saturate(1.5);
  --header-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --panel-solid: #0a1020;
  --line: rgba(110, 170, 255, 0.16);
  --line-strong: rgba(110, 200, 255, 0.4);
  --text: #e6f1ff;
  --dim: #7f93b5;
  --faint: #4b5b78;
  --cyan: #3ad8ff;
  --magenta: #ff3da8;
  --lime: #a6ff3d;
  --amber: #ffc94d;
  --run: #3dff9a;
  --starved: #ffc94d;
  --blocked: #ff4d6d;
  --idle: #5b6b88;
  --gold: #ffd23f;
  --on-accent: #041018;          /* text on bright accent buttons */
  --topbar: linear-gradient(180deg, rgba(5,8,16,0.92), rgba(5,8,16,0.55));
  --backdrop: rgba(2,4,10,0.7);
  --backdrop-strong: rgba(2,4,10,0.82);
  --hud-shadow: 0 1px 3px #000, 0 0 6px #000;   /* legibility for text on the map */
  --cel-card: linear-gradient(180deg, rgba(10,16,34,0.97), rgba(6,10,22,0.97));
  --head: 'Orbitron', 'Rajdhani', system-ui, sans-serif;
  --body: 'Rajdhani', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--body); font-size: 15px;
  user-select: none; -webkit-user-select: none;
}
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#text { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ── top bar ── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 48px;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: var(--blur);
  box-shadow: var(--header-shadow);
  z-index: 5;
}
.logo {
  font-family: var(--head); font-weight: 700; letter-spacing: 0.18em; font-size: 15px;
  color: #fff; text-shadow: 0 0 12px rgba(58, 216, 255, 0.7);
  margin-right: 8px;
}
.logo span { color: var(--magenta); text-shadow: 0 0 12px rgba(255, 61, 168, 0.8); margin: 0 2px; }
.chip {
  font-family: var(--head); font-size: 11px; letter-spacing: 0.12em;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--cyan);
  box-shadow: 0 0 10px rgba(58, 216, 255, 0.15) inset;
}
.chip.dim { color: var(--dim); border-color: var(--line); box-shadow: none; }
.spacer { flex: 1; }
.speed { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.speed button {
  background: none; border: 0; padding: 4px 10px; color: var(--dim);
  font-weight: 700; font-size: 13px;
}
.speed button + button { border-left: 1px solid var(--line); }
.speed button.on { color: var(--on-accent); background: var(--cyan); box-shadow: 0 0 14px rgba(58,216,255,0.6); }
.btn {
  background: rgba(58, 216, 255, 0.06); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 5px 14px; font-weight: 700; letter-spacing: 0.06em;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(58, 216, 255, 0.16); box-shadow: 0 0 14px rgba(58, 216, 255, 0.3); }
.btn.icon { width: 32px; padding: 5px 0; }
.btn.primary { background: var(--cyan); color: var(--on-accent); border-color: var(--cyan); box-shadow: 0 0 18px rgba(58,216,255,0.5); }
.btn.primary:disabled { background: transparent; color: var(--faint); border-color: var(--line); box-shadow: none; cursor: default; }
.btn.danger { border-color: rgba(255, 77, 109, 0.5); color: #ff8da1; background: rgba(255, 77, 109, 0.06); }
.btn.danger:hover { background: rgba(255, 77, 109, 0.18); box-shadow: 0 0 14px rgba(255, 77, 109, 0.35); }

/* ── panels ── */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: var(--blur); padding: 14px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.panel h3 {
  margin: 0 0 10px; font-family: var(--head); font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.panel h3 .sub { font-family: var(--body); letter-spacing: 0.05em; text-transform: none; color: var(--faint); font-size: 12px; }

#left {
  position: fixed; top: 60px; left: 12px; width: 270px; bottom: 12px;
  display: flex; flex-direction: column; gap: 10px; z-index: 4; pointer-events: none;
}
#left .panel { pointer-events: auto; }
#inventoryPanel { overflow-y: auto; min-height: 0; flex: 0 1 auto; }
#inventory .row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
#inventory .row .n { flex: 1; color: var(--text); }
#inventory .row .c { font-variant-numeric: tabular-nums; font-weight: 700; }
#inventory .row .r { font-variant-numeric: tabular-nums; color: var(--run); width: 48px; text-align: right; font-size: 12px; }
#inventory .row .r.zero { color: var(--faint); }
#inventory .empty { color: var(--faint); font-size: 13px; }

.ico { width: 14px; height: 14px; flex: none; display: inline-block; vertical-align: -2px; overflow: visible; }

/* milestone */
#milestone .mname { font-family: var(--head); font-size: 14px; letter-spacing: 0.08em; margin-bottom: 2px; color: var(--text); }
#milestone .munl { font-size: 12px; color: var(--dim); margin-bottom: 10px; }
#milestone .req { margin-bottom: 8px; }
#milestone .req .top { display: flex; align-items: center; gap: 6px; font-size: 13px; }
#milestone .req .top .n { flex: 1; }
#milestone .req .top .v { font-variant-numeric: tabular-nums; color: var(--dim); }
#milestone .bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.06); margin-top: 4px; overflow: hidden; }
#milestone .bar i { display: block; height: 100%; border-radius: 4px; transition: width 0.3s; }
#milestone .btn { width: 100%; margin-top: 6px; font-family: var(--head); font-size: 12px; letter-spacing: 0.16em; padding: 8px; }
#milestone .done { color: var(--run); font-family: var(--head); font-size: 12px; letter-spacing: 0.1em; }

/* inspector */
#inspector {
  /* placed by UI.placeInspector(): centred unless that would cover the selection */
  position: fixed; top: 50%; left: 50%; width: 300px; max-height: calc(100% - 140px);
  overflow-y: auto; z-index: 4; transition: left 0.15s ease-out, top 0.15s ease-out;
}
.insp-close {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: 7px; color: var(--faint); font-size: 13px;
}
.insp-close:hover { color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.05); }
#inspector .ihead { padding-right: 26px; }
#inspector .ihead { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
#inspector .ihead .title { font-family: var(--head); font-size: 15px; letter-spacing: 0.08em; }
#inspector .ihead .stat { margin-left: auto; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
#inspector .desc { color: var(--dim); font-size: 13px; margin: 0 0 12px; line-height: 1.35; }
#inspector .label { font-family: var(--head); font-size: 10px; letter-spacing: 0.16em; color: var(--faint); text-transform: uppercase; margin: 12px 0 6px; }
.recipe {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  background: rgba(255,255,255,0.02); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; margin-bottom: 6px; font-size: 13px; flex-wrap: wrap;
}
.recipe:hover { border-color: var(--line-strong); }
.recipe.on { border-color: var(--cyan); background: rgba(58,216,255,0.08); box-shadow: 0 0 14px rgba(58,216,255,0.2) inset; }
.recipe .arrow { color: var(--faint); margin: 0 2px; }
.recipe .rname { font-weight: 700; font-size: 14px; }
.recipe .pm { margin-left: auto; color: var(--dim); font-size: 12px; }
.recipe .rio { flex-basis: 100%; display: flex; align-items: center; gap: 6px; color: var(--dim); }
.recipe .rt { margin-left: auto; color: var(--faint); font-size: 12px; }
.qty { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.buf { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; min-height: 18px; }
.buf .none { color: var(--faint); }
.pbar { height: 5px; border-radius: 5px; background: rgba(255,255,255,0.06); overflow: hidden; margin-top: 6px; }
.pbar i { display: block; height: 100%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
#inspector .actions { margin-top: 16px; display: flex; gap: 8px; }
#inspector .actions .btn { flex: 1; }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.kv span:first-child { color: var(--dim); }

.s { font-weight: 700; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; margin-right: 8px; }
.s::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: currentColor; box-shadow: 0 0 8px currentColor; }
.s.run { color: var(--run); } .s.starved { color: var(--starved); } .s.blocked { color: var(--blocked); } .s.idle { color: var(--idle); }

/* build dock: tab rail on the right edge, building list beside it */
#buildbar {
  --rail: 46px; --list: 214px;
  /* centred on the right edge, so a longer list grows out from the middle */
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 5; max-height: calc(100% - 140px);
  display: flex; flex-direction: row-reverse;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: var(--blur); transition: background 0.2s, border-color 0.2s;
}
/* away from the pointer the dock is just its contents, floating on the map */
#buildbar:not(.near) { background: transparent; border-color: transparent; backdrop-filter: none; }
#buildbar:not(.near) .bb-rail { border-left-color: transparent; }
#buildbar:not(.near) :is(.bb-title, .card .nm, .card .cnt, .bb-tab) { text-shadow: var(--hud-shadow); }
.bb-rail {
  width: var(--rail); flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0; border-left: 1px solid var(--line); transition: border-color 0.2s;
}
.bb-tabs { display: flex; flex-direction: column; gap: 4px; }
.bb-tab {
  position: relative; width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  background: none; border: 1px solid transparent; border-radius: 9px; color: var(--faint);
}
.bb-tab:hover { color: var(--dim); background: rgba(255,255,255,0.04); }
.bb-tab.on { color: var(--cyan); background: rgba(58,216,255,0.1); border-color: rgba(58,216,255,0.3); filter: drop-shadow(0 0 6px rgba(58,216,255,0.5)); }
.bb-tab.new::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 8px var(--lime);
}
.bb-fold { margin-top: auto; }
.bb-main { width: var(--list); display: flex; flex-direction: column; min-height: 0; padding: 8px 6px 8px 8px; }
.bb-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 6px; }
.bb-title { font-family: var(--head); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); }
.bb-latest {
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: none; color: var(--faint);
}
.bb-latest:hover { color: var(--dim); border-color: var(--line-strong); }
.bb-latest.on { color: var(--cyan); border-color: rgba(58,216,255,0.5); background: rgba(58,216,255,0.1); }
.bb-latest.on::before { content: '✓ '; }
.bb-cards { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding-right: 2px; }
.card {
  position: relative; flex: none; display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px 6px 12px; border-radius: 8px; text-align: left;
  background: rgba(255,255,255,0.02); border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.card::before {
  content: ''; position: absolute; left: 4px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px;
  background: var(--c); box-shadow: 0 0 8px var(--c); opacity: 0.85;
}
.card:hover { border-color: color-mix(in srgb, var(--c) 45%, transparent); background: rgba(255,255,255,0.05); }
.card.active { border-color: var(--c); box-shadow: 0 0 16px -6px var(--c), 0 0 0 1px var(--c) inset; background: rgba(255,255,255,0.07); }
.card .nm { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cnt { font-weight: 700; font-size: 13px; color: var(--c); font-variant-numeric: tabular-nums; }
.card .key {
  min-width: 18px; text-align: center; font-family: var(--body); font-size: 11px; font-weight: 700; color: var(--faint);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 4px;
}
.card.poor .nm { color: var(--dim); }
.card.poor .cnt { color: var(--blocked); opacity: 0.8; }
.card.locked { opacity: 0.35; cursor: not-allowed; }
.card.locked::before { background: var(--faint); box-shadow: none; }
.card .lock { font-size: 11px; color: var(--faint); letter-spacing: 0.08em; }
.bb-main .pipe-chip { margin-top: 8px; align-self: stretch; justify-content: center; }
/* folded: just the rail */
#buildbar.collapsed .bb-main { display: none; }
#buildbar.collapsed .bb-tab.on { color: var(--faint); background: none; border-color: transparent; filter: none; }
#buildbar .bb-fold .chev path { transform: rotate(90deg); }
#buildbar.collapsed .bb-fold .chev path { transform: rotate(-90deg); }


/* detail panel floats to the right of the bar */
.bb-detail {
  position: absolute; right: calc(100% + 8px); top: 0; width: 250px;
  background: var(--panel); border: 1px solid var(--c); border-radius: 14px; padding: 10px 12px;
  backdrop-filter: var(--blur); box-shadow: 0 0 24px -10px var(--c);
}
.dt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dt-name { font-family: var(--head); font-size: 13px; letter-spacing: 0.08em; color: var(--c); text-shadow: 0 0 10px var(--c); }
.dt-count { font-size: 12px; font-weight: 700; color: var(--run); white-space: nowrap; }
.dt-count.zero { color: var(--blocked); }
.dt-desc { font-size: 12.5px; color: var(--dim); line-height: 1.3; margin: 4px 0 8px; }
.dt-label { font-family: var(--head); font-size: 9px; letter-spacing: 0.18em; color: var(--faint); text-transform: uppercase; margin-bottom: 4px; }
.dt-row {
  display: flex; align-items: center; gap: 7px; font-size: 13.5px; padding: 3px 6px; margin: 0 -6px;
  border-radius: 6px; cursor: help;
}
.dt-row:hover { background: rgba(255,255,255,0.05); }
.dt-row .n { flex: 1; }
.dt-row .v { color: var(--dim); font-variant-numeric: tabular-nums; }
.dt-row .v b { color: var(--text); }
.dt-row.short .v b { color: var(--blocked); }
.dt-hint { font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.dt-hint kbd { font-family: var(--body); font-weight: 700; font-size: 11px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--cyan); }

/* item tooltip */
#tip {
  position: fixed; z-index: 30; pointer-events: none; min-width: 190px; max-width: 280px;
  background: var(--panel); backdrop-filter: var(--blur); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 20px -8px rgba(58,216,255,0.5);
}
.tip-h { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.tip-stock { color: var(--dim); margin: 3px 0 6px; }
.tip-stock b { color: var(--text); }
.tip-rate { color: var(--run); font-weight: 700; }
.tip-src { border-top: 1px solid var(--line); padding-top: 5px; margin-top: 5px; color: var(--dim); line-height: 1.35; }
.tip-b { font-weight: 700; }
.tip-lock { margin-left: 6px; font-size: 11px; color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; }
.tip-io { display: flex; align-items: center; gap: 5px; color: var(--text); margin-top: 2px; }
.tip-io .arrow { color: var(--faint); }
.tip-t { margin-left: auto; color: var(--faint); font-size: 12px; }
[data-tip] { cursor: help; }

/* hint */
#hint {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 4; max-width: min(520px, calc(100% - 640px)); min-width: 280px;
  background: var(--panel); backdrop-filter: var(--blur); border: 1px solid rgba(166, 255, 61, 0.35); border-radius: 12px;
  padding: 10px 36px 10px 14px; font-size: 14px; line-height: 1.35;
  box-shadow: 0 0 24px -8px rgba(166,255,61,0.5);
}
#hint .step { font-family: var(--head); font-size: 10px; letter-spacing: 0.16em; color: var(--lime); display: block; margin-bottom: 3px; }
#hint .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--faint); font-size: 16px; }
#hint kbd, .help-grid kbd {
  font-family: var(--body); font-weight: 700; font-size: 12px; padding: 0 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: rgba(58,216,255,0.08); color: var(--cyan);
}

/* toasts */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  background: var(--panel); backdrop-filter: var(--blur); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 7px 14px; font-weight: 600; font-size: 14px;
  animation: toast 2.6s forwards;
}
.toast.err { border-color: rgba(255,77,109,0.6); color: #ffb3c0; }
.toast.good { border-color: rgba(61,255,154,0.6); color: #b9ffd9; box-shadow: 0 0 20px -6px var(--run); }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* modals */
.modal { position: fixed; inset: 0; z-index: 20; background: var(--backdrop); display: grid; place-items: center; backdrop-filter: blur(4px); }
.modal-card {
  width: min(620px, calc(100% - 32px)); max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--panel); backdrop-filter: var(--blur); border: 1px solid var(--line-strong); border-radius: 16px; padding: 22px 26px;
  box-shadow: 0 0 60px -20px rgba(58,216,255,0.5);
}
.modal-card.center { text-align: center; }
.modal-card h2 { font-family: var(--head); font-size: 13px; letter-spacing: 0.18em; color: var(--cyan); margin: 4px 0 14px; text-transform: uppercase; }
.modal-card p { color: var(--dim); line-height: 1.45; }
.modal-card b { color: var(--text); }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: baseline; font-size: 14px; margin-bottom: 18px; }
.help-grid > kbd, .help-grid > :nth-child(odd) { white-space: nowrap; }
.port { color: var(--cyan); }
.win-title {
  font-family: var(--head); font-size: 28px; letter-spacing: 0.2em; margin: 10px 0;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255,61,168,0.5));
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

@media (max-width: 900px) {
  #left { width: 220px; }
  #inspector { width: 250px; }
  #hint { max-width: calc(100% - 24px); top: auto; bottom: 24px; }
}

/* ── upload ready: pulse the button ── */
#milestone .btn.primary:not(:disabled) { animation: readyPulse 1.4s ease-in-out infinite; }
@keyframes readyPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(58,216,255,0.45); }
  50% { box-shadow: 0 0 26px rgba(58,216,255,0.95), 0 0 50px rgba(255,61,168,0.35); }
}

#btnSound.off { color: var(--faint); text-decoration: line-through; }

/* ── newly unlocked build cards ── */
.card.new::after {
  content: 'NEW'; position: absolute; top: -6px; right: 6px;
  font-family: var(--head); font-size: 8px; letter-spacing: 0.14em; padding: 1px 5px; border-radius: 5px;
  background: var(--c); color: var(--on-accent); box-shadow: 0 0 10px var(--c);
  animation: newBob 1.2s ease-in-out infinite;
}
.card.new { border-color: var(--c); }
@keyframes newBob { 50% { transform: translateY(-2px); } }

/* ── milestone celebration ── */
#celebrate {
  position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; cursor: pointer;
  background: radial-gradient(ellipse at center, var(--backdrop), transparent 70%);
  transition: opacity 0.45s;
}
#celebrate.out { opacity: 0; }
.cel-flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at center, rgba(160,240,255,0.55), rgba(255,61,168,0.15) 40%, transparent 70%);
  animation: celFlash 1.1s ease-out forwards;
}
@keyframes celFlash { 0% { opacity: 0; } 8% { opacity: 1; } 100% { opacity: 0; } }
.cel-sweep {
  position: absolute; left: 0; right: 0; height: 2px; top: 50%; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--cyan), #fff, var(--magenta), transparent);
  box-shadow: 0 0 24px var(--cyan);
  animation: celSweep 1.2s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes celSweep {
  0% { transform: scaleX(0); opacity: 1; }
  45% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1) scaleY(60); opacity: 0; }
}
.cel-card {
  position: relative; text-align: center; padding: 34px 48px 26px; min-width: min(560px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  background: var(--cel-card);
  border: 1px solid rgba(58,216,255,0.5); border-radius: 20px;
  box-shadow: 0 0 80px -10px rgba(58,216,255,0.6), 0 0 140px -30px rgba(255,61,168,0.6), inset 0 0 40px -20px rgba(58,216,255,0.6);
  animation: celCard 0.7s cubic-bezier(.2,1.4,.4,1) 0.15s both;
}
.cel-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: 20px; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--a, 0deg), var(--cyan), var(--magenta), var(--amber), var(--lime), var(--cyan));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: celSpin 3s linear infinite;
}
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes celSpin { to { --a: 360deg; } }
@keyframes celCard { from { opacity: 0; transform: scale(0.82); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
.cel-kicker {
  font-family: var(--head); font-size: 11px; letter-spacing: 0.3em; color: var(--lime);
  text-shadow: 0 0 10px rgba(166,255,61,0.7);
  animation: celUp 0.5s ease-out 0.35s both;
}
.cel-name {
  font-family: var(--head); font-weight: 700; font-size: clamp(26px, 4.4vw, 46px); margin: 12px 0 14px;
  background: linear-gradient(90deg, var(--cyan), #fff, var(--magenta), var(--amber), var(--cyan));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(58,216,255,0.55));
  animation: celTrack 0.9s cubic-bezier(.2,.8,.2,1) 0.3s both, celShimmer 3s linear infinite;
}
@keyframes celTrack { from { letter-spacing: 0.6em; opacity: 0; } to { letter-spacing: 0.06em; opacity: 1; } }
@keyframes celShimmer { to { background-position: 300% 0; } }
.cel-line {
  height: 2px; margin: 0 auto 14px; width: 70%;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--magenta), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: celLine 0.7s ease-out 0.55s both;
}
@keyframes celLine { from { transform: scaleX(0); } }
.cel-tier {
  font-family: var(--head); font-size: 15px; letter-spacing: 0.24em; color: var(--text);
  animation: celUp 0.5s ease-out 0.7s both;
}
.cel-tier b { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); font-size: 20px; }
.cel-label {
  font-family: var(--head); font-size: 10px; letter-spacing: 0.2em; color: var(--faint);
  text-transform: uppercase; margin: 20px 0 10px; animation: celUp 0.4s ease-out 0.85s both;
}
.cel-unlocks { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cel-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(58,216,255,0.06);
  font-weight: 700; font-size: 14px;
  animation: celPop 0.45s cubic-bezier(.2,1.6,.4,1) both;
}
.cel-chip .dot { width: 9px; height: 9px; border-radius: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); }
@keyframes celPop { from { opacity: 0; transform: translateY(8px) scale(0.7); } }
@keyframes celUp { from { opacity: 0; transform: translateY(10px); } }
.cel-lore {
  max-width: 520px; margin: 22px auto 0; padding: 12px 16px; text-align: left; font-size: 15px; line-height: 1.45; color: var(--text);
  border-left: 2px solid var(--cyan); background: rgba(58,216,255,0.05); border-radius: 0 10px 10px 0;
  animation: celUp 0.5s ease-out 1.2s both;
}
.cel-lore span, .lore-quote span { font-family: var(--head); font-size: 10px; letter-spacing: 0.2em; color: var(--cyan); }
.cel-hint { margin-top: 22px; font-size: 12px; color: var(--faint); letter-spacing: 0.1em; animation: celUp 0.4s ease-out 1.6s both; }

/* ── collapsible layout ── */
#topbar, #left, #hint { transition: transform 0.25s ease, top 0.25s ease; }
body.hdr-hidden #topbar { transform: translateY(-100%); box-shadow: none; }   /* no shadow peeking in from off-screen */
body.hdr-hidden #left, body.hdr-hidden #hint { top: 12px; }
#hdrShow {
  position: fixed; top: 0; left: 50%; z-index: 6; display: flex; align-items: center; gap: 8px;
  padding: 3px 12px 5px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px;
  background: var(--panel); color: var(--dim); backdrop-filter: var(--blur);
  transform: translate(-50%, -110%); transition: transform 0.25s ease;
}
#hdrShow .logo { font-size: 10px; margin: 0; }
#hdrShow:hover { color: var(--cyan); border-color: var(--line-strong); }
body.hdr-hidden #hdrShow { transform: translate(-50%, 0); }
body.hdr-hidden #hint { top: 40px; }

.panel h3 .ctl { display: flex; align-items: center; gap: 4px; }
.pbtn {
  display: grid; place-items: center; width: 20px; height: 20px; padding: 0;
  background: none; border: 1px solid transparent; border-radius: 6px; color: var(--faint);
}
.pbtn:hover { color: var(--cyan); border-color: var(--line); background: rgba(58,216,255,0.06); }
.pbtn.on { color: var(--cyan); }
.chev path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; transform-origin: 6px 6px; }
.collapsed .chev path { transform: rotate(180deg); }

/* collapsed panels keep only their header */
.panel.collapsed { padding-bottom: 4px; }
.panel.collapsed h3 { margin-bottom: 0; }
#inventoryPanel.collapsed #inventory { display: none; }
#inventoryPanel.collapsed .sub { display: none; }
#milestone .mpct { font-family: var(--body); font-size: 12px; letter-spacing: 0.04em; color: var(--dim); margin-right: 4px; display: none; }
#milestone.ready .mpct { color: var(--run); font-weight: 700; text-shadow: 0 0 8px var(--run); }
#milestone .mname-inline { display: none; text-transform: none; letter-spacing: 0.04em; color: var(--text); }
#milestone.collapsed > :not(h3) { display: none; }
#milestone.collapsed .mpct, #milestone.minimal .mpct { display: inline; }
#milestone.collapsed .mname-inline { display: inline; }
#milestone.collapsed.ready { box-shadow: 0 0 20px -6px var(--cyan); border-color: var(--line-strong); }

/* minimal HUD: no backdrop, just tracked requirements */
#milestone.minimal {
  background: none; border-color: transparent; box-shadow: none; backdrop-filter: none;
  padding: 4px 6px 6px; transition: background 0.2s, border-color 0.2s;
}
#milestone.minimal:hover { background: var(--panel); border-color: var(--line); backdrop-filter: var(--blur); }
#milestone.minimal h3 { margin-bottom: 6px; }
#milestone.minimal .mname { display: none; }
#milestone.minimal .munl { margin: -2px 0 8px; text-shadow: var(--hud-shadow); }
#milestone.minimal .mname-inline { display: inline; }
#milestone.minimal h3, #milestone.minimal .req { text-shadow: var(--hud-shadow); }
#milestone.minimal .req { margin-bottom: 5px; }
#milestone.minimal .req.met .v { color: var(--run); }
#milestone.minimal .bar { height: 3px; background: rgba(255,255,255,0.1); }
#milestone.minimal .pbtn { opacity: 0; transition: opacity 0.2s; }
#milestone.minimal:hover .pbtn, #milestone.minimal .pbtn:focus-visible { opacity: 1; }
#milestone.minimal [data-upload]:disabled { display: none; }
#milestone.minimal.collapsed { padding-bottom: 4px; }
#milestone .mtitle { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the goal name wraps instead of being cut short */
#milestone.minimal .mtitle { white-space: normal; overflow: visible; line-height: 1.3; }
#milestone.collapsed .mword, #milestone.minimal .mword { display: none; }

/* Core Stock minimal view: same treatment as the milestone HUD */
#inventoryPanel.minimal {
  background: none; border-color: transparent; box-shadow: none; backdrop-filter: none;
  padding: 4px 6px 6px; transition: background 0.2s, border-color 0.2s;
}
#inventoryPanel.minimal:hover { background: var(--panel); border-color: var(--line); backdrop-filter: var(--blur); }
#inventoryPanel.minimal h3 { margin-bottom: 4px; }
#inventoryPanel.minimal h3, #inventoryPanel.minimal #inventory { text-shadow: var(--hud-shadow); }
#inventoryPanel.minimal #inventory .row { padding: 1px 0; font-size: 13.5px; }
#inventoryPanel.minimal .sub { display: none; }
#inventoryPanel.minimal .pbtn { opacity: 0; transition: opacity 0.2s; }
#inventoryPanel.minimal:hover .pbtn, #inventoryPanel.minimal .pbtn:focus-visible { opacity: 1; }
#inventoryPanel.minimal.collapsed { padding-bottom: 4px; }


/* pocket dimension */
.btn.wide { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
#inspector .dt-row { margin: 0; }
#spaceBar {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 14px; padding: 6px 14px 6px 6px;
  background: var(--panel); border: 1px solid rgba(255,184,77,0.55); border-radius: 12px;
  box-shadow: 0 0 24px -8px rgba(255,184,77,0.7); backdrop-filter: var(--blur);
  transition: top 0.25s ease;
}
#spaceBar .sb-title { font-family: var(--head); font-size: 11px; letter-spacing: 0.16em; color: #ffb84d; text-shadow: 0 0 10px rgba(255,184,77,0.6); }
#spaceBar .sb-title b { color: var(--text); }
#spaceBar .sb-stat { font-size: 13px; color: var(--dim); }
body.hdr-hidden #spaceBar { top: 24px; }
body.in-pocket #hint { display: none !important; }

/* new game options */
.chip.mode { color: var(--amber); border-color: rgba(255,201,77,0.45); box-shadow: 0 0 10px rgba(255,201,77,0.15) inset; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin: 8px 0;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.opt:hover { border-color: var(--line-strong); background: rgba(58,216,255,0.04); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt-box {
  flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 6px;
  border: 1.5px solid var(--line-strong); display: grid; place-items: center; transition: all 0.15s;
}
.opt-box::after { content: ''; width: 9px; height: 5px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.opt input:checked + .opt-box { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px rgba(58,216,255,0.6); }
.opt input:checked + .opt-box::after { opacity: 1; }
.opt input:focus-visible + .opt-box { outline: 2px solid var(--cyan); outline-offset: 2px; }
.opt:has(input:checked) { border-color: rgba(58,216,255,0.5); background: rgba(58,216,255,0.06); }
.opt-text { display: flex; flex-direction: column; gap: 3px; }
.opt-text b { color: var(--text); font-size: 15px; }
.opt-text span { color: var(--dim); font-size: 13.5px; line-height: 1.35; }
.modal-card .warn { font-size: 13px; color: var(--faint); margin-top: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.dt-free { font-size: 13px; color: var(--run); padding: 2px 0; }

/* rate settings */
#inspector .label .unit { font-family: var(--body); letter-spacing: 0.04em; text-transform: none; color: var(--faint); margin-left: 4px; }
.rate-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13.5px; }
.rate-row .rname { flex: 1; }
.rate-row .rname b { color: var(--faint); }
.rate-row input {
  width: 72px; padding: 4px 8px; border-radius: 8px; font: inherit; font-weight: 700; text-align: right;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line-strong); color: var(--text);
}
.rate-row input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 10px rgba(58,216,255,0.35); }
.rate-row input::placeholder { color: var(--dim); }
.rate-row .rflow { width: 78px; text-align: right; font-size: 12px; color: var(--run); font-variant-numeric: tabular-nums; }

/* pipe tiers */
.pipe-chip {
  margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 7px; padding: 2px 8px;
  font-family: var(--head); font-size: 10px; letter-spacing: 0.1em; color: var(--text);
}
.pipe-chip span { color: var(--faint); }
.pipe-chip i { font-style: normal; font-family: var(--body); letter-spacing: 0.02em; color: var(--dim); margin-left: 4px; }
.pipe-chip:hover { border-color: var(--line-strong); color: var(--cyan); }
.pipe-up { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; margin-bottom: 6px; }
.pipe-up.locked { opacity: 0.45; }
.pu-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.pu-head span { color: var(--dim); }
.pu-head .btn { margin-left: auto; padding: 3px 10px; font-size: 12px; }
.pu-lock { margin-left: auto; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.pipe-up .buf { margin-top: 5px; }

/* Quanta */
.chip.quanta { color: var(--gold); border-color: rgba(255,210,63,0.45); box-shadow: 0 0 10px rgba(255,210,63,0.15) inset; }
.chip.quanta b { font-weight: 700; }
.chip.quanta i { font-style: normal; font-family: var(--body); letter-spacing: 0.02em; color: var(--run); }
.q-ico { width: 14px; text-align: center; color: var(--gold); text-shadow: 0 0 6px rgba(255,210,63,0.7); }
.tip-q { color: var(--gold); }
.field {
  user-select: text;
  width: 100%; padding: 6px 8px; border-radius: 8px; font: inherit; font-size: 13.5px;
  background: var(--panel-solid); border: 1px solid var(--line-strong); color: var(--text); margin-bottom: 10px;
}
.field:focus { outline: none; border-color: var(--cyan); }
.desc.small { font-size: 12px; margin-top: 6px; }

/* Quanta, Codex and Research stay reachable with the header hidden: top right */
#hudCorner {
  position: fixed; top: 6px; right: 12px; z-index: 6; display: flex; align-items: center; gap: 6px;
  opacity: 0; transform: translateY(-6px); transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
body.hdr-hidden #hudCorner { opacity: 1; transform: none; }
body.hdr-hidden #hudCorner .hud-ico { pointer-events: auto; }
#quantaHud {
  margin-right: 4px;
  font-family: var(--head); font-size: 14px; letter-spacing: 0.1em; color: var(--gold);
  text-shadow: 0 0 10px rgba(255,210,63,0.6), var(--hud-shadow);
}
.hud-ico {
  position: relative; width: 26px; height: 26px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--cyan); backdrop-filter: var(--blur);
}
.hud-ico:hover { border-color: var(--line-strong); box-shadow: 0 0 12px -2px currentColor; }
.hud-ico.research { color: var(--lime); }
.hud-ico.research.can { animation: researchPulse 1.6s ease-in-out infinite; }
.hud-dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px var(--lime); }
#quantaHud b { font-weight: 700; }
#quantaHud i { font-style: normal; font-family: var(--body); font-size: 12px; letter-spacing: 0.02em; color: var(--run); text-shadow: var(--hud-shadow); }
.tip-t2 { color: var(--faint); font-size: 12px; }

/* ── research ── */
.research-btn { position: relative; border-color: rgba(166,255,61,0.45); color: var(--lime); }
.research-btn.can { animation: researchPulse 1.6s ease-in-out infinite; }
@keyframes researchPulse { 50% { box-shadow: 0 0 18px rgba(166,255,61,0.6); background: rgba(166,255,61,0.12); } }
.rs-badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--lime); color: var(--on-accent); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 10px rgba(166,255,61,0.7);
}
#researchModal { background: var(--backdrop-strong); }
.rs-panel {
  position: fixed; inset: 3vh 2vw; display: flex; flex-direction: column;
  background: var(--panel); backdrop-filter: var(--blur); border: 1px solid var(--line-strong); border-radius: 18px;
  box-shadow: 0 0 80px -20px rgba(166,255,61,0.35), 0 20px 60px rgba(0,0,0,0.6); overflow: hidden;
}
.rs-header { display: flex; align-items: center; gap: 18px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.rs-title { font-family: var(--head); font-size: 18px; letter-spacing: 0.24em; color: var(--lime); text-shadow: 0 0 14px rgba(166,255,61,0.6); }
.rs-sub { color: var(--dim); font-size: 13.5px; flex: 1; }
.rs-quanta { font-family: var(--head); font-size: 16px; letter-spacing: 0.08em; color: var(--gold); text-shadow: 0 0 10px rgba(255,210,63,0.5); }
.rs-tree { flex: 1; display: flex; gap: 0; overflow-x: auto; overflow-y: hidden; padding: 0 10px; overscroll-behavior-x: contain; }
.rs-col { flex: none; width: 250px; display: flex; flex-direction: column; border-right: 1px dashed var(--line); padding: 0 8px; }
.rs-col-head { position: relative; padding: 16px 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.rs-col-head b { font-family: var(--head); font-size: 12px; letter-spacing: 0.2em; color: var(--faint); }
.rs-col-head span { font-size: 13px; color: var(--faint); }
.rs-col.reached .rs-col-head b { color: var(--lime); }
.rs-col.reached .rs-col-head span { color: var(--dim); }
/* progress rail along the top of the tree */
.rs-col-head::after { content: ''; position: absolute; left: -8px; right: -8px; bottom: 4px; height: 2px; background: var(--line); }
.rs-col.reached .rs-col-head::after { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.rs-col-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 18px; }
.rs-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,0.02);
  position: relative; transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.rs-card::before { content: ''; position: absolute; left: 10px; right: 10px; top: 0; height: 2px; border-radius: 2px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.rs-top { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); font-family: var(--head); }
.rs-name { font-weight: 700; font-size: 16px; margin: 4px 0 3px; color: var(--c); }
.rs-desc { font-size: 12.5px; color: var(--dim); line-height: 1.3; margin-bottom: 8px; }
.rs-cost .dt-row { font-size: 13px; margin: 0; }
.rs-card .btn { margin-top: 8px; font-size: 13px; padding: 6px; }
.rs-card.locked { opacity: 0.45; }
.rs-card.locked .btn, .rs-card.done .btn, .rs-card.done .rs-cost { display: none; }
.rs-card.done { border-color: rgba(61,255,154,0.35); background: rgba(61,255,154,0.04); }
.rs-card.done .rs-state { color: var(--run); }
.rs-card.affordable { border-color: var(--c); box-shadow: 0 0 22px -8px var(--c); }
.rs-card.flash { animation: rsFlash 1.2s ease-out; }
/* codex */
.codex-btn { border-color: rgba(58,216,255,0.45); color: var(--cyan); }
#codexModal { background: var(--backdrop-strong); }
.cx-panel { box-shadow: 0 0 80px -20px rgba(58,216,255,0.35), 0 20px 60px rgba(0,0,0,0.6); }
.cx-title { color: var(--cyan); text-shadow: 0 0 14px rgba(58,216,255,0.6); }
.cx-body { flex: 1; min-height: 0; display: flex; }
.cx-side { width: 250px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
#cxSearch {
  margin: 12px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.03); color: var(--text); font: inherit; font-size: 14px; outline: none; user-select: text;
}
#cxSearch:focus { border-color: var(--cyan); box-shadow: 0 0 12px -4px var(--cyan); }
.cx-list { flex: 1; overflow-y: auto; padding: 0 8px 14px; }
.cx-group { font-family: var(--head); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); padding: 10px 6px 4px; }
.cx-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.cx-item:hover { background: rgba(58,216,255,0.08); }
.cx-item.on { background: rgba(58,216,255,0.16); box-shadow: inset 2px 0 0 var(--cyan); }
.cx-item span { flex: 1; }
.cx-item.locked span { color: var(--dim); }
.cx-item i { font-style: normal; font-size: 11px; color: var(--faint); }
.cx-none { color: var(--faint); padding: 10px 6px; font-size: 13px; }
.cx-detail { flex: 1; overflow-y: auto; padding: 18px 26px 30px; }
.cx-head { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cx-back { flex: none; }
.cx-head > .ico { width: 34px; height: 34px; }
.cx-name { font-size: 24px; font-weight: 700; color: var(--c); line-height: 1.1; }
.cx-meta { color: var(--dim); font-size: 13.5px; }
.cx-stats { margin-left: auto; display: flex; gap: 22px; }
.cx-stats div { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--faint); }
.cx-stats b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.cx-stats i { font-style: normal; color: var(--dim); }
.cx-lock { color: var(--amber); font-style: normal; font-size: 12px; margin-left: 8px; }
.cx-sec { font-family: var(--head); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); margin: 20px 0 8px; }
.cx-sec span { font-family: var(--body); letter-spacing: 0; text-transform: none; color: var(--faint); font-size: 13px; margin-left: 6px; }
.cx-sub { font-size: 12px; color: var(--faint); margin: 12px 0 5px; }
.cx-p { color: var(--dim); margin: 0 0 8px; line-height: 1.4; max-width: 640px; }
.cx-p b { color: var(--text); }
.cx-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); background: color-mix(in srgb, var(--c) 8%, transparent); font-size: 14px;
}
.cx-chip:hover { border-color: var(--c); box-shadow: 0 0 10px -3px var(--c); }
.cx-chip b { font-variant-numeric: tabular-nums; }
.cx-recipe { border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 10px; padding: 10px 14px; max-width: 640px; }
.cx-machine { display: flex; align-items: baseline; gap: 4px; }
.cx-machine b { color: var(--c); font-size: 16px; }
.cx-time { margin-left: auto; color: var(--faint); font-size: 13px; }
.cx-io { display: flex; align-items: center; gap: 16px; margin: 10px 0 6px; }
.cx-io-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.cx-io-row i { font-style: normal; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cx-arrow { color: var(--faint); font-size: 20px; }
.cx-note { color: var(--faint); font-size: 12px; }
.cx-raw { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.cx-via { color: var(--dim); font-size: 13px; margin-left: 6px; }
.cx-tree { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; max-width: 760px; }
.cx-tree details > summary { list-style: none; cursor: pointer; padding: 2px 0; display: flex; align-items: center; }
.cx-tree details > summary::-webkit-details-marker { display: none; }
.cx-tree details > summary::before { content: '▸'; width: 14px; color: var(--faint); transition: transform 0.15s; display: inline-block; }
.cx-tree details[open] > summary::before { transform: rotate(90deg); }
.cx-leaf { display: flex; align-items: center; padding: 2px 0 2px 14px; }
.cx-kids { margin-left: 6px; padding-left: 12px; border-left: 1px dashed var(--line); }
.cx-n { font-variant-numeric: tabular-nums; color: var(--text); min-width: 46px; display: inline-block; font-size: 13.5px; }
.cx-uses { display: flex; flex-direction: column; gap: 5px; }
.cx-use { display: flex; align-items: center; }
.cx-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-tag { font-size: 13px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--c, var(--dim)); }
.cx-tag b { color: var(--text); margin-left: 3px; }
.cx-tag.done { opacity: 0.5; }
.cx-table { display: grid; grid-template-columns: auto auto auto auto; gap: 0; max-width: 560px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cx-tr { display: contents; }
.cx-tr > span { padding: 5px 12px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cx-tr > span:not(:first-child) { text-align: right; color: var(--dim); }
.cx-th > span { border-top: none; font-size: 12px; color: var(--faint) !important; background: rgba(255,255,255,0.02); }
.tip-cx { margin-top: 6px; font-size: 11.5px; color: var(--faint); }
.tip-cx kbd { font-family: var(--body); font-weight: 700; font-size: 11px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--cyan); }
#inventory .row { cursor: pointer; }
@media (max-width: 700px) {
  .cx-side { width: 170px; }
  .cx-detail { padding: 14px; }
  .cx-head { flex-wrap: wrap; }
  .cx-stats { margin-left: 0; }
}
@keyframes rsFlash { 0%, 40% { box-shadow: 0 0 0 2px #fff, 0 0 30px var(--c); } }

/* ── light theme ── */
:root[data-theme="light"] {
  --bg: #eef2f8;
  --panel: rgba(255, 255, 255, 0.72);
  --header-shadow: 0 4px 16px rgba(20, 40, 80, 0.1);
  --panel-solid: #ffffff;
  --line: rgba(30, 60, 120, 0.14);
  --line-strong: rgba(20, 90, 170, 0.35);
  --text: #16203a;
  --dim: #4c5d7d;
  --faint: #8a98b3;
  --cyan: #0a8fc4;
  --magenta: #c8126f;
  --lime: #3d8a00;
  --amber: #a86f00;
  --run: #0e9a54;
  --starved: #c48600;
  --blocked: #d2304c;
  --idle: #8a98b3;
  --gold: #a87900;
  --on-accent: #ffffff;
  --topbar: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.7));
  --backdrop: rgba(214, 222, 236, 0.7);
  --backdrop-strong: rgba(214, 222, 236, 0.85);
  --hud-shadow: 0 1px 2px #fff, 0 0 6px #fff;
  --cel-card: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,247,252,0.98));
}
:root[data-theme="light"] .logo { color: #16203a; text-shadow: none; }
:root[data-theme="light"] .logo span { text-shadow: none; }
:root[data-theme="light"] .panel { box-shadow: 0 10px 30px rgba(20, 40, 80, 0.12); }
:root[data-theme="light"] .ico { filter: saturate(1.2) brightness(0.85); }
/* neon-coloured text (var(--c) / inline building colours) needs depth on white */
:root[data-theme="light"] :is(.card .cnt, .dt-name, .rs-name, .cx-name, .cx-machine b, .ihead .title, .tip-b, .cel-name) { filter: brightness(0.68) saturate(1.3); }
:root[data-theme="light"] .dt-name, :root[data-theme="light"] .rs-title, :root[data-theme="light"] .cx-title { text-shadow: none; }
/* a collapsed tracker still offers UPLOAD once the milestone is ready */
#milestone.collapsed.ready > [data-upload]:not(:disabled) { display: block; margin-top: 8px; }

/* story */
.lore-card { max-width: 560px; }
.lore-kicker { font-family: var(--head); font-size: 10px; letter-spacing: 0.28em; color: var(--lime); text-shadow: 0 0 10px rgba(166,255,61,0.6); }
.lore-card h2 { margin-top: 8px; }
.lore-text { border-left: 2px solid var(--cyan); padding: 2px 0 2px 16px; margin: 6px 0 18px; text-align: left; }
.modal-card .lore-text p { color: var(--text); font-size: 15.5px; line-height: 1.5; margin: 0 0 10px; }
.lore-text p:first-child { font-weight: 700; }
.lore-quote {
  max-width: 640px; padding: 10px 14px; line-height: 1.5; font-size: 15px;
  border-left: 2px solid var(--cyan); background: rgba(58,216,255,0.05); border-radius: 0 10px 10px 0;
}
.cx-mission span { color: var(--lime); font-weight: 700; }
.cx-mission-name { color: var(--lime); }
.cx-goals { display: flex; flex-direction: column; gap: 8px; max-width: 480px; }
.cx-goal { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; }
.cx-goal-v { justify-self: end; color: var(--dim); font-variant-numeric: tabular-nums; font-size: 14px; }
.cx-goal.met .cx-goal-v { color: var(--run); }
.cx-goal .bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.cx-goal .bar i { display: block; height: 100%; border-radius: 4px; transition: width 0.3s; }
.cx-ready { color: var(--run); margin-top: 8px; }
.cx-ready:empty { display: none; }
.cx-story { max-width: 640px; display: flex; flex-direction: column; gap: 6px; }
.cx-story details { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.cx-story summary { cursor: pointer; font-weight: 700; color: var(--text); list-style: none; }
.cx-story summary::-webkit-details-marker { display: none; }
.cx-story summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--faint); transition: transform 0.15s; }
.cx-story details[open] summary::before { transform: rotate(90deg); }
.cx-story p { margin: 8px 0 0 14px; line-height: 1.5; color: var(--dim); }
.cx-story details[open]:last-child p { color: var(--text); }

/* pocket blueprints */
.bp-row { display: flex; gap: 8px; }
.bp-row .btn { flex: 1; font-size: 13px; }
.bp-row + .btn.wide { margin-top: 8px; font-size: 13px; }
#spaceBar .btn[data-bp-save], #spaceBar .btn[data-bp-load], #spaceBar .btn[data-empty-pocket] { font-size: 12.5px; padding: 4px 10px; }
