:root {
  --void: #07080a;
  --line: #e7eadf;
  --accent: #28d7bb;
  --signal: #f4c95d;
  --ship-thrust: #28d7bb;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--line);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: geometricPrecision;
}

body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body,
canvas,
.hud,
.action-dock {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select {
  -webkit-user-select: none;
  touch-action: manipulation;
  user-select: none;
}

#space {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: var(--void);
  image-rendering: auto;
  touch-action: none;
}

svg {
  shape-rendering: geometricPrecision;
  text-rendering: geometricPrecision;
}

.ship {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--ship-size, clamp(23px, 3.5vw, 39px));
  height: auto;
  pointer-events: none;
  transform-origin: 50% 62%;
  --ship-metal-alpha: 0.9;
  --ship-sheen: 0.1;
  filter: drop-shadow(0 0 8px rgb(40 215 187 / 0.14));
  z-index: 2;
}

.ship-main {
  opacity: var(--ship-metal-alpha);
  stroke: rgb(7 8 10 / 0.22);
  stroke-width: 0.7;
}

.ship-core {
  opacity: 0.92;
}

.ship-sheen {
  opacity: var(--ship-sheen);
}

.ship-thrust {
  fill: var(--ship-thrust);
  opacity: 0;
  transition: opacity 90ms linear;
}

.ship.is-thrusting .ship-thrust {
  opacity: 0.95;
}

@media (hover: none), (pointer: coarse) {
  body > .ship {
    --ship-size: clamp(46px, 12vw, 62px);
  }
}

body.auth-locked .hud,
body.auth-locked .action-dock,
body.auth-locked .game-panel,
body.auth-locked .modal,
body.auth-locked .logout-button {
  visibility: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(7 8 10 / 0.86);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(360px, 100%);
  border: 1px solid rgb(231 234 223 / 0.22);
  background: rgb(7 8 10 / 0.94);
  padding: 18px;
}

.auth-card header {
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 0;
  color: var(--accent);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-card p {
  margin: 5px 0 0;
  color: rgb(231 234 223 / 0.62);
  font-size: 0.78rem;
}

.auth-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: rgb(231 234 223 / 0.62);
  font-size: 0.68rem;
  font-weight: 800;
}

.auth-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgb(231 234 223 / 0.22);
  background: rgb(7 8 10 / 0.82);
  color: var(--line);
  padding: 0 11px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

/* iOS Safari auto-zooms focused form controls rendered below 16px. */
@supports (-webkit-touch-callout: none) {
  @media (pointer: coarse) {
    input:not([type="range"]),
    select,
    textarea {
      font-size: 16px;
    }
  }
}

.auth-card input:focus {
  border-color: rgb(40 215 187 / 0.72);
}

.auth-submit,
.auth-disabled {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid rgb(40 215 187 / 0.68);
  background: rgb(40 215 187 / 0.12);
  color: var(--accent);
  font-weight: 900;
}

.auth-disabled {
  border-color: rgb(231 234 223 / 0.12);
  background: rgb(231 234 223 / 0.04);
  color: rgb(231 234 223 / 0.32);
}

.auth-status {
  min-height: 1rem;
  color: rgb(231 234 223 / 0.58);
}

.auth-status.is-error {
  color: #f4c95d;
}

.control-gate {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(7 8 10 / 0.86);
}

.control-gate[hidden] {
  display: none;
}

.control-card {
  width: min(360px, 100%);
  border: 1px solid rgb(231 234 223 / 0.22);
  background: rgb(7 8 10 / 0.96);
  padding: 18px;
}

.control-card h2 {
  margin: 0;
  color: var(--signal);
  font-size: 0.98rem;
  font-weight: 800;
}

.control-card header p,
.control-status {
  margin: 6px 0 0;
  color: rgb(231 234 223 / 0.62);
  font-size: 0.78rem;
  line-height: 1.45;
}

.control-status {
  min-height: 2.2rem;
  margin-top: 18px;
}

.control-continue {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 1px solid rgb(40 215 187 / 0.68);
  background: rgb(40 215 187 / 0.12);
  color: var(--accent);
  font-weight: 900;
}

.control-continue:disabled {
  opacity: 0.48;
}

.control-locked .logout-button {
  z-index: 21;
}

.logout-button {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  z-index: 6;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: rgb(231 234 223 / 0.58);
  cursor: pointer;
  touch-action: manipulation;
}

