/* Stellar Conflicts UI theme: pixel HUD on dark space.
   Markup comes from src/views/ui; the design reference is the "UI kit" board
   on the design canvas. Plain CSS, no build step: public/ is embedded. */

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark;

  --void: #0F1218;
  --panel: #141922;
  --panel-2: #11151D;
  --well: #0A0C11;
  --raised: #232A36;
  --raised-hover: #2A3240;
  --ink: #06080C;
  --edge: #2E3646;
  --edge-2: #3A4354;
  --edge-soft: #1A202B;

  --text: #E9E4D6;
  --text-2: #B9BFCB;
  --muted: #8C93A3;
  --faint: #5E6878;

  --hull: #E9DFC4;
  --hull-shade: #B3A98E;
  --teal: #3EC1C9;
  --teal-dark: #1F7F8A;
  --teal-deep: #134E55;
  --teal-light: #9BE7EC;
  --amber: #E8B04A;
  --amber-dark: #9A6E1E;
  --amber-deep: #4A3810;
  --green: #7BC67E;
  --green-dark: #4E8A52;
  --red: #E2574C;
  --red-light: #F08A80;
  --red-dark: #8C2F2A;
  --red-deep: #2A1416;
  --purple: #B48CF0;
  --purple-dark: #8A63C8;

  --font-ui: "Share Tech Mono", ui-monospace, monospace;
  --font-display: "Doto", "Share Tech Mono", ui-monospace, monospace;
  --font-prose: "Atkinson Hyperlegible", system-ui, sans-serif;

  /* 2px pixel border with notched corners, no border-radius anywhere. */
  --px-edge: 0 -2px 0 0 var(--edge), 0 2px 0 0 var(--edge), -2px 0 0 0 var(--edge), 2px 0 0 0 var(--edge);
  --rivet: linear-gradient(var(--faint), var(--faint));
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

body.sc {
  margin: 0;
  min-height: 100vh;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

.sc a { color: var(--teal); }
.sc a:hover { color: var(--teal-light); }

.sc :focus-visible { outline: 2px dashed var(--amber); outline-offset: 3px; }

.sc h1, .sc h2, .sc h3 { margin: 0; font-weight: 400; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout helpers ---------- */

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.container { max-width: 1360px; margin: 0 auto; padding: 40px 32px 64px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 32px; }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .container { padding: 24px 16px 48px; }
}

/* ---------- Type ---------- */

.display { font-family: var(--font-display); font-weight: 700; letter-spacing: .08em; line-height: 1.05; }
.display.xl { font-size: 64px; }
.display.lg { font-size: 44px; }
.display.md { font-size: 32px; }

/* Floating heading: Doto, outlined, sits straight on the starfield. */
.kicker {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--amber);
}

.title { font-size: 24px; letter-spacing: .02em; }
.label { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Outline for text drawn over the scene. */
.ol { text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink); }

.nameplate { font-size: 15px; letter-spacing: .04em; white-space: nowrap; }

