/* AuburnFlame PBBG stylesheet: pixel HUD components (riveted frames, bevelled
   buttons, segmented meters, inventory slots) in an ember palette.
   No inline styles anywhere (the CSP forbids them), so everything visual
   lives here. Colours are tokens; components below only use tokens. */

@font-face {
  font-family: "Share Tech Mono";
  src: url("/assets/fonts/share-tech-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Doto";
  src: url("/assets/fonts/doto-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Doto";
  src: url("/assets/fonts/doto-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Surfaces, darkest to lightest */
  --void: #140e0d;      /* page background, deep space */
  --well: #0d0908;      /* inset fields and meter troughs */
  --panel: #1b1312;     /* framed panels */
  --raised: #2a1d1a;    /* buttons, slots */
  --raised-hi: #34241f; /* hover */
  --edge: #3d2a26;      /* inner frame line */
  --edge-hi: #5a3f37;   /* rivets, ghost outlines */
  --ink: #070403;       /* the hard 2px outline around everything */

  /* Text */
  --text: #f1e3cf;      /* parchment */
  --text-dim: #c9b7a6;
  --muted: #a08f88;

  /* Roles */
  --ember: #f08a3c;      /* primary action, links, focus */
  --ember-hi: #f7ad6f;
  --ember-lo: #a14f17;
  --brass: #e6c15a;      /* credits, ore, rewards */
  --brass-lo: #9b7a24;
  --brass-hi: #f4dd96;
  --crimson: #e0475a;    /* hostile, danger, HP */
  --crimson-lo: #8c2433;
  --crimson-hi: #f29aa4;
  --sage: #8cc084;       /* healthy, success */
  --ice: #6fc3d9;        /* friendly, information, MP */
  --violet: #a98bf5;     /* epic, XP */

  --hp: var(--crimson);
  --mp: var(--ice);
  --xp: var(--violet);

  /* Older token names, kept so module stylesheets written against them still work. */
  --space-0: var(--well);
  --space-1: var(--panel);
  --space-2: var(--raised);
  --space-3: var(--raised-hi);
  --line: var(--edge);
  --accent: var(--ember);
  --accent-strong: var(--ember-lo);
  --ok: var(--sage);
  --danger: var(--crimson);
  --radius: 0;

  --font: "Share Tech Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: "Doto", "Share Tech Mono", ui-monospace, monospace;
  --gap: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--void);
  /* A sparse pixel starfield. */
  background-image:
    radial-gradient(1px 1px at 12% 18%, #f1e3cf88 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 42%, #f1e3cf66 50%, transparent 51%),
    radial-gradient(2px 2px at 35% 77%, #f08a3c55 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 85%, #f1e3cf77 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 8%, #6fc3d955 50%, transparent 51%);
  background-size: 420px 420px;
  background-attachment: fixed;
  -webkit-font-smoothing: none;
  font-synthesis: none;
}

a { color: var(--ember); text-decoration: none; }
a:focus-visible { color: var(--ember-hi); text-decoration: underline; }
@media (hover: hover) { a:hover { color: var(--ember-hi); text-decoration: underline; } }
img { max-width: 100%; image-rendering: pixelated; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 var(--gap); font-weight: 700; }
h1 { font: 700 1.9rem/1.1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
h2 { font-size: 1.15rem; letter-spacing: 0.04em; }
h3 { font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
p { margin: 0 0 var(--gap); }
.muted { color: var(--muted); }
.mono { font-family: var(--font); }
.credits strong { color: var(--brass); }
.empty { font-style: normal; }
::selection { background: var(--ember); color: var(--ink); }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--ember); color: var(--ink); padding: 6px 12px; box-shadow: 0 0 0 2px var(--ink);
}
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ── Frame: the riveted panel every surface uses ──────────────────────── */

.frame, .panel, .card, .panel-dialog, .map-stage, .hud, fieldset {
  position: relative;
  background:
    linear-gradient(var(--edge-hi), var(--edge-hi)) 6px 6px / 2px 2px no-repeat,
    linear-gradient(var(--edge-hi), var(--edge-hi)) calc(100% - 6px) 6px / 2px 2px no-repeat,
    linear-gradient(var(--edge-hi), var(--edge-hi)) 6px calc(100% - 6px) / 2px 2px no-repeat,
    linear-gradient(var(--edge-hi), var(--edge-hi)) calc(100% - 6px) calc(100% - 6px) / 2px 2px no-repeat,
    var(--panel);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 0 0 4px #160f0e;
}

/* A label chip sitting on a frame's top edge: <span class="tab">Cargo</span> */
.tab {
  position: absolute; top: -12px; left: 14px;
  padding: 1px 8px 2px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--ember); color: var(--ink); box-shadow: 0 0 0 2px var(--ink);
}
.tab.foe { background: var(--crimson); }
.tab.gold { background: var(--brass); }
.tab.ice { background: var(--ice); }
.tab.cream { background: var(--text); }

/* ── HUD ─────────────────────────────────────────────────────────────── */

.hud {
  display: flex; align-items: center; gap: 18px;
  margin: 10px 10px 0; padding: 10px 18px;
  position: sticky; top: 10px; z-index: 20;
}
.brand img { display: block; height: 40px; width: auto; image-rendering: auto; }
.brand .brand-icon { display: none; height: 30px; }
.hud-stat { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; white-space: nowrap; }
.hud-stat > .muted { letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.75rem; }
.hud-stat strong { font-variant-numeric: tabular-nums; }
.guest-links, .public-links, .staff-links { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; }
.guest-links { margin-left: auto; }
.public-links { padding: 10px 20px; }

/* Segmented meter: a trough with 5px blocks and 2px gaps. */
.meter {
  position: relative; display: inline-block; width: 130px; height: 14px; padding: 2px;
  background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.meter > span { position: absolute; inset: 2px auto 2px 2px; max-width: calc(100% - 4px); }
.meter.hp > span { background: repeating-linear-gradient(90deg, var(--hp) 0 5px, transparent 5px 7px); }
.meter.mp > span { background: repeating-linear-gradient(90deg, var(--mp) 0 5px, transparent 5px 7px); }
.meter.xp > span { background: repeating-linear-gradient(90deg, var(--xp) 0 5px, transparent 5px 7px); }
.meter.ok > span { background: repeating-linear-gradient(90deg, var(--sage) 0 5px, transparent 5px 7px); }
.meter.gold > span { background: repeating-linear-gradient(90deg, var(--brass) 0 5px, transparent 5px 7px); }
/* Widths come in 5% steps as classes (no inline styles under the CSP). */
.w0>span{width:0}.w5>span{width:5%}.w10>span{width:10%}.w15>span{width:15%}.w20>span{width:20%}
.w25>span{width:25%}.w30>span{width:30%}.w35>span{width:35%}.w40>span{width:40%}.w45>span{width:45%}
.w50>span{width:50%}.w55>span{width:55%}.w60>span{width:60%}.w65>span{width:65%}.w70>span{width:70%}
.w75>span{width:75%}.w80>span{width:80%}.w85>span{width:85%}.w90>span{width:90%}.w95>span{width:95%}
.w100>span{width:100%}

/* ── Game layout: the map fills the screen; the bar sits along the bottom ── */

/* --bar-height is measured by app.js; the sheets and toasts sit above it. */
:root { --bar-height: 76px; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
/* No page pinch-zoom or double-tap zoom in the game (the map takes taps only). */
body.in-game { height: 100vh; height: 100dvh; overflow: hidden; touch-action: pan-x pan-y; }

/* The map lies under everything and covers the screen: a canvas drawn by
   map.js, with the camera on your ship. */
.game-layout > #main {
  position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none;
  background: radial-gradient(ellipse at center, #2a1611 0%, var(--well) 75%);
}
.map-stage { position: absolute; inset: 0; padding: 0; background: none; box-shadow: none; }
#map-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
/* The stars under the canvas: a tile per 1000 map units (map.js STAR_TILE),
   slid by map.js with a transform, so moving them never repaints. */
.map-stars {
  position: absolute; left: -1000px; top: -1000px; right: -1000px; bottom: -1000px; pointer-events: none;
  background: url("/assets/art/starfield.svg") 0 0 / 1000px 1000px repeat; will-change: transform;
}
@media (max-width: 820px) { .map-stars { left: -800px; top: -800px; right: -800px; bottom: -800px; background-size: 800px 800px; } }
#map-canvas:focus-visible { outline: 3px solid var(--ember); outline-offset: -3px; }
/* For screen readers and keyboards only. */
.sr-only:not(:focus-within) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Taps never select text (Safari needs the prefix; the callout is iOS's
   long-press menu). */
.game-layout > #main, .map-header, .game-bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#main:focus { outline: none; }
.guest-main { max-width: 980px; margin: 0 auto; padding: 18px 12px; }

/* Alerts (battle, stat points, new mail) in the top-right corner. */
#alerts {
  position: fixed; z-index: 12; top: calc(8px + var(--safe-top)); right: 8px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 60%;
}
#alerts:empty { display: none; }
#alerts .notice { margin: 0; }

/* The bar: round pinned buttons either side of the captain button. */
.game-bar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 8px max(10px, calc((100% - 680px) / 2)) calc(8px + var(--safe-bottom));
  background: var(--panel); box-shadow: 0 -2px 0 var(--ink), inset 0 2px 0 var(--edge);
}
.bar-side { display: flex; justify-content: space-evenly; gap: 6px; min-width: 0; }
.bar-button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  color: var(--text-dim); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; text-align: center;
}
.bar-button img {
  width: 52px; height: 52px; padding: 8px; object-fit: contain; border-radius: 50%; image-rendering: auto;
  background: var(--raised); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 -4px 0 #170f0d;
}
.bar-button:focus-visible { text-decoration: none; color: var(--ember-hi); outline: none; }
.bar-button:focus-visible img { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ember), inset 0 -4px 0 #170f0d; }
@media (hover: hover) {
  .bar-button:hover { text-decoration: none; color: var(--ember-hi); }
  .bar-button:hover img { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ember), inset 0 -4px 0 #170f0d; }
}
.bar-button:active img { transform: translateY(1px); }

.captain {
  display: block; width: 210px; min-height: 0; padding: 6px 10px 6px 6px; margin: 0;
  color: var(--text); font: inherit; text-align: left; text-transform: none; letter-spacing: 0; cursor: pointer;
  background: var(--raised); border: 0; border-radius: 34px;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge-hi), inset 0 -5px 0 #170f0d;
}
.captain:focus-visible, .captain:has(+ * .menu-sheet:popover-open) { outline: none; box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ember), inset 0 -5px 0 #170f0d; }
@media (hover: hover) { .captain:hover { background: var(--raised-hi); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ember), inset 0 -5px 0 #170f0d; } }
#hud { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.captain-ship {
  flex: none; width: 48px; height: 48px; padding: 4px; object-fit: contain; border-radius: 50%;
  background: var(--well); box-shadow: inset 0 0 0 2px var(--edge); image-rendering: auto;
}
.captain-vitals { flex: 1; min-width: 0; display: grid; gap: 2px; }
.captain-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0.78rem; line-height: 1.2; }
.captain .hud-stat { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: 0.62rem; line-height: 1; }
.captain .hud-stat > .muted { display: none; }
.captain .meter { width: 100%; height: 9px; padding: 1px; }
.captain .meter > span { inset: 1px auto 1px 1px; max-width: calc(100% - 2px); }
.captain .hud-stat strong { font-weight: 400; color: var(--text-dim); }

