:root {
  --bg: #04060d;
  --panel: rgba(12, 20, 38, .82);
  --panel-edge: #1f3556;
  --text: #dce8f7;
  --muted: #7f93ad;
  --accent: #4fd2ff;
  --accent-dim: rgba(79, 210, 255, .18);
  --good: #6cf0b0;
  --warn: #f7cf7f;
  --bad: #ff6b7d;
  --sidebar: 300px;
  --topbar: 52px;
  font-family: "Rajdhani", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}
* { box-sizing: border-box; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(4, 8, 18, .55); border-left: 1px solid rgba(31, 53, 86, .6); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2a4c78, #1c3355);
  border: 2px solid transparent; border-radius: 6px; background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgba(79, 210, 255, .25);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #3a6aa4, #27477a); background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: #2a4c78 rgba(4, 8, 18, .55); }
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 85% 0%, rgba(40, 70, 140, .35) 0, transparent 55%),
    radial-gradient(ellipse at 0% 100%, rgba(110, 40, 140, .25) 0, transparent 50%),
    var(--bg);
  overflow: hidden;
}

.topbar {
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--panel-edge);
  background: rgba(6, 10, 22, .9);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent), inset 0 0 6px var(--accent);
}
.brand-name {
  font-family: "Orbitron", sans-serif; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; font-size: 1rem;
}
.topbar-right { display: flex; align-items: center; gap: 1.25rem; }
.admin-switch {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em;
}
.admin-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.admin-track {
  position: relative; width: 34px; height: 18px; flex: none;
  border: 1px solid var(--panel-edge); border-radius: 9px; background: rgba(12, 20, 38, .9);
  transition: background .15s, border-color .15s;
}
.admin-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.admin-switch input:checked ~ .admin-track { background: rgba(247, 207, 127, .2); border-color: var(--warn); }
.admin-switch input:checked ~ .admin-track::after { transform: translateX(16px); background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.admin-switch:has(input:checked) { color: var(--warn); }
.admin-switch input:focus-visible ~ .admin-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.status { display: flex; gap: 1.25rem; margin: 0; font-size: .85rem; }
.status div { display: flex; gap: .4rem; align-items: center; }
.status dt { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.status dd { margin: 0; color: var(--warn); font-weight: 600; }
.status dd::before { content: "●"; margin-right: .3rem; font-size: .7em; vertical-align: middle; }
.status dd[data-state="online"] { color: var(--good); }
.status dd[data-state="offline"] { color: var(--bad); }

.layout {
  height: calc(100% - var(--topbar));
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  gap: .75rem;
  padding: .75rem;
}
.sidebar { display: flex; flex-direction: column; gap: .75rem; overflow-y: auto; min-height: 0; }

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  padding: .9rem 1rem 1rem;
  backdrop-filter: blur(6px);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}
.panel::before {
  content: ""; position: absolute; top: 0; left: 0; width: 40px; height: 2px;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.panel-title {
  margin: 0 0 .75rem;
  font-family: "Orbitron", sans-serif; font-weight: 500;
  font-size: .8rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent);
}
.muted { color: var(--muted); font-size: .9rem; margin: 0; }
.stats { margin: 0; }
.stats div {
  display: flex; justify-content: space-between;
  padding: .35rem 0; border-bottom: 1px dashed rgba(127, 147, 173, .2);
}
.stats div:last-child { border-bottom: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.faction-id { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.faction-emblem {
  width: 44px; height: 44px; flex: none;
  border: 1px solid var(--panel-edge);
  background: repeating-linear-gradient(45deg, var(--accent-dim) 0 4px, transparent 4px 8px);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.faction-name { font-size: 1.15rem; font-weight: 600; }
.faction-emblem.has-icon {
  background: center / cover no-repeat var(--emblem-image);
  clip-path: none; border-radius: 6px; border-color: var(--emblem-color, var(--panel-edge));
}
.account { margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--panel-edge); }
.account-connect {
  width: 100%; padding: .55rem .75rem;
  font: inherit; font-weight: 600; letter-spacing: .04em; color: #fff;
  background: #5865f2; border: 0; border-radius: 4px; cursor: pointer;
}
.account-connect:hover { background: #4752c4; }
.account-connect:disabled { background: #3a3f63; color: var(--muted); cursor: not-allowed; }
.account-connect:focus-visible, .account-disconnect:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-user { display: flex; align-items: center; gap: .5rem; }
.account-avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.account-disconnect {
  font: inherit; font-size: .85rem; color: var(--muted);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
}
.account-disconnect:hover { color: var(--text); }
.account-error { margin: .5rem 0 0; color: var(--bad); font-size: .9rem; }

.map-frame {
  position: relative; min-height: 0; min-width: 0;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  overflow: hidden;
  background: #02030a;
  box-shadow: inset 0 0 60px rgba(79, 210, 255, .06);
}
#galaxy-map {
  display: block; width: 100%; height: 100%; cursor: grab; touch-action: none;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
#galaxy-map.dragging { cursor: grabbing; }
.map-hud {
  position: absolute; left: .75rem; right: .75rem; bottom: .75rem;
  display: flex; justify-content: space-between; align-items: end;
  pointer-events: none;
  font-size: .85rem; color: var(--muted); letter-spacing: .08em;
}
.map-controls { display: flex; gap: .35rem; pointer-events: auto; }
.map-controls button {
  width: 34px; height: 34px;
  font: inherit; font-size: 1.1rem; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 3px;
  cursor: pointer;
}
.map-controls button:hover { border-color: var(--accent); color: var(--accent); }
.map-controls button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.map-search {
  position: absolute; top: .75rem; left: .75rem; z-index: 2;
  width: min(320px, calc(100% - 1.5rem));
}
.map-search input {
  width: 100%; padding: .5rem .75rem;
  font: inherit; font-size: .95rem; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 3px;
  backdrop-filter: blur(6px);
}
.map-search input::placeholder { color: var(--muted); }
.map-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.map-search-results {
  list-style: none; margin: .35rem 0 0; padding: .25rem;
  max-height: min(60vh, 420px); overflow-y: auto;
  background: rgba(8, 14, 28, .94); border: 1px solid var(--panel-edge); border-radius: 3px;
  backdrop-filter: blur(6px);
}
.map-search-results li {
  display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center;
  padding: .3rem .45rem; border-radius: 2px;
}
.search-result { cursor: pointer; }
.search-result:hover, .search-result.active { background: var(--accent-dim); }
.search-icon { grid-row: span 2; width: 36px; height: 36px; border-radius: 3px; background: #02030a; }
.search-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hint { grid-template-columns: 1fr !important; }

.context-menu {
  position: fixed; z-index: 50; min-width: 190px; padding: .3rem;
  background: rgba(8, 14, 28, .96); border: 1px solid var(--panel-edge); border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(79, 210, 255, .05);
  backdrop-filter: blur(8px);
  transform-origin: top left;
}
.context-menu.opening { animation: menu-in .14s ease-out both; }
.context-heading {
  padding: .3rem .6rem .35rem; margin-bottom: .2rem;
  border-bottom: 1px solid var(--panel-edge);
  font-family: "Orbitron", sans-serif; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.context-item {
  display: block; width: 100%; padding: .4rem .6rem; text-align: left;
  font: inherit; font-weight: 600; color: var(--text); background: none; border: 0; border-radius: 2px; cursor: pointer;
}
.context-item:hover:not(:disabled), .context-item:focus-visible { background: var(--accent-dim); color: #fff; outline: none; }
.context-item:disabled { color: var(--muted); font-weight: 500; font-style: italic; cursor: default; }
@keyframes menu-in { from { opacity: 0; transform: scale(.94) translateY(-4px); } }

.world-panel {
  --edge: var(--accent);
  position: absolute; z-index: 3; display: flex;
  max-height: calc(100% - 70px);
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, .6));
}
.world-panel-info { width: 250px; }
.world-panel-build { width: 360px; }
.wp-shell {
  position: relative; display: flex; width: 100%; min-height: 0;
  background: linear-gradient(180deg, rgba(14, 24, 46, .95), rgba(8, 14, 30, .95));
  border: 1px solid var(--panel-edge);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.world-panel-info .wp-shell {
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
}
.wp-shell::before {
  content: ""; position: absolute; top: 0; height: 2px; width: 56px;
  background: var(--edge); box-shadow: 0 0 10px var(--edge);
}
.world-panel-build .wp-shell::before { left: 0; }
.world-panel-info .wp-shell::before { right: 0; }
.wp-shell::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 40px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(79, 210, 255, .18), transparent);
  opacity: 0;
}
.wp-inner { flex: 1; min-width: 0; overflow-y: auto; padding: .85rem .95rem 1rem; }

.world-panel-build.opening { animation: unfold-right .42s cubic-bezier(.2, .8, .2, 1) .14s both; }
.world-panel-info.opening { animation: unfold-left .42s cubic-bezier(.2, .8, .2, 1) .14s both; }
.world-panel.opening .wp-shell::after { animation: scan .7s ease-out .45s both; }
.world-panel.opening .wp-inner > * { animation: rise .3s ease-out both; animation-delay: calc(.4s + var(--n, 0) * .05s); }
.world-panel.closing { animation: fold .18s ease-in both; }
@keyframes unfold-right {
  0% { clip-path: inset(49% 100% 49% 0); opacity: .5; }
  45% { clip-path: inset(49% 0 49% 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); }
}
@keyframes unfold-left {
  0% { clip-path: inset(49% 0 49% 100%); opacity: .5; }
  45% { clip-path: inset(49% 0 49% 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); }
}
@keyframes fold { to { clip-path: inset(49% 0 49% 0); opacity: 0; } }
@keyframes scan { 0% { opacity: 1; transform: translateY(-40px); } 100% { opacity: 0; transform: translateY(520px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.construct-leader {
  position: absolute; z-index: 2; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, rgba(79, 210, 255, .9), rgba(79, 210, 255, .35));
  box-shadow: 0 0 6px rgba(79, 210, 255, .7);
}
.construct-leader::after {
  content: ""; position: absolute; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.leader-build { transform-origin: left center; }
.leader-build::after { left: -2px; }
.leader-info { transform-origin: right center; background: linear-gradient(90deg, rgba(79, 210, 255, .35), rgba(79, 210, 255, .9)); }
.leader-info::after { right: -2px; }
.construct-leader.opening { animation: leader-in .2s ease-out both; }
.construct-leader.closing, .construct-reticle.closing { animation: fade-out .15s ease-in both; }
@keyframes leader-in { from { transform: scaleX(0); } }
@keyframes fade-out { to { opacity: 0; } }

.construct-reticle { position: absolute; z-index: 1; pointer-events: none; }
.construct-reticle::before, .construct-reticle::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
}
.construct-reticle::before { border: 1px dashed rgba(79, 210, 255, .55); animation: spin 24s linear infinite; }
.construct-reticle::after {
  inset: -6px; border: 2px solid transparent;
  border-top-color: rgba(79, 210, 255, .85); border-bottom-color: rgba(79, 210, 255, .85);
  animation: spin 6s linear infinite reverse;
}
.construct-reticle.opening { animation: reticle-in .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reticle-in { from { opacity: 0; transform: scale(1.6); } }

.wp-head { position: relative; margin-bottom: .6rem; padding-right: 1.5rem; }
.world-panel-info .wp-head { padding-right: 0; }
.wp-eyebrow {
  font-family: "Orbitron", sans-serif; font-size: .64rem; letter-spacing: .24em; text-transform: uppercase;
  color: var(--accent);
}
.wp-title { margin: .1rem 0 0; font-size: 1.35rem; font-weight: 600; line-height: 1.15; }
.wp-close {
  position: absolute; top: -.2rem; right: -.25rem; width: 28px; height: 28px;
  font: inherit; font-size: 1.3rem; line-height: 1; color: var(--muted);
  background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
}
.wp-close:hover { color: var(--text); border-color: var(--panel-edge); }
.wp-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.wp-chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .5rem;
  font-size: .8rem; font-weight: 600; border: 1px solid var(--panel-edge); border-radius: 999px; background: rgba(4, 8, 18, .6);
}
.wp-dot { width: 8px; height: 8px; border-radius: 50%; }
.terrain-superhot { color: #ff8a4c; } .terrain-hot { color: #f7cf7f; } .terrain-neutral { color: #7fe0a0; }
.terrain-cold { color: #9fd0ff; } .terrain-supercold { color: #d9f0ff; } .terrain-barren { color: #b9ada0; }
.wp-facts { margin: 0 0 .75rem; font-size: .9rem; }
.wp-facts div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border-bottom: 1px dashed rgba(127, 147, 173, .18); }
.wp-facts dt { color: var(--muted); }
.wp-facts dd { margin: 0; font-weight: 600; text-align: right; }
.wp-section { margin-top: .8rem; }
.wp-section-title, .slot-group-head, .detail-sub {
  margin: 0 0 .4rem; font-family: "Orbitron", sans-serif; font-weight: 500;
  font-size: .64rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.prod-table { font-size: .9rem; font-variant-numeric: tabular-nums; }
.prod-row { display: grid; grid-template-columns: 1fr 3rem 3.4rem 3rem; gap: .25rem; padding: .22rem 0; text-align: right; }
.prod-row > :first-child { text-align: left; }
.prod-header { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; padding-top: 0; }
.prod-name { font-weight: 600; }
.prod-credits .prod-name { color: #ffd76a; } .prod-bms .prod-name { color: #9fb8d4; } .prod-food .prod-name { color: #8fdc8a; }
.prod-mult { color: var(--accent); }
.prod-total { font-weight: 700; }
.meter { margin-bottom: .45rem; }
.meter-top { display: flex; justify-content: space-between; font-size: .85rem; }
.meter-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-bar { height: 4px; margin-top: .2rem; background: rgba(127, 147, 173, .18); border-radius: 2px; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 2px; transition: width .3s ease; }

.world-panel { --industrial: #f7c96a; --special: #b98cff; --defense: #ff8a7a; --wall: #c9b79a; --orbit: #4fd2ff; --weapon: #ff7a5c;
  --planetary: #7fe0a0; --lunar: #a9c8ff; --extra: #ffc466; --space: #e08bff; --colony: #8fe3ff; }
.fill-industrial { background: var(--industrial); } .fill-special { background: var(--special); }
.fill-defense { background: var(--defense); } .fill-wall { background: var(--wall); } .fill-orbit { background: var(--orbit); }

.wp-note { margin: 0 0 .6rem; padding: .4rem .55rem; font-size: .85rem; color: var(--muted);
  border-left: 2px solid var(--panel-edge); background: rgba(4, 8, 18, .5); }
.wp-note.admin { color: var(--warn); border-left-color: var(--warn); }
.wp-flash { margin: 0 0 .6rem; padding: .4rem .55rem; font-size: .85rem; color: var(--bad);
  border-left: 2px solid var(--bad); background: rgba(255, 107, 125, .08); }
.wp-empty { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }

.slot-group { margin-bottom: .85rem; }
.slot-group-head { display: flex; justify-content: space-between; align-items: baseline; }
.group-industrial .slot-group-head span:first-child { color: var(--industrial); }
.group-special .slot-group-head span:first-child { color: var(--special); }
.group-defense .slot-group-head span:first-child { color: var(--defense); }
.group-orbit .slot-group-head span:first-child { color: var(--orbit); }
.slot-count { font-family: "Rajdhani", sans-serif; font-size: .85rem; letter-spacing: .04em; }
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.slot-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  min-height: 74px; padding: .45rem .3rem .4rem;
  font: inherit; color: var(--text); text-align: center;
  background: rgba(4, 8, 18, .55); border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.slot-tile:hover { border-color: var(--accent); background: rgba(79, 210, 255, .08); transform: translateY(-1px); }
.slot-tile:focus-visible, .wp-btn:focus-visible, .wp-back:focus-visible, .wp-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.slot-tile.empty { border-style: dashed; color: var(--muted); }
.wp-view.enter .slot-tile { animation: tile-in .26s ease-out both; animation-delay: calc(var(--i, 0) * .03s); }
@keyframes tile-in { from { opacity: 0; transform: scale(.9); } }
.tile-plus { font-size: 1.3rem; line-height: 1; }
.tile-name { font-size: .78rem; font-weight: 600; line-height: 1.1; }
.slot-tile.walled { padding-top: 1.15rem; border-color: rgba(201, 183, 154, .55); }
.slot-tile.walled::before {
  content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 7px;
  background:
    linear-gradient(90deg, var(--wall) 0 60%, transparent 60% 100%) 0 0 / 12px 4px repeat-x,
    linear-gradient(var(--wall), var(--wall)) 0 4px / 100% 3px no-repeat;
  opacity: .85;
}
.wall-band {
  position: absolute; top: 9px; left: 0; right: 0;
  font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--wall);
}

.bicon {
  --tone: var(--accent);
  position: relative; display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px;
  color: var(--tone);
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--tone) 32%, transparent), transparent 70%),
    linear-gradient(160deg, rgba(26, 38, 64, .95), rgba(6, 10, 20, .95));
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  border-radius: 6px;
  box-shadow: inset 0 0 10px color-mix(in srgb, var(--tone) 22%, transparent), 0 0 8px color-mix(in srgb, var(--tone) 18%, transparent);
}
.bicon::after {
  content: ""; position: absolute; inset: 2px; border-radius: 4px; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), transparent 45%);
}
.bicon svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 2px color-mix(in srgb, var(--tone) 70%, transparent));
}
.bicon svg .fill { fill: currentColor; fill-opacity: .22; stroke: none; }
.bicon svg .solid { fill: currentColor; stroke: none; }
.bicon-industrial { --tone: var(--industrial); } .bicon-special { --tone: var(--special); }
.bicon-defense { --tone: var(--defense); } .bicon-wall { --tone: var(--wall); }
.bicon-orbit { --tone: var(--orbit); } .bicon-weapon { --tone: var(--weapon); }
.bicon-planetary { --tone: var(--planetary); } .bicon-lunar { --tone: var(--lunar); }
.bicon-extra { --tone: var(--extra); } .bicon-space { --tone: var(--space); }
.bicon-xs { width: 18px; height: 18px; border-radius: 4px; }
.bicon-xs svg { width: 13px; height: 13px; stroke-width: 1.8; }
.slot-tile.filled .bicon { width: 38px; height: 38px; }
.slot-tile.filled .bicon svg { width: 26px; height: 26px; }
.slot-tile.filled .bicon-xs { width: 18px; height: 18px; }
.slot-tile.filled .bicon-xs svg { width: 13px; height: 13px; }
.tile-weapons { display: flex; gap: 3px; min-height: 18px; align-items: center; }
.mount-empty { width: 14px; height: 14px; border: 1px dashed rgba(220, 232, 247, .35); border-radius: 3px; }
.arm-art { display: inline-block; flex: none; width: 56px; height: 28px; border: 1px solid var(--panel-edge); border-radius: 4px; background: rgba(4, 8, 18, .55); }
.slot-tile .arm-art { width: 48px; height: 24px; }
.slot-tile .arm-art.xs { width: 24px; height: 14px; border-radius: 3px; }
.arm-grid { margin-top: .45rem; }
.slot-tile.locked { cursor: default; color: var(--muted); border-style: dotted; opacity: .6; }
.slot-tile.locked:hover { transform: none; border-color: var(--panel-edge); background: rgba(4, 8, 18, .55); }
.tile-lock { position: relative; width: 12px; height: 9px; margin-top: 7px; border-radius: 2px; background: var(--muted); }
.tile-lock::before {
  content: ""; position: absolute; left: 2px; top: -7px; width: 8px; height: 8px;
  border: 2px solid var(--muted); border-bottom: 0; border-radius: 5px 5px 0 0; box-sizing: border-box;
}
.dev-stage { display: flex; align-items: center; gap: .55rem; margin-bottom: .45rem; }
.dev-pips { display: inline-flex; gap: 4px; }
.dev-pips i { width: 9px; height: 9px; transform: rotate(45deg); border: 1px solid rgba(220, 232, 247, .4); }
.dev-pips i.on { background: var(--good); border-color: var(--good); box-shadow: 0 0 5px var(--good); }
.dev-label { font-weight: 700; }
.dev-stage-0 .dev-label { color: var(--muted); }
.dev-stage-4 .dev-label { color: var(--good); }
.meter-bar { position: relative; }
.fill-dev { background: linear-gradient(90deg, #3fb98a, var(--good)); }
.meter-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(4, 8, 18, .9); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 6px; height: 6px; transform: rotate(45deg); border: 1px solid rgba(220, 232, 247, .45); }
.pips i.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 4px var(--accent); }

.wp-back {
  margin: 0 0 .4rem; padding: 0; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--accent); background: none; border: 0; cursor: pointer;
}
.wp-back:hover { text-decoration: underline; }
.detail-title { margin: 0 0 .6rem; font-size: 1.05rem; font-weight: 600; }
.detail-industrial { color: var(--industrial); } .detail-special { color: var(--special); }
.detail-defense { color: var(--defense); } .detail-orbit { color: var(--orbit); } .detail-weapon { color: var(--weapon); }
.detail-sub { margin-top: .8rem; }
.wp-view.detail.enter { animation: slide-in .24s ease-out both; }
.wp-view:not(.detail).enter { animation: slide-back .24s ease-out both; }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } }
@keyframes slide-back { from { opacity: 0; transform: translateX(-14px); } }
.option-list { display: grid; gap: .4rem; }
.option-card, .built-card {
  padding: .55rem .6rem; background: rgba(4, 8, 18, .55); border: 1px solid var(--panel-edge); border-radius: 3px;
}
.wp-view.enter .option-card { animation: rise .25s ease-out both; animation-delay: calc(.05s + var(--i, 0) * .035s); }
.world-panel.opening .wp-inner > .wp-view.enter { animation-delay: calc(.4s + var(--n, 0) * .05s); }
.world-panel.opening .wp-view.enter .slot-tile { animation-delay: calc(.5s + var(--i, 0) * .03s); }
.world-panel.opening .wp-view.enter .option-card { animation-delay: calc(.5s + var(--i, 0) * .035s); }
.option-card:hover { border-color: rgba(79, 210, 255, .5); }
.built-card { border-color: rgba(79, 210, 255, .45); box-shadow: inset 0 0 18px rgba(79, 210, 255, .06); }
.option-head { display: flex; align-items: center; gap: .55rem; }
.option-head > div { flex: 1; min-width: 0; }
.option-name { font-weight: 700; line-height: 1.15; }
.option-tiers { font-size: .78rem; color: var(--muted); }
.option-desc { margin: .4rem 0 .5rem; font-size: .86rem; line-height: 1.3; color: #b7c6d9; }
.option-foot, .action-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.option-foot .cost, .action-row .cost { flex: 1; }
.action-row { padding-top: .45rem; margin-top: .4rem; border-top: 1px dashed rgba(127, 147, 173, .2); }
.action-label { flex: 1 1 100%; font-size: .82rem; color: var(--muted); }
.demolish-row { justify-content: flex-end; }
.demolish-warn { flex: 1; font-size: .85rem; font-weight: 600; color: var(--bad); }
.maxed { font-size: .85rem; color: var(--good); }
.cost { display: inline-flex; gap: .6rem; font-size: .8rem; font-variant-numeric: tabular-nums; }
.cost-credits { color: #ffd76a; } .cost-bms { color: #9fb8d4; }
.wp-btn {
  padding: .3rem .75rem; font: inherit; font-size: .85rem; font-weight: 700; letter-spacing: .04em;
  color: var(--text); background: rgba(127, 147, 173, .14); border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer;
}
.wp-btn:hover:not(:disabled) { border-color: var(--accent); }
.wp-btn.primary { color: #04121c; background: var(--accent); border-color: var(--accent); }
.wp-btn.primary:hover:not(:disabled) { background: #8ae3ff; }
.wp-btn.danger { color: #fff; background: #c8384b; border-color: #ff6b7d; }
.wp-btn.danger-outline { color: var(--bad); background: none; border-color: rgba(255, 107, 125, .5); }
.wp-btn.danger-outline:hover:not(:disabled) { border-color: var(--bad); background: rgba(255, 107, 125, .1); }
.wp-btn:disabled { opacity: .45; cursor: not-allowed; }


.map-controls { align-items: center; }
.map-controls button { display: inline-grid; place-items: center; padding: 0; }
.map-controls button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.map-controls button:disabled { opacity: .35; cursor: default; border-color: var(--panel-edge); color: var(--text); }
.map-controls button.active { color: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 8px var(--accent-dim); }
.control-gap { width: .35rem; }
.help-button { font-weight: 700; }

.minimap {
  position: absolute; top: .75rem; right: .75rem; z-index: 2; width: 184px; aspect-ratio: 1;
  border: 1px solid var(--panel-edge); border-radius: 3px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(79, 210, 255, .05);
  animation: fade-in .2s ease-out both;
}
.map-legend {
  position: absolute; right: .75rem; bottom: 3.6rem; z-index: 2; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem .75rem;
  max-width: calc(100% - 1.5rem); padding: .35rem .6rem; pointer-events: none;
  font-size: .75rem; letter-spacing: .06em; color: var(--muted);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 3px;
}
.map-legend[hidden] { display: none; }
.map-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.map-legend i { width: 10px; height: 10px; border-radius: 2px; opacity: .85; }
.minimap canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

.tooltip {
  position: fixed; z-index: 70; max-width: 270px; padding: .5rem .65rem; pointer-events: none;
  font-size: .85rem; line-height: 1.3; color: var(--text);
  background: rgba(8, 14, 28, .97); border: 1px solid var(--panel-edge); border-radius: 3px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .55);
  animation: fade-in .12s ease-out both;
}
.tip-title { font-weight: 700; margin-bottom: .15rem; }
.tip-line { color: var(--muted); }
.tip-desc { margin: .2rem 0; color: #b7c6d9; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.panel-head .panel-title { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-nav { display: flex; gap: .3rem; flex: none; }
.system-nav button {
  width: 28px; height: 26px; padding: 0; font: inherit; font-size: 1.1rem; line-height: 1; color: var(--text);
  background: rgba(4, 8, 18, .6); border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer;
}
.system-nav button:hover { border-color: var(--accent); color: var(--accent); }
.system-list { display: grid; gap: .15rem; max-height: 340px; overflow-y: auto; margin-right: -.35rem; padding-right: .35rem; }
.system-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; width: 100%;
  padding: .3rem .4rem; text-align: left; font: inherit; color: var(--text);
  background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
}
.system-row:hover { background: rgba(79, 210, 255, .07); }
.system-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.system-row.active { background: var(--accent-dim); border-color: rgba(79, 210, 255, .45); }
.system-moon { padding-left: 1.6rem; }
.system-icon { width: 26px; height: 26px; border-radius: 50%; }
.system-text { display: grid; min-width: 0; }
.system-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-meta { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-badges { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--orbit, #4fd2ff); }
.system-stage { display: inline-flex; gap: 2px; }
.system-stage i { width: 5px; height: 5px; transform: rotate(45deg); border: 1px solid rgba(220, 232, 247, .4); }
.system-stage i.on { background: var(--good); border-color: var(--good); }
.system-platforms { color: #ff9a7c; font-weight: 600; }

.search-heading { display: flex !important; justify-content: space-between; padding: .2rem .45rem !important; }
.search-heading .search-meta { text-transform: uppercase; letter-spacing: .14em; font-size: .7rem; }
.search-clear { font: inherit; font-size: .78rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; }
.search-clear:hover { text-decoration: underline; }
.search-cell {
  grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 3px;
  font-family: "Orbitron", sans-serif; font-weight: 700; color: var(--accent); background: #02030a;
  border: 1px dashed var(--panel-edge);
}

.help-card { width: min(520px, 100%); }
.help-groups { max-height: min(62vh, 560px); overflow-y: auto; }
.help-group > summary { cursor: pointer; padding: .35rem 0 .15rem; font-weight: 700; color: var(--accent); }
.help-list { margin: 0 0 .4rem; display: grid; gap: .1rem; }
.help-intro { margin: 0 0 .3rem; font-size: .85rem; }
.help-notice { min-height: 1.1em; margin: 0 0 .3rem; font-size: .85rem; color: var(--accent); }
.help-key { min-width: 2.4rem; padding: .15rem .5rem; font: inherit; font-size: .85rem; font-weight: 700; color: var(--text); background: rgba(79, 210, 255, .06);
  border: 1px solid var(--panel-edge); border-bottom-width: 2px; border-radius: 4px; cursor: pointer; }
.help-key:hover { border-color: var(--accent); }
.help-key.changed { color: var(--accent); }
.help-key.waiting { border-color: var(--accent); background: rgba(79, 210, 255, .18); }
.help-list div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed rgba(127, 147, 173, .2); }
.help-list dt { font-size: .92rem; }
.help-list dt small { display: block; color: var(--muted); font-size: .78rem; }
.help-list dd { margin: 0; display: flex; gap: .25rem; flex: none; }
kbd {
  min-width: 1.6rem; padding: .1rem .4rem; text-align: center;
  font: 600 .8rem "Rajdhani", sans-serif; color: var(--text);
  background: rgba(4, 8, 18, .8); border: 1px solid var(--panel-edge); border-bottom-width: 2px; border-radius: 3px;
}

.wp-tabs { display: none; }
.ghost { position: relative; display: inline-grid; opacity: .55; filter: saturate(.6); }
.ghost::after { content: ""; position: absolute; inset: -3px; border: 1px dashed currentColor; border-radius: 8px; color: rgba(220, 232, 247, .5); }
.slot-tile.planned { border-style: dashed; border-color: rgba(220, 232, 247, .35); }
.slot-tile.inactive { opacity: .5; filter: grayscale(.8); }
.slot-tile.damaged { border-color: rgba(255, 107, 92, .7); background: repeating-linear-gradient(135deg, rgba(255, 107, 92, .1) 0 6px, transparent 6px 12px); }
.slot-tile.damaged .tile-name { color: #ff8a7a; }
.slot-tile.damaged .badge, .slot-tile.damaged svg { filter: grayscale(.85); opacity: .6; }
.repair-row .action-label { color: #ff8a7a; }
.repair-note { color: #ffbe5c; }
.planned-band { color: var(--muted) !important; }
.plan-tag {
  flex: none; padding: .05rem .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--warn); border: 1px solid rgba(247, 207, 127, .5); border-radius: 999px;
}
.plan-banner {
  display: flex; align-items: center; gap: .55rem; margin-bottom: .45rem; padding: .4rem .5rem;
  background: rgba(247, 207, 127, .07); border: 1px dashed rgba(247, 207, 127, .45); border-radius: 3px;
}
.option-card.is-planned { border-color: rgba(247, 207, 127, .55); }
.wp-btn.active { color: var(--warn); border-color: rgba(247, 207, 127, .6); }
.preview {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem; margin: -.1rem 0 .5rem;
  font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--muted);
}
.action-row .preview { flex: 1 1 100%; margin: 0; }
.preview-label { font-weight: 700; color: var(--text); }
.preview-up span:nth-child(2), .preview-up .preview-total { color: var(--good); }
.preview-down span:nth-child(2), .preview-down .preview-total { color: var(--bad); }
.wp-notice { margin: 0 0 .6rem; padding: .4rem .55rem; font-size: .85rem; color: var(--good);
  border-left: 2px solid var(--good); background: rgba(108, 240, 176, .07); }
.wp-tools { margin-top: .4rem; border-top: 1px solid var(--panel-edge); padding-top: .55rem; }
.wp-tools summary {
  cursor: pointer; list-style: none; font-family: "Orbitron", sans-serif; font-size: .7rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent);
}
.wp-tools summary::-webkit-details-marker { display: none; }
.wp-tools summary::before { content: "▸"; display: inline-block; margin-right: .45rem; transition: transform .15s; }
.wp-tools[open] summary::before { transform: rotate(90deg); }
.tool-row { display: flex; align-items: center; gap: .45rem; padding: .25rem 0; flex-wrap: wrap; }
.tool-row .wp-btn { padding: .25rem .6rem; }
.tool-label { flex: 1; min-width: 0; font-size: .88rem; }
.tool-label small { color: var(--muted); }
.tool-all .tool-label { font-weight: 700; }
.tool-note { margin: .2rem 0 0; font-size: .82rem; color: var(--muted); }

.map-frame.construct-narrow .construct-leader { display: none; }
.map-frame.construct-narrow .world-panel {
  left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-height: 52% !important;
}
.map-frame.construct-narrow .wp-shell { clip-path: none; border-left: 0; border-right: 0; border-bottom: 0; }
.map-frame.construct-narrow .wp-shell::before { left: 0; right: auto; }
.map-frame.construct-narrow[data-construct-tab="build"] .world-panel-info,
.map-frame.construct-narrow[data-construct-tab="info"] .world-panel-build { display: none !important; }
.map-frame.construct-narrow .wp-tabs {
  position: sticky; top: -.85rem; z-index: 1; display: flex; gap: .3rem; margin: -.85rem -.95rem .7rem; padding: .5rem .6rem;
  background: rgba(10, 18, 36, .98); border-bottom: 1px solid var(--panel-edge);
}
.map-frame.construct-narrow .wp-close { display: none; }
.wp-tab {
  flex: 1; padding: .45rem; font: inherit; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
}
.wp-tab.active { color: var(--accent); border-color: var(--panel-edge); background: var(--accent-dim); }
.wp-tab-close { width: 40px; font-size: 1.4rem; color: var(--muted); background: none; border: 0; cursor: pointer; }

.titled { display: flex; align-items: center; gap: .35rem; }
.titled > span { min-width: 0; overflow-wrap: anywhere; }
.wp-rename {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0;
  color: var(--muted); background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
}
.wp-rename svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wp-rename:hover { color: var(--accent); border-color: var(--panel-edge); }
.wp-rename:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.rename-overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(2, 4, 10, .6); backdrop-filter: blur(2px);
  animation: fade-in .15s ease-out both;
}
.rename-card {
  width: min(380px, 100%); padding: 1rem 1.1rem 1.05rem;
  background: linear-gradient(180deg, rgba(14, 24, 46, .98), rgba(8, 14, 30, .98));
  border: 1px solid var(--panel-edge); box-shadow: 0 18px 40px rgba(0, 0, 0, .6);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  animation: rise .2s ease-out both;
}
.rename-eyebrow { font-family: "Orbitron", sans-serif; font-size: .64rem; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); }
.rename-title { margin: .15rem 0 .8rem; font-size: 1.3rem; font-weight: 600; overflow-wrap: anywhere; }
.rename-field { display: grid; gap: .3rem; font-size: .8rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.rename-field input {
  padding: .5rem .65rem; font: inherit; font-size: 1rem; letter-spacing: normal; text-transform: none; color: var(--text);
  background: rgba(4, 8, 18, .8); border: 1px solid var(--panel-edge); border-radius: 3px;
}
.rename-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.rename-hint { margin: .45rem 0 0; font-size: .8rem; color: var(--muted); }
.rename-error { margin: .5rem 0 0; font-size: .85rem; color: var(--bad); }
.rename-actions { display: flex; align-items: center; gap: .4rem; margin-top: .9rem; flex-wrap: wrap; }
.rename-spacer { flex: 1; }
.rename-reset { color: var(--muted); }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .world-panel, .world-panel *, .construct-leader, .construct-reticle, .construct-reticle::before,
  .construct-reticle::after, .context-menu, .rename-overlay, .rename-card { animation: none !important; transition: none !important; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { padding: 0 12px; gap: .5rem; }
  .brand-name { font-size: .8rem; letter-spacing: .12em; }
  .topbar-right { gap: .7rem; }
  .status { gap: .6rem; }
  .status dt { display: none; }
  .admin-switch > span:first-child { display: none; }
  .layout { height: auto; grid-template-columns: 1fr; padding: .6rem 12px; }
  .map-frame { order: -1; height: calc(100dvh - var(--topbar) - 1.2rem); min-height: 420px; }
  .sidebar { overflow: visible; }
  .minimap { width: 118px; top: .6rem; right: .6rem; }
  .map-search { top: .6rem; left: .6rem; width: calc(100% - 1.2rem); }
  .map-frame:has(.minimap:not([hidden])) .map-search { width: calc(100% - 118px - 1.8rem); }
  .map-hud { left: .6rem; right: .6rem; bottom: .6rem; }
  #map-coords { display: none; }
  .map-controls { flex-wrap: wrap; justify-content: flex-end; }
  .help-button { display: none !important; }
  .map-frame.construct-narrow .map-hud { display: none; }
}

@media (max-width: 420px) {
  .brand-mark { display: none; }
  .status div:last-child { display: none; }
}

@media (pointer: coarse) {
  .map-controls button { width: 40px; height: 40px; }
  .context-item { min-height: 44px; }
  .slot-tile { min-height: 82px; }
  .wp-btn { padding: .45rem .85rem; }
  .system-row { padding: .5rem .4rem; }
  .search-result { min-height: 48px; }
}

.group-planetary .slot-group-head span:first-child { color: var(--planetary); }
.group-lunar .slot-group-head span:first-child { color: var(--lunar); }
.group-extra .slot-group-head span:first-child { color: var(--extra); }
.group-space .slot-group-head span:first-child { color: var(--space); }
.detail-planetary { color: var(--planetary); } .detail-lunar { color: var(--lunar); }
.detail-extra { color: var(--extra); } .detail-space { color: var(--space); }
.chip-extra { color: var(--extra); } .chip-space { color: var(--space); }
.world-icon { flex: none; display: block; }
.world-tile .tile-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lunar-grid { display: grid; grid-template-columns: 4.6rem 1fr 1fr; gap: .35rem; align-items: stretch; }
.lunar-label { display: flex; flex-direction: column; justify-content: center; font-size: .8rem; font-weight: 600; line-height: 1.15; }
.lunar-label small { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lunar-label.muted { opacity: .55; }
.world-card { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; padding: .5rem .6rem;
  background: rgba(4, 8, 18, .55); border: 1px solid var(--panel-edge); border-radius: 3px; }
.mega-card { border-color: color-mix(in srgb, var(--extra) 28%, var(--panel-edge)); }
.mega-card .option-foot { justify-content: space-between; }
.biome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; margin: .3rem 0 .5rem; }
.biome-choice {
  display: flex; align-items: center; gap: .35rem; padding: .35rem .45rem; font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--text); background: rgba(4, 8, 18, .6); border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer;
}
.biome-choice i { width: 10px; height: 10px; border-radius: 50%; background: var(--biome); box-shadow: 0 0 6px var(--biome); }
.biome-choice:hover:not(:disabled), .biome-choice.active { border-color: var(--biome); background: color-mix(in srgb, var(--biome) 12%, rgba(4, 8, 18, .6)); }
.biome-choice:disabled { opacity: .45; cursor: default; }
.candidate-list { display: grid; gap: .25rem; margin-top: .5rem; max-height: 320px; overflow-y: auto; }
.candidate {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .5rem; padding: .3rem .45rem;
  font: inherit; color: var(--text); text-align: left; background: rgba(4, 8, 18, .55);
  border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer;
}
.candidate:hover, .candidate.active { border-color: #78f0aa; background: rgba(120, 240, 170, .08); }
.candidate-name { font-weight: 600; }
.candidate-meta { color: var(--muted); font-size: .8rem; }
.pick-confirm { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; margin: .4rem 0;
  padding: .5rem .6rem; border: 1px solid rgba(120, 240, 170, .55); border-radius: 3px; background: rgba(120, 240, 170, .07); }
.mega-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.mega-list li { display: grid; grid-template-columns: auto 1fr; column-gap: .45rem; align-items: center; font-size: .88rem; }
.mega-list li small { grid-column: 2; color: var(--muted); font-size: .76rem; }
.mega-dismantle { border-top-color: rgba(255, 107, 125, .35); }
#galaxy-map.picking { cursor: crosshair; }
.map-frame.construct-picking .world-panel-info, .map-frame.construct-picking .construct-leader,
.map-frame.construct-picking .construct-reticle { display: none !important; }

.context-item { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; white-space: nowrap; }
.context-item small { font-size: .74rem; font-weight: 500; color: var(--muted); font-style: normal; }
.context-item.danger { color: #ff7d8c; }
.context-item.danger:hover:not(:disabled), .context-item.danger:focus-visible { background: rgba(255, 107, 125, .16); color: #ffb3bc; }
.context-item.has-submenu::after { content: "›"; margin-left: auto; color: inherit; opacity: .8; }
.context-item.checked::before { content: "●"; font-size: .55rem; color: var(--accent); margin-right: .1rem; align-self: center; }
.context-group { position: relative; }
.context-submenu { position: absolute; left: calc(100% + .3rem); top: -.3rem; min-width: 150px; }
.context-group.flip > .context-submenu { left: auto; right: calc(100% + .3rem); }
.context-heading.danger { color: #ff7d8c; }
.context-note { margin: .1rem .6rem .45rem; max-width: 240px; font-size: .84rem; color: var(--muted); white-space: normal; }
.context-confirm { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; }
.context-confirm .context-item { justify-content: center; }
.admin-hint, .admin-toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 30; padding: .45rem .8rem;
  font-weight: 600; font-size: .9rem; border-radius: 3px; pointer-events: none;
  background: rgba(8, 14, 28, .94); border: 1px solid rgba(255, 107, 125, .6); color: #ffb3bc;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.admin-hint { top: 4.2rem; }
.admin-toast { bottom: 4.2rem; border-color: var(--panel-edge); color: var(--text); }
.admin-toast.error { border-color: rgba(255, 107, 125, .7); color: #ffb3bc; }
.group-colony .slot-group-head span:first-child { color: var(--colony); }
.detail-colony { color: var(--colony); }
.bicon-colony { --tone: var(--colony); }
.fill-colony { background: var(--colony); }
.colony-tile .tile-sub { color: var(--defense); }
.slot-tile.habitat-slot { border-color: rgba(143, 227, 255, .35); box-shadow: inset 0 -2px 0 rgba(143, 227, 255, .35); }
.context-submenu.scrolling { max-height: min(60vh, 300px); overflow-y: auto; }

html.lazy-loading, html.lazy-loading * { cursor: progress !important; }
.stage-next { display: flex; align-items: flex-start; gap: .5rem; margin: .1rem 0 .5rem; padding: .4rem .5rem; border: 1px dashed rgba(79, 210, 255, .3); border-radius: 3px; background: rgba(79, 210, 255, .04); }
.stage-next > span:last-child { display: grid; gap: .1rem; min-width: 0; }
.stage-next strong { font-size: .85rem; color: var(--accent); }
.stage-next small { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.panel-toggle { cursor: pointer; user-select: none; }
.panel-toggle::after { content: "▾"; display: inline-block; margin-left: .45rem; font-size: .8em; opacity: .6; transition: transform .15s ease; }
.panel.collapsed .panel-toggle::after { transform: rotate(-90deg); }
.panel-toggle:hover { color: #bdefff; }
.panel.collapsed { padding-bottom: .55rem; }
.panel.collapsed > .panel-title { margin-bottom: 0; }
.panel.collapsed > :not(.panel-title):not(.panel-head), .panel.collapsed > .panel-head > :not(.panel-title) { display: none; }
.panel.collapsed > .panel-head { margin-bottom: 0; }

.wp-control { display: grid; gap: .4rem; margin-bottom: .8rem; }
.wp-owner strong { font-weight: 700; }
.wp-control select { min-width: 0; max-width: 100%; height: 30px; padding: 0 .4rem; font: inherit; color: var(--text); background: rgba(4, 8, 18, .85); border: 1px solid var(--panel-edge); border-radius: 3px; }
.wp-control-actions { flex-wrap: wrap; }
.sidebar > .panel.dragging { opacity: .45; outline: 1px dashed var(--accent); }
.panel-reset { align-self: center; margin: .2rem 0 .6rem; padding: .25rem .6rem; font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 1px solid var(--panel-edge); border-radius: 3px; cursor: pointer; }
.panel-reset:hover { color: var(--accent); border-color: var(--accent); }
.stat-line { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .5rem; }
.stat-chip { display: inline-flex; align-items: baseline; gap: .35rem; padding: .12rem .45rem; font-size: .8rem; color: #dce8f7; background: rgba(79, 210, 255, .07); border: 1px solid rgba(79, 210, 255, .25); border-radius: 2px; }
.stat-chip small { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-chip strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-chip em { font-style: normal; color: #8be0a4; }
.over-cap { color: #ff7a7a !important; }
.economy-note { margin: .35rem 0 0; font-size: .74rem; }
.ov-caps { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.ov-cap { display: inline-flex; align-items: baseline; gap: .35rem; padding: .2rem .5rem; font-size: .82rem; border: 1px solid rgba(79, 210, 255, .25); border-radius: 2px; background: rgba(79, 210, 255, .06); }
.ov-cap small { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ov-cap strong { font-variant-numeric: tabular-nums; }
button.ov-cap { font: inherit; font-size: .82rem; color: var(--text); cursor: pointer; }
button.ov-cap:hover, button.ov-cap:focus-visible { border-color: var(--accent); background: rgba(79, 210, 255, .14); }
.cap-link { cursor: pointer; border-radius: 2px; text-decoration: underline dotted rgba(79, 210, 255, .45); text-underline-offset: 3px; }
.cap-link:hover, .cap-link:focus-visible { color: var(--accent); text-decoration-color: var(--accent); outline: none; }
.host-block { display: grid; gap: .35rem; margin: .3rem 0 .6rem; }
.host-block .detail-sub { display: flex; align-items: baseline; gap: .3rem; margin: .3rem 0 0; }
.host-count { font-variant-numeric: tabular-nums; color: #dce8f7; }

.work-bar { display: grid; gap: .25rem; min-width: 0; }
.work-line { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; font-size: .8rem; }
.work-label { font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-eta { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.work-track { position: relative; height: 6px; overflow: hidden; background: rgba(4, 8, 18, .85); border: 1px solid rgba(31, 53, 86, .9); border-radius: 2px; }
.work-track i { position: absolute; inset: 0 auto 0 0; width: 0; }
.work-cap { background: repeating-linear-gradient(135deg, rgba(247, 207, 127, .28) 0 4px, rgba(247, 207, 127, .1) 4px 8px); }
.work-fill { background: linear-gradient(90deg, #2a7bb0, var(--accent)); box-shadow: 0 0 8px rgba(79, 210, 255, .45); transition: width .9s linear; }
.work-bar.paused .work-fill { background: linear-gradient(90deg, #8a6d2c, var(--warn)); box-shadow: none; }
.work-bar.paused .work-label { color: var(--warn); }
.slot-tile.building { border-style: dashed; border-color: rgba(79, 210, 255, .55); background: repeating-linear-gradient(135deg, rgba(79, 210, 255, .07) 0 6px, transparent 6px 12px); }
.slot-tile .tile-progress { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(4, 8, 18, .8); overflow: hidden; }
.slot-tile .tile-progress i { display: block; height: 100%; background: var(--accent); }
.slot-tile.upgrading .pips { outline: 1px dashed rgba(79, 210, 255, .6); outline-offset: 2px; }
.work-banner {
  display: grid; gap: .45rem; margin-bottom: .45rem; padding: .5rem .55rem;
  background: rgba(79, 210, 255, .06); border: 1px dashed rgba(79, 210, 255, .45); border-radius: 3px;
}
.work-banner-head { display: flex; align-items: center; gap: .55rem; }
.work-banner-head .tool-label { flex: 1; min-width: 0; }
.work-time { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.option-foot .work-time { margin-right: auto; padding-left: .4rem; }
.fund-grid { display: grid; gap: .45rem; }
.fund-row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, auto); align-items: center; gap: .5rem; font-size: .82rem; }
.fund-row .fund-name { font-weight: 700; }
.fund-row .fund-numbers { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.fund-row .work-track { grid-column: 1 / -1; }
.fund-row.done .fund-numbers { color: var(--good); }
.fund-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.fund-form label { display: grid; align-content: end; gap: .15rem; min-width: 0; font-size: .75rem; color: var(--muted); }
.fund-form .fund-label { font-weight: 700; color: var(--text); }
.fund-form .fund-have { font-size: .7rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.project-card { min-width: 0; overflow-wrap: anywhere; }
.fund-form input {
  width: 100%; height: 30px; padding: 0 .4rem; font: inherit; font-weight: 600; color: var(--text);
  background: rgba(4, 8, 18, .85); border: 1px solid var(--panel-edge); border-radius: 3px; font-variant-numeric: tabular-nums;
}
.fund-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fund-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.fund-actions .tool-note { flex: 1 1 100%; margin: 0; }
.fund-who { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.fund-who strong { color: var(--text); font-weight: 600; }
.work-mini { position: absolute; left: 5px; right: 5px; bottom: 4px; gap: 0; }
.work-mini .work-line { display: none; }
.work-mini .work-track { height: 4px; }
.work-queue { display: grid; gap: .35rem; }
.work-row { align-items: center; }
.work-row-main { flex: 1; min-width: 0; }
.wp-production { display: grid; gap: .5rem; }
.wp-batch { padding: .35rem .45rem; background: rgba(4, 8, 18, .5); border: 1px solid rgba(31, 53, 86, .9); border-radius: 3px; }
.boot-loader { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: radial-gradient(ellipse at center, #0b1530, #03060f 75%); transition: opacity .45s ease; }
.boot-loader.leaving { opacity: 0; pointer-events: none; }
.boot-card { width: min(360px, calc(100vw - 32px)); display: grid; gap: .7rem; text-align: center; }
.boot-title { font-family: "Orbitron", sans-serif; font-weight: 700; font-size: 1.3rem; letter-spacing: .3em; color: #dce8f7; }
.boot-track { height: 6px; overflow: hidden; background: rgba(4, 8, 18, .85); border: 1px solid rgba(79, 210, 255, .35); border-radius: 3px; }
.boot-fill { width: 0; height: 100%; background: linear-gradient(90deg, #2a8fd6, #4fd2ff); box-shadow: 0 0 10px #4fd2ff; transition: width .25s ease; }
.boot-status { font-size: .85rem; color: #8aa0bd; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .boot-loader, .boot-fill { transition: none; } }

.crop-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px; background: rgba(2, 4, 10, .78); }
.crop-panel { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 18px; border: 1px solid var(--panel-edge); border-radius: 6px; background: var(--bg); color: var(--text); }
.crop-panel h3 { margin: 0 0 4px; font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: .06em; }
.crop-hint { margin: 0 0 12px; opacity: .7; font-size: 13px; }
.crop-body { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.crop-frame { flex: 1 1 260px; max-width: 320px; }
.crop-stage { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; border: 1px solid var(--accent);
  background: repeating-conic-gradient(#0d1424 0 25%, #070b16 0 50%) 0 0 / 16px 16px; }
.crop-stage:active { cursor: grabbing; }
.crop-previews { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 12px; opacity: .9; }
.crop-preview { border: 1px solid var(--panel-edge); border-radius: 3px; background: #070b16; }
.crop-zoom { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-percent { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.crop-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.hud-menu { position: relative; display: inline-flex; }
.hud-pop {
  position: absolute; right: 0; bottom: calc(100% + .4rem); z-index: 12; min-width: 220px; padding: .3rem;
  display: grid; gap: 2px; background: linear-gradient(180deg, rgba(14, 22, 40, .98), rgba(7, 11, 24, .98));
  border: 1px solid var(--panel-edge); border-top: 2px solid var(--accent); border-radius: 3px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
}
.hud-pop[hidden] { display: none; }
.hud-pop-head { padding: .2rem .5rem .3rem; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.map-controls .hud-pop button.hud-item {
  width: 100%; height: auto; min-height: 32px; display: flex; align-items: center; justify-content: flex-start; gap: .55rem; padding: .3rem .55rem;
  font-size: .9rem; letter-spacing: .02em; text-align: left; border-color: transparent; background: transparent; position: relative;
}
.map-controls .hud-pop button.hud-item[hidden] { display: none; }
.map-controls .hud-pop button.hud-item:hover { background: rgba(79, 210, 255, .08); border-color: var(--panel-edge); }
.map-controls .hud-pop button.hud-item svg { flex: none; }
.map-controls .hud-pop button.hud-item[aria-pressed="true"], .map-controls .hud-pop button.hud-item.active { color: var(--accent); box-shadow: none; }
.hud-check { width: 18px; flex: none; text-align: center; color: var(--accent); font-weight: 700; }
.hud-label { flex: 1; }
.map-controls button.hud-menu-button { position: relative; }
.hud-dot { min-width: 10px; height: 10px; top: -3px; right: -3px; padding: 0; }
.help-link {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; margin-left: .35rem; vertical-align: middle;
  font: 700 .8rem "Rajdhani", sans-serif; color: var(--accent); text-decoration: none;
  border: 1px solid var(--panel-edge); border-radius: 999px; background: rgba(79, 210, 255, .06);
}
.help-link:hover { border-color: var(--accent); background: rgba(79, 210, 255, .16); }
.help-titled { display: flex; align-items: center; gap: .1rem; }
.help-slot:empty { display: none; }