.logout-button[hidden] {
  display: none;
}

.logout-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-button:hover,
.logout-button:focus-visible {
  color: var(--accent);
  outline: none;
}

.hud {
  position: fixed;
  top: 12px;
  left: 50%;
  width: min(520px, calc(100vw - 28px));
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 3;
}

.action-dock {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: translateX(-50%);
}

.action-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: rgb(7 8 10 / 0.78);
  cursor: pointer;
}

.action-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inspect-button {
  border: 1px solid rgb(40 215 187 / 0.68);
  color: var(--accent);
}

.scanner-button {
  border: 1px solid rgb(244 201 93 / 0.58);
  color: var(--signal);
}

.inventory-button {
  border: 1px solid rgb(40 215 187 / 0.58);
  color: var(--accent);
}

.gate-button {
  border: 1px solid rgb(158 234 255 / 0.62);
  color: #9eeaff;
}

.action-button:hover {
  background: rgb(7 8 10 / 0.9);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(7 8 10 / 0.72);
}

.modal[hidden],
.action-button[hidden],
.game-panel[hidden],
.scanner-panel[hidden] {
  display: none;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgb(231 234 223 / 0.24);
  background: rgb(7 8 10 / 0.94);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgb(231 234 223 / 0.18);
  padding: 12px;
  cursor: move;
  touch-action: none;
}

.modal-top h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: var(--void);
  color: var(--line);
  cursor: pointer;
}

.inspect-data {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 8px 12px;
  margin: 0;
  padding: 12px;
  font-size: 12px;
}

.inspect-data dt {
  color: var(--accent);
  font-weight: 800;
}

.inspect-data dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.inspect-extra {
  padding: 0 12px 12px;
}

.inspect-panel-block {
  border-top: 1px solid rgb(231 234 223 / 0.12);
  padding-top: 10px;
}

.inspect-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.loot-tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 46px;
  border: 1px solid rgb(231 234 223 / 0.13);
  background: rgb(7 8 10 / 0.48);
  color: var(--line);
  cursor: grab;
  font: inherit;
  overflow: hidden;
}

.loot-tile:hover,
.loot-tile:focus-visible {
  border-color: rgb(40 215 187 / 0.48);
  outline: 0;
}

.loot-tile svg {
  width: min(46px, 92%);
  height: min(46px, 92%);
}

.loot-tile em {
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: #fff;
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 4px #000;
}

.loot-tile.is-empty {
  cursor: default;
  opacity: 0.28;
}

.mine-actions {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 6px;
  margin-bottom: 8px;
}

.mine-actions button {
  min-height: 42px;
  border: 1px solid rgb(231 234 223 / 0.14);
  background: rgb(40 215 187 / 0.1);
  color: var(--line);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
}

.mine-actions button:disabled {
  cursor: default;
  opacity: 0.34;
}

.mine-progress {
  height: 5px;
  overflow: hidden;
  margin: -2px 0 8px;
  border: 1px solid rgb(231 234 223 / 0.12);
  background: rgb(231 234 223 / 0.04);
}

.mine-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.probe-grid {
  display: grid;
  gap: 7px;
  margin-bottom: 8px;
}

.probe-card {
  display: grid;
  gap: 5px;
  border: 1px solid rgb(231 234 223 / 0.1);
  background: rgb(7 8 10 / 0.34);
  padding: 6px;
}

.probe-card > div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.probe-card b,
.probe-target b,
.probe-target span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.probe-card b {
  color: var(--line);
  font-size: 10px;
  font-weight: 900;
}

.probe-card em {
  color: #fff;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.probe-target {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgb(231 234 223 / 0.1);
  background: rgb(40 215 187 / 0.07);
  color: var(--line);
  cursor: pointer;
  font: inherit;
  padding: 0 7px;
}

.probe-target span {
  color: rgb(231 234 223 / 0.56);
  font-size: 8px;
  font-weight: 900;
}

.inspect-status {
  margin: 8px 0 0;
  color: rgb(231 234 223 / 0.62);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.game-panel {
  position: fixed;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  border: 1px solid rgb(231 234 223 / 0.24);
  background: rgb(7 8 10 / 0.91);
  touch-action: auto;
}

.game-panel-floating {
  right: 18px;
  bottom: 76px;
}

.game-panel-resizable {
  padding-bottom: 12px;
}

.game-panel-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid rgb(231 234 223 / 0.16);
  cursor: move;
  touch-action: none;
}