/* Sheets rise from the bar: the main menu (a popover) and the window every
   screen opens in (#panel). */
.menu-sheet, .panel-dialog {
  position: fixed; inset: auto 0 var(--bar-height) 0; margin: 0 auto; padding: 0; width: min(760px, 100%);
  color: var(--text); border: 0;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 0 0 4px #160f0e, 0 -12px 40px rgb(0 0 0 / 0.55);
}
.menu-sheet {
  width: min(560px, 100%); top: 0; max-height: none; overflow: auto; overscroll-behavior: contain;
  padding: calc(14px + var(--safe-top)) 16px 16px; background: var(--panel);
}
.menu-sheet:popover-open, .panel-dialog[open] { animation: sheet-up 0.16s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
#menu-status { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; margin-right: 4px; }
.menu-name { font: 700 1.2rem/1.1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.menu-pilot { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text); font-size: 0.8rem; line-height: 1.3; }
.menu-pilot:focus-visible { text-decoration: none; outline: none; }
.menu-pilot:focus-visible .ring { box-shadow: 0 0 0 2px var(--ember); }
@media (hover: hover) { .menu-pilot:hover { text-decoration: none; color: var(--text); } .menu-pilot:hover .ring { box-shadow: 0 0 0 2px var(--ember); } }
.menu-sheet h2 { margin: 12px 0 6px; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; }
.menu-news { margin-top: 18px; font-size: 0.85rem; }
.menu-news .card { background: none; box-shadow: none; padding: 10px 0; }
.menu-foot { margin-top: 16px; padding-top: 10px; box-shadow: inset 0 2px 0 var(--edge); color: var(--muted); font-size: 0.68rem; }
.menu-foot .link-button { margin-bottom: 8px; font-size: 0.85rem; }
.menu-foot p { margin: 0; }
.menu-foot a { color: var(--muted); text-decoration: underline; }

/* A radial menu (views::components::radial): spokes evenly round a centre on
   a faint compass rose. --n is the number of spokes and --i each one's place,
   so any count up to 16 lays itself out. */
.radial {
  --hub: 24cqw;
  position: relative; width: min(100%, 440px); aspect-ratio: 1; margin: 6px auto 0; container-type: inline-size;
  background:
    radial-gradient(circle closest-side, transparent 0 31%, rgb(241 227 207 / 0.07) 31% 31.6%, transparent 31.6% 52%, rgb(241 227 207 / 0.05) 52% 52.5%, transparent 52.5%),
    repeating-conic-gradient(from -1.5deg, rgb(241 227 207 / 0.035) 0 3deg, transparent 3deg 45deg);
  border-radius: 50%;
}
.radial-spokes { list-style: none; margin: 0; padding: 0; --n: 1; }
.radial-spokes > li {
  --a: calc((var(--i, 0) + 0.5) * 360deg / var(--n));
  position: absolute; left: 50%; top: 50%; width: 22cqw;
  transform: translate(-50%, -50%) translate(calc(sin(var(--a)) * 38cqw), calc(cos(var(--a)) * -38cqw));
}
.spoke {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px;
  color: var(--text); font-size: clamp(0.66rem, 3.2cqw, 0.82rem); line-height: 1.2; text-align: center;
}
.spoke img { width: clamp(30px, 10cqw, 44px); height: clamp(30px, 10cqw, 44px); object-fit: contain; image-rendering: auto; }
.spoke:focus-visible { text-decoration: none; color: var(--ember-hi); outline: none; }
.spoke:focus-visible img { filter: drop-shadow(0 0 4px var(--ember)); }
@media (hover: hover) { .spoke:hover { text-decoration: none; color: var(--ember-hi); } .spoke:hover img { filter: drop-shadow(0 0 4px var(--ember)); } }
/* The hub (the centre's first picture, --hub across) sits on the exact
   centre; the words hang below it. */
.radial-centre {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, calc(var(--hub) / -2)); width: 40cqw;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; font-size: 0.8rem; line-height: 1.3;
}
.radial-spokes > li:nth-child(2) { --i: 1; } .radial-spokes > li:nth-child(3) { --i: 2; } .radial-spokes > li:nth-child(4) { --i: 3; }
.radial-spokes > li:nth-child(5) { --i: 4; } .radial-spokes > li:nth-child(6) { --i: 5; } .radial-spokes > li:nth-child(7) { --i: 6; }
.radial-spokes > li:nth-child(8) { --i: 7; } .radial-spokes > li:nth-child(9) { --i: 8; } .radial-spokes > li:nth-child(10) { --i: 9; }
.radial-spokes > li:nth-child(11) { --i: 10; } .radial-spokes > li:nth-child(12) { --i: 11; } .radial-spokes > li:nth-child(13) { --i: 12; }
.radial-spokes > li:nth-child(14) { --i: 13; } .radial-spokes > li:nth-child(15) { --i: 14; } .radial-spokes > li:nth-child(16) { --i: 15; }
.radial-spokes:has(> li:nth-child(2):last-child) { --n: 2; } .radial-spokes:has(> li:nth-child(3):last-child) { --n: 3; }
.radial-spokes:has(> li:nth-child(4):last-child) { --n: 4; } .radial-spokes:has(> li:nth-child(5):last-child) { --n: 5; }
.radial-spokes:has(> li:nth-child(6):last-child) { --n: 6; } .radial-spokes:has(> li:nth-child(7):last-child) { --n: 7; }
.radial-spokes:has(> li:nth-child(8):last-child) { --n: 8; } .radial-spokes:has(> li:nth-child(9):last-child) { --n: 9; }
.radial-spokes:has(> li:nth-child(10):last-child) { --n: 10; } .radial-spokes:has(> li:nth-child(11):last-child) { --n: 11; }
.radial-spokes:has(> li:nth-child(12):last-child) { --n: 12; } .radial-spokes:has(> li:nth-child(13):last-child) { --n: 13; }
.radial-spokes:has(> li:nth-child(14):last-child) { --n: 14; } .radial-spokes:has(> li:nth-child(15):last-child) { --n: 15; }
.radial-spokes:has(> li:nth-child(16):last-child) { --n: 16; }