.prose { font-family: var(--font-prose); font-size: 19px; line-height: 1.65; color: #D3D8E0; max-width: 72ch; }
.prose p { margin: 0 0 22px; }
.prose h2 { font-family: var(--font-ui); font-size: 28px; line-height: 1.2; margin: 48px 0 16px; color: var(--text); }
.prose h2::before { content: ""; display: inline-block; width: 12px; height: 12px; background: var(--teal); margin-right: 14px; vertical-align: 4px; }

/* Accent colour utilities, used by icons and text. */
.c-teal { color: var(--teal); }
.c-amber { color: var(--amber); }
.c-green { color: var(--green); }
.c-red { color: var(--red-light); }
.c-cream { color: var(--hull); }
.c-purple { color: var(--purple); }
.c-muted { color: var(--muted); }

.icon { display: inline-block; flex: none; vertical-align: -2px; }

/* ---------- Frames ---------- */

/* Riveted panel: dark fill, double inset border, a rivet in each corner. */
.frame {
  position: relative;
  background:
    var(--rivet) 6px 6px / 2px 2px no-repeat,
    var(--rivet) calc(100% - 6px) 6px / 2px 2px no-repeat,
    var(--rivet) 6px calc(100% - 6px) / 2px 2px no-repeat,
    var(--rivet) calc(100% - 6px) calc(100% - 6px) / 2px 2px no-repeat,
    var(--panel-2);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 0 0 4px var(--panel);
}
.frame.glass { background-color: rgba(14, 17, 24, .95); }

.panel { padding: 30px 22px 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.well { background: var(--well); box-shadow: inset 0 0 0 2px var(--edge-soft); }

/* Tab label sitting on a frame's top edge. */
.tab {
  position: absolute; top: -12px; left: 14px;
  margin: 0; padding: 1px 8px 2px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 400;
  letter-spacing: .14em; text-transform: uppercase;
  background: var(--teal); color: #08161A;
  box-shadow: 0 0 0 2px var(--ink);
}
.tab.amber { background: var(--amber); color: #1A1206; }
.tab.red { background: var(--red); color: #1A0806; }
.tab.cream { background: var(--hull); color: #08161A; }
.tab.green { background: var(--green); color: #0D1A0E; }
.tab.purple { background: var(--purple); color: #160D24; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px 2px;
  border: 0; border-radius: 0;
  background: var(--raised); color: var(--text);
  font: inherit; font-size: 17px; text-decoration: none; cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 #171C25, inset 0 2px 0 var(--edge-2);
}
.sc .btn:hover { background: var(--raised-hover); color: var(--text); }
.btn:active, .btn.pressed {
  transform: translateY(2px);
  box-shadow: 0 0 0 2px var(--ink), inset 0 -1px 0 #171C25, inset 0 2px 0 #171C25;
}
.btn.primary { background: var(--teal); color: #08161A; box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--teal-dark), inset 0 2px 0 var(--teal-light); }
.sc .btn.primary:hover { background: #5ACFD6; color: #08161A; }
.btn.danger { background: var(--red); color: #1A0806; box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--red-dark), inset 0 2px 0 #F59A90; }
.sc .btn.danger:hover { background: #EA6D63; color: #1A0806; }
.btn.gold { background: var(--amber); color: #1A1206; box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--amber-dark), inset 0 2px 0 #F6D58E; }
.sc .btn.gold:hover { background: #EDBE65; color: #1A1206; }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 2px var(--edge-2); }
.sc .btn.ghost:hover { background: var(--panel); }
.btn.sm { min-height: 34px; padding: 0 12px 2px; font-size: 14px; }
.btn.block { width: 100%; }
.btn .cost { font-size: 13px; opacity: .8; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: #1A1F28; color: var(--faint); cursor: not-allowed; transform: none;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--raised);
}

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0;
  background: #161B25; color: var(--text); cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 -6px 0 0 #0D1016;
}
.icon-btn:hover { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--teal), inset 0 -6px 0 0 #0D1016; }

.badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; background: var(--red); color: #1A0806;
  box-shadow: 0 0 0 2px var(--ink);
}
.badge.inline { position: static; display: inline-flex; margin-left: 6px; vertical-align: 1px; }
.badge.amber { background: var(--amber); color: #1A1206; }

.keycap {
  display: inline-flex; align-items: center; justify-content: center; font-family: inherit;
  min-width: 26px; height: 26px; padding: 0 6px 2px;
  font-size: 13px; color: var(--text); background: var(--raised);
  box-shadow: 0 0 0 2px var(--ink), inset 0 -3px 0 #171C25;
}
.keycap.sm { min-width: 18px; height: 18px; padding: 0 4px 1px; font-size: 12px; color: var(--text-2); background: var(--well); box-shadow: inset 0 0 0 1px var(--edge-2); }

.tag { display: inline-block; padding: 1px 8px 2px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; background: var(--teal); color: #08161A; }
.tag.amber { background: var(--amber); color: #1A1206; }
.tag.green { background: var(--green); color: #0D1A0E; }
.tag.red { background: var(--red); color: #1A0806; }
.tag.purple { background: var(--purple); color: #160D24; }
.tag.cream { background: var(--hull); color: #08161A; }
.tag.outline { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 2px var(--edge-2); }

/* ---------- Meters ---------- */

.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; margin-bottom: 6px; }
.seg {
  position: relative; display: flex; height: 12px; padding: 2px;
  background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.seg > i { display: block; height: 100%; }
.seg .mark { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--red); }
.f-teal { background: repeating-linear-gradient(90deg, var(--teal) 0 5px, transparent 5px 7px); }
.f-amber { background: repeating-linear-gradient(90deg, var(--amber) 0 5px, transparent 5px 7px); }
.f-green { background: repeating-linear-gradient(90deg, var(--green) 0 5px, transparent 5px 7px); }
.f-red { background: repeating-linear-gradient(90deg, var(--red) 0 5px, transparent 5px 7px); }
.f-cream { background: repeating-linear-gradient(90deg, var(--hull) 0 5px, transparent 5px 7px); }
.f-purple { background: repeating-linear-gradient(90deg, var(--purple) 0 5px, transparent 5px 7px); }
.f-muted { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 7px); }
.f-ghost { background: repeating-linear-gradient(90deg, #F59A90 0 5px, transparent 5px 7px); opacity: .55; }

.pips { display: inline-flex; gap: 6px; }
.pip { width: 12px; height: 12px; background: var(--well); box-shadow: inset 0 0 0 2px var(--edge-2); }
.pip.on { background: var(--amber); box-shadow: inset 0 0 0 2px var(--amber-dark); }

/* Hotbar slot with an optional cooldown shade rising from the bottom. */
.slot {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; padding: 0; border: 0;
  background: #161B25; color: var(--text); font: inherit; cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 -6px 0 0 #0D1016;
}
.slot:hover { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--teal), inset 0 -6px 0 0 #0D1016; }
.slot .key { position: absolute; top: 2px; left: 5px; font-size: 11px; color: var(--muted); }
.slot .cd { position: absolute; left: 2px; right: 2px; bottom: 2px; height: var(--cd, 0%); background: rgba(6, 8, 12, .78); }
.slot .cd-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--amber); }

.hotbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; }
.hotbar .sep { width: 2px; height: 40px; background: var(--edge); margin: 0 4px; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--red-light); }

.input {
  display: block; width: 100%; height: 44px; padding: 0 12px;
  border: 0; border-radius: 0; background: var(--well); color: var(--text);
  font: inherit; font-size: 16px;
  box-shadow: inset 0 0 0 2px var(--edge-2);
}
textarea.input { height: auto; min-height: 96px; padding: 12px; line-height: 1.5; resize: vertical; }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--teal); }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--red); }
.input::placeholder { color: var(--faint); }

.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.select .caret { position: absolute; right: 12px; top: 14px; pointer-events: none; color: var(--hull); }

/* Pixel switch built on a real checkbox. */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; flex: none; width: 56px; height: 28px; background: var(--well); box-shadow: inset 0 0 0 2px var(--edge-2); }
.switch .track::after { content: ""; position: absolute; top: 5px; left: 5px; width: 18px; height: 18px; background: var(--faint); }
.switch .state::after { content: "OFF"; font-size: 13px; color: var(--muted); }
.switch input:checked ~ .track { background: var(--teal-deep); box-shadow: inset 0 0 0 2px var(--teal); }
.switch input:checked ~ .track::after { left: 33px; background: var(--hull); }
.switch input:checked ~ .state::after { content: "ON"; }
.switch input:focus-visible ~ .track { outline: 2px dashed var(--amber); outline-offset: 3px; }
.switch .end { display: flex; align-items: center; gap: 10px; }

.check { display: flex; align-items: center; gap: 12px; min-height: 32px; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 22px; height: 22px; margin: 0; cursor: pointer;
  background: var(--well); box-shadow: inset 0 0 0 2px var(--edge-2);
}
.check input[type="checkbox"]:checked { background: var(--teal); box-shadow: inset 0 0 0 2px var(--teal-dark); }
.check input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 10px; width: 2px; height: 2px; background: #08161A;
  box-shadow: 2px 2px #08161A, 4px 4px #08161A, 6px 2px #08161A, 8px 0 #08161A, 10px -2px #08161A, 12px -4px #08161A;
}
.check input[type="radio"] { clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px); }
.check input[type="radio"]:checked::after { content: ""; position: absolute; left: 7px; top: 7px; width: 8px; height: 8px; background: var(--teal); }

fieldset.group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset.group legend { padding: 0; margin-bottom: 8px; }

/* Range slider; --v is the filled percentage, kept in sync by an inline handler. */
.range {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 14px; margin: 6px 0; cursor: pointer;
  background: repeating-linear-gradient(90deg, var(--teal) 0 5px, transparent 5px 7px) 2px 2px / calc(var(--v, 50%) - 4px) 10px no-repeat, var(--well);
  box-shadow: inset 0 0 0 2px var(--edge);
}
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 26px; background: var(--hull); box-shadow: inset -3px -3px 0 var(--hull-shade), 0 0 0 2px var(--ink); }
.range::-moz-range-thumb { width: 14px; height: 26px; border: 0; border-radius: 0; background: var(--hull); box-shadow: inset -3px -3px 0 var(--hull-shade), 0 0 0 2px var(--ink); }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper input {
  width: 80px; height: 44px; border: 0; text-align: center; font: inherit; font-size: 20px;
  background: var(--well); color: var(--text); box-shadow: inset 0 0 0 2px var(--edge-soft);
  appearance: textfield; -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Tabs: links or buttons, htmx-friendly. */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; box-shadow: inset 0 -2px 0 var(--edge); }
.tabs a, .tabs button {
  position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px 2px;
  border: 0; background: var(--panel); color: var(--muted); font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--raised);
}
.sc .tabs a:hover, .tabs button:hover { color: var(--text); }
.sc .tabs [aria-current="true"] { background: #1F2633; color: var(--text); box-shadow: inset 0 0 0 2px var(--edge), inset 0 3px 0 var(--teal); }

/* Segmented control built on radios: no JS needed. */
.segmented { display: inline-flex; gap: 4px; padding: 4px; margin: 0; border: 0; background: var(--well); box-shadow: inset 0 0 0 2px var(--edge); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px 2px; font-size: 14px; color: var(--muted); }
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--hull); color: #08161A; }
.segmented input:focus-visible + span { outline: 2px dashed var(--amber); outline-offset: 2px; }

/* ---------- Feedback ---------- */

.toast {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel-2);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 4px 0 0 0 var(--accent, var(--teal));
}
.toast.amber { --accent: var(--amber); }
.toast.green { --accent: var(--green); }
.toast.purple { --accent: var(--purple); }
.toast.red { --accent: var(--red); background: var(--red-deep); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px #7A2C26, inset 4px 0 0 0 var(--red); }
.toast-body { flex: 1; min-width: 0; }
.toast-detail { font-size: 13px; color: var(--muted); }

.banner {
  padding: 18px 12px 16px; text-align: center; background: #1A1608;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--amber), inset 0 0 0 4px var(--amber-deep);
}
.banner .display { font-size: 34px; color: var(--amber); }

/* ---------- Command menu (FF-style) ---------- */

.commands { display: flex; flex-direction: column; margin: 0 -6px; }
.cmd {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 42px; padding: 0 10px 0 24px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 17px; text-align: left; text-decoration: none; cursor: pointer;
}
.cmd::before {
  content: ""; display: none; position: absolute; left: 8px; top: 50%; margin-top: -5px; width: 2px; height: 2px;
  background: var(--hull);
  box-shadow: 0 2px var(--hull), 0 4px var(--hull), 0 6px var(--hull), 0 8px var(--hull), 2px 2px var(--hull), 2px 4px var(--hull), 2px 6px var(--hull), 4px 4px var(--hull);
}
.cmd:hover, .cmd:focus-visible, .cmd.hot { background: #1B2230; outline: none; }
.cmd:hover::before, .cmd:focus-visible::before, .cmd.hot::before { display: block; }
.sc .cmd:hover { color: var(--text); }
.cmd.danger, .sc .cmd.danger:hover { color: var(--red-light); }
.cmd:disabled, .cmd[aria-disabled="true"] { color: var(--faint); cursor: not-allowed; }
.cmd .cost { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--amber); }

/* ---------- Inventory ---------- */

.inventory { display: grid; grid-template-columns: repeat(8, 56px); gap: 12px; }
@media (max-width: 720px) { .inventory { grid-template-columns: repeat(5, 56px); } }
.item {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0; border: 0; background: #161B25; color: var(--rc); cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--rb, var(--edge-2));
}
.item.common { --rc: #A9B3C4; --rb: var(--edge-2); }
.item.uncommon { --rc: var(--green); --rb: var(--green-dark); }
.item.rare { --rc: var(--teal); --rb: #2FA3AB; }
.item.epic { --rc: var(--purple); --rb: var(--purple-dark); }
.item.legendary { --rc: var(--amber); --rb: var(--amber); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--amber), inset 0 0 0 4px var(--amber-deep); }
.item.empty { background: var(--void); cursor: default; --rb: #1E2430; }
.item.locked { background: repeating-linear-gradient(45deg, var(--panel-2) 0 4px, #161B25 4px 8px); cursor: not-allowed; --rb: #1E2430; }
.item[aria-selected="true"] { outline: 2px solid var(--hull); outline-offset: 2px; }
.item .qty { position: absolute; right: 4px; bottom: 1px; font-size: 13px; color: var(--text); }

.r-common { color: #A9B3C4; }
.r-uncommon { color: var(--green); }
.r-rare { color: var(--teal); }
.r-epic { color: var(--purple); }
.r-legendary { color: var(--amber); }

.tooltip { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.stat { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.stat .up { color: var(--green); }
.stat .down { color: var(--red-light); }

/* ---------- Dialog ---------- */

.dialog { display: flex; flex-direction: column; gap: 14px; padding: 18px; background: var(--well); box-shadow: inset 0 0 0 2px #7A2C26; }
.dialog-title { font-size: 22px; }

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 8px 10px; text-align: left; font-weight: 400; }
.table thead th { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); box-shadow: inset 0 -2px 0 var(--edge); }
.table tbody tr:nth-child(odd) { background: var(--panel); }
.table tbody tr:hover { background: #1B2230; }
.table .num { text-align: right; }

/* ---------- Starfield ---------- */

.space { position: relative; overflow: hidden; background: var(--void); }
.space::before, .space::after { content: ""; position: absolute; left: 0; top: 0; background: transparent; pointer-events: none; }
.space::before {
  width: 2px; height: 2px;
  box-shadow: 84px 62px #D8DEE8, 312px 140px #D8DEE8, 530px 48px #AEB6C4, 760px 210px #D8DEE8, 1010px 90px #AEB6C4, 1290px 160px #D8DEE8, 1390px 420px #AEB6C4, 1180px 610px #D8DEE8, 940px 760px #AEB6C4, 620px 840px #D8DEE8, 300px 700px #AEB6C4, 60px 520px #D8DEE8, 220px 380px #AEB6C4, 470px 300px #D8DEE8, 860px 470px #AEB6C4, 1100px 330px #D8DEE8, 1340px 780px #AEB6C4, 700px 590px #D8DEE8, 150px 860px #AEB6C4, 1230px 40px #D8DEE8;
}
.space::after {
  width: 1px; height: 1px;
  box-shadow: 40px 30px #5A6272, 190px 110px #5A6272, 260px 230px #747C8C, 380px 60px #5A6272, 450px 410px #747C8C, 590px 260px #5A6272, 650px 120px #747C8C, 720px 360px #5A6272, 820px 80px #747C8C, 890px 280px #5A6272, 960px 180px #747C8C, 1060px 230px #5A6272, 1150px 120px #747C8C, 1260px 300px #5A6272, 1380px 220px #747C8C, 1310px 520px #5A6272, 1210px 450px #747C8C, 1050px 500px #5A6272, 900px 640px #747C8C, 780px 700px #5A6272;
}
.space > * { position: relative; }

/* ---------- Motion ---------- */

/* Stepped blink for things that need attention: unread DMs, ready items. */
@keyframes sc-blink { 50% { opacity: 0; } }
.blink { animation: sc-blink 1s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .blink { animation: none; } }

/* htmx: dim a region while its request is in flight. */
.htmx-request.dim-while-loading, .htmx-request .dim-while-loading { opacity: .6; transition: opacity .1s steps(2); }

/* ---------- Error page ---------- */

.error { max-width: 640px; margin: 0 auto; padding: 120px 24px; display: flex; flex-direction: column; gap: 14px; }
.error h1 { font-family: var(--font-display); font-weight: 700; font-size: 44px; letter-spacing: .06em; }
.error-code { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .16em; text-transform: uppercase; color: var(--amber); }
.error p { margin: 0; color: var(--text-2); }
.error-note { padding: 10px 14px; background: var(--panel-2); box-shadow: inset 4px 0 0 var(--amber); }
.error-reference { font-size: 13px; }

/* ---------- Page kinds (src/views/layout.rs) ---------- */

.skip-link { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--hull); color: #08161A; }
.sc .skip-link:focus { top: 12px; color: #08161A; }

.sc .logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.sc .logo:hover { color: var(--text); }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: .08em; }

/* Site: header, page, footer; the footer sticks to the bottom on short pages. */
body.site { display: flex; flex-direction: column; }
.site-main { flex: 1 0 auto; }

.site-bar { max-width: 1360px; margin: 0 auto; padding: 0 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; }
.site-header { background: var(--panel-2); box-shadow: 0 2px 0 var(--edge); }
.site-header .site-bar { min-height: 68px; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.site-nav a { padding: 10px 2px; color: var(--text-2); text-decoration: none; font-size: 17px; }
.sc .site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -4px 0 var(--teal); }
.site-user { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.sc .site-pilot { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.sc .site-pilot:hover { color: var(--teal-light); }
.avatar { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--well); box-shadow: inset 0 0 0 2px var(--edge); color: var(--teal); }

.site-footer { margin-top: 48px; background: #0B0E13; box-shadow: inset 0 2px 0 var(--edge); }
.site-footer .site-bar { padding-top: 24px; padding-bottom: 24px; }
.site-footer a { color: var(--muted); }
.site-footer-build { margin-left: auto; }

/* Landing: full-bleed starfield, status line pinned to the bottom. */
body.landing { display: flex; flex-direction: column; }
.landing-main { flex: 1 0 auto; min-height: 100vh; padding-bottom: 72px; }
.landing-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 22px;
  padding: 14px 24px 18px; pointer-events: none;
}
.landing-footer a, .landing-footer span { pointer-events: auto; }

/* Game: the HUD owns the viewport. */
body.game { height: 100vh; overflow: hidden; }

@media (max-width: 720px) {
  .site-bar { padding: 0 16px; }
  .site-user { margin-left: 0; }
  .landing-footer { position: static; }
  .landing-main { padding-bottom: 0; }
}

/* Lost-link alert (public/js/link.js). Hidden while the link is fine; only
   shown when the page has actually lost the server. */
.link-alert {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100;
  max-width: calc(100% - 32px); padding: 10px 16px; font-size: 15px;
  background: var(--panel-2); color: var(--amber);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 4px 0 0 0 var(--amber);
}
.link-alert[data-link="connecting"], .link-alert[data-link="connected"] { display: none; }
.link-alert[data-link="offline"] {
  color: var(--red-light); background: var(--red-deep);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px #7A2C26, inset 4px 0 0 0 var(--red);
}
.link-alert[data-link="update"] {
  display: flex; align-items: center; gap: 12px; color: var(--text);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 4px 0 0 0 var(--teal);
}