.game-panel-top h2 {
  margin: 0;
  color: var(--signal);
  font-size: 12px;
  letter-spacing: 0;
}

.game-panel-close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: var(--void);
  color: var(--line);
  cursor: pointer;
}

.game-panel-body {
  flex: 1 1 auto;
  min-height: 0;
}

.game-scroll {
  padding-inline: 0 8px;
  overscroll-behavior: contain;
  scrollbar-color: rgb(231 234 223 / 0.32) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.game-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.game-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.game-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgb(231 234 223 / 0.28);
}

.game-panel-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
}

.game-panel-resize::after {
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 42px;
  height: 2px;
  background: rgb(231 234 223 / 0.28);
  content: "";
  transform: translateX(-50%);
}

.scanner-panel {
  width: min(360px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 96px));
  min-height: min(360px, calc(100vh - 16px));
}

.inventory-panel {
  width: min(360px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 96px));
  min-height: min(560px, calc(100vh - 16px));
}

.refinery-panel {
  width: min(390px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 96px));
  min-height: min(420px, calc(100vh - 16px));
}

.stargate-panel {
  width: min(360px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 96px));
  min-height: min(360px, calc(100vh - 16px));
}

.modal-close svg,
.game-panel-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.modal-close:hover,
.game-panel-close:hover {
  color: var(--signal);
}

.scanner-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 8px;
  overflow: hidden;
}

.scanner-controls label {
  flex: 0 0 28px;
  display: grid;
  grid-template-columns: 78px 1fr 68px;
  align-items: center;
  gap: 8px;
  color: rgb(231 234 223 / 0.72);
  font-size: 10px;
  font-weight: 800;
}

.scanner-controls input[type="range"] {
  min-width: 0;
  accent-color: var(--signal);
}

.scanner-controls input[type="number"] {
  width: 68px;
  height: 28px;
  border: 1px solid rgb(231 234 223 / 0.22);
  background: var(--void);
  color: var(--line);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.scanner-readout {
  flex: 0 0 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
}

.scanner-readout dt,
.scanner-readout dd {
  min-width: 0;
  margin: 0;
}

.scanner-readout dt {
  color: rgb(231 234 223 / 0.56);
  font-size: 10px;
  font-weight: 800;
}

.scanner-readout dd {
  grid-row: 2;
  color: var(--signal);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scan-start {
  flex: 0 0 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid rgb(244 201 93 / 0.5);
  background: rgb(244 201 93 / 0.08);
  color: var(--signal);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
}

.scan-start:disabled {
  cursor: wait;
  opacity: 0.58;
}

.scan-progress {
  flex: 0 0 5px;
  height: 5px;
  min-height: 5px;
  overflow: hidden;
  background: rgb(231 234 223 / 0.14);
}

.scan-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--signal);
}

.scan-status {
  flex: 0 0 14px;
  margin: 0;
  color: rgb(231 234 223 / 0.64);
  font-size: 11px;
  line-height: 14px;
}

.scan-results {
  display: grid;
  flex: 1 1 0;
  align-content: start;
  grid-auto-rows: max-content;
  min-height: 84px;
  max-height: none;
  gap: 6px;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.scan-results li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  height: 38px;
  min-height: 38px;
  padding: 6px;
  border: 1px solid rgb(231 234 223 / 0.14);
  background: rgb(231 234 223 / 0.035);
}

.scan-results .scan-empty {
  height: auto;
}