/* A ring meter round a picture (views::components::ring): the XP ring. */
.ring {
  --p: 0%; display: grid; place-items: center; width: var(--hub, 96px); aspect-ratio: 1; padding: 4px; border-radius: 50%;
  background: conic-gradient(var(--ring, var(--xp)) var(--p), rgb(241 227 207 / 0.14) 0);
}
.ring > img { width: 100%; height: 100%; padding: 8%; object-fit: contain; border-radius: 50%; background: var(--panel); image-rendering: auto; }
.ring.w5{--p:5%}.ring.w10{--p:10%}.ring.w15{--p:15%}.ring.w20{--p:20%}.ring.w25{--p:25%}.ring.w30{--p:30%}.ring.w35{--p:35%}
.ring.w40{--p:40%}.ring.w45{--p:45%}.ring.w50{--p:50%}.ring.w55{--p:55%}.ring.w60{--p:60%}.ring.w65{--p:65%}.ring.w70{--p:70%}
.ring.w75{--p:75%}.ring.w80{--p:80%}.ring.w85{--p:85%}.ring.w90{--p:90%}.ring.w95{--p:95%}.ring.w100{--p:100%}

#panel:empty { display: none; }
.panel-dialog {
  z-index: 18; max-height: calc(100dvh - var(--bar-height) - var(--safe-top) - 48px);
  display: flex; flex-direction: column;
}
.panel-dialog:not([open]) { display: none; }
/* --scrollbar-width (set by app.js) keeps the button clear of the body's scrollbar. */
.panel-close { position: absolute; top: 10px; right: calc(10px + var(--scrollbar-width, 0px)); z-index: 2; display: block; }
.panel-dialog .close {
  width: 34px; height: 34px; min-height: 0; padding: 0; font-size: 1.2rem; line-height: 1;
  color: var(--text); background: var(--raised); border: 0; cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge);
}
.panel-dialog .close:focus-visible { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--crimson); }
@media (hover: hover) { .panel-dialog .close:hover { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--crimson); } }
.panel-body { overflow: auto; overscroll-behavior: contain; padding: 14px 20px 20px; min-height: 0; }
/* Module screens are framed cards on their own; in the window the window is the frame. */
.panel-body > :is(.card, .panel, section, article) { background: none; box-shadow: none; padding: 0; margin: 0; }
.panel-body > :is(.card, .panel, section, article) > .tab:first-child { position: static; display: inline-block; justify-self: start; align-self: start; margin: 2px 0 12px; }
.panel-body > :is(.card, .panel, section, article) > :is(h1, h2):first-of-type { margin-right: 44px; }

/* ── Galaxy map ──────────────────────────────────────────────────────── */

.map-header {
  position: fixed; z-index: 10; top: calc(8px + var(--safe-top)); left: 8px; max-width: calc(100% - 16px);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 8px 14px;
  background: rgb(27 19 18 / 0.88); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge);
}
.map-header h1 { font-size: 1.2rem; margin: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.78rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.map-object { cursor: pointer; }
.map-object image { transition: transform 0.15s steps(3); transform-box: fill-box; transform-origin: center; }
.map-object:focus image { transform: scale(1.15); }
/* Hover effects only where there is a real pointer: on phones a :hover change
   makes Safari spend the first tap on hovering, and the tap never clicks. The
   same goes for every hover style in this file. */
@media (hover: hover) {
  .map-object:hover image { transform: scale(1.15); }
  .map-hit:hover { background: rgb(255 255 255 / 0.04); }
  .map-object.loot:hover .loot-icon { opacity: 1; }
}
.map-object:focus { outline: none; }
.map-object:focus-visible image { filter: drop-shadow(0 0 3px var(--ember)); }
.map-object text {
  fill: var(--text); font: 13px var(--font); letter-spacing: 0.08em; text-transform: uppercase;
  paint-order: stroke; stroke: var(--ink); stroke-width: 4px; pointer-events: none;
}
.map-object.hostile text { fill: var(--crimson-hi); }
.map-object.player text { fill: var(--ice); }
.map-object.loot text { fill: var(--brass); }
.map-self image { filter: drop-shadow(0 0 4px var(--ember)); }
/* Docked ships are inside their base. */
.map-self.docked { display: none; }
.place-badge circle { fill: var(--panel); stroke: var(--edge-hi); stroke-width: 3; }
.docked-here > image { filter: drop-shadow(0 0 14px var(--ember)); }
.map-object.landmark.docked-here .map-label { fill: var(--ember); }
.map-self text { fill: var(--ember); }
.ship-move { transition: transform 0.8s ease-in-out; }
.star { fill: var(--text); opacity: 0.55; }

/* ── Panels, cards, forms ────────────────────────────────────────────── */

.panel, .card { padding: 26px 20px 20px; }
.panel.narrow { max-width: 480px; margin: 32px auto; }
.card + .card, .panel + .panel { margin-top: 22px; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }

form { display: grid; gap: 12px; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label { display: grid; gap: 6px; font-size: 0.82rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
label > input, label > select, label > textarea { text-transform: none; letter-spacing: normal; }
fieldset { margin: 6px 0 0; padding: 22px 14px 14px; border: 0; }
legend {
  position: absolute; top: -12px; left: 14px; padding: 1px 8px 2px;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--text); color: var(--ink); box-shadow: 0 0 0 2px var(--ink);
}
input, select, textarea {
  font: 16px var(--font); color: var(--text);
  background: var(--well); border: 0; border-radius: 0; padding: 10px 12px; min-height: 44px;
  box-shadow: inset 0 0 0 2px var(--edge-hi);
}
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ember); }
input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--crimson); }
input[type="radio"], input[type="checkbox"] {
  appearance: none; flex: 0 0 auto; width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0; cursor: pointer;
  background: var(--well); box-shadow: inset 0 0 0 2px var(--edge-hi); position: relative;
}
input[type="checkbox"]:checked { background: var(--ember); box-shadow: inset 0 0 0 2px var(--ember-lo); }
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); }
input[type="radio"]:checked::after { content: ""; position: absolute; inset: 7px; background: var(--ember); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.choice {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer;
  color: var(--text); text-transform: none; letter-spacing: normal; font-size: 0.95rem;
  box-shadow: inset 0 0 0 2px transparent;
}
@media (hover: hover) { .choice:hover { box-shadow: inset 0 0 0 2px var(--edge-hi); } }
.choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ember); }
.choice.wide { grid-column: 1 / -1; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px 2px; border: 0; border-radius: 0; cursor: pointer;
  font: 17px var(--font); color: var(--text); background: var(--raised);
  box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 #170f0d, inset 0 2px 0 #4a332c;
}
@media (hover: hover) { button:hover, .button:hover { background: var(--raised-hi); color: var(--text); text-decoration: none; } }
button:active, .button:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--ink), inset 0 -1px 0 #170f0d, inset 0 2px 0 #170f0d; }
button.primary, .button.primary { background: var(--ember); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--ember-lo), inset 0 2px 0 var(--ember-hi); }
@media (hover: hover) { button.primary:hover, .button.primary:hover { background: #f59c57; color: var(--ink); } }
button.danger, .button.danger { background: var(--crimson); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--crimson-lo), inset 0 2px 0 var(--crimson-hi); }
button.gold, .button.gold { background: var(--brass); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), inset 0 -4px 0 var(--brass-lo), inset 0 2px 0 var(--brass-hi); }
button.ghost, .button.ghost { background: transparent; color: var(--text-dim); box-shadow: inset 0 0 0 2px var(--edge-hi); }
button.small, .button.small { min-height: 34px; padding: 0 12px 2px; font-size: 14px; }
button:disabled, .button[aria-disabled="true"] { background: #211715; color: #6e5a53; cursor: not-allowed; transform: none; box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px #2c1f1c; }
.link-button { min-height: 0; padding: 0; background: none; box-shadow: none; color: var(--ember); font-size: 0.95rem; }
@media (hover: hover) { .link-button:hover { background: none; color: var(--ember-hi); text-decoration: underline; } }
.link-button:active { transform: none; box-shadow: none; }
.htmx-request button, button.htmx-request { opacity: 0.6; }

/* Keycap hint: <kbd>1</kbd> */
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px 2px;
  font: 13px var(--font); color: var(--text); background: var(--raised);
  box-shadow: 0 0 0 2px var(--ink), inset 0 -3px 0 #170f0d;
}

