/* Continuum — galaxy map.
   Avorion's language: deep space behind everything, the map is the screen,
   instruments float over it as thin holographic panels with clipped corners.
   Gold is the Continuum's faction colour; cyan is the interface; red is
   hostile; resources wear the game's own material colours. */

:root {
  --void: #060a14;
  --space: #0b1326;
  --glass: rgba(10, 18, 36, 0.74);
  --glass-hi: rgba(16, 28, 54, 0.9);
  --edge: rgba(98, 160, 230, 0.22);
  --edge-hi: rgba(120, 214, 255, 0.55);
  --text: #dbe7f7;
  --muted: #7f93b3;
  --holo: #57d6ff;
  --gold: #ffb53d;
  --gold-soft: rgba(255, 181, 61, 0.16);
  --hostile: #ff4b5c;
  --player: #ffffff;

  --iron: #c9a98a;
  --titanium: #e8ecf2;
  --naonite: #4ddc84;
  --trinium: #4b9bff;
  --xanion: #ffd84a;
  --ogonite: #ff8a3d;
  --avorion: #ff3d5e;

  --font: "Saira", "Segoe UI", system-ui, sans-serif;
  --cut: 10px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 40px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  font-variation-settings: "wdth" 100;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--holo); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- map --------------------------------------------------------------- */

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  touch-action: none;
}
#map.dragging { cursor: grabbing; }
#map:focus-visible { outline: none; }

/* ---- top bar ----------------------------------------------------------- */

.hud-top {
  position: fixed;
  top: var(--s4); left: var(--s4); right: var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s5);
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
}
.brand svg { width: 34px; height: 34px; }
.brand path { fill: var(--gold); filter: drop-shadow(0 0 6px rgba(255, 181, 61, 0.6)); }
.brand circle { fill: none; stroke: var(--gold); stroke-width: 1; opacity: 0.5; }
.brand span {
  font-size: 26px;
  font-weight: 300;
  font-variation-settings: "wdth" 125;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(87, 214, 255, 0.35);
}
.mode-tag {
  align-self: center;
  padding: 2px 8px 1px;
  border: 1px solid var(--hostile);
  color: var(--hostile);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 75, 92, 0.5);
}
.login-card h1 .mode-tag { vertical-align: middle; margin-left: 6px; }
.readout {
  text-shadow: 0 0 6px var(--void), 0 0 12px var(--void);
  color: var(--muted);
  font-size: 14px;
  max-width: 46ch;
  line-height: 1.3;
}
.readout b { color: var(--text); font-weight: 600; }
.readout b.gold { color: var(--gold); }
.readout b.war { color: var(--hostile); }
.storage {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--edge);
}
.storage:hover, .storage:focus-visible { color: var(--text); border-color: var(--edge-hi); }
.storage svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.storage .gauge { width: 46px; height: 4px; background: rgba(255, 255, 255, 0.08); }
.storage .gauge i { display: block; height: 100%; background: var(--holo); }
.storage .gauge i.warn { background: var(--gold); }
.storage .gauge i.full { background: var(--hostile); }
.storage-detail {
  position: fixed;
  top: 58px;
  right: var(--s4);
  width: 280px;
  padding: var(--s3) var(--s4);
  background: var(--glass-hi);
  border: 1px solid var(--edge-hi);
  font-size: 13px;
  z-index: 6;
}
.storage-detail dl { display: grid; grid-template-columns: 1fr auto; gap: 3px var(--s3); margin: 0; }
.storage-detail dt { color: var(--muted); }
.storage-detail dd { margin: 0; text-align: right; }
.storage-detail p { color: var(--muted); margin-top: var(--s2); }
.storage + .storage-detail + .link { margin-left: var(--s3); }
.link {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
  color: var(--muted);
}
.link i {
  width: 8px; height: 8px;
  background: var(--muted);
  transform: rotate(45deg);
}
.link.live i { background: var(--holo); box-shadow: 0 0 8px var(--holo); animation: pulse 2.4s ease-in-out infinite; }
.link.stale i { background: var(--hostile); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---- left rail --------------------------------------------------------- */

.rail {
  position: fixed;
  left: var(--s4);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.rail button {
  position: relative;
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  background: var(--glass);
  border: 1px solid var(--edge);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.rail svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.rail button span {
  position: absolute;
  left: 62px;
  white-space: nowrap;
  padding: var(--s1) var(--s2);
  background: var(--glass-hi);
  border: 1px solid var(--edge);
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.rail button:hover span, .rail button:focus-visible span { opacity: 1; }
.rail button:hover { color: var(--text); border-color: var(--edge-hi); }
.rail button[aria-pressed="true"] { color: var(--holo); border-color: var(--holo); background: rgba(87, 214, 255, 0.1); }
.rail .signout { margin-top: var(--s4); }

/* ---- drawer (fleet, stations, treasury, log) --------------------------- */

.drawer {
  position: fixed;
  left: 84px;
  top: 76px;
  bottom: 64px;
  width: min(560px, calc(100vw - 100px));
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(-12px); } }
.drawer > header {
  display: flex;
  align-items: center;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--edge);
}
.drawer h2 {
  font-size: 20px;
  font-weight: 400;
  font-variation-settings: "wdth" 120;
  letter-spacing: 0.03em;
}
.x {
  margin-left: auto;
  width: 32px; height: 32px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
}
.x:hover { color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5) var(--s5); }
.drawer-body::-webkit-scrollbar, .s3d-contacts ol::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-thumb, .s3d-contacts ol::-webkit-scrollbar-thumb { background: var(--edge); }

.tallies { display: flex; gap: var(--s5); flex-wrap: wrap; margin-bottom: var(--s5); }
.tally { min-width: 76px; }
.tally b {
  display: block;
  font-size: 34px;
  font-weight: 300;
  font-variation-settings: "wdth" 110;
  line-height: 1.05;
}
.tally span { color: var(--muted); font-size: 13px; }

.rows { display: flex; flex-direction: column; }
.ship-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: var(--s1) var(--s3);
  align-items: center;
  padding: var(--s2) var(--s2);
  border-bottom: 1px solid rgba(98, 160, 230, 0.12);
  text-align: left;
  width: 100%;
}
.ship-row:hover { background: rgba(87, 214, 255, 0.06); }
.ship-row svg { width: 18px; height: 18px; }
.ship-row .name { font-weight: 600; }
.ship-row .what { grid-column: 2; color: var(--muted); font-size: 13px; }
.ship-row .eta { grid-row: 1 / span 2; grid-column: 3; text-align: right; font-size: 13px; color: var(--muted); }
.ship-row .eta b { display: block; color: var(--text); font-weight: 500; font-size: 14px; }