.scan-results b {
  min-width: 0;
  color: var(--line);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-results em {
  color: var(--signal);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.scan-results b span {
  margin-left: 6px;
  color: rgb(231 234 223 / 0.58);
  font-weight: 400;
}

.scan-results li > span {
  grid-column: 1 / -1;
  color: rgb(231 234 223 / 0.58);
  font-size: 10px;
}

.scan-actions {
  display: flex;
  gap: 4px;
}

.scan-icon-button {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 1px solid rgb(244 201 93 / 0.34);
  border-radius: 50%;
  background: rgb(7 8 10 / 0.62);
  color: var(--signal);
  cursor: pointer;
}

.scan-icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scan-icon-button:hover,
.scan-icon-button.is-marked,
.scan-icon-button.is-saved {
  border-color: rgb(244 201 93 / 0.82);
}

.scan-icon-button.is-saved svg {
  fill: currentColor;
}

.stargate-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 8px;
  overflow: hidden;
}

.stargate-summary {
  display: grid;
  gap: 2px;
  min-height: 36px;
  margin: 0;
  padding: 8px;
  border: 1px solid rgb(231 234 223 / 0.12);
  background: rgb(231 234 223 / 0.03);
}

.stargate-summary b,
.stargate-summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stargate-summary b {
  color: var(--line);
  font-size: 12px;
}

.stargate-summary span {
  color: rgb(158 234 255 / 0.68);
  font-size: 10px;
  font-weight: 700;
}

.stargate-routes {
  display: grid;
  flex: 1 1 0;
  align-content: start;
  grid-auto-rows: max-content;
  min-height: 116px;
  gap: 6px;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.stargate-routes li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 8px;
  min-height: 46px;
  padding: 6px;
  border: 1px solid rgb(231 234 223 / 0.14);
  background: rgb(231 234 223 / 0.035);
}

.stargate-routes b,
.stargate-routes small,
.stargate-routes em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stargate-routes b {
  color: var(--line);
  font-size: 11px;
  font-weight: 800;
}

.stargate-routes b span,
.stargate-routes small {
  color: rgb(231 234 223 / 0.56);
  font-weight: 500;
}

.stargate-routes b span {
  margin-left: 6px;
}

.stargate-routes small {
  grid-column: 2;
  grid-row: 2;
  font-size: 10px;
}

.stargate-routes em {
  grid-column: 3;
  grid-row: 1 / 3;
  color: #9eeaff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stargate-actions {
  grid-row: 1 / 3;
  display: flex;
  gap: 4px;
}

.stargate-empty {
  grid-template-columns: 1fr;
}

.inventory-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 8px;
  overflow: visible;
}

.refinery-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.refinery-summary,
.refinery-queue,
.refinery-status {
  margin: 0;
  color: rgb(231 234 223 / 0.66);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.refinery-summary,
.refinery-queue {
  display: grid;
  gap: 3px;
  border: 1px solid rgb(231 234 223 / 0.1);
  background: rgb(231 234 223 / 0.035);
  padding: 8px;
}

.refinery-summary b,
.refinery-queue b {
  color: var(--line);
  font-size: 11px;
  font-weight: 900;
}

.refinery-progress {
  height: 6px;
  overflow: hidden;
  border: 1px solid rgb(231 234 223 / 0.13);
  background: rgb(231 234 223 / 0.05);
}

.refinery-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.refinery-list {
  display: grid;
  gap: 6px;
}

.refinery-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 58px;
  gap: 6px;
  align-items: center;
  min-height: 46px;
  border: 1px solid rgb(231 234 223 / 0.1);
  background: rgb(7 8 10 / 0.36);
  padding: 7px;
}

.refinery-row b,
.refinery-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refinery-row b {
  color: var(--line);
  font-size: 10px;
  font-weight: 900;
}

.refinery-row span,
.refinery-empty {
  color: rgb(231 234 223 / 0.55);
  font-size: 9px;
  font-weight: 800;
}

.refinery-row input,
.refinery-row button {
  min-height: 34px;
  border: 1px solid rgb(231 234 223 / 0.13);
  background: rgb(7 8 10 / 0.58);
  color: var(--line);
  font: inherit;
  font-size: 9px;
  font-weight: 900;
}

.refinery-row input {
  width: 100%;
  padding: 0 6px;
}

.refinery-row button {
  cursor: pointer;
}

.refinery-row button:disabled {
  cursor: default;
  opacity: 0.36;
}

.inventory-loadout {
  flex: 0 0 auto;
  border: 1px solid rgb(231 234 223 / 0.13);
  background: rgb(231 234 223 / 0.025);
  overflow: visible;
}

.inventory-loadout-grid {
  --inventory-slot-size: 56px;
  display: grid;
  grid-template-areas:
    ". scanner ."
    "mining-rig ship ore-processor"
    ". engine .";
  grid-template-columns: repeat(3, var(--inventory-slot-size));
  grid-template-rows: repeat(3, var(--inventory-slot-size));
  justify-content: center;
  gap: 18px;
  padding: 12px;
  overflow: visible;
}

.inventory-ship-preview {
  grid-area: ship;
  display: grid;
  place-items: center;
  width: var(--inventory-slot-size);
  height: var(--inventory-slot-size);
}

