:root {
  color-scheme: dark;
  --bg: #04060c;
  --panel: rgba(9, 14, 26, 0.86);
  --panel-solid: rgba(8, 12, 22, 0.97);
  --border: rgba(110, 150, 215, 0.22);
  --border-strong: rgba(120, 170, 240, 0.42);
  --text: #dde6f5;
  --muted: #7f90b0;
  --accent: #4fc3f7;
  --info: #4fc3f7;
  --error: #ff6b6b;
  --good: #7ee08a;
  --warn: #ffd166;
  --hull: #5bd47a;
  --shield: #4f9cf7;
  --xp: #c58cff;
  --tier-common: #7d8ba3;
  --tier-uncommon: #43c46e;
  --tier-rare: #3d8bff;
  --tier-epic: #b45cff;
  --font-ui: "Rajdhani", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cut: 10px;
}

@font-face { font-family: "Rajdhani"; font-weight: 500; font-display: swap; src: url("fonts/rajdhani-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Rajdhani"; font-weight: 600; font-display: swap; src: url("fonts/rajdhani-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Rajdhani"; font-weight: 700; font-display: swap; src: url("fonts/rajdhani-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Rajdhani"; font-weight: 500; font-display: swap; src: url("fonts/rajdhani-latin-ext-500-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Rajdhani"; font-weight: 600; font-display: swap; src: url("fonts/rajdhani-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Rajdhani"; font-weight: 700; font-display: swap; src: url("fonts/rajdhani-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
  background: rgba(10, 16, 30, 0.9);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 6px 10px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }

button {
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #1a2742, #0f182b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
button:hover:not(:disabled) { border-color: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 10px color-mix(in srgb, var(--accent) 30%, transparent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary {
  color: #0b0f18;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 100%, #fff 25%), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 70%, #fff 30%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
button.primary:hover:not(:disabled) { box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent); }
button.active { border-color: var(--accent); color: var(--accent); background: linear-gradient(180deg, #1c2a46, #121c31); }

kbd {
  font: 600 10px var(--font-ui);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 3px;
  margin-left: 2px;
}
button.primary kbd { color: #0b0f18; border-color: rgba(0, 0, 0, 0.3); }

/* Panels: dark glass with cut corners and a faction-coloured top edge. */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(18, 27, 47, 0.9), rgba(7, 11, 21, 0.9));
  border: 1px solid var(--border);
  padding: 12px;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--cut);
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 0%, transparent) 70%);
  opacity: 0.8;
  pointer-events: none;
}

h1, h2, h3 { font-family: var(--font-ui); }
.panel h2 { font-weight: 700; font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase; }

.muted { color: var(--muted); }
.error { color: var(--error); min-height: 1.4em; margin: 0; }
.info { color: var(--good); margin: 0; }
button.link { background: none; border: none; box-shadow: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: 13px system-ui, sans-serif; letter-spacing: 0; }
button.link:hover:not(:disabled) { text-decoration: underline; box-shadow: none; }
.auth-panel #forgot-form, .auth-panel #reset-form { display: flex; flex-direction: column; gap: 10px; }
.auth-panel #forgot-form[hidden], .auth-panel #reset-form[hidden] { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.column { display: flex; flex-direction: column; gap: 8px; }

.screen { position: fixed; inset: 0; }

/* ---------------- Icons and item tiles ---------------- */

.icon { display: inline-block; flex: none; vertical-align: -3px; }
.icon svg { width: 100%; height: 100%; display: block; }
.amount { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tile {
  --tile: 48px;
  --tier: var(--tier-common);
  position: relative;
  flex: none;
  width: var(--tile);
  height: var(--tile);
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--tier) 75%, #000);
  background:
    radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--tier) 45%, transparent), transparent 70%),
    linear-gradient(180deg, #1a2338, #0b101c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 -8px 14px rgba(0, 0, 0, 0.35);
}
.tile svg { width: 78%; height: 78%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
button.tile:hover:not(:disabled) { border-color: var(--tier); box-shadow: 0 0 10px color-mix(in srgb, var(--tier) 60%, transparent); }
.tile.tier-common { --tier: var(--tier-common); }
.tile.tier-uncommon { --tier: var(--tier-uncommon); }
.tile.tier-rare { --tier: var(--tier-rare); }
.tile.tier-epic { --tier: var(--tier-epic); }
.tile.empty { border: 1px dashed var(--border-strong); background: rgba(8, 12, 22, 0.6); box-shadow: none; }
.tile-count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font: 700 11px var(--font-ui);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.tile .tile-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  font: 700 12px/16px var(--font-ui);
  display: none;
  background: #3a1520;
  border-color: #ff6b6b;
  color: #ffb3b3;
}
.tile:hover .tile-x, .tile:focus-within .tile-x { display: block; }
canvas.portrait { display: block; }

/* ---------------- Auth ---------------- */

#auth {
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(1200px 600px at 75% 20%, rgba(232, 137, 43, 0.16), transparent 60%),
    radial-gradient(900px 700px at 15% 85%, rgba(43, 196, 196, 0.13), transparent 60%),
    radial-gradient(1px 1px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 60%, #cfe3ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 70%, #ffd9b0 50%, transparent 51%),
    var(--bg);
  background-size: auto, auto, 330px 330px, 270px 270px, 410px 410px, 230px 230px, 370px 370px, auto;
}

.auth-panel { width: min(380px, 100%); padding: 22px 22px 18px; }
.auth-panel h1 {
  margin: 0 0 4px;
  font: 700 34px/1 var(--font-ui);
  letter-spacing: 0.22em;
  text-align: center;
  background: linear-gradient(180deg, #ffffff, #9fb8de);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-panel h1 + .tabs { margin-top: 16px; }
.auth-tagline { margin: 0 0 4px; text-align: center; font: 600 12px var(--font-ui); letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.auth-panel form { display: flex; flex-direction: column; gap: 10px; }
.auth-panel label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font: 600 12px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; }
.auth-panel label input, .auth-panel label select { font: 14px system-ui, sans-serif; letter-spacing: 0; text-transform: none; color: var(--text); padding: 8px 10px; }
.auth-panel #register-fields { display: flex; flex-direction: column; gap: 10px; }
.auth-panel #auth-submit { padding: 9px; font-size: 16px; letter-spacing: 0.12em; text-transform: uppercase; }

.tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  box-shadow: none;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 7px 10px 6px;
}
.tab:hover:not(:disabled) { color: var(--text); box-shadow: none; border-color: transparent; border-bottom-color: var(--border-strong); }
.tab.active, .tab.active:hover:not(:disabled) { color: var(--accent); border-bottom-color: var(--accent); background: linear-gradient(0deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent); }

/* ---------------- Game ---------------- */

#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-head { display: flex; align-items: baseline; gap: 6px; font: 700 18px var(--font-ui); letter-spacing: 0.04em; }
.hud-head .muted { font-size: 14px; }

.bar {
  position: relative;
  height: 15px;
  background: rgba(3, 6, 12, 0.85);
  border: 1px solid rgba(110, 150, 215, 0.25);
  border-radius: 2px;
  overflow: hidden;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 0; transition: width 0.25s ease-out; }
.bar .fill::after { content: ""; position: absolute; inset: 0 0 50% 0; background: rgba(255, 255, 255, 0.18); }
.bar .fill.hull { background: linear-gradient(90deg, #2f9e55, var(--hull)); }
.bar .fill.shield { background: linear-gradient(90deg, color-mix(in srgb, var(--shield) 60%, #000), var(--shield)); }
.bar .fill.xp { background: linear-gradient(90deg, #6b3fb0, var(--xp)); }
.bar span {
  position: relative;
  display: block;
  font: 700 11px/13px var(--font-ui);
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 4px 0 0; }
.stats dt { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stats dd { margin: 0; text-align: right; font: 600 15px var(--font-ui); font-variant-numeric: tabular-nums; }

/* Action bar: fixed slots, so nothing jumps when a button becomes unavailable (it is disabled instead). */
#actions {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
}
#actions .row { justify-content: center; flex-wrap: wrap; gap: 5px; }
#actions button { white-space: nowrap; padding: 4px 8px; font-size: 13px; }
#actions kbd { margin-left: 4px; }
body.in-hangar .weapons-row { display: none; }
#ammo-buttons button { display: inline-flex; align-items: center; gap: 6px; min-width: 104px; justify-content: flex-start; }
@media (min-width: 1101px) {
  /* Centred in the space between the HUD and the chat. */
  #actions { left: calc(274px + (100% - 274px - 364px) / 2); max-width: calc(100% - 274px - 364px - 12px); }
}
.icon-btn { margin-left: auto; padding: 0 6px; font: 16px/22px system-ui, sans-serif; color: var(--muted); background: none; border-color: transparent; box-shadow: none; }
.icon-btn:hover:not(:disabled) { color: var(--error); border-color: transparent; box-shadow: none; }
#ammo-buttons button .ammo-count { margin-left: auto; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
#ammo-buttons button.active .ammo-count { color: var(--text); }
#ammo-buttons button.empty-ammo { opacity: 0.55; }
#btn-rocket { display: inline-flex; align-items: center; gap: 6px; }

#events {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  max-width: calc(100% - 560px);
  min-width: 240px;
}
.event {
  background: linear-gradient(90deg, transparent, rgba(8, 12, 22, 0.88) 15%, rgba(8, 12, 22, 0.88) 85%, transparent);
  padding: 3px 26px;
  font: 600 15px var(--font-ui);
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px #000;
  transition: opacity 0.6s, transform 0.6s;
  animation: event-in 0.25s ease-out;
}
@keyframes event-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.event.error, .event.died { color: var(--error); }
.event.reward, .event.levelUp, .event.loot { color: var(--good); }
.event.levelUp { font-size: 20px; color: #ffe08a; }
.event.mapChanged, .event.respawned { color: var(--accent); }
.event.fade { opacity: 0; transform: translateY(-4px); }

/* Chat stays above every panel (the station panel opens on a docked login) and the panels keep its column free. */
#chat {
  position: absolute;
  z-index: 20;
  right: 12px;
  bottom: 12px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#chat-log { height: 180px; overflow-y: auto; font-size: 13px; overflow-wrap: anywhere; scrollbar-width: thin; }
#chat-log > div { padding: 1px 0; }
#chat-log .ch { color: var(--muted); font: 600 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.06em; }
#chat-log .from { color: var(--accent); font-weight: 600; }
#chat-log .global .from { color: var(--warn); }
#chat-form { display: flex; gap: 6px; }
#chat-input { flex: 1; min-width: 0; }

.overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(18, 27, 47, 0.96), rgba(7, 11, 21, 0.97));
  animation: overlay-in 0.16s ease-out;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.overlay h2 { margin: 0 0 8px; }

#mission-tracker { border-top: 1px solid var(--border); padding-top: 6px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
#mission-tracker .tracked > div:first-child { color: var(--warn); font: 600 13px var(--font-ui); letter-spacing: 0.04em; }

/* ---------------- Station panel ---------------- */

.overlay.wide { width: min(780px, calc(100% - 32px)); height: min(660px, calc(100% - 32px)); display: flex; flex-direction: column; padding: 14px 16px; }
/* Wide panels sit between the HUD (left, 262 px) and the chat (right, 352 px), so neither is covered. */
@media (min-width: 1101px) {
  .overlay.wide { left: calc(274px + (100% - 274px - 364px) / 2); width: min(780px, calc(100% - 274px - 364px - 16px)); }
}
.station-head { display: flex; gap: 8px; align-items: flex-end; }
.station-head .tabs { flex: 1; flex-wrap: wrap; margin: 0; }
.station-head .tab { flex: 0 1 auto; }
#station-status { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 10px; font-size: 13px; }
#station-status .ok { color: var(--good); }
#station-status .wallet { display: inline-flex; gap: 14px; font: 600 15px var(--font-ui); }
#station-body { flex: 1; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
#station-body h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
  font: 700 13px var(--font-ui);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
#station-body h3::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }
#station-body h3:first-child { margin-top: 0; }
#station-body p { margin: 4px 0; }

.card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(20, 30, 52, 0.55), rgba(10, 15, 27, 0.55));
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card.active { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 12%, transparent); }
.card.locked { opacity: 0.55; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head strong { font: 700 17px var(--font-ui); letter-spacing: 0.04em; }
.badge { font: 700 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); border: 1px solid var(--accent); border-radius: 2px; padding: 0 6px; margin-left: 6px; }
.objectives { margin: 0; padding-left: 18px; }
.reward { color: var(--good); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }

.line { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(110, 150, 215, 0.12); flex-wrap: wrap; }
.line .grow { flex: 1 1 220px; min-width: 0; }
.line .price { color: var(--warn); font: 600 15px var(--font-ui); font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; gap: 10px; align-items: center; }
.line button, .line select { padding: 3px 9px; }
input.qty { width: 84px; padding: 3px 6px; }

.slots { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.slots > .muted { min-width: 110px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 12px; padding: 1px 4px 1px 8px; font-size: 12px; }
.chip.empty { color: var(--muted); border-style: dashed; padding-right: 8px; }
.chip-x { padding: 0 5px; border-radius: 10px; line-height: 1.2; }

/* Hangar: ship portrait next to its slot grids; escorts and the inventory as tile grids. */
.ship-card { flex-direction: row; align-items: stretch; gap: 14px; }
.ship-card .portrait-frame {
  flex: none;
  width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 4px;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%);
}
.ship-card .portrait-frame .muted { font: 600 11px var(--font-ui); text-transform: uppercase; letter-spacing: 0.1em; }
.ship-card .ship-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.slot-group { display: flex; flex-direction: column; gap: 4px; }
.slot-group > .label { font: 600 12px var(--font-ui); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.slot-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ship-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 600 13px var(--font-ui); color: var(--muted); }
.ship-stats b { color: var(--text); font-weight: 700; }

.escort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-bottom: 8px; }
.escort-card { flex-direction: row; align-items: center; gap: 10px; margin: 0; padding: 8px; }
.escort-card .escort-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.escort-card strong { font: 700 15px var(--font-ui); }

.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.inv-item { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: rgba(10, 15, 27, 0.5); }
.inv-item .inv-name { font: 700 14px var(--font-ui); line-height: 1.1; }
.inv-item .inv-sub { font-size: 11px; color: var(--muted); }
.inv-item .inv-fit { grid-column: 1 / -1; display: flex; gap: 4px; }
.inv-item .inv-fit select { flex: 1; min-width: 0; padding: 2px 4px; font-size: 12px; }
.inv-item .inv-fit button { padding: 2px 8px; }

.supply-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.supply { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 74px; text-align: center; }
.supply .supply-name { font: 600 11px var(--font-ui); color: var(--muted); line-height: 1.1; }

/* Shop: cards with the item icon, its stats and the price. */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin-bottom: 4px; }
.shop-card { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin: 0; }
.shop-card .shop-text { min-width: 0; }
.shop-card .shop-name { font: 700 16px var(--font-ui); line-height: 1.1; display: flex; align-items: center; gap: 6px; }
.shop-card .shop-sum { font-size: 12px; color: var(--muted); }
.shop-card .shop-buy { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.shop-card .shop-buy .price { margin-right: auto; color: var(--warn); font: 600 15px var(--font-ui); display: inline-flex; gap: 10px; }
.shop-card .owned { font: 600 11px var(--font-ui); color: var(--muted); }
.tier-label { font: 700 10px var(--font-ui); letter-spacing: 0.1em; text-transform: uppercase; border-radius: 2px; padding: 0 4px; }
.tier-label.tier-common { color: var(--tier-common); }
.tier-label.tier-uncommon { color: var(--tier-uncommon); }
.tier-label.tier-rare { color: var(--tier-rare); }
.tier-label.tier-epic { color: var(--tier-epic); }

.event.alert { color: var(--warn); }
.event.rift { color: #d46bff; }

#chat-log .group .from { color: var(--good); }
#chat-log .clan .from { color: #c58cff; }

/* ---------------- Group and rift ---------------- */

#rift-bar { border-top: 1px solid var(--border); border-left: 3px solid #d46bff; padding: 4px 0 0 8px; font-size: 12px; }
#rift-bar .rift-title { color: #d46bff; font: 700 13px var(--font-ui); letter-spacing: 0.04em; }

#group-tracker { border-top: 1px solid var(--border); padding-top: 6px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
#group-tracker .dead { opacity: 0.5; }

.mini-bar { position: relative; height: 4px; background: #0b1120; border-radius: 2px; overflow: hidden; }
.mini-bar .fill { position: absolute; inset: 0 auto 0 0; }
.mini-bar .fill.hull { background: var(--hull); }
.mini-bar .fill.shield { background: var(--shield); }
.member-bars { display: flex; flex-direction: column; gap: 2px; width: 90px; }

#group-members { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#group-members .member { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; }
#group-members .member.dead { opacity: 0.55; }
#group-members .grow { flex: 1; min-width: 0; }
#group-invite-form { margin-bottom: 10px; flex-wrap: nowrap; }
#group-invite-name { flex: 1; min-width: 0; }
.group-actions { justify-content: flex-end; }
#btn-group .badge { margin-left: 4px; }

#jump-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#jump-list button { width: 100%; display: flex; justify-content: space-between; gap: 8px; }

@media (max-width: 1100px) {
  #hud { width: 200px; font-size: 12px; }
  #chat { width: 260px; }
  #chat-log { height: 110px; }
  #actions { left: 12px; transform: none; max-width: calc(100% - 296px); }
  #actions .row { justify-content: flex-start; flex-wrap: wrap; }
  #actions button { padding: 4px 8px; font-size: 13px; }
  #ammo-buttons button { min-width: 0; }
  #events { top: 12px; left: 224px; transform: none; align-items: flex-start; max-width: calc(100% - 480px); min-width: 0; }
  .overlay.wide { left: calc(212px + (100% - 212px - 284px) / 2); width: min(780px, calc(100% - 212px - 284px - 16px)); }
}
@media (max-width: 860px) {
  .overlay.wide { left: calc((100% - 284px) / 2); width: min(780px, calc(100% - 316px)); }
  .ship-card { flex-direction: column; }
  .ship-card .portrait-frame { width: 100%; flex-direction: row; }
}

/* ---------------- Hangar, auction and workshop ---------------- */

body.in-hangar #ammo-buttons,
body.in-hangar #btn-rocket,
body.in-hangar #btn-portal,
body.in-hangar #btn-jump,
body.in-hangar #btn-unlock,
body.in-hangar #btn-pet { display: none; }
body.in-hangar #rift-bar { display: none; }

.lot-stats { margin: 0; }
.lot-title { display: inline-flex; align-items: center; gap: 10px; }
input.bid { width: 140px; max-width: 100%; padding: 3px 6px; }
.countdown { font: 700 15px var(--font-ui); font-variant-numeric: tabular-nums; color: var(--warn); }

@media (max-width: 640px) {
  #hud { width: 170px; font-size: 11px; padding: 8px; }
  /* Phones: the HUD keeps only the name and the bars, the action bar only the essentials. */
  #hud .stats, #hud #rift-bar, #hud #mission-tracker, #hud #group-tracker { display: none; }
  #ammo-buttons button { min-width: 0; padding: 4px 6px; }
  #ammo-buttons kbd, #actions .row kbd { display: none; }
  #btn-unlock { display: none; }
  .hud-head { font-size: 15px; }
  .stats dd { font-size: 13px; }
  #actions { left: 8px; right: 8px; bottom: 142px; max-width: none; transform: none; padding: 6px; }
  #chat { left: 8px; right: 8px; bottom: 8px; width: auto; }
  #chat-log { height: 60px; }
  #events { left: 164px; max-width: calc(100% - 172px); }
  /* Chat runs across the bottom on phones: the wide panel ends above it. */
  .overlay.wide { left: 50%; top: 8px; transform: translateX(-50%); width: calc(100% - 16px); height: calc(100% - 136px); }
  .station-head { flex-wrap: wrap; }
}