.station-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 2px var(--s3);
  align-items: center;
  padding: var(--s2) var(--s2);
  border-bottom: 1px solid rgba(98, 160, 230, 0.12);
  width: 100%;
  text-align: left;
}
.station-row:hover { background: rgba(255, 181, 61, 0.06); }
.station-row svg { width: 22px; height: 22px; }
.station-row .what { grid-column: 2; color: var(--muted); font-size: 13px; }
.station-row .where { grid-row: 1 / span 2; grid-column: 3; font-size: 13px; color: var(--muted); }

.construction {
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  border: 1px dashed rgba(255, 181, 61, 0.45);
  background: var(--gold-soft);
}
.construction p { font-size: 14px; }
.construction .bar { height: 4px; margin-top: var(--s2); background: rgba(255, 181, 61, 0.2); }
.construction .bar i { display: block; height: 100%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.empty { color: var(--muted); padding: var(--s3) 0; max-width: 44ch; }

.contract-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 2px var(--s3);
  align-items: center;
  width: 100%;
  padding: var(--s2);
  text-align: left;
  border-bottom: 1px solid rgba(98, 160, 230, 0.12);
}
.contract-row:hover { background: rgba(87, 214, 255, 0.06); }
.contract-row svg { width: 18px; height: 18px; }
.contract-row .title { font-weight: 500; }
.contract-row .what { grid-column: 2; color: var(--muted); font-size: 13px; }
.contract-row .pay { grid-row: 1 / span 2; grid-column: 3; text-align: right; font-weight: 600; color: var(--gold); }
.contract-row.closed { opacity: 0.55; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s4); }
.chip {
  --pc: var(--holo);
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid rgba(98, 160, 230, 0.25);
  border-left: 3px solid var(--pc);
}
.chip:hover { color: var(--text); }
.chip.on { color: var(--text); background: color-mix(in srgb, var(--pc) 18%, transparent); border-color: var(--pc); }