.inventory-ship-preview .ship {
  position: static;
  width: calc(var(--inventory-slot-size) * 0.94);
  height: auto;
  pointer-events: none;
  transform: none !important;
  z-index: auto;
}

.inventory-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: -2px 12px 12px;
  padding-top: 9px;
  border-top: 1px solid rgb(231 234 223 / 0.1);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.inventory-credits {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-mass {
  justify-self: end;
  color: var(--signal);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

.inventory-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--inventory-slot-size);
  height: var(--inventory-slot-size);
  padding: 0;
  border: 1px solid rgb(231 234 223 / 0.16);
  background: rgb(7 8 10 / 0.62);
  color: var(--line);
  cursor: pointer;
  font: inherit;
  overflow: visible;
  text-align: center;
}

.inventory-slot svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.2;
}

.inventory-slot.is-empty {
  border-style: dashed;
  color: rgb(231 234 223 / 0.46);
}

.inventory-slot.has-item {
  border-color: rgb(40 215 187 / 0.28);
  background: rgb(7 8 10 / 0.76);
}

.inventory-slot.is-broken {
  border-color: rgb(244 201 93 / 0.62);
  filter: saturate(0.35);
}

.inventory-slot.has-item svg {
  width: 46px;
  height: 46px;
  opacity: 1;
}

.inventory-slot:hover,
.inventory-slot:focus-visible,
.inventory-slot.is-drop-ok {
  border-color: rgb(40 215 187 / 0.72);
  outline: 0;
}

.inventory-slot.is-drop-blocked {
  border-color: rgb(244 201 93 / 0.8);
}

.slot-scanner {
  grid-area: scanner;
}

.slot-engine {
  grid-area: engine;
}

.slot-mining-rig {
  grid-area: mining-rig;
}

.slot-ore-processor {
  grid-area: ore-processor;
}

.inventory-cargo {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 120px;
  overflow: hidden;
}

.inventory-cargo-list {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.cargo-pod {
  margin-bottom: 8px;
  border: 1px solid rgb(231 234 223 / 0.14);
  background: rgb(231 234 223 / 0.03);
}

.cargo-pod summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  cursor: pointer;
  color: var(--line);
  font-size: 11px;
  font-weight: 900;
  list-style: none;
}

.cargo-pod summary::-webkit-details-marker {
  display: none;
}

.cargo-pod summary span {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.cargo-items {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  padding: 0 8px 8px;
}

.cargo-item {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 0;
  padding: 2px;
  border: 1px solid rgb(231 234 223 / 0.11);
  background: rgb(7 8 10 / 0.46);
  color: var(--line);
  cursor: grab;
  font: inherit;
  overflow: hidden;
  text-align: center;
}

.cargo-item svg {
  display: block;
  width: min(46px, 96%);
  height: min(46px, 96%);
}

.cargo-item em {
  position: absolute;
  right: 3px;
  bottom: 2px;
  max-width: calc(100% - 6px);
  overflow: hidden;
  color: #fff;
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
  text-overflow: ellipsis;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 4px #000;
  white-space: nowrap;
}

.cargo-item:hover,
.cargo-item:focus-visible {
  border-color: rgb(40 215 187 / 0.5);
  outline: 0;
}

.cargo-item.can-equip {
  border-color: rgb(40 215 187 / 0.18);
}

.inventory-tooltip {
  position: fixed;
  z-index: 1010;
  max-width: min(240px, calc(100vw - 20px));
  padding: 7px 8px;
  border: 1px solid rgb(231 234 223 / 0.18);
  background: rgb(7 8 10 / 0.96);
  color: var(--line);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 100ms ease, transform 100ms ease;
  white-space: pre-line;
}

.inventory-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.inventory-popup {
  position: fixed;
  z-index: 1001;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 24px));
  max-height: min(540px, calc(100vh - 34px));
  border: 1px solid rgb(231 234 223 / 0.18);
  background: rgb(7 8 10 / 0.98);
  box-shadow: 0 18px 64px rgb(0 0 0 / 0.42);
  transform: translate(-50%, -50%);
}

.inventory-popup[hidden] {
  display: none;
}

.inventory-popup-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid rgb(231 234 223 / 0.12);
  cursor: move;
  touch-action: none;
}