/* ── Tables and grids ────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 2px solid var(--edge); vertical-align: middle; }
th { color: var(--muted); font-weight: 400; font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (hover: hover) { tbody tr:hover { background: #ffffff08; } }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.item-slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 96px; padding: 10px 6px 10px; font-size: 0.74rem; text-align: center;
  background: var(--raised);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 0 -6px 0 0 #170f0d;
}
@media (hover: hover) { .item-slot:hover { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--ember), inset 0 -6px 0 0 #170f0d; } }
.item-slot img { width: 44px; height: 44px; object-fit: contain; }
.item-slot.empty { background: var(--well); box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px #2a1d1a; }
.item-slot .slot-no { position: absolute; top: 3px; left: 6px; color: var(--muted); font-size: 0.68rem; }
.item-slot button { min-height: 28px; padding: 0 8px 2px; font-size: 12px; }
.stat-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.stat-list dt { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.82rem; }
.stat-list dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ── Battle ──────────────────────────────────────────────────────────── */

/* The battle fills the screen, over the bar, and while it is on it has no
   close button (app.js ignores Esc too): you win, lose or flee. */
.panel-dialog:has(.battle-screen) {
  inset: 0; width: 100%; max-height: none; height: 100vh; height: 100dvh; z-index: 40;
  background: radial-gradient(ellipse at 50% 38%, #2a1611 0%, var(--well) 70%); box-shadow: none; animation: none;
}
.panel-dialog:has(.battle-screen.active) .panel-close { display: none; }
.panel-dialog:has(.battle-screen) .panel-body { flex: 1; display: flex; padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom)); }
.battle-screen {
  flex: 1; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 560px; margin: 0 auto; min-height: 0;
}
.battle-foe h1 { margin: 0 44px 0 0; font-size: 1.3rem; }
.battle-screen.active .battle-foe h1 { margin-right: 0; }
.battle-foe p { margin: 2px 0 6px; font-size: 0.8rem; }