.powers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s2); margin-bottom: var(--s4); }
.power {
  --pc: var(--gold);
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 2px var(--s3);
  padding: var(--s3);
  text-align: left;
  border: 1px solid rgba(98, 160, 230, 0.18);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 14%, transparent), transparent 70%);
}
.power:hover { border-color: var(--pc); }
.power .swatch { grid-row: 1 / span 3; width: 4px; background: var(--pc); box-shadow: 0 0 10px var(--pc); }
.power .pname { font-weight: 600; color: var(--pc); }
.power .pstats, .power .pcap { color: var(--muted); font-size: 13px; }

.relations { display: flex; flex-direction: column; }
.relation {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 2px var(--s3);
  align-items: center;
  padding: var(--s2) 0;
  border-bottom: 1px solid rgba(98, 160, 230, 0.12);
  font-size: 14px;
}
.relation .pair b { font-weight: 600; }
.relation .status { grid-column: 1; color: var(--muted); font-size: 13px; }
.relation.war .status { color: var(--hostile); }
.relation.pact .status { color: #38d39f; }
.relation .meter { grid-column: 2; grid-row: 1 / span 2; position: relative; height: 6px; background: rgba(255, 255, 255, 0.06); }
.relation .meter::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--edge-hi); }
.relation .meter i { position: absolute; top: 0; bottom: 0; background: var(--muted); }
.relation.war .meter i { background: var(--hostile); }
.relation.pact .meter i { background: #38d39f; }
.how-to { color: var(--muted); font-size: 14px; margin-bottom: var(--s4); max-width: 52ch; }
.how-to code { color: var(--holo); font-family: inherit; font-weight: 600; }

.materials { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s6); }
.material { display: grid; grid-template-columns: 14px 92px 1fr auto; gap: var(--s3); align-items: center; }
.material .gem { width: 12px; height: 12px; transform: rotate(45deg); }
.material .meter { height: 6px; background: rgba(255, 255, 255, 0.06); }
.material .meter i { display: block; height: 100%; }
.material .amount { min-width: 9ch; text-align: right; font-weight: 500; }
.section-title {
  font-size: 15px;
  font-weight: 500;
  font-variation-settings: "wdth" 115;
  color: var(--holo);
  margin: var(--s5) 0 var(--s3);
}
.section-title:first-child { margin-top: 0; }
.traits { display: flex; flex-direction: column; gap: var(--s3); }
.trait { display: grid; grid-template-columns: 92px 1fr 40px; gap: var(--s3); align-items: center; font-size: 14px; }
.trait .meter { position: relative; height: 6px; background: rgba(255, 255, 255, 0.06); }
.trait .meter i { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--holo); box-shadow: 0 0 6px var(--holo); }
.trait .meter::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--edge); }
.trait span:last-child { text-align: right; color: var(--muted); }

.log { display: flex; flex-direction: column; }
.log li {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: var(--s3);
  padding: var(--s2) 0;
  border-bottom: 1px solid rgba(98, 160, 230, 0.1);
}
.log li::before { content: ""; width: 6px; height: 6px; margin-top: 8px; transform: rotate(45deg); background: var(--muted); }
.log li.claim::before, .log li.build::before, .log li.founding::before { background: var(--gold); }
.log li.trade::before, .log li.explore::before { background: var(--holo); }
.log li.loss::before, .log li.battle::before { background: var(--hostile); }
.log time { display: block; color: var(--muted); font-size: 12px; }

.players li { padding: var(--s2) 0; border-bottom: 1px solid rgba(98, 160, 230, 0.12); }

/* ---- inspector (right) ------------------------------------------------- */