.inventory-popup-top b {
  min-width: 0;
  padding-left: 12px;
  overflow: hidden;
  color: var(--line);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-popup-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--line);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.inventory-popup-body {
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.inventory-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.inventory-equipped {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 54px;
  margin-bottom: 8px;
  padding: 5px;
  border: 1px solid rgb(40 215 187 / 0.38);
  background: rgb(40 215 187 / 0.055);
  color: var(--line);
  gap: 7px;
}

.inventory-equipped svg {
  width: 42px;
  height: 42px;
}

.inventory-equipped b,
.inventory-equipped small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-equipped b {
  font-size: 10px;
  font-weight: 900;
}

.inventory-equipped small {
  color: rgb(231 234 223 / 0.54);
  font-size: 9px;
  font-weight: 700;
}

.inventory-pick-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 54px;
  padding: 5px;
  border: 1px solid rgb(231 234 223 / 0.12);
  background: rgb(231 234 223 / 0.035);
  color: var(--line);
  cursor: pointer;
  gap: 7px;
  text-align: left;
}

.inventory-pick-item.is-equipped {
  border-color: rgb(40 215 187 / 0.58);
}

.inventory-pick-item svg {
  width: 42px;
  height: 42px;
}

.inventory-pick-item span,
.inventory-detail dd {
  min-width: 0;
}

.inventory-pick-item b,
.inventory-pick-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-pick-item b {
  font-size: 10px;
  font-weight: 900;
}

.inventory-pick-item small {
  color: rgb(231 234 223 / 0.54);
  font-size: 9px;
  font-weight: 700;
}

.inventory-popup-empty {
  margin: 0;
  color: rgb(231 234 223 / 0.58);
  font-size: 11px;
  font-weight: 800;
}

.inventory-detail {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.inventory-cursor-drop {
  position: fixed;
  z-index: 1020;
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  min-height: 42px;
  max-width: min(190px, calc(100vw - 16px));
  padding: 4px 8px 4px 4px;
  border: 1px solid rgb(40 215 187 / 0.38);
  background: rgb(7 8 10 / 0.94);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);
  color: var(--line);
  font-size: 10px;
  font-weight: 900;
  gap: 7px;
  pointer-events: none;
}

.inventory-cursor-drop[hidden] {
  display: none;
}

.inventory-cursor-drop svg {
  width: 34px;
  height: 34px;
}