/* Solid bars with the numbers on them. */
.vbar {
  position: relative; display: block; height: 20px; padding: 2px; background: var(--well);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 1px var(--edge);
}
.vbar > span { position: absolute; inset: 2px auto 2px 2px; max-width: calc(100% - 4px); transition: width 0.4s ease-out; }
.vbar.hp > span { background: linear-gradient(#e0453a, #a3241c); }
.vbar.mp > span { background: linear-gradient(#4aa8e8, #1f6aa8); }
.vbar.shield { height: 12px; }
.vbar.shield > span { background: linear-gradient(#9fe8ff, #3fb6d9); }
.vbar.shield > b { font-size: 0.62rem; line-height: 8px; }
.arena .combatant.cloaked .ship-art { opacity: 0.35; filter: drop-shadow(0 0 6px #9fe8ff); }
.vbar.foe { height: 24px; }
.vbar > b { position: relative; display: block; font: 400 0.78rem/16px var(--font); text-align: center; color: #fff; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.battle-foe .vbar > b { line-height: 20px; }

/* The arena: the foe up on the right facing left, you down on the left. */
.arena { position: relative; flex: 1; min-height: 150px; }
.arena .combatant { position: absolute; }
.arena .combatant.foe { right: 8%; top: 6%; }
.arena .combatant.you { left: 8%; bottom: 4%; }
.combatant .ship { position: relative; display: block; width: clamp(80px, 26vw, 128px); aspect-ratio: 1; }
.combatant .ship > img { width: 100%; height: 100%; object-fit: contain; }
.combatant.foe .ship-art { transform: scaleX(-1); }
.combatant.hit .ship-art { animation: hit 0.4s steps(4) var(--at) backwards; }
.combatant.foe.hit .ship-art { animation-name: hit-flipped; }
@keyframes hit { 0%, 100% { transform: translateX(0); filter: none; } 25% { transform: translateX(-6px); filter: brightness(2); } 75% { transform: translateX(6px); } }
@keyframes hit-flipped { 0%, 100% { transform: scaleX(-1); filter: none; } 25% { transform: scaleX(-1) translateX(-6px); filter: brightness(2); } 75% { transform: scaleX(-1) translateX(6px); } }
/* Hit effects: SVG frames over the ship, each shown for one frame at 24 fps, the hits
   of an action one after another (at-N), staggered a little round the ship. */
.impact { position: absolute; pointer-events: none; }
.impact.gun_hit { width: 40%; height: 40%; left: 30%; top: 30%; }
.impact.missile_hit { width: 86%; height: 86%; left: 7%; top: 7%; }
.combatant .impact img {
  position: absolute; inset: 0; width: 100%; height: 100%; transform: none; opacity: 0;
  animation: impact-frame 41.7ms step-end; animation-delay: calc(var(--at) + var(--f) * 41.7ms);
}
@keyframes impact-frame { from, to { opacity: 1; } }
.impact .f1 { --f: 0; } .impact .f2 { --f: 1; } .impact .f3 { --f: 2; } .impact .f4 { --f: 3; }
.impact .f5 { --f: 4; } .impact .f6 { --f: 5; } .impact .f7 { --f: 6; }
.at-0 { --at: 0.15s; } .at-1 { --at: 0.6s; } .at-2 { --at: 1.05s; }
.at-3 { --at: 1.5s; } .at-4 { --at: 1.95s; } .at-5 { --at: 2.4s; }
.impact.gun_hit.at-1, .impact.gun_hit.at-4 { left: 22%; top: 34%; }
.impact.gun_hit.at-2, .impact.gun_hit.at-5 { left: 36%; top: 22%; }

/* Your bars: hold one to drink the potion beside it. */
.battle-you { display: grid; gap: 6px; }
.you-name { margin: 0; font-size: 0.85rem; }
.vital {
  display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; width: 100%; min-height: 0; padding: 0;
  color: var(--text); font: inherit; text-align: left; text-transform: none; letter-spacing: 0; background: none; border: 0; box-shadow: none;
}
.potion { position: relative; display: block; width: 34px; height: 30px; }
.potion img { width: 30px; height: 30px; object-fit: contain; image-rendering: auto; }
.potion b { position: absolute; right: -2px; bottom: -4px; font-size: 0.68rem; color: var(--text); text-shadow: 0 1px 0 #000, 0 0 3px #000; }

.battle-feed { max-height: 4.6em; overflow: auto; overscroll-behavior: contain; font-size: 0.8rem; }
.battle-log { list-style: none; margin: 0; padding: 6px 10px; background: rgb(13 9 8 / 0.7); box-shadow: inset 0 0 0 1px #2a1d1a; }
.battle-log li + li { margin-top: 3px; padding-top: 3px; border-top: 1px dashed var(--edge); }
.battle-earlier summary { cursor: pointer; color: var(--accent); margin: 4px 0; }
.battle-earlier .battle-log { color: var(--text-dim); }

/* The action pad, along the bottom. */
.battle-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.battle-pad button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; margin: 0;
  font-size: 0.9rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.battle-pad button small { font-size: 0.66rem; letter-spacing: 0.1em; color: var(--muted); }
.battle-pad button.attack { grid-column: 1 / -1; min-height: 64px; font-size: 1.05rem; }
.battle-pad button.auto { grid-column: 1 / -1; min-height: 40px; font-size: 0.8rem; }
.battle-pad button:disabled { opacity: 0.4; }
.quick-slots { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick-slots button { min-height: 44px; font-size: 0.7rem; letter-spacing: 0.06em; }
.battle-result { text-align: center; }
.battle-result > * { grid-column: 1 / -1; margin: 0; }
.battle-result .headline { font: 700 1.4rem var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ember); }
.battle-result ul { list-style: none; padding: 0; font-size: 0.85rem; }
.battle-result form button { width: 100%; }

/* Spell and item lists: sheets over the pad. */
.battle-list {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: min(560px, 100%); max-height: 60dvh; overflow: auto;
  padding: 12px 12px calc(12px + var(--safe-bottom)); color: var(--text); border: 0; background: var(--panel);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), 0 -12px 40px rgb(0 0 0 / 0.55);
}
.battle-list:popover-open { display: grid; gap: 8px; animation: sheet-up 0.16s ease-out; }
.battle-list h2 { margin: 0; font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.battle-list button { flex-direction: row; justify-content: flex-start; gap: 10px; letter-spacing: 0.06em; text-transform: none; }
.battle-list button img { width: 32px; height: 32px; object-fit: contain; image-rendering: auto; }
.battle-list button small { margin-left: auto; }

/* Press and hold: a fill runs along the button, and the action fires when it
   is full (app.js). */
.hold { position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.hold::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 0; height: 4px; background: var(--ember); pointer-events: none;
}
.battle-pad .hold::after { left: 2px; top: 2px; bottom: 2px; width: 4px; height: auto; background: var(--brass); }
.hold.holding::after { width: calc(100% - 4px); transition: width var(--hold-time, 0.7s) linear; }
.vital.hold.holding::after { width: 100%; }
.battle-pad .hold.holding::after { background: rgb(232 168 60 / 0.4); }

/* ── Messages ────────────────────────────────────────────────────────── */

#flash { position: fixed; right: 18px; bottom: calc(var(--bar-height) + 10px); z-index: 50; display: grid; gap: 10px; max-width: min(440px, calc(100vw - 36px)); }
.flash {
  margin: 0; padding: 12px 16px; color: var(--text); background: var(--panel);
  animation: flash-in 0.2s steps(3), flash-out 0.4s ease 6s forwards;
}
.flash-ok { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--sage), inset 6px 0 0 var(--sage); padding-left: 22px; }
.flash-error { box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--crimson), inset 6px 0 0 var(--crimson); padding-left: 22px; }
/* A message that says "click here" is a link to the screen that fixes it. */
.flash a { display: block; margin: -12px -16px -12px -22px; padding: 12px 16px 12px 22px; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.flash a:focus-visible { color: var(--ember-hi); }
@media (hover: hover) { .flash a:hover { color: var(--ember-hi); } }
@keyframes flash-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes flash-out { to { opacity: 0; visibility: hidden; } }
.notice { padding: 12px 14px; background: var(--well); box-shadow: inset 0 0 0 2px var(--edge); }
.notice.warn { box-shadow: inset 0 0 0 2px var(--brass); }
.notice.gold { box-shadow: inset 0 0 0 2px var(--brass), inset 6px 0 0 var(--brass); }

/* Lost-link alert and new-build reload (assets/link.js). Hidden while the
   link is fine; shown only when the page has lost the server, or a new
   version is live and the page has unsaved input. */
.link-alert {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 16px; color: var(--brass); background: var(--panel);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge), inset 6px 0 0 var(--brass);
}
.link-alert[data-link="connecting"], .link-alert[data-link="connected"] { display: none; }
.link-alert[data-link="offline"] {
  color: var(--crimson-hi);
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--crimson-lo), inset 6px 0 0 var(--crimson);
}
.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 6px 0 0 var(--ember);
}
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px 1px;
  font-size: 12px; color: var(--ink); background: var(--text-dim); box-shadow: 0 0 0 2px var(--ink);
}
.badge.unread, .badge.alert { background: var(--crimson); }
.badge.gold { background: var(--brass); }
.badge.ok { background: var(--sage); }
/* Unspent stat points: a gentle glow until they are spent. */
.badge.points { animation: points-glow 1.6s ease-in-out infinite; }
@keyframes points-glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--ink); }
  50% { box-shadow: 0 0 0 2px var(--ink), 0 0 10px 2px var(--brass); }
}
@media (prefers-reduced-motion: reduce) { .badge.points { animation: none; } }

.prose { line-height: 1.7; }
.prose img { max-width: 100%; }
.prose blockquote { margin: 0 0 var(--gap); padding: 6px 14px; box-shadow: inset 4px 0 0 var(--edge-hi); color: var(--text-dim); }
.prose code { padding: 0 4px; background: var(--well); }
.error-page { text-align: center; padding: 56px 16px; }

.site-footer { padding: 18px; text-align: center; color: var(--muted); font-size: 0.8rem; }
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ── Small screens: tighter bar, sheets full width, galaxy chip name only ── */

@media (max-width: 820px) {
  /* iOS zooms into any field under 16px when it is focused. */
  input, select, textarea { font-size: 16px; }
  .panel-body { padding: 12px 14px 16px; }
  .map-header { padding: 4px 10px; gap: 2px 10px; }
  .map-header h1 { font-size: 0.95rem; }
  .map-title .muted, .map-legend { display: none; }
  #flash { left: 10px; right: 10px; max-width: none; }
  .meter { width: 86px; }
  h1 { font-size: 1.5rem; }
  .brand .brand-logo { display: none; }
  .brand .brand-icon { display: block; }
}

/* Phones: icons only on the pinned buttons, a narrower captain. */
@media (max-width: 480px) {
  .game-bar { gap: 4px; padding-inline: 6px; }
  .bar-side { gap: 2px; }
  .bar-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .bar-button img { width: 46px; height: 46px; padding: 7px; }
  .captain { width: 172px; padding-right: 8px; }
  .captain-ship { width: 40px; height: 40px; }
  #hud { gap: 6px; min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── module: inventory: the hold as a list, Orna style ── */
.inv-tabs { display: flex; gap: 4px; margin: 0 0 10px; overflow-x: auto; scrollbar-width: none; }
.inv-tabs label { flex: none; cursor: pointer; }
.inv-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.inv-tabs span {
  display: block; padding: 6px 12px; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.inv-tabs input:checked + span { color: var(--ink); background: var(--ember); box-shadow: none; }
.inv-tabs input:focus-visible + span { outline: 2px solid var(--ember); outline-offset: 2px; }
#inventory:has(.inv-tabs input[value="gear"]:checked) .inv-row:not(.cat-gear),
#inventory:has(.inv-tabs input[value="consumables"]:checked) .inv-row:not(.cat-consumables),
#inventory:has(.inv-tabs input[value="materials"]:checked) .inv-row:not(.cat-materials),
#inventory:has(.inv-tabs input[value="other"]:checked) .inv-row:not(.cat-other) { display: none; }
.inv-list { list-style: none; margin: 0; padding: 0; }
.inv-row + .inv-row { box-shadow: inset 0 1px 0 var(--edge); }
.inv-row { display: flex; align-items: center; }
.inv-row a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 7px 4px; color: var(--text); }
.inv-tick { flex: none; display: grid; place-items: center; width: 36px; min-height: 44px; margin: 0; cursor: pointer; }
.inv-tick input, .inv-select-all input { width: 18px; height: 18px; margin: 0; accent-color: var(--ember, var(--accent)); }
/* The bulk bar: "All" always; the actions once a row is ticked. */
.inv-bulk-bar {
  position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 4px; background: var(--panel); box-shadow: 0 -1px 0 var(--edge);
}
.inv-bulk-bar button { margin: 0; min-height: 40px; display: none; }
.inv-bulk:has(input[name=stacks]:checked) .inv-bulk-bar button { display: inline-block; }
.inv-select-all { display: flex; align-items: center; gap: 6px; margin: 0 auto 0 6px; font-size: 0.85rem; }
.inv-row a:focus-visible { text-decoration: none; background: var(--raised); outline: none; }
@media (hover: hover) { .inv-row a:hover { text-decoration: none; background: var(--raised); } }
.inv-row img { flex: none; width: 44px; height: 44px; object-fit: contain; }
.inv-name { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.inv-name strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 400; color: var(--rarity, var(--text)); }
.inv-name small { font-size: 0.75rem; color: var(--muted); }
.inv-count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.inv-foot { margin-top: 12px; font-size: 0.8rem; }

/* An item's sheet: rises over the hold. */
#item-sheet:empty { display: none; }
.item-sheet {
  position: fixed; z-index: 45; inset: auto 0 var(--bar-height) 0; margin: 0 auto; width: min(560px, 100%);
  max-height: calc(100dvh - var(--bar-height) - var(--safe-top) - 24px); overflow: auto; overscroll-behavior: contain;
  padding: 16px; color: var(--text); border: 0; background: var(--panel); animation: sheet-up 0.16s ease-out;
  box-shadow: 0 0 0 2px var(--ink), inset 0 0 0 2px var(--edge-hi), inset 0 0 0 4px #160f0e, 0 -12px 40px rgb(0 0 0 / 0.6);
}
dialog.item-sheet:not([open]), .item-sheet[popover]:not(:popover-open) { display: none; }
.item-head { display: flex; align-items: center; gap: 14px; margin: 0 44px 12px 0; }
.item-head img { flex: none; width: 72px; height: 72px; object-fit: contain; }
.item-head h2 { margin: 0; color: var(--rarity, var(--text)); }
.item-head p { margin: 2px 0 0; font-size: 0.8rem; }
.item-sheet .stat-list { margin-bottom: 10px; }
.item-sheet .better { color: var(--sage, #8fd18a); }
.item-sheet .worse { color: var(--crimson-hi, #ff6b5a); }
.item-sheet .worn { font-size: 0.85rem; }
.item-sheet .worn [class*="rarity-"] strong { font-weight: 400; color: var(--rarity); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.sheet-actions button { margin: 0; min-height: 44px; }
.sheet-actions .primary, .sheet-count { grid-column: 1 / -1; }
.sheet-count { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.85rem; }
.sheet-count input { width: 7em; }
.sheet-note { margin: 8px 0 0; font-size: 0.75rem; }

/* ── module: character: the captain, Orna style ── */
.paper-doll {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; align-items: center; justify-items: center;
  grid-template-areas: ". head ." "weapon hub offhand" "chest . legs";
  margin: 0 0 14px;
}
.area-head { grid-area: head; } .area-weapon { grid-area: weapon; } .area-offhand { grid-area: offhand; }
.area-chest { grid-area: chest; } .area-legs { grid-area: legs; }
.hub { grid-area: hub; --hub: 104px; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; font-size: 0.85rem; }
.hub .ring { margin-bottom: 6px; }
.hub strong { font: 700 1.05rem var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.gear-slot {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 76px; min-height: 0; padding: 4px; margin: 0;
  color: var(--text-dim); font: 0.68rem var(--font); letter-spacing: 0.08em; text-transform: uppercase; text-align: center;
  background: none; border: 0; box-shadow: none; cursor: pointer;
}
.gear-slot img { width: 56px; height: 56px; object-fit: contain; }
.gear-empty { display: block; width: 56px; height: 56px; box-shadow: inset 0 0 0 2px var(--edge); background: var(--well); opacity: 0.6; }
.gear-slot:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; text-decoration: none; }
@media (hover: hover) { .gear-slot:hover { color: var(--ember-hi); text-decoration: none; background: none; } }
.stat-chips { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-chips li {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  font-size: 0.85rem; background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.stat-chips .muted { font-size: 0.66rem; letter-spacing: 0.12em; }
.stat-chips button { margin-top: 2px; }
.full-stats summary { cursor: pointer; padding: 8px 0; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.85rem; }
.full-stats[open] summary { margin-bottom: 8px; }

/* ── module: station: the factory's recipe book ── */
.recipe-cards { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.recipe-card {
  display: grid; grid-template-columns: 48px 1fr; gap: 4px 12px; align-items: start; padding: 8px;
  background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.recipe-card img { width: 48px; height: 48px; object-fit: contain; }
.recipe-text strong { color: var(--rarity, var(--text)); font-weight: 400; }
.recipe-text small { display: block; font-size: 0.72rem; }
.ingredients { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 0.8rem; }
.ingredients .short { color: var(--crimson-hi, #ff6b5a); }
.recipe-craft { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 8px; }
.recipe-craft label { display: grid; gap: 2px; font-size: 0.75rem; margin: 0; }
.recipe-craft input[name=boost] { width: 6em; }
.recipe-preview { align-self: center; }
.recipe-craft button { margin: 0; }

/* ── module: markets ── */
.market-rates { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.market-rates li { display: grid; gap: 1px; padding: 6px 8px; font-size: 0.78rem; background: var(--well); box-shadow: inset 0 0 0 1px var(--edge); }
.market-rates strong { font-weight: 400; color: var(--text-dim); }
.market-rates strong.better { color: var(--sage, #8fd18a); }
.market-list { list-style: none; margin: 0 0 10px; padding: 0; }
.market-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.market-list li + li { box-shadow: inset 0 1px 0 var(--edge); }
.market-list img { flex: none; width: 40px; height: 40px; object-fit: contain; }
.market-form, .market-sell { display: flex; gap: 6px; align-items: center; flex: none; }
.market-form select { min-width: 0; width: 4.5em; }
.market-list .inv-name strong { color: var(--rarity, var(--text)); }

/* ── module: shipyard: your ship, choosing a starter, the shipyard ── */
.hull-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.hull-card {
  display: grid; gap: 6px; justify-items: center; padding: 14px 12px; text-align: center;
  background: var(--well); box-shadow: inset 0 0 0 1px var(--edge);
}
.hull-card img { width: 96px; height: 96px; object-fit: contain; image-rendering: auto; }
.hull-card h2 { margin: 0; }
.hull-card p { margin: 0; font-size: 0.82rem; }
.hull-card button { width: 100%; margin-top: 4px; }
.hull-facts { justify-self: stretch; text-align: left; font-size: 0.82rem; gap: 2px 12px; }
/* Phones: the art beside the words, so all three starters fit on a screen or two. */
@media (max-width: 480px) {
  .hull-card { grid-template-columns: 72px 1fr; justify-items: start; text-align: left; column-gap: 12px; }
  .hull-card img { grid-row: span 3; width: 72px; height: 72px; }
  .hull-card .hull-facts, .hull-card button { grid-column: 1 / -1; }
}
/* The blueprint: line art, drawn in blueprint blue on a grid. */
.blueprint {
  display: grid; place-items: center; margin: 4px 0 12px; padding: 10px;
  background:
    linear-gradient(rgb(111 195 217 / 0.08) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, rgb(111 195 217 / 0.08) 1px, transparent 1px) 0 0 / 20px 20px,
    #0b1a24;
  box-shadow: inset 0 0 0 1px rgb(111 195 217 / 0.35);
}
.blueprint img { width: min(100%, 360px); height: auto; filter: invert(1) sepia(1) saturate(4) hue-rotate(165deg) brightness(1.1); image-rendering: auto; }
.ship-parts { list-style: none; margin: 0 0 12px; padding: 0; }
.ship-parts li { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 0; }
.ship-parts li + li { box-shadow: inset 0 1px 0 var(--edge); }
.ship-parts img { flex: none; width: 40px; height: 40px; object-fit: contain; }
.part-name { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.part-name small { color: var(--muted); font-size: 0.75rem; }
.part-empty { flex: 1; color: var(--muted); }
.ship-parts form { display: flex; gap: 6px; }
.hangar { list-style: none; margin: 0 0 10px; padding: 0; }
.hangar li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.hangar img { width: 40px; height: 40px; object-fit: contain; image-rendering: auto; }
.hangar li > span:nth-child(2) { flex: 1; }

/* ── module: shops ── */

.shop-art { display: block; width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.storefront .item-slot .price { color: var(--accent); font-size: 0.72rem; }
.storefront .item-slot form.inline { justify-content: center; }
.shop-stock input[type="number"] { width: 110px; }

/* ── module: station ── */
.station-banner { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius); margin-bottom: var(--gap); border: 1px solid var(--line); }
.station-tabs { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: var(--gap); }
.station h2 { margin-top: var(--gap); }
.station-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.station .item-slot button { margin-top: 4px; }

/* ── module: library ── */
.book-list td:first-child { min-width: 9em; }
.book-list td:nth-child(3) { color: var(--muted); }
.write-book { margin-top: var(--gap); }
.write-book summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
/* Legacy books break lines with newlines as well as <br>. */
.book .prose.legacy { white-space: pre-line; }

/* ── module: spells ── */
.spell-list { list-style: none; margin: 0 0 var(--gap); padding: 0; display: grid; gap: 8px; }
.spell-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--space-2); display: grid; gap: 8px; }
.spell-word { font-family: var(--mono); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.spell-info { display: grid; gap: 4px; margin-bottom: var(--gap); }

/* ── module: guilds ── */
.guild-members { margin: 0 0 var(--gap); padding-left: 18px; columns: 2 160px; }
.guild-controls { margin: 0 0 var(--gap); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.guild-controls summary { cursor: pointer; color: var(--accent); }
.guild-controls form + form { margin-top: 10px; }
.guild-description { color: var(--muted); }

/* ── module: home ── */
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: var(--gap); align-items: start; }
.news-item header { margin-bottom: 8px; }
.news-item footer { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }
@media (max-width: 820px) { .home-columns { grid-template-columns: 1fr; } }

/* ── module: players ── */
.rank-banned { color: var(--muted); }
.rank-mod { color: var(--text); }
.rank-gmod { color: #c27000; }
.rank-admin { color: #00c700; }
.rank-owner { color: #ff4040; }
.vital-full { color: #5fa8ff; }
.vital-good { color: var(--ok); }
.vital-low { color: #ffe14a; }
.vital-out { color: var(--danger); }
.profile-head { display: flex; gap: var(--gap); align-items: flex-start; }
.profile-head .avatar { width: 120px; height: 120px; flex: none; image-rendering: pixelated; }
.profile-actions { align-items: start; }
.gift-link { color: var(--ok); }
.player-list, .online-list, .rank-choices { list-style: none; margin: 0; padding: 0; }
.player-list li + li, .online-list li + li { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.rank-choices { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ── module: mail ── */
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-list li { padding: 6px 0; border-top: 1px solid var(--line); }
.mail-unread, .mail-unread a { color: var(--ok); }
.mail-read, .mail-read a { color: var(--danger); }
.mail-from { font-size: 0.85rem; }
.mail-body { color: var(--ok); }

/* ── module: chat ── */
.chat-log { list-style: none; margin: 0; padding: 10px; max-height: 340px; overflow: auto; background: var(--space-0); border-radius: 8px; font-size: 0.9rem; overflow-wrap: anywhere; }
.chat-log li + li { margin-top: 4px; }
#chat form.inline .grow { flex: 1; }

/* ── module: character ── */
.hud-pilot strong { color: var(--accent); }
.buff-plus { color: var(--ok); }
.buff-minus { color: var(--danger); }
.buff-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.buff-list li { display: flex; align-items: center; gap: 8px; }
.buff-list img, .buff img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.buff ul { margin: 6px 0; padding-left: 20px; }

/* ── module: inventory ── */
.item-slot .item-ap { font-size: 0.75rem; }
.item-pick { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; }
.item-actions { width: 100%; font-size: 0.8rem; }
.item-actions summary { cursor: pointer; color: var(--accent); }
.item-action-list { display: grid; gap: 4px; margin-top: 4px; }
.cargo form.inline { margin-top: var(--gap); }

/* ── module: items ── */
.offer-list { margin: 0 0 var(--gap); padding-left: 20px; }
.item-icon { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; image-rendering: pixelated; }
.item-picture { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }

/* ── module: tickets ── */
.tickets textarea { min-height: 200px; }

/* ── module: admin ── */
.admin-menu { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 0 0 var(--gap); }
.admin-lookup { margin-bottom: var(--gap); }
.admin-tool { border-top: 1px solid var(--line); padding-top: var(--gap); }
.admin-tool h2 + form, .admin-tool form + h2 { margin-top: var(--gap); }
.admin-new-item { margin-bottom: var(--gap); }
.admin-new-item summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; }
.admin-items img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.ticket-body { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--space-2); }
.admin-back { margin-top: var(--gap); }
.icon-current { display: flex; align-items: center; gap: 12px; }
.icon-rarity { color: var(--rarity); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.icon-current img, .icon-choice img { object-fit: contain; }
.icon-picker img:is([src$=".png"], [src$=".gif"]) { image-rendering: pixelated; }
.icon-path { overflow-wrap: anywhere; color: var(--text-dim); }
.icon-picker summary { cursor: pointer; color: var(--accent); margin-top: 10px; }
.icon-filter { width: 100%; margin: 10px 0; }
.icon-choices { max-height: 360px; overflow-y: auto; padding: 2px 4px 4px 2px; }
.icon-group h3 { margin: 10px 0 6px; font-size: 0.8rem; }
.icon-group:first-child h3 { margin-top: 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.icon-choice { position: relative; display: grid; place-items: center; padding: 6px; cursor: pointer; }
@media (hover: hover) { .icon-choice:hover { filter: brightness(1.2); } }
.icon-choice:has(input:checked) { outline: 3px solid var(--ember); outline-offset: 2px; }
.icon-choice:has(input:focus-visible) { outline: 3px dashed var(--ember-hi); outline-offset: 2px; }
.icon-choice input[type="radio"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.icon-choice[hidden], .icon-group[hidden] { display: none; }

/* ── module: map ── */
/* Colours fall back to the original tokens when the ember palette is absent. */

.map-stage { --map-self: var(--ember, var(--accent)); --map-player: var(--ice, #bfe3ff); --map-hostile: var(--crimson-hi, #ff8a8a); --map-loot: var(--brass, #ffd36e); }
.map-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.map-legend { list-style: none; margin: 0; padding: 0; align-items: center; }
.map-legend .lg::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; vertical-align: 0; }
.lg-self::before { background: var(--map-self); }
.lg-player::before { background: var(--map-player); }
.lg-hostile::before { background: var(--map-hostile); }
.lg-loot::before { background: var(--map-loot); }

/* Starfield */
.starfield .star.s0 { opacity: 0.35; }
.starfield .star.s1 { opacity: 0.6; }
.starfield .star.s2 { opacity: 0.85; animation: map-twinkle 4s ease-in-out infinite alternate; }
.starfield .nebula { fill: var(--map-player); opacity: 0.07; filter: blur(60px); }
@keyframes map-twinkle { to { opacity: 0.25; } }

/* Objects: an HTML button inside a foreignObject is the hit area. */
.map-hit-area { overflow: visible; }
.map-hit {
  display: block; width: 100%; height: 100%; padding: 0; margin: 0;
  background: transparent; border: 0; border-radius: 50%; cursor: pointer;
}
.map-hit:focus-visible { outline: 3px solid var(--map-self); outline-offset: 2px; }
.map-object:focus-within image { transform: scale(1.15); }
.map-object .map-label { font-size: 12px; }
.map-object.landmark .map-label { fill: var(--muted); font-size: 16px; letter-spacing: 0.04em; }
.map-object.hostile .map-label { fill: var(--map-hostile); }
.map-object.player .map-label { fill: var(--map-player); }
.map-object.loot .map-label { fill: var(--map-loot); font-size: 11px; }
.map-self .map-label { fill: var(--map-self); }
.map-self image { filter: drop-shadow(0 0 6px var(--map-self)); }
.ship-flip { transform: scaleX(-1); }
/* Ships turn to where they fly (app.js sets the heading). */
.ship-heading { transition: transform 0.6s ease; }
.map-object.npc image { filter: hue-rotate(40deg); }

.self-ring { fill: none; stroke: var(--map-self); stroke-width: 1.5; stroke-dasharray: 4 5; opacity: 0.7; animation: map-spin 12s linear infinite; transform-box: fill-box; transform-origin: center; }
.duel-ring { fill: none; stroke: var(--map-hostile); stroke-width: 2; opacity: 0.8; animation: map-pulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.map-trail { stroke: var(--map-self); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; pointer-events: none; }
.map-waypoint { fill: none; stroke: var(--map-self); stroke-width: 2; pointer-events: none; }
@keyframes map-spin { to { transform: rotate(360deg); } }
@keyframes map-pulse { 50% { transform: scale(1.15); opacity: 0.35; } }

/* Loot: debris that glows; the item's own picture shows on hover or focus. */
.loot-glow { fill: var(--map-loot); opacity: 0.18; animation: map-pulse 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.map-object.loot.reserved { opacity: 0.55; }
.map-object.loot.reserved .loot-glow { animation: none; }
.loot-icon { opacity: 0; transition: opacity 0.15s ease; pointer-events: none; }
.map-object.loot:focus-within .loot-icon { opacity: 1; }



/* Pilot card (side panel) */
.pilot-card h2 { margin: 0; }
.pilot-card .pilot-ship { width: 56px; height: 56px; object-fit: contain; }
.pilot-card .row + .row { margin-top: var(--gap); }

/* Docked at the starbase: a radial menu round the base. */
.dock-station .dock-base { width: var(--hub); height: var(--hub); object-fit: contain; image-rendering: auto; }

/* Galaxy travel */
.galaxy-chart { margin: 0 0 var(--gap); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #000; }
.galaxy-chart svg { display: block; width: 100%; height: auto; }
.chart-box { fill: transparent; stroke: transparent; stroke-width: 2; }
.chart-area:focus-within .chart-box { stroke: var(--ice, #bfe3ff); }
@media (hover: hover) { .chart-area:hover .chart-box { stroke: var(--ice, #bfe3ff); } }
.chart-area.here .chart-box { stroke: var(--ember, var(--accent)); stroke-dasharray: 6 4; }
.chart-area.home .chart-label { font-weight: 700; }
.chart-label { fill: var(--text); font-size: 17px; paint-order: stroke; stroke: #000; stroke-width: 3px; pointer-events: none; }
.chart-hit { border-radius: 8px; }
.galaxy-table button { white-space: nowrap; }
.galaxy-table tr.here td { background: var(--space-2); }
.badge.here { border-color: var(--ember, var(--accent)); color: var(--ember, var(--accent)); }
.galaxy-info .row img { width: 72px; height: 72px; }
.galaxy-info h1 { margin-bottom: 4px; }
.galaxy-switch { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-bottom: var(--gap); font-size: 0.9rem; }
.member-list { display: flex; flex-wrap: wrap; gap: 4px 10px; list-style: none; margin: 0; padding: 0; }

/* ── Rarity tiles: the backdrop behind an item's picture ──────────────────
   <img class="rarity rarity-epic">, or rarity-* on a container and .rarity
   on the tiles inside it. The tier comes from the item's drop roll.
   Each tile is a glow in the tier colour over a dark gradient, framed by
   a trim in a brighter shade with a specular glint at the top-left. */
.rarity-junk      { --rarity: #8a837d; }
.rarity-common    { --rarity: #ece4d6; }
.rarity-uncommon  { --rarity: #5fd16a; }
.rarity-rare      { --rarity: #4fa8f0; }
.rarity-epic      { --rarity: #a66cf0; }
.rarity-legendary { --rarity: #f2b632; }
.rarity-mythic    { --rarity: #ff8bd0; }
.rarity-junk, .rarity-common, .rarity-uncommon, .rarity-rare, .rarity-epic, .rarity-legendary, .rarity-mythic {
  --rarity-hi: color-mix(in srgb, var(--rarity) 55%, #fff);
  --rarity-lo: color-mix(in srgb, var(--rarity) 45%, #000);
  --rarity-bg:
    radial-gradient(closest-side, color-mix(in srgb, var(--rarity) 45%, transparent), transparent),
    linear-gradient(160deg, color-mix(in srgb, var(--rarity) 32%, var(--well)), var(--well) 85%);
  --rarity-trim: linear-gradient(135deg, #fff 0%, var(--rarity-hi) 14%, var(--rarity) 34%, var(--rarity-lo) 62%,
    var(--rarity) 86%, var(--rarity-hi) 100%);
}
.rarity-mythic {
  --rarity-bg:
    radial-gradient(closest-side, rgb(255 255 255 / 0.4), transparent),
    linear-gradient(rgb(13 9 8 / 0.4), rgb(13 9 8 / 0.4)),
    conic-gradient(from 210deg, #ff5f6d, #ffc371, #f9f871, #5fd16a, #4fc3f7, #a66cf0, #ff5f6d);
  --rarity-trim: linear-gradient(135deg, #fff 0%, transparent 22%),
    conic-gradient(from 210deg, #ff8a94, #ffd79b, #fbfa9e, #8fe597, #85d6fa, #c49cf6, #ff8a94);
}
.rarity {
  padding: 3px;
  border: 2px solid var(--rarity, var(--edge-hi));
  border-image: var(--rarity-trim, linear-gradient(var(--edge-hi), var(--edge-hi))) 1;
  background: var(--rarity-bg, var(--well));
}
.rarity-rare.rarity, .rarity-rare .rarity,
.rarity-epic.rarity, .rarity-epic .rarity,
.rarity-legendary.rarity, .rarity-legendary .rarity,
.rarity-mythic.rarity, .rarity-mythic .rarity { box-shadow: 0 0 8px -2px var(--rarity); }
.item-slot img.rarity { padding: 4px; }

/* A stack's action in the bank and factory: how many, then the button. */
.stack-action { display: flex; gap: 4px; justify-content: center; margin: 0; }
.stack-count { width: 4.5em; min-height: 32px; padding: 2px 4px; }

/* Market rows: tap the item for its sheet; type how many, then the button. */
.market-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--text); }
.market-item:hover { text-decoration: none; }
.market-form { display: flex; gap: 4px; align-items: center; margin: 0; }
.trade-rep { font-size: 0.85rem; color: var(--brass, #e6c15a); }
.market-overflow p { margin: 0 0 8px; }

/* Workshops (The Guild 2): a recipe is what it makes, then its ingredients'
   icons with how many each; above your workshop's level, locked. */
.workshop + .workshop { margin-top: 14px; }
.workshop h2 { margin: 0; }
:is(.recipe-card, .upgrade) .ingredients { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 4px 0 0; padding: 0; }
:is(.recipe-card, .upgrade) .ingredients li { position: relative; width: 32px; height: 32px; padding: 2px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--edge); }
:is(.recipe-card, .upgrade) .ingredients li img { width: 28px; height: 28px; object-fit: contain; }
:is(.recipe-card, .upgrade) .ingredients li.short { box-shadow: inset 0 0 0 1px var(--crimson-hi, #ff6b5a); }
.ingredient-count { position: absolute; right: -4px; bottom: -6px; min-width: 16px; padding: 0 3px; font-size: 0.7rem; line-height: 14px; text-align: center; color: var(--text); background: var(--ink); box-shadow: 0 0 0 1px var(--edge); }
.recipe-card.locked { opacity: 0.5; }
.recipe-lock { align-self: center; }

/* Gathering: the bar over the map while the ship works a piece. */
.gather-bar { position: absolute; left: 50%; bottom: calc(var(--bar-height, 72px) + 24px); z-index: 5; width: 200px; height: 12px; transform: translateX(-50%); background: var(--ink); box-shadow: 0 0 0 2px var(--edge-hi), 0 4px 14px rgb(0 0 0 / 0.5); }
.gather-bar > span { display: block; width: 0; height: 100%; background: var(--brass, #e6c15a); transition-property: width; transition-timing-function: linear; }

.workshop .upgrade { gap: 10px; align-items: center; }
.workshop .upgrade .ingredients { margin: 0; }
.market-rates .market-stock { display: block; font-size: 0.72rem; }
.market-stock.short { color: var(--gold-hi, #ffd36b); }
.market-stock.glut { color: var(--muted, #8a8f98); }
.point-lines { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; font-size: 0.85rem; }
.stat-chips small { display: block; font-size: 0.66rem; }