.inspector {
  position: fixed;
  right: var(--s4);
  top: 76px;
  width: 340px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding: var(--s4) var(--s5) var(--s5);
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.inspector .kind { color: var(--muted); font-size: 13px; }
.inspector h2 {
  font-size: 24px;
  font-weight: 400;
  font-variation-settings: "wdth" 118;
  line-height: 1.15;
  margin: 2px 0 var(--s3);
}
.inspector h2 .coord { color: var(--holo); }
.inspector .x { position: absolute; top: var(--s2); right: var(--s2); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4); font-size: 14px; margin-bottom: var(--s4); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts .danger { color: var(--hostile); }
.facts .ours { color: var(--gold); }
.here { margin: var(--s3) 0 var(--s4); }
.here li { display: flex; align-items: center; gap: var(--s2); padding: 6px 0; border-top: 1px solid rgba(98, 160, 230, 0.12); font-size: 14px; }
.here li svg { width: 16px; height: 16px; flex: none; }
.here li span { color: var(--muted); margin-left: auto; font-size: 13px; }
.here li button { text-align: left; }
.here li button:hover { color: var(--holo); }
.progress { height: 4px; background: rgba(87, 214, 255, 0.15); margin: var(--s2) 0 var(--s4); }
.progress i { display: block; height: 100%; background: var(--holo); box-shadow: 0 0 8px var(--holo); }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.btn {
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--void);
  background: var(--holo);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  box-shadow: 0 0 18px rgba(87, 214, 255, 0.35);
}
.btn:hover { background: #8de6ff; }
.btn.ghost { color: var(--holo); background: rgba(87, 214, 255, 0.1); box-shadow: none; outline: 1px solid rgba(87, 214, 255, 0.45); outline-offset: -1px; }
.btn.ghost:hover { background: rgba(87, 214, 255, 0.2); }
.btn.alert { background: var(--hostile); color: #fff; box-shadow: 0 0 18px rgba(255, 75, 92, 0.45); }
.btn.alert:hover { background: #ff7480; }

/* ---- map tools, ticker, follow bar, tooltip ---------------------------- */

.map-tools {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  display: flex;
  gap: var(--s1);
}
.map-tools button {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--glass);
  border: 1px solid var(--edge);
  color: var(--muted);
}
.map-tools button:hover { color: var(--holo); border-color: var(--edge-hi); }
.map-tools svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.following .ticker { right: 470px; }
.ticker {
  position: fixed;
  left: 84px;
  right: 260px;
  bottom: var(--s4);
  height: 40px;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  background: var(--glass);
  border: 1px solid var(--edge);
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
}
.ticker time { color: var(--muted); font-size: 12px; }
.ticker .event { overflow: hidden; text-overflow: ellipsis; }
.ticker .event.fresh { animation: ticker-in 0.5s ease-out; }
@keyframes ticker-in { from { opacity: 0; transform: translateY(8px); } }
.ticker i { width: 6px; height: 6px; flex: none; transform: rotate(45deg); background: var(--muted); }
.ticker i.claim, .ticker i.build, .ticker i.founding { background: var(--gold); }
.ticker i.trade, .ticker i.explore { background: var(--holo); }
.ticker i.loss, .ticker i.battle { background: var(--hostile); }

.follow-bar {
  position: fixed;
  bottom: var(--s4);
  right: 196px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: rgba(87, 214, 255, 0.12);
  border: 1px solid var(--holo);
  box-shadow: 0 0 24px rgba(87, 214, 255, 0.25);
  font-size: 14px;
}
.follow-bar b { color: var(--holo); font-weight: 600; }
.follow-bar button { padding: 4px 12px; background: var(--holo); color: var(--void); font-weight: 600; }

.tip {
  position: fixed;
  pointer-events: none;
  padding: var(--s2) var(--s3);
  background: var(--glass-hi);
  border: 1px solid var(--edge-hi);
  font-size: 13px;
  max-width: 260px;
  z-index: 5;
}
.tip strong { display: block; font-size: 15px; font-weight: 600; }
.tip span { color: var(--muted); }

/* ---- 3D sector view ---------------------------------------------------- */

.sector3d {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #02040a;
  animation: s3d-in 0.35s ease-out;
}
@keyframes s3d-in { from { opacity: 0; transform: scale(1.03); } }
#s3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#s3d-canvas.dragging { cursor: grabbing; }
.s3d-head {
  position: absolute;
  top: var(--s4); left: var(--s4); right: var(--s4);
  display: flex;
  align-items: flex-start;
  gap: var(--s5);
  pointer-events: none;
}
.s3d-head > * { pointer-events: auto; }
.s3d-head h2 {
  font-size: 30px;
  font-weight: 300;
  font-variation-settings: "wdth" 125;
  letter-spacing: 0.02em;
  text-shadow: 0 0 20px rgba(87, 214, 255, 0.4);
}
.s3d-head p { color: var(--muted); font-size: 14px; }
.s3d-source {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--edge);
  background: var(--glass);
}
.s3d-source.live { color: var(--holo); border-color: var(--holo); }
.s3d-source.combat { color: #fff; background: var(--hostile); border-color: var(--hostile); animation: pulse 1.2s ease-in-out infinite; }
.s3d-head .x { background: var(--glass); border: 1px solid var(--edge); width: 40px; height: 40px; }
.s3d-contacts {
  position: absolute;
  right: var(--s4);
  top: 84px;
  bottom: 56px;
  width: 260px;
  display: flex;
  flex-direction: column;
  padding: var(--s3) var(--s4);
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.s3d-contacts h3 { font-size: 14px; font-weight: 500; color: var(--holo); margin-bottom: var(--s2); font-variation-settings: "wdth" 115; }
.s3d-contacts ol { overflow-y: auto; flex: 1; }
.s3d-contacts li button {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: var(--s2);
  align-items: center;
  width: 100%;
  padding: 5px 0;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid rgba(98, 160, 230, 0.1);
}
.s3d-contacts li button:hover { color: var(--holo); }
.s3d-contacts li i { width: 7px; height: 7px; transform: rotate(45deg); }
.s3d-contacts li .hp { width: 46px; height: 3px; background: rgba(255, 255, 255, 0.1); }
.s3d-contacts li .hp b { display: block; height: 100%; background: currentColor; }
.s3d-help { position: absolute; left: var(--s4); bottom: var(--s4); color: var(--muted); font-size: 13px; }

/* ---- sign in ----------------------------------------------------------- */

body.login { overflow: auto; display: grid; place-items: center; padding: var(--s4); }
#stars { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; }
.login-card {
  width: min(400px, 100%);
  padding: var(--s6) var(--s6) var(--s5);
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.login-card .emblem { width: 56px; height: 56px; margin-bottom: var(--s4); }
.login-card .emblem path { fill: var(--gold); filter: drop-shadow(0 0 10px rgba(255, 181, 61, 0.7)); }
.login-card .emblem circle { fill: none; stroke: var(--gold); opacity: 0.5; }
.login-card h1 {
  font-size: 40px;
  font-weight: 300;
  font-variation-settings: "wdth" 125;
  letter-spacing: 0.04em;
  line-height: 1;
}
.lede { color: var(--muted); margin: var(--s3) 0 var(--s6); }
.login-card label { display: block; font-size: 14px; color: var(--muted); margin-bottom: var(--s2); }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: rgba(2, 6, 14, 0.6);
  border: 1px solid var(--edge);
}
.login-card input:focus { outline: none; border-color: var(--holo); box-shadow: 0 0 0 3px rgba(87, 214, 255, 0.15); }
.login-card .btn { width: 100%; margin-top: var(--s4); padding: 12px; font-size: 15px; }
.login-card .btn:disabled { opacity: 0.6; cursor: default; }
.error { margin-top: var(--s3); color: var(--hostile); font-size: 14px; }

/* ---- small screens ----------------------------------------------------- */

@media (max-width: 900px) {
  .readout { display: none; }
  .storage .gauge { display: none; }
  .ticker { right: 200px; }
  .inspector {
    top: auto;
    bottom: 64px;
    left: 76px;
    right: var(--s4);
    width: auto;
    max-height: 46vh;
  }
}
@media (max-width: 600px) {
  .hud-top { top: var(--s3); left: var(--s3); right: var(--s3); }
  .brand span { font-size: 20px; }
  .storage { display: none !important; }
  .rail { left: var(--s3); top: auto; bottom: 64px; transform: none; }
  .rail button { width: 44px; height: 44px; }
  .rail button span { display: none; }
  .rail .signout { margin-top: 0; }
  .drawer { left: var(--s3); right: var(--s3); width: auto; top: 64px; bottom: 64px; }
  .inspector { left: 64px; right: var(--s3); bottom: 64px; }
  .ticker { left: var(--s3); right: 190px; bottom: var(--s3); }
  .following .ticker { right: 190px; }
  .map-tools { right: var(--s3); bottom: var(--s3); }
  .follow-bar { bottom: 60px; right: var(--s3); }
  .s3d-contacts { top: auto; left: var(--s3); right: var(--s3); width: auto; height: 34vh; bottom: var(--s3); }
  .s3d-help { display: none; }
  .s3d-head h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Phase 4: identity, projects, society, history ------------------- */

.sentinel-chip {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--edge);
}
.sentinel-chip + .storage { margin-left: var(--s2); }

.powers.wide { grid-template-columns: 1fr; }
.power .pname { text-align: left; font-size: 17px; }
.power .pname:hover { text-decoration: underline; text-underline-offset: 3px; }
.power .swatch { grid-row: 1 / span 12; }
.power .motto { font-style: italic; color: var(--text); }
.power .values { color: var(--pc); font-size: 13px; font-weight: 500; }
.power .tradition { color: var(--muted); font-size: 13px; }
.power .ambition, .power .project { font-size: 13px; color: var(--muted); }
.power .ambition b, .power .project b { color: var(--text); font-weight: 600; }
.power .pbar { display: block; height: 3px; background: rgba(255, 255, 255, 0.08); margin: 2px 0 4px; }
.power .pbar i { display: block; height: 100%; background: var(--pc); box-shadow: 0 0 6px var(--pc); }
.power .society { display: grid; grid-template-columns: 1fr; gap: 3px; margin-top: 4px; font-size: 13px; }
.power .society .pop { color: var(--muted); }
.power .crisis, .power .boom { justify-self: start; padding: 0 8px; font-size: 12px; font-weight: 600; }
.power .crisis { background: var(--hostile); color: #fff; }
.power .boom { background: #38d39f; color: var(--void); }
.gauge-row { display: grid; grid-template-columns: 86px 1fr 30px; gap: var(--s2); align-items: center; color: var(--muted); }
.gauge-row .gbar { height: 4px; background: rgba(255, 255, 255, 0.08); }
.gauge-row .gbar i { display: block; height: 100%; background: var(--holo); }
.gauge-row.low .gbar i { background: var(--hostile); }
.gauge-row .gval { text-align: right; }

.chron { margin-bottom: var(--s4); }
.chron article { padding: var(--s2) 0; border-bottom: 1px solid rgba(98, 160, 230, 0.12); }
.chron h4 { margin: 0 0 2px; font-size: 15px; font-weight: 600; }
.chron .yr { color: var(--muted); font-weight: 400; margin-right: var(--s2); }
.chron p { color: var(--text); font-size: 14px; line-height: 1.5; max-width: 62ch; }
.decisions li { padding: var(--s2) 0; border-bottom: 1px solid rgba(98, 160, 230, 0.1); font-size: 14px; }
.decisions time { color: var(--muted); font-size: 12px; }
.decisions p { color: var(--muted); font-style: italic; font-size: 13px; }
.here li.monument { color: var(--text); }
.here li.inscription { font-style: italic; color: var(--muted); font-size: 13px; border-top: 0; padding-top: 0; }
@media (max-width: 900px) { .sentinel-chip { display: none !important; } }
.readout .stardate { color: var(--holo); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* Story drawer (director.lua) */
.story-title { margin: 0 0 var(--s1); font-size: 18px; font-weight: 600; color: var(--hostile, #ff4b5c); }
.story-intro { color: var(--text); font-size: 14px; line-height: 1.5; max-width: 62ch; margin: 0 0 var(--s3); }
.story-stage { color: var(--muted); font-size: 13px; margin: var(--s1) 0 var(--s3); }
.story-meter .gbar i { background: var(--hostile, #ff4b5c); }

/* Power cards: flagship, market, sworn pilots */
.power .flagship, .power .market, .power .sworn { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.power .flagship b { color: var(--text); font-weight: 600; }
.power .flagship .bio { display: block; font-style: italic; }

/* Pilots panel */
.contract-row .rank { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; }
.pilot-oath { color: var(--text); margin: 0 0 var(--s3); }
.back { background: none; border: 0; color: var(--holo, #57d6ff); cursor: pointer; padding: 0; margin-bottom: var(--s2); font: inherit; }