.inventory-cursor-drop span {
  overflow: hidden;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-detail > svg {
  width: 64px;
  height: 64px;
}

.inventory-warning {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  color: var(--line);
}

.inventory-warning > svg {
  width: 54px;
  height: 54px;
  grid-row: 1 / span 3;
}

.inventory-warning p,
.inventory-warning b,
.inventory-warning small {
  margin: 0;
}

.inventory-warning p {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.inventory-warning b {
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-warning small {
  color: rgb(231 234 223 / 0.58);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.inventory-confirm-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inventory-detail dl {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 5px 8px;
  margin: 0;
  color: var(--line);
  font-size: 10px;
  line-height: 1.25;
}

.inventory-detail dt {
  color: rgb(231 234 223 / 0.48);
  font-weight: 900;
}

.inventory-detail dd {
  margin: 0;
  font-weight: 800;
}

.inventory-detail-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.inventory-split {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) auto;
  align-items: end;
  width: 100%;
  gap: 8px;
}

.inventory-split label {
  display: grid;
  gap: 4px;
}

.inventory-split span {
  color: rgb(231 234 223 / 0.5);
  font-size: 9px;
  font-weight: 900;
}

.inventory-split input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid rgb(231 234 223 / 0.14);
  background: rgb(231 234 223 / 0.055);
  color: var(--line);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 0 8px;
}

.inventory-action {
  min-width: 96px;
  height: 40px;
  border: 1px solid rgb(40 215 187 / 0.55);
  background: rgb(40 215 187 / 0.1);
  color: var(--line);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.inventory-action.is-compact {
  min-width: 74px;
  height: 34px;
  font-size: 10px;
}

.inventory-action.is-muted {
  border-color: rgb(231 234 223 / 0.2);
  background: rgb(231 234 223 / 0.055);
}

.inventory-action.is-danger {
  border-color: rgb(255 122 96 / 0.55);
  background: rgb(255 122 96 / 0.12);
  color: #ffd7ce;
}

.readout {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0;
  color: #7adfff;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 0 14px rgb(40 215 187 / 0.28);
}

.location-line {
  max-width: 100%;
  overflow: hidden;
  color: rgb(158 234 255 / 0.72);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readout b {
  color: #9eeaff;
  font-size: 22px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

@media (max-width: 560px) {
  .logout-button {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
  }

  .hud {
    top: 10px;
    width: min(360px, calc(100vw - 22px));
  }

  .location-line {
    font-size: 10px;
  }

  .readout b {
    font-size: 19px;
  }

  .action-dock {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .action-button {
    width: 44px;
    height: 44px;
  }

  .game-panel-top {
    height: 46px;
    padding: 0 8px 0 12px;
  }

  .modal-close,
  .game-panel-close {
    width: 44px;
    height: 44px;
  }

  .game-panel-resize {
    height: 30px;
  }

  .game-panel-resize::after {
    bottom: 13px;
  }

  .scanner-panel {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    height: min(520px, calc(100vh - 88px));
    height: min(520px, calc(100dvh - 88px));
    min-height: min(360px, calc(100vh - 88px));
    min-height: min(360px, calc(100dvh - 88px));
  }

  .inventory-panel {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    height: min(680px, calc(100vh - 88px));
    height: min(680px, calc(100dvh - 88px));
    min-height: min(560px, calc(100vh - 88px));
    min-height: min(560px, calc(100dvh - 88px));
  }

  .stargate-panel {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    height: min(520px, calc(100vh - 88px));
    height: min(520px, calc(100dvh - 88px));
    min-height: min(360px, calc(100vh - 88px));
    min-height: min(360px, calc(100dvh - 88px));
  }

  .refinery-panel {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    height: min(620px, calc(100vh - 88px));
    height: min(620px, calc(100dvh - 88px));
    min-height: min(420px, calc(100vh - 88px));
    min-height: min(420px, calc(100dvh - 88px));
  }

  .scanner-controls {
    gap: 11px;
    padding: 12px 12px 10px;
  }

  .scanner-controls label {
    flex-basis: 56px;
    grid-template-columns: 1fr 68px;
  }

  .scanner-controls label span {
    grid-column: 1 / -1;
  }

  .scanner-controls input[type="range"] {
    height: 32px;
  }

  .scanner-controls input[type="number"] {
    height: 40px;
  }

  .scanner-readout {
    flex-basis: 34px;
  }

  .scan-start {
    flex-basis: 44px;
    height: 44px;
    min-height: 44px;
  }

  .scan-status {
    flex-basis: 18px;
    line-height: 18px;
  }

  .scan-results {
    min-height: 104px;
    gap: 8px;
  }

  .scan-results li {
    height: 52px;
    min-height: 52px;
    padding: 6px;
  }

  .scan-actions {
    gap: 6px;
  }

  .scan-icon-button {
    width: 44px;
    height: 44px;
  }

  .scan-icon-button svg {
    width: 18px;
    height: 18px;
  }

  .stargate-body {
    padding: 12px 12px 10px;
  }

  .stargate-routes {
    gap: 8px;
  }

  .stargate-routes li {
    min-height: 58px;
  }

  .inventory-body {
    padding: 12px 12px 10px;
  }

  .inventory-loadout-grid {
    --inventory-slot-size: 54px;
    gap: 16px;
    padding: 10px;
  }

  .inventory-ship-preview .ship {
    width: 52px;
  }

  .inventory-slot {
    width: var(--inventory-slot-size);
    height: var(--inventory-slot-size);
  }

  .cargo-pod summary {
    min-height: 48px;
  }

  .cargo-item {
    min-height: 0;
  }

  .cargo-items {
    gap: 4px;
    padding: 0 6px 8px;
  }

  .cargo-item svg {
    width: min(46px, 96%);
    height: min(46px, 96%);
  }

  .cargo-item em {
    font-size: 7px;
  }

  .inventory-popup {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 28px);
  }

  .inventory-picker-grid {
    grid-template-columns: 1fr;
  }

  .inventory-pick-item {
    min-height: 56px;
  }

  .inspect-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .loot-tile {
    min-height: 48px;
  }
}

@media (hover: none), (pointer: coarse) {
  .logout-button,
  .action-button,
  .modal-close,
  .game-panel-close {
    width: 44px;
    height: 44px;
  }

  .game-panel-top {
    height: 46px;
  }

  .game-panel-resize {
    height: 30px;
  }

  .game-panel-resize::after {
    bottom: 13px;
  }
}
