/*
 * Eternal War — the whole stylesheet.
 *
 * Hand-written on purpose: no build step, no framework. Colours, type and
 * spacing are variables at the top, so a restyle starts there rather than in
 * rules.
 *
 * The look is the "Eternal War" design system: a calm strategic command table.
 * Dark but never black, very little decoration, and technical rather than
 * rounded — 2–6px corners, thin corner brackets on panels instead of soft
 * cards. The UI chrome stays neutral so the factions bring the colour. Three
 * rules carry most of it:
 *
 * - One interactive accent. `--accent` means "you can act on this / this is
 *   the active thing" and nothing else; good and bad are `--success`, `--warn`
 *   and `--danger`.
 * - No neon. Depth is black shadow, never a coloured halo; glow is kept for
 *   the one selected or active thing.
 * - Faction colour is selective: ownership, battle sides and selection only,
 *   never the global chrome.
 *
 * The faces are system fonts, with no files to serve: Bahnschrift (Windows)
 * or DIN Alternate (macOS) for labels, headings and numbers, the platform's UI
 * face for reading. It has no light theme, so neither does the app.
 */

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

:root {
  color-scheme: dark;

  /* Ground and surfaces, stepping up in lightness: `surface-2` is a recessed
     well (inputs, inner cards), `surface-1` a control, `surface-3` hover. */
  --bg: #06080d;
  --stage: #05060a;
  --surface-1: #0e131c;
  --surface-2: #090c13;
  --surface-3: #161d29;
  --hud-bg: rgb(10 14 21 / 0.74);

  /* Lines. Decorative strengths below 3:1: a control is also recognisable by
     its fill or its label, never by its border alone. */
  --border: rgb(150 180 205 / 0.1);
  --border-strong: rgb(150 180 205 / 0.2);
  --border-stronger: rgb(150 180 205 / 0.32);
  --hud-border: rgb(150 180 205 / 0.16);
  --sf-edge: rgb(150 205 228 / 0.5);

  /* Text. `--text-muted` is for uppercase micro labels and meta only — it is
     too faint for a sentence somebody has to read. */
  --text-primary: #e5e9ef;
  --text-secondary: #9ba6b5;
  --text-muted: #6c7888;
  --title-fade: #8fa9bb;

  /* The one interactive accent, and the judgments. */
  --accent: #7cc0da;
  --accent-dim: rgb(124 192 218 / 0.13);
  --success: #7fab84;
  --success-dim: rgb(127 171 132 / 0.14);
  --danger: #e2726a;
  --danger-dim: rgb(226 114 106 / 0.14);
  --danger-soft: #ee9a92;
  --warn: #d9a441;
  --warn-dim: rgb(217 164 65 / 0.14);
  --dev: #ef9f27;

  /* The map. A faction's own colour always arrives inline (§2). */
  --neutral-planet: #5f5e5a;
  --planet-rim: #bfe3f5;

  /* Type */
  --font-display: Bahnschrift, "DIN Alternate", "Segoe UI Semibold", "Segoe UI",
    system-ui, sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, monospace;

  /* Spacing, radius, elevation */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space: var(--space-4);

  --radius-sm: 2px;
  --radius: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px -3px rgb(0 0 0 / 0.5);
  --shadow-md: 0 12px 30px -14px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 24px 60px -24px rgb(0 0 0 / 0.75);
  --shadow-hud: inset 0 1px 0 rgb(255 255 255 / 0.04),
    0 16px 36px -16px rgb(0 0 0 / 0.85);
  --shadow-report: 0 30px 70px -20px rgb(0 0 0 / 0.9);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-dim);
  --focus-field: 0 0 0 3px var(--accent-dim);

  --opacity-disabled: 0.42;
  --opacity-disabled-tool: 0.34;
  --opacity-ghost: 0.4;

  --blur-hud: 9px;
  --blur-panel: 8px;
  --blur-backdrop: 4px;

  /* Motion. Visual only: nothing here changes what the game does. */
  --motion-fast: 150ms;
  --motion-normal: 280ms;
  --motion-slow: 520ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 0.84, 0.44, 1);

  /* The panel's thin technical corner brackets, drawn as eight hairlines in
     the background so they cost no markup. */
  --sf-brackets:
    linear-gradient(var(--sf-edge), var(--sf-edge)) 0 0 / 9px 1px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 0 0 / 1px 9px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 100% 0 / 9px 1px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 100% 0 / 1px 9px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 0 100% / 9px 1px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 0 100% / 1px 9px no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 100% 100% / 9px 1px
      no-repeat,
    linear-gradient(var(--sf-edge), var(--sf-edge)) 100% 100% / 1px 9px
      no-repeat;
  --panel-fill: linear-gradient(
    180deg,
    rgb(14 19 28 / 0.9),
    rgb(7 10 16 / 0.94)
  );
  --sf-fill: linear-gradient(180deg, rgb(15 21 31 / 0.8), rgb(7 10 16 / 0.86));
  --dialog-fill: linear-gradient(
    180deg,
    rgb(15 21 31 / 0.97),
    rgb(7 10 16 / 0.98)
  );
  --rule-fade: linear-gradient(90deg, rgb(150 205 228 / 0.35), transparent 85%)
    1;
}

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

/* The scrollbar's space is always kept, so moving between a short page and a
   long one does not shift the centred page sideways by half its width. */
html {
  scrollbar-color: var(--border-stronger) transparent;
  scrollbar-gutter: stable;
}

/* Every screen sits on the same ground: a sparse star field, a faint blue wash
   in the middle and a deep red one in a corner. All of it stays put while the
   page scrolls. */
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  font: 400 13px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='340'%3E%3Ccircle cx='165' cy='77' r='0.8' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='37' cy='274' r='0.5' fill='%23fff' fill-opacity='0.4'/%3E%3Ccircle cx='298' cy='29' r='0.6' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='44' cy='222' r='0.8' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='123' cy='46' r='0.8' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='289' cy='63' r='0.6' fill='%23fff' fill-opacity='0.55'/%3E%3Ccircle cx='31' cy='295' r='0.8' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='113' cy='23' r='0.6' fill='%23fff' fill-opacity='0.4'/%3E%3Ccircle cx='214' cy='73' r='0.5' fill='%23fff' fill-opacity='0.55'/%3E%3Ccircle cx='157' cy='286' r='0.6' fill='%23fff' fill-opacity='0.26'/%3E%3Ccircle cx='297' cy='292' r='0.6' fill='%23fff' fill-opacity='0.4'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='230' height='230'%3E%3Ccircle cx='24' cy='140' r='0.5' fill='%23fff' fill-opacity='0.55'/%3E%3Ccircle cx='15' cy='158' r='0.6' fill='%23fff' fill-opacity='0.48'/%3E%3Ccircle cx='174' cy='136' r='0.8' fill='%23fff' fill-opacity='0.4'/%3E%3Ccircle cx='119' cy='149' r='0.8' fill='%23fff' fill-opacity='0.4'/%3E%3Ccircle cx='76' cy='63' r='0.6' fill='%23fff' fill-opacity='0.32'/%3E%3Ccircle cx='20' cy='147' r='0.7' fill='%23fff' fill-opacity='0.55'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 70% 60% at 50% 45%, rgb(46 104 140 / 0.16), transparent 70%),
    radial-gradient(ellipse 55% 50% at 100% 100%, rgb(120 44 56 / 0.09), transparent 70%);
  background-size:
    340px 340px,
    230px 230px,
    100% 100%,
    100% 100%;
  background-attachment: fixed;
}

::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}

a {
  color: var(--accent);
  text-decoration-color: rgb(124 192 218 / 0.35);
  text-underline-offset: 0.2em;
  transition: color var(--motion-fast) var(--ease);
}

a:hover {
  color: var(--text-primary);
  text-decoration-color: currentColor;
}

/* A heading that links somewhere is still the heading. */
h1 a,
h2 a,
h3 a {
  color: inherit;
  text-decoration: none;
}

h1 a:hover,
h2 a:hover,
h3 a:hover {
  color: var(--text-primary);
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* A page title reads as text; everything under it that names a section is a
   tracked, uppercased label in the display face. The capitals come from CSS,
   never from the markup. */
h1,
h2,
h3 {
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}

h1 {
  font: 600 20px/1.3 var(--font-sans);
  letter-spacing: 0.01em;
}

h2 {
  font: 600 12px/1.3 var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h3 {
  font: 600 11px/1.3 var(--font-sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

p {
  margin: 0 0 var(--space-3);
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

ul,
ol {
  padding-left: 1.2rem;
}

li::marker {
  color: var(--text-muted);
  font-family: var(--font-display);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* One width for every page: the map screens need the room, and every other
   page keeps the same frame so moving between them does not jump. Prose keeps
   its own reading width (`.lead`, forms, cards). */
.container {
  max-width: min(97vw, 1920px);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
}

.lead,
.lede {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 40rem;
}

.empty {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Navbar -------------------------------------------------------------- */

/* The top bar is HUD glass: it floats over the star field, and the page
   scrolls under it. */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--hud-bg);
  border-bottom: 1px solid var(--hud-border);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
}

.navbar-inner {
  max-width: min(97vw, 1920px);
  margin: 0 auto;
  padding: 0 var(--space-4);
  height: 52px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.navbar a {
  color: inherit;
  text-decoration: none;
}

/* The brand carries the campaign's name, which is whatever somebody typed. It
   must give way rather than push the nav off the bar: a flex item defaults to
   min-width:auto, and text-overflow needs a block box, so both are needed. */
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbar .brand {
  color: var(--text-primary);
}

.navbar .brand:hover {
  color: var(--accent);
}

.navbar .button {
  padding: 6px 14px;
  min-height: 30px;
}

/* Outside a campaign there are no main links at all. */
.nav-links:empty {
  display: none;
}

.nav-links {
  display: flex;
  align-self: stretch;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li {
  display: flex;
}

.nav-links a,
.dropdown a,
.dropdown button {
  display: block;
  padding: 7px 12px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* The current page is lit on the bar's own bottom edge. */
.nav-links a {
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  padding-top: 9px;
  transition:
    color var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* The settings pages' tabs: always one line. On a narrow screen the row
   scrolls sideways on its own rather than wrapping or widening the page. */
.subnav {
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.subnav ul {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.subnav a {
  display: block;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition:
    color var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.subnav a:hover {
  color: var(--text-primary);
}

.subnav a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.navbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* The gamemaster's switch between their two views (§15.1). A form button,
   since the view is a stored preference; drawn as a switch because it is one,
   so none of the ordinary button's fill, border or shadow applies. */
.view-switch-form {
  display: flex;
  margin: 0;
}

.view-switch,
.view-switch:hover {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.view-switch:hover {
  color: var(--text-secondary);
}

.view-switch[aria-checked="true"],
.view-switch[aria-checked="true"]:hover {
  color: var(--text-primary);
}

.switch-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition:
    background var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-sm);
  background: var(--text-muted);
  transition:
    transform var(--motion-fast) var(--ease),
    background var(--motion-fast) var(--ease);
}

.view-switch[aria-checked="true"] .switch-track {
  border-color: rgb(124 192 218 / 0.5);
  background: var(--accent-dim);
}

.view-switch[aria-checked="true"] .switch-thumb {
  background: var(--accent);
  transform: translateX(16px);
}

.view-switch:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

/* On a phone the switch keeps its track and drops the word. */
@media (max-width: 720px) {
  .switch-label {
    display: none;
  }
}

/* --- Menus (<details>) --------------------------------------------------- */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition:
    background var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.menu-toggle:hover,
.menu[open] > .menu-toggle {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.menu-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 10;
  min-width: 14rem;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--sf-brackets), var(--dialog-fill);
  border: 1px solid var(--hud-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-report);
  animation: rise var(--motion-normal) var(--ease-out);
}

/* A menu entry lights like a main-menu button: a rail on its left edge. */
.dropdown a,
.dropdown button {
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition:
    background var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.dropdown a:hover,
.dropdown button:hover,
.dropdown a[aria-current="page"] {
  color: var(--text-primary);
  background: linear-gradient(90deg, rgb(124 192 218 / 0.14), transparent 80%);
  border-left-color: var(--accent);
}

.dropdown form {
  margin: 0;
}

/* Separates where you go between campaigns from the account itself. */
.dropdown hr {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* The logout form's button, dressed as the link above it. */
.dropdown button {
  width: 100%;
  min-height: 0;
  text-align: left;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  background: none;
  cursor: pointer;
  box-shadow: none;
}

.dropdown-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 6px;
  padding: 6px 12px 10px;
  border-bottom: 1px solid var(--border);
}

.dropdown-header strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dropdown-header span {
  color: var(--text-secondary);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid rgb(124 192 218 / 0.5);
  background: linear-gradient(180deg, rgb(124 192 218 / 0.2), rgb(124 192 218 / 0.07));
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
}

.profile-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Three bars, drawn with the element and its two pseudo-elements. */
.burger,
.burger::before,
.burger::after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
}

.burger {
  position: relative;
  margin: 9px 0;
  color: var(--text-secondary);
}

.burger::before,
.burger::after {
  content: "";
  position: absolute;
  left: 0;
}

.burger::before {
  top: -6px;
}

.burger::after {
  top: 6px;
}

/* Wide screens show the inline links; narrow screens the hamburger menu. Both
 * lists are rendered, exactly one is displayed. */
.nav-mobile {
  display: none;
}

@media (max-width: 720px) {
  .nav-desktop {
    display: none;
  }

  .nav-mobile {
    display: block;
    position: static; /* let the menu span the navbar, not the button */
  }

  .dropdown-full {
    left: 0;
    right: 0;
    top: 100%;
    border-radius: 0;
    border-width: 0 0 1px;
  }

  .profile-name {
    display: none;
  }

  /* The brand shares the row with the burger and the avatar here. */
  .brand {
    max-width: 10rem;
  }
}

/* --- Content ------------------------------------------------------------- */

/* A page title with its one action beside it, wrapping on narrow screens. */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid transparent;
  border-image: var(--rule-fade);
}

.page-header h1 {
  margin-bottom: 0;
}

/* A panel: dark translucent fill, thin technical brackets at its corners, a
   black shadow for depth. No backdrop blur: it would make the card the
   containing block of the fixed "+" dialog inside it. */
.card {
  position: relative;
  background: var(--sf-brackets), var(--panel-fill);
  border: 1px solid rgb(150 180 205 / 0.12);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

/* A panel's heading is its label: tracked caps in the accent, over a hairline. */
.card > h2:first-child,
.card > .stack:first-child > h2:first-child {
  color: var(--accent);
  align-self: stretch;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}

/* A card inside a panel is a recessed well, not another panel. */
.card .card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 14px;
}

/* A card's heading with its one control at the right: a section's "+", a
   card's Remove. Full width even inside a `.stack`, which aligns to the start. */
.card-head {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-head h2,
.card-head h3 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card > .card-head:first-child,
.card > .stack:first-child > .card-head:first-child {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.card > .card-head:first-child h2,
.card > .stack:first-child > .card-head:first-child h2 {
  color: var(--accent);
}

.card-head form {
  margin: 0;
}

/* More than one control at a card head's right end. */
.card-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* A card holding something that cannot be undone, such as deleting. */
.card-danger {
  border-color: rgb(226 114 106 / 0.34);
  --sf-edge: rgb(238 154 146 / 0.5);
}

.card-danger > h2:first-child,
.card-danger > .stack:first-child > h2:first-child {
  color: var(--danger-soft);
}

.card-head .button-danger {
  padding: 5px 10px;
  min-height: 28px;
  font-size: 12px;
}

/*
 * A card's Remove on a page saved as a whole: a checkbox dressed as a small
 * danger button. Ticked, it only marks the card — dimmed, its name struck
 * through — until Save. All of it is CSS, so it works without app.js.
 */
.remove-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.2;
  color: var(--danger);
  background: var(--surface-1);
  border: 1px solid rgb(226 114 106 / 0.34);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease);
}

.remove-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.remove-toggle:has(input:focus-visible) {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.remove-toggle .remove-on,
.remove-toggle:has(input:checked) .remove-off {
  display: none;
}

.remove-toggle:has(input:checked) .remove-on {
  display: inline;
}

.remove-toggle:hover,
.remove-toggle:has(input:checked) {
  background: var(--danger-dim);
  border-color: rgb(226 114 106 / 0.6);
}

.card:has(> .card-head input[name="remove"]:checked) > :not(.card-head) {
  opacity: var(--opacity-ghost);
}

.card:has(> .card-head input[name="remove"]:checked) > .card-head h3 {
  text-decoration: line-through;
  opacity: 0.6;
}

/*
 * The trigger and ability tables: one full-width card per row. Its own
 * settings sit in one row; its consequences are tiles side by side, as many as
 * fit, the last tile being the way to add one more. One column on a phone.
 */
.row-list {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.row-list > .row-card {
  margin: 0;
  align-items: stretch;
}

.row-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
}

.row-settings .field {
  width: auto;
  flex: 0 1 14rem;
}

.row-settings .field:first-child {
  flex: 1 1 16rem;
}

.row-settings .field-check {
  min-height: 34px;
}

/* An ability's cost: one small number per resource, side by side. */
.ability-cost {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.ability-cost > legend {
  padding: 0;
  margin-bottom: var(--space-1);
  font-size: 13px;
  color: var(--text-secondary);
}

.ability-cost .field {
  width: auto;
  flex: 0 1 7rem;
}

.row-subhead {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.consequence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--space-3);
  align-items: start;
}

/* The legend is for screen readers; the head below shows the kind beside
   its Remove. */
.consequence > legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.consequence-grid > .consequence {
  position: relative;
  align-items: stretch;
  margin: 0;
  gap: var(--space-2);
}

/* A tile is as wide as its column. A fieldset otherwise never shrinks below
   its content, and a select is as wide as its longest option, so one tile
   with "every Battle Group of the faction it fires for" would spill over its
   neighbour; the select is cut to the tile instead. */
.consequence-grid > .consequence {
  min-inline-size: 0;
}

.consequence .field {
  max-width: none;
}

.consequence .field > :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
}

.consequence-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.consequence-kind-label {
  font-size: 13px;
  font-weight: 600;
}

.consequence-new {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* A trigger's consequence marked for removal: the same toggle, one tile of
   the card rather than the card. */
.consequence:has(.consequence-head input:checked) > :not(legend, .consequence-head) {
  opacity: var(--opacity-ghost);
}

.consequence:has(.consequence-head input:checked) .consequence-kind-label {
  text-decoration: line-through;
  opacity: 0.6;
}

/* In the "Add a consequence" and "Add a trigger" dialogs every field has the
   same width — the full field width, whatever kind is chosen — rather than
   each kind's wrapper shrinking to its own content. */
.add-popover-body:has(.consequence-add, .trigger-add) > .stack,
.stack.consequence-add,
.consequence-add .stack,
.stack.trigger-add,
.trigger-add .stack {
  align-self: stretch;
  align-items: stretch;
}

/* "Add a consequence": the fields of the kind chosen in its select, and
   nothing else. Without :has every kind's fields show, each under its name. */
@supports selector(:has(a)) {
  .consequence-add > .consequence-kind {
    display: none;
  }

  .consequence-add:has(select option[value="text"]:checked)
    > .consequence-kind[data-kind="text"] {
    display: flex;
  }
  .consequence-add:has(select option[value="resource"]:checked)
    > .consequence-kind[data-kind="resource"] {
    display: flex;
  }
  .consequence-add:has(select option[value="movement"]:checked)
    > .consequence-kind[data-kind="movement"] {
    display: flex;
  }
  .consequence-add:has(select option[value="ability_lock"]:checked)
    > .consequence-kind[data-kind="ability_lock"] {
    display: flex;
  }
  .consequence-add:has(select option[value="defended"]:checked)
    > .consequence-kind[data-kind="defended"] {
    display: flex;
  }
  .consequence-add:has(select option[value="ignore_rematch"]:checked)
    > .consequence-kind[data-kind="ignore_rematch"] {
    display: flex;
  }
  .consequence-add:has(select option[value="extra_duel"]:checked)
    > .consequence-kind[data-kind="extra_duel"] {
    display: flex;
  }
  .consequence-add:has(select option[value="reinforced_pdf"]:checked)
    > .consequence-kind[data-kind="reinforced_pdf"] {
    display: flex;
  }
  .consequence-add:has(select option[value="found_pdf"]:checked)
    > .consequence-kind[data-kind="found_pdf"] {
    display: flex;
  }
  .consequence-add:has(select option[value="extra_duel_now"]:checked)
    > .consequence-kind[data-kind="extra_duel_now"] {
    display: flex;
  }
  .consequence-add:has(select option[value="fire_annihilation"]:checked)
    > .consequence-kind[data-kind="fire_annihilation"] {
    display: flex;
  }

  .consequence-kind-name {
    display: none;
  }
}

/* "Add a trigger": what the condition chosen in its select watches for, and
   its threshold, and no other condition's. Without :has all of them show. */
@supports selector(:has(a)) {
  .trigger-add > .trigger-condition {
    display: none;
  }

  .trigger-add:has(select option[value="annihilation"]:checked)
    > .trigger-condition[data-condition="annihilation"] {
    display: flex;
  }
  .trigger-add:has(select option[value="beachhead"]:checked)
    > .trigger-condition[data-condition="beachhead"] {
    display: flex;
  }
  .trigger-add:has(select option[value="warpath"]:checked)
    > .trigger-condition[data-condition="warpath"] {
    display: flex;
  }
  .trigger-add:has(select option[value="bulwark"]:checked)
    > .trigger-condition[data-condition="bulwark"] {
    display: flex;
  }
  .trigger-add:has(select option[value="decapitation"]:checked)
    > .trigger-condition[data-condition="decapitation"] {
    display: flex;
  }
  .trigger-add:has(select option[value="vanguard"]:checked)
    > .trigger-condition[data-condition="vanguard"] {
    display: flex;
  }
  .trigger-add:has(select option[value="custom"]:checked)
    > .trigger-condition[data-condition="custom"] {
    display: flex;
  }

  .trigger-condition-name {
    display: none;
  }
}

/* A "+" whose fields hold something not yet saved. */
form[data-unsaved-form] .add-popover.is-unsaved > summary {
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* A page's one Save, above and below its panels. */
.save-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.save-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/*
 * What app.js marks as differing from what is stored, on every form saved as a
 * whole, is not drawn on the field itself: a rule beside every edited field
 * was too frequent and pushed fields out of line. The save bar's tag says the
 * page holds unsaved changes, and a player who would join or leave a group
 * gets a tag of their own.
 */

.group-members {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-members .is-joining {
  color: var(--accent);
}

.group-members .is-leaving {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.7;
}

.unsaved-tag {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
}

/* Each player with the one Battle Group select that places them. */
.lineup-players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-2) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.lineup-player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
}

.lineup-player select {
  width: auto;
}

form[data-unsaved-form] > .card fieldset {
  align-self: stretch;
}

/*
 * A faction's panel on the Factions page: a <details>, so it folds without
 * app.js, and the panels share a `name`, so only one is open at a time. Its
 * summary is the panel's heading — swatch, name, what it holds — with a
 * chevron that turns when it opens.
 */
.faction-panel > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  list-style: none;
  cursor: pointer;
}

.faction-panel > summary::-webkit-details-marker {
  display: none;
}

.faction-panel > summary::after {
  content: "";
  align-self: center;
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid var(--text-secondary);
  border-bottom: 1.5px solid var(--text-secondary);
  transform: rotate(-45deg);
  transition: transform var(--motion-fast) var(--ease);
}

.faction-panel[open] > summary::after {
  transform: rotate(45deg);
}

.faction-panel > summary:hover::after {
  border-color: var(--accent);
}

.faction-panel > summary h2 {
  margin: 0;
  color: var(--accent);
}

.faction-panel > summary .faction-swatch {
  align-self: center;
  margin: 0 2px;
}

.faction-panel[open] > summary {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

/* A faction's name and colour on one line where they fit. */
.faction-details {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
}

.faction-details .field {
  width: auto;
}

.faction-details .field:first-of-type {
  flex: 1 1 14rem;
}

/* Cards side by side, as many as fit; one column on a phone. Space 12px. */
.card-grid {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-grid > .card {
  margin: 0;
}

/*
 * The "+" that opens a form for one more card as a dialog in the middle of the
 * screen. While it is open, its summary stops being the "+" and becomes the
 * darkened backdrop over the whole page: it takes every click beside the
 * dialog, and a click on it closes the <details> — no JavaScript needed.
 */
.add-popover > summary {
  list-style: none;
  padding: 3px 12px;
  min-height: 30px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* The same dialog behind a button that says what it does in words. */
.add-popover > summary.popover-labelled {
  font-size: 13px;
  padding: 8px 14px;
  white-space: nowrap;
}

.add-popover > summary::-webkit-details-marker {
  display: none;
}

.add-popover[open] > summary,
.add-popover[open] > summary:hover {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 0;
  background: rgb(6 8 12 / 0.6);
  backdrop-filter: blur(var(--blur-backdrop));
  -webkit-backdrop-filter: blur(var(--blur-backdrop));
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: default;
  /* The "+" is a .button, whose colours step in over a moment: as the
     backdrop that would flash the whole screen on the way to dark. */
  transition: none;
}

.add-popover[open] > summary > span {
  display: none;
}

/* Opened, the card is a dialog: brighter glass, the report's deep shadow, and
   a short rise into place. */
.add-popover > .add-popover-body {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  margin: 0;
  padding: var(--space-5);
  background: var(--sf-brackets), var(--dialog-fill);
  border: 1px solid rgb(150 180 205 / 0.16);
  box-shadow: var(--shadow-report);
  animation: rise-centred var(--motion-normal) var(--ease-out);
}

/* A dialog's own Save, at its bottom right. */
.popover-actions {
  display: flex;
  justify-content: flex-end;
}

/* The page behind an open dialog stays where it is. Hiding the scrollbar does
   not shift it sideways, since `html` always keeps the scrollbar's space. */
html:has(.add-popover[open]) {
  overflow: hidden;
}

/* A single form on its own (log in, sign up): a centred 440px column. */
.card-narrow {
  max-width: 440px;
  margin: var(--space-5) auto;
  padding: 2rem 1.75rem 1.75rem;
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}

.stack:last-child {
  margin-bottom: 0;
}

dl.stack {
  gap: 2px;
}

dt {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

dd {
  margin: 0 0 var(--space-2);
  color: var(--text-primary);
}

/* Form fields: a sentence-case label over a recessed well. */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  max-width: 24rem;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

input,
select,
textarea {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition:
    border-color var(--motion-fast) var(--ease),
    box-shadow var(--motion-fast) var(--ease);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-stronger);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-field);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  padding: 0;
}

input[type="color"] {
  padding: 3px;
  height: 36px;
  min-width: 48px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: var(--radius-sm);
}

input[type="file"] {
  padding: 6px;
  font-size: 12px;
}

input[type="file"]::file-selector-button {
  font: 500 12px var(--font-sans);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 10px;
  margin-right: var(--space-3);
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: var(--surface-3);
}

select {
  cursor: pointer;
}

/* Buttons are sentence case in the reading face. A bare button is the step
   forward — the accent's glass — because that is what every page's one button
   does; `.button-secondary` is everything else, `.button-danger` the
   destructive. */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  color: var(--text-primary);
  background: linear-gradient(180deg, rgb(124 192 218 / 0.2), rgb(124 192 218 / 0.07));
  border: 1px solid rgb(124 192 218 / 0.5);
  border-radius: var(--radius);
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--motion-fast) var(--ease),
    border-color var(--motion-fast) var(--ease),
    box-shadow var(--motion-fast) var(--ease),
    color var(--motion-fast) var(--ease),
    transform 80ms var(--ease);
}

button:hover,
.button:hover {
  color: var(--text-primary);
  background: linear-gradient(180deg, rgb(143 178 196 / 0.32), rgb(143 178 196 / 0.16));
  border-color: rgb(143 178 196 / 0.68);
}

button:active:not(:disabled),
.button:active {
  transform: translateY(1px);
}

button:focus-visible,
.button:focus-visible,
summary.button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.card-narrow button {
  width: 100%;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Messages keep a rail on their edge in the colour of what happened, washing
   out to the right. */
.message {
  padding: 9px 12px;
  margin: 0 0 var(--space-4);
  border-left: 2px solid var(--border-stronger);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(90deg, var(--surface-3), transparent 85%);
  color: var(--text-primary);
  animation: rise var(--motion-normal) var(--ease-out);
}

.message-ok {
  background: linear-gradient(90deg, var(--success-dim), transparent 85%);
  border-left-color: var(--success);
}

.message-error {
  background: linear-gradient(90deg, var(--danger-dim), transparent 85%);
  border-left-color: var(--danger);
  color: var(--danger-soft);
}

/* Tables: micro-label column heads, hairline rows. */
table {
  border-collapse: collapse;
}

th,
td {
  padding: 7px 12px 7px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

thead th {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

tbody tr {
  transition: background var(--motion-fast) var(--ease);
}

tbody tr:hover {
  background: rgb(255 255 255 / 0.015);
}

/* Maps, drawn by shared/src/shared/view/draw.gleam on the server and in the
 * browser alike. Waypoints are hollow so a unit marker on one stays legible.
 * The field behind them is the stage: a faint grid that fades out towards the
 * edges, and corner brackets around the frame. */

.map {
  display: block;
  width: 100%;
  max-width: 40rem;
  height: auto;
  font-family: var(--font-display);
}

.map-route {
  fill: none;
  stroke: rgb(150 180 205 / 0.2);
  stroke-width: 1.5;
  transition: stroke var(--motion-fast) var(--ease);
}

/* A planet is a lit sphere: its body in the holder's colour — or dark with a
   pale rim when nobody holds it, which also gets no halo — under a shared
   shading of light from the upper left. */
.map-planet {
  fill: #1f232b;
  stroke: rgb(191 227 245 / 0.45);
  stroke-width: 2.5;
  transition:
    fill var(--motion-slow) var(--ease),
    stroke var(--motion-fast) var(--ease);
}

.map-planet-shade {
  fill: url(#map-shade);
  pointer-events: none;
}

/* The bands across a homeworld's face. */
.map-planet-bands {
  fill: url(#map-bands);
  pointer-events: none;
}

/* A held planet's glow in its holder's colour: soft, and under everything
   else of the planet. */
.map-planet-halo {
  fill: var(--owner-colour);
  opacity: 0.32;
  filter: blur(9px);
  pointer-events: none;
}

/* A homeworld's orbit: in its holder's colour, or plain while nobody holds it
   (the editor). */
.map-orbit,
.map-orbit-tick {
  fill: none;
  stroke: var(--owner-colour, var(--text-muted));
  pointer-events: none;
}

.map-orbit {
  stroke-width: 1.5;
  opacity: 0.7;
}

.map-orbit.is-outer {
  stroke-width: 1.2;
  stroke-dasharray: 2 5;
  opacity: 0.45;
}

.map-orbit-tick {
  stroke-width: 2;
  opacity: 0.85;
}

/* A waypoint is a small dot. Only drawn small: a tap still reaches it within
   `geometry.waypoint_radius` and the pointer slack. */
.map-waypoint {
  r: 4.5px;
  fill: rgb(125 150 180 / 0.5);
  stroke: none;
}

.map-monument {
  fill: none;
  stroke: var(--planet-rim);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.55;
}

/* A PDF (§11.2): a square bastion around its planet in the faction's colour,
   so it is never mistaken for a round unit token. Remembered is faded and
   dashed like a remembered unit; one founded this round is drawn open. */
.map-pdf-wall {
  fill: none;
  stroke: var(--faction-colour);
  stroke-width: 4;
}

.map-pdf.is-remembered .map-pdf-wall {
  opacity: 0.55;
  stroke-dasharray: 6 4;
}

.map-pdf.is-pending .map-pdf-wall {
  stroke-width: 2;
  stroke-dasharray: 2 4;
}

/* Text sizes are in map units: the map is 1200 wide and usually drawn at about
 * half that, so these read as roughly 11–12px on screen. */
.map-slot {
  fill: var(--stage);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
}

.map-label {
  fill: #c8cfd9;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  paint-order: stroke;
  stroke: var(--stage);
  stroke-width: 5px;
  stroke-linejoin: round;
  pointer-events: none;
}

/* The one selected thing may glow. */
.map-route.is-selected,
.is-selected > .map-planet {
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgb(124 192 218 / 0.6));
}

.map-route.is-flagged,
.is-flagged > .map-planet {
  stroke: var(--danger);
  stroke-width: 3;
  stroke-dasharray: 6 4;
}

/* A route being dragged out of a planet in the editor: a straight line to the
   pointer, and the planet it would join if let go now, lit like a target. */
.map-route-sketch {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 8 6;
  stroke-linecap: round;
  pointer-events: none;
}

/* The grip on the middle of the selected route: drag it to bend the route. */
.map-bend-handle {
  fill: rgb(124 192 218 / 0.15);
  stroke: var(--accent);
  stroke-width: 2;
  cursor: grab;
}

.is-bending .map-bend-handle {
  cursor: grabbing;
}

.is-target > .map-planet {
  stroke: var(--success);
  stroke-width: 6;
  filter: drop-shadow(0 0 6px rgb(127 171 132 / 0.7));
}

/* --- Map library ---------------------------------------------------------- */

.map-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.map-card {
  display: grid;
  grid-template-columns: minmax(0, 18rem) 1fr;
  gap: var(--space-5);
  align-items: start;
}

.map-card h2 {
  margin: 0;
}

/* The stage behind a map drawn in a frame: a 56px grid, faded out at the
   edges by a vignette over it, and 22px brackets on the frame's corners. */
.map-thumbnail .map,
.map-editor .map,
.campaign-canvas .map {
  --stage-edge: rgb(150 205 228 / 0.4);
  background-color: var(--stage);
  background-image:
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    linear-gradient(var(--stage-edge), var(--stage-edge)),
    radial-gradient(ellipse at center, transparent 45%, var(--stage) 95%),
    radial-gradient(ellipse at center, rgb(46 104 140 / 0.12), transparent 70%),
    linear-gradient(rgb(140 196 224 / 0.044) 1px, transparent 1px),
    linear-gradient(90deg, rgb(140 196 224 / 0.044) 1px, transparent 1px);
  background-position:
    0 0, 0 0, 100% 0, 100% 0, 0 100%, 0 100%, 100% 100%, 100% 100%,
    0 0, 0 0, center, center;
  background-size:
    22px 1px, 1px 22px, 22px 1px, 1px 22px, 22px 1px, 1px 22px, 22px 1px,
    1px 22px, 100% 100%, 100% 100%, 56px 56px, 56px 56px;
  background-repeat:
    no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat,
    no-repeat, no-repeat, no-repeat, no-repeat, repeat, repeat;
  border-radius: var(--radius-md);
}

.map-thumbnail .map {
  border: 1px solid var(--border);
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.map-actions form {
  margin: 0;
}

.map-rename summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color var(--motion-fast) var(--ease);
}

.map-rename summary:hover {
  color: var(--accent);
}

.map-rename form {
  margin-top: var(--space-4);
}

/* Every button that is not the step forward: a plain control. */
.button-secondary {
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  font-weight: 500;
}

.button-secondary:hover {
  color: var(--text-primary);
  background: var(--surface-3);
  border-color: var(--border-stronger);
}

/* A status is a tag: display caps beside a diamond, in the colour of the
   judgment it carries. The diamond stands on the text's baseline rather than
   the middle of its line box: the tag is all capitals, so the line box's
   descender space would leave the diamond low beside them — by how much
   depends on the font. */
.status {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 6px;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.status::before {
  content: "";
  flex: none;
  align-self: baseline;
  width: 6px;
  height: 6px;
  margin-bottom: 1px;
  border: 1px solid currentColor;
  transform: rotate(45deg);
}

.status-ready {
  color: var(--success);
  border-color: rgb(127 171 132 / 0.4);
  background: var(--success-dim);
}

.status-ready::before {
  background: currentColor;
}

.status-draft {
  color: var(--warn);
  border-color: rgb(217 164 65 / 0.4);
  background: var(--warn-dim);
}

.status-error {
  color: var(--danger);
  border-color: rgb(226 114 106 / 0.4);
  background: var(--danger-dim);
}

.status-error::before {
  background: currentColor;
}

/* The save tag beside a Save button, the map editor's included. It is as tall
   as the button, so their edges line up: stretched to the row, with its one
   line of text centred in it (a wrapping flex line, so `align-content` places
   it) and still standing on the baseline beside its diamond. */
.save-state {
  margin: 0;
  white-space: nowrap;
}

.editor-save .save-state,
.save-bar-actions .save-state {
  align-self: stretch;
  flex-wrap: wrap;
  align-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

/* `.status` sets a display, which would otherwise override `hidden`. */
.save-state[hidden] {
  display: none;
}

@media (max-width: 40rem) {
  .map-card {
    grid-template-columns: 1fr;
  }
}

/* --- The two map screens ---------------------------------------------------- */

/* The map grows with the window, but never taller than it: the whole map
   stays in view while a unit is dragged across it. */
.campaign-canvas .map,
.map-editor .map {
  width: 100%;
  max-width: none;
  height: auto;
  max-height: calc(100vh - 6rem);
}

/* --- Map editor ------------------------------------------------------------ */

.map-editor .map {
  max-width: none;
  border: 1px solid var(--border);
  touch-action: none;
  user-select: none;
}

/* The editor's toolbar is a HUD strip of tool buttons. */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-3);
  padding: 8px 10px;
  background: var(--sf-brackets), var(--sf-fill);
  border: 1px solid rgb(150 180 205 / 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.editor-tools + .editor-tools:not(.editor-save) {
  padding-left: var(--space-5);
  border-left: 1px solid var(--border);
}

.editor-save {
  margin-left: auto;
}

/* A tool: small, square-cornered, uppercase. */
.editor-tools button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-secondary);
  background: rgb(255 255 255 / 0.025);
  border: 1px solid rgb(150 180 205 / 0.16);
}

.editor-tools button:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgb(124 192 218 / 0.08);
  border-color: rgb(124 192 218 / 0.4);
}

.editor-save button:not(.button-secondary) {
  color: var(--text-primary);
  border-color: rgb(124 192 218 / 0.55);
  background: linear-gradient(180deg, rgb(124 192 218 / 0.3), rgb(124 192 218 / 0.1));
}

/* The chosen tool: an accent edge and an underline. */
.editor-tools [aria-pressed="true"],
.editor-tools [aria-pressed="true"]:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgb(124 192 218 / 0.2), rgb(124 192 218 / 0.06));
  box-shadow: inset 0 -2px 0 var(--accent);
}

.editor-tools button:disabled {
  opacity: var(--opacity-disabled-tool);
  filter: none;
}

.editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: var(--space-4);
  align-items: start;
}

.editor-canvas.tool-select .map-planet {
  cursor: grab;
}

.editor-canvas.tool-planet {
  cursor: crosshair;
}

.editor-canvas.tool-route .map-planet {
  cursor: pointer;
}

/* An "i" beside a control, explaining it while hovered or focused. The text
   spans the whole row it sits in, so it never runs off a narrow panel. */
.info-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.info-tip,
.info-tip:hover,
.info-tip:focus-visible {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
}

.info-tip:hover,
.info-tip:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

.info-tip-text {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 10;
  padding: 8px 12px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
  box-shadow: 0 10px 24px -8px rgb(0 0 0 / 0.55);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  cursor: auto;
}

.info-tip:hover .info-tip-text,
.info-tip:focus .info-tip-text {
  display: block;
  animation: rise var(--motion-fast) var(--ease-out);
}

/* A missing start planet, with the picker that answers it on the same line. */
.editor-issue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.editor-issue select {
  width: auto;
}

.editor-side {
  display: grid;
  gap: var(--space-3);
}

.editor-panel {
  margin: 0;
  padding: var(--space-4);
}

.editor-panel input[type="file"] {
  max-width: 100%;
}

.editor-panel h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.editor-panel select,
.editor-panel input[type="number"] {
  padding: 6px 8px;
}

.editor-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.editor-curve {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.editor-curve input[type="range"] {
  flex: 1;
  min-width: 0;
}

.field-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
}

.button-danger {
  color: var(--danger);
  background: var(--surface-1);
  border-color: rgb(226 114 106 / 0.34);
  font-weight: 500;
}

.button-danger:hover {
  color: var(--danger);
  background: var(--danger-dim);
  border-color: rgb(226 114 106 / 0.6);
}

@media (max-width: 48rem) {
  .editor-body {
    grid-template-columns: 1fr;
  }

  .editor-save {
    margin-left: 0;
  }

  .editor-tools + .editor-tools:not(.editor-save) {
    padding-left: 0;
    border-left: 0;
  }
}

.editor-error {
  color: var(--danger-soft);
}

.editor-problems {
  margin-top: var(--space-4);
}

.editor-problems ul {
  margin: 6px 0 0;
  padding-left: 1.25rem;
}

.editor-draft {
  background: linear-gradient(90deg, var(--accent-dim), transparent 85%);
  border-left-color: var(--accent);
}

button:disabled,
button:disabled:hover {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  box-shadow: none;
}

/* A faction's colour is its identity (spec §2), so it travels with its name —
   as a diamond, the one shape a faction marker takes. */
.faction-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 8px 0 2px;
  transform: rotate(45deg);
  vertical-align: 1px;
}

/* The guided setup: several small forms per card, each saving on its own. */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 0;
  width: 100%;
  background: var(--surface-2);
}

legend {
  padding: 0 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* --- The campaign map (spec §14.1, §15.3) --------------------------------- */

.campaign-map {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: var(--space-4);
  align-items: start;
}

.campaign-canvas {
  position: relative;
  /* The browser's own pan and zoom must not eat a tap meant for the map, and
     dragging a unit must not select the page's text on the way (§15.3). */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.campaign-canvas .map {
  width: 100%;
  height: auto;
  cursor: pointer;
  border: 1px solid var(--border);
}

/* A held planet takes its faction's colour, which arrives as inline data
   because a faction may pick any hex it likes (§2). */
.map-planet.is-owned {
  fill: var(--owner-colour);
  stroke: rgb(255 255 255 / 0.28);
  stroke-width: 1.5;
}

/* Units standing on fields. Drawn after the planets, so a marker is never
   hidden behind the field it stands on. */
.map-unit {
  cursor: grab;
}

/* A token above its field (§8.2): a shape in the faction's colour with a pale
   outline, so it stands apart from a planet of the same colour. */
.map-unit-mark {
  fill: var(--faction-colour);
  stroke: #e5e9ef;
  stroke-width: 2;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.8));
}

/* The ring around the selected token, broken into four arcs. */
.map-unit-ring {
  fill: none;
  stroke: #e5e9ef;
  stroke-width: 2;
  stroke-dasharray: 22.5 5.8;
  stroke-dashoffset: 3;
  pointer-events: none;
}

/* The same token beside a unit's name in the side panel. */
.token-icon {
  flex: none;
  width: 16px;
  height: 16px;
  overflow: visible;
}

.token-icon .map-unit-mark {
  stroke-width: 2.5;
  filter: none;
}

/* What is not live is faded — but fading alone says nothing to someone who
   cannot see the difference, so the outline changes too and the marker's
   title spells it out (§14.1, §7). */
.map-unit.is-remembered,
.map-unit.is-retreated {
  cursor: pointer;
}

.map-unit.is-remembered .map-unit-mark,
.map-unit.is-retreated .map-unit-mark {
  opacity: 0.55;
  stroke: var(--text-muted);
  stroke-dasharray: 4 3;
}

.map-unit.is-retreated .map-unit-mark {
  opacity: 0.35;
}

.map-unit.is-selected .map-unit-mark {
  filter: drop-shadow(0 0 6px rgb(255 255 255 / 0.35));
}

/* Where a selected unit could land (§15.3). Under the planets, so a halo never
   covers the planet it belongs to. It breathes slowly — ambient, not an
   alarm — and holds still for those who asked for less motion. */
.map-reachable {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 4;
  opacity: 0.85;
  animation: breathe 4.2s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.45;
  }

  50% {
    opacity: 0.95;
  }
}

/* A declared movement (§3.2): a line from field to field and a ghost where the
   unit will stand once the reveal moves it. One being planned is dashed, so a
   draft never reads as a decision already made. */
.map-path {
  fill: none;
  stroke: var(--faction-colour);
  stroke-width: 3;
  stroke-linecap: square;
  stroke-linejoin: miter;
  opacity: 0.8;
  pointer-events: none;
}

.map-path.is-planned {
  stroke-dasharray: 6 5;
}

/* Ghost tokens (§15.3): where the movement being planned lands, see-through;
   and, for a selected unit that has declared its movement, where it started. */
.map-shadow {
  pointer-events: none;
}

.map-shadow .map-unit-mark {
  fill: var(--faction-colour);
  stroke: var(--text-primary);
  stroke-width: 2;
  stroke-dasharray: 4 3;
}

.map-shadow.is-landing {
  opacity: 0.55;
}

.map-shadow.is-origin {
  opacity: 0.35;
}

/* A unit being dragged: its token follows the pointer, a little see-through so
   the field under it stays readable. Never a target itself. */
.map-carried {
  pointer-events: none;
  opacity: 0.85;
}

.map-carried .map-unit-mark {
  fill: var(--faction-colour);
  stroke: var(--text-primary);
  stroke-width: 2;
  filter: drop-shadow(0 6px 8px rgb(0 0 0 / 0.7));
}

/* The field a drag would be dropped on: green where the unit can end its
   movement, red where it cannot. The drag hint says which in words. */
.map-drop-target {
  fill: none;
  stroke-width: 3;
  pointer-events: none;
}

.map-drop-target.is-valid {
  stroke: var(--success);
}

.map-drop-target.is-invalid {
  stroke: var(--danger);
  stroke-dasharray: 5 4;
}

.campaign-side {
  display: grid;
  gap: var(--space-3);
}

.campaign-side .card {
  margin-bottom: 0;
  padding: var(--space-4);
}

/* Round, phase, the round's wait and the factions: the board's status strip. */
.campaign-standing {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* The round and phase are the one active thing here: an accent tag, its
   diamond lit. */
.campaign-standing > .status,
.campaign-standing .round-progress > .status {
  justify-self: start;
  margin: 0;
  padding: 7px 14px;
  font-size: 11px;
  color: var(--text-primary);
  border-color: var(--hud-border);
  background: var(--sf-brackets), var(--sf-fill);
  box-shadow: var(--shadow-hud);
}

.campaign-standing > .status::before,
.campaign-standing .round-progress > .status::before {
  width: 7px;
  height: 7px;
  color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 9px var(--accent);
}

/* The round, and its three phases in order beside it (§3): the ones already
   played dim, the current one lit with the accent, the ones to come faint. */
.round-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.round-progress > .status {
  margin: 0;
}

.phase-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.phase-step + .phase-step::before {
  content: "›";
  padding-right: 4px;
  color: var(--text-muted);
  letter-spacing: 0;
}

.phase-step.is-done {
  color: var(--text-secondary);
}

/* The current phase is a small lit tab, the accent's one active thing. */
.phase-step.is-current > span {
  padding: 3px 8px;
  color: var(--text-primary);
  border: 1px solid rgb(124 192 218 / 0.45);
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
}

.unit-list,
.faction-list,
.round-log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.round-log {
  list-style: decimal-leading-zero;
  padding-left: 2.2rem;
  gap: 3px;
}

.round-log li::marker {
  font-size: 11px;
}

/* A unit list is a stack of menu entries: a rail on the left that lights on
   hover, and stays lit on the chosen one. */
.unit-list li {
  display: flex;
}

.unit-list button,
.unit-list a {
  display: flex;
  align-items: center;
  /* A button centres its content by default, which would shift a short
     name's token to the right of the ones above and below it. */
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 0;
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
  background: rgb(11 16 24 / 0.55);
  border: 1px solid rgb(150 180 205 / 0.11);
  border-left: 2px solid rgb(150 180 205 / 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition:
    border-color var(--motion-fast) var(--ease),
    background var(--motion-fast) var(--ease),
    transform var(--motion-fast) var(--ease);
}

.unit-list button:hover,
.unit-list a:hover {
  color: var(--text-primary);
  background: linear-gradient(90deg, rgb(124 192 218 / 0.14), rgb(11 16 24 / 0.55) 80%);
  border-color: rgb(124 192 218 / 0.28);
  border-left-color: var(--accent);
  box-shadow: none;
  transform: translateX(3px);
}

.unit-list .is-selected,
.unit-list .is-selected:hover {
  color: var(--text-primary);
  background: linear-gradient(90deg, rgb(124 192 218 / 0.2), rgb(11 16 24 / 0.55) 85%);
  border-color: rgb(124 192 218 / 0.4);
  border-left-color: var(--accent);
  transform: none;
}

/* The factions as a roster: each marked with its colour's diamond. */
.faction-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 9px 12px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.faction-list .swatch {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  transform: rotate(45deg);
  background: var(--faction-colour);
  flex: none;
}

.badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  color: var(--text-secondary);
  background: var(--surface-3);
}

/* An account that has not confirmed its address, or has been locked
   (/admin/users): the one thing on its row an administrator acts on. */
.badge-warning {
  border-color: rgb(217 164 65 / 0.4);
  background: var(--warn-dim);
  color: var(--warn);
}

.badge-danger {
  border-color: rgb(226 114 106 / 0.4);
  background: var(--danger-dim);
  color: var(--danger);
}

/* A wide table scrolls sideways inside its card rather than widening the page
   on a phone. */
.table-scroll {
  overflow-x: auto;
}

.table-scroll table {
  min-width: 100%;
  white-space: nowrap;
}

/* What the round is waiting for. Neutral on purpose: at the start of an
   Assault Phase "nobody is ready yet" is the ordinary state of a working
   campaign, and colouring it red teaches the reader to see a problem. The
   accent is reserved for "and that is you" — lit, never blinking. */
.waiting {
  position: relative;
  margin: 6px 0 0;
  padding: 10px 12px;
  background: linear-gradient(90deg, var(--surface-3), transparent 90%);
  border-left: 2px solid var(--border-stronger);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-primary);
}

.waiting-you {
  background: linear-gradient(90deg, rgb(124 192 218 / 0.14), transparent 90%);
  border-left-color: var(--accent);
}

.waiting p {
  margin: 0;
}

.waiting p + p {
  margin-top: var(--space-2);
}

.waiting-detail {
  margin: 6px 0 0;
  padding-left: 1.1rem;
  font-size: 12px;
  color: var(--text-secondary);
}

/* The ready toggle, under the notice that says what the round waits for. */
.campaign-standing > form {
  justify-self: start;
  margin: 0;
}

/* How the factions stand, under the board: reference, not a call to act. */
.campaign-overview {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.campaign-controls {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

/* On a phone the panel goes under the map, and the unit list becomes the
   primary way to select — tapping a 6-unit-wide waypoint is not a target
   anyone wants to hit with a thumb (§15.3). */
@media (max-width: 900px) {
  .campaign-map {
    grid-template-columns: 1fr;
  }
}

/* The questions and refusals of declaring a movement (§15.3), laid over the map
   they are about. Not a passing status message: the map dims, and nothing on
   it can be pressed until the question is answered. */
.campaign-stage {
  position: relative;
}

.campaign-modal-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgb(6 8 12 / 0.6);
  backdrop-filter: blur(var(--blur-backdrop));
  -webkit-backdrop-filter: blur(var(--blur-backdrop));
  animation: fade var(--motion-fast) var(--ease);
}

/* An order awaiting confirmation: the dialog, with the report's title rule. */
.campaign-modal {
  position: relative;
  width: 100%;
  max-width: 26rem;
  background: var(--sf-brackets), var(--dialog-fill);
  color: var(--text-secondary);
  border: 1px solid rgb(150 180 205 / 0.16);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow-report);
  animation: rise var(--motion-normal) var(--ease-out);
}

.campaign-modal h2 {
  margin: 0 0 var(--space-3);
  padding-bottom: 11px;
  font-size: 16px;
  letter-spacing: 0.07em;
  line-height: 1.25;
  color: var(--text-primary);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, rgb(150 205 228 / 0.4), transparent 90%) 1;
}

/* Planning by clicks: the controls sit on the map, where the clicking is, as
   HUD glass. */
.campaign-plan-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(40rem, calc(100% - 28px));
  display: grid;
  gap: var(--space-2);
  background: var(--sf-brackets), var(--sf-fill);
  border: 1px solid rgb(150 180 205 / 0.12);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
}

.campaign-plan-bar .hint {
  margin: 0;
}

/* While dragging: what dropping now would do, at the top of the map so the
   pointer never covers it. It takes no pointer events, so the drag carries on
   underneath. */
.campaign-drag-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  margin: 0;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-left: 2px solid var(--success);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
  box-shadow: 0 10px 24px -8px rgb(0 0 0 / 0.55);
  pointer-events: none;
}

/* The card naming the token under the pointer: its name and where it stands
   with this round's decision. Laid over the map in a frame with the map's own
   proportions (the map is letterboxed on a short window), so a position in
   map coordinates lands on the token. Above the token, below it near the top
   edge, turned inwards near either side. Never a target itself. */
.campaign-hover-layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.campaign-hover-frame {
  position: relative;
  height: 100%;
  max-width: 100%;
}

.campaign-hover-card {
  --hover-gap: 22px;
  position: absolute;
  z-index: 5;
  width: max-content;
  max-width: 18rem;
  padding: 8px 12px;
  transform: translate(-50%, calc(-100% - var(--hover-gap)));
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-left: 2px solid var(--faction-colour);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur-hud));
  -webkit-backdrop-filter: blur(var(--blur-hud));
  box-shadow: 0 10px 24px -8px rgb(0 0 0 / 0.55);
  animation: fade var(--motion-fast) var(--ease);
}

.campaign-hover-card.is-below {
  transform: translate(-50%, var(--hover-gap));
}

.campaign-hover-card.is-left {
  transform: translate(-16px, calc(-100% - var(--hover-gap)));
}

.campaign-hover-card.is-right {
  transform: translate(calc(-100% + 16px), calc(-100% - var(--hover-gap)));
}

.campaign-hover-card.is-below.is-left {
  transform: translate(-16px, var(--hover-gap));
}

.campaign-hover-card.is-below.is-right {
  transform: translate(calc(-100% + 16px), var(--hover-gap));
}

.campaign-hover-card p {
  margin: 0;
}

.campaign-hover-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.campaign-hover-name .swatch {
  flex: none;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  background: var(--faction-colour);
}

.campaign-hover-card .campaign-hover-status {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.campaign-drag-hint.is-invalid {
  color: var(--danger-soft);
  border-left-color: var(--danger);
}

.campaign-modal .actions,
.campaign-plan-bar .actions,
.campaign-side .card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.campaign-side .card .actions form {
  margin: 0;
}

/* The battle screens (§6, §15.3). Ordinary server-rendered pages: a list of
   the round's battles, and one battle with a row per duel. Nothing here needs
   JavaScript, so nothing here depends on it. */

.battle-list,
.duel-list,
.player-choice,
.summary-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.duel-list {
  list-style: decimal-leading-zero;
  padding-left: 2.2rem;
}

/* A battle is a row with the battle red on its rail. */
.battle-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 9px 12px;
  border: 1px solid rgb(150 180 205 / 0.12);
  border-left: 2px solid rgb(226 114 106 / 0.6);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgb(226 114 106 / 0.08), rgb(10 14 21 / 0.82) 60%);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--motion-fast) var(--ease),
    background var(--motion-fast) var(--ease);
}

.battle-list li:hover {
  border-color: rgb(150 180 205 / 0.3);
  border-left-color: var(--danger-soft);
  background: linear-gradient(90deg, rgb(226 114 106 / 0.16), rgb(14 20 30 / 0.88) 65%);
}

.battle-list a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
}

.battle-list a::before {
  content: "⚔";
  margin-right: 8px;
  color: var(--danger-soft);
  letter-spacing: 0;
}

.battle-list a:hover {
  color: var(--accent);
}

.battle-sides,
.battle-status,
.battle-groups {
  color: var(--text-secondary);
  font-size: 12px;
}

.battle-status {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.battle-pools ul,
.battle-selection {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

/* A duel is one line until the screen is narrow enough that it cannot be. */
.duel-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.duel-players {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.duel-settled,
.duel-waiting {
  color: var(--text-secondary);
}

.duel-enter,
.duel-pending form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.duel-enter input[type="number"] {
  width: 5rem;
  font-variant-numeric: tabular-nums;
}

.duel-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.player-choice label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* The §14.2 round summary: one combined recap of the previous round, never
   several. Its entries are marked with the selectable diamond. */
.round-summary .summary-list {
  list-style: "◇  ";
  padding-left: 1.4rem;
}

.round-summary .summary-list li::marker {
  color: var(--text-muted);
  font-size: 10px;
}

/* Its categories are sections of that one summary (§14.2). */
.summary-section + .summary-section {
  margin-top: var(--space-3);
}

.summary-section h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

/* A faction's five pools (spec §9), read like the HUD's resource strip: each
   resource's own glyph over a display numeral. Scrolls sideways inside itself
   rather than widening the page on a phone. */
.resource-pools {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  overflow-x: auto;
}

.resource-pools table {
  min-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-collapse: separate;
  border-spacing: 0;
}

.resource-pools th,
.resource-pools td {
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.resource-pools tbody tr:last-child > * {
  border-bottom: 0;
}

.resource-pools th[scope="row"],
.resource-pools thead th:first-child {
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.resource-pools thead th:first-child {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--text-muted);
}

.resource-pools .swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  transform: rotate(45deg);
  background: var(--faction-colour);
  vertical-align: 1px;
}

/* A resource's head: its glyph, drawn as a mask so it takes the text colour
   and the accent on hover; the name beside it stays for anyone reading. */
.res-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.res-ico {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  background: var(--text-secondary);
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
  transition: background-color var(--motion-fast) var(--ease);
}

.resource-pools th:hover .res-ico {
  background: var(--accent);
}

[data-res="conquest"] {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M4 14V2M4 3h8l-2 3 2 3H4'/%3E%3C/svg%3E");
}

[data-res="warfare"] {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M3 3l10 10M13 3L3 13M2 6l4-4M10 14l4-4M14 6l-4-4M6 14l-4-4'/%3E%3C/svg%3E");
}

[data-res="plunder"] {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M8 1.8l5.2 3v6.4L8 14.2l-5.2-3V4.8zM2.8 4.8L8 7.8l5.2-3M8 7.8v6.4'/%3E%3C/svg%3E");
}

[data-res="monument"] {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.5' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M5.6 14V6L8 1.6 10.4 6v8M3.6 14h8.8'/%3E%3C/svg%3E");
}

[data-res="glory"] {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M8 1.6l1.9 4 4.3.6-3.1 3 .7 4.3L8 11.4 4.2 13.5l.7-4.3-3.1-3 4.3-.6z'/%3E%3C/svg%3E");
}

/* The note under the table is in the same scrolling box, and would otherwise
   be as wide as the table rather than the screen. */
.resource-pools > .hint {
  max-width: calc(100vw - 2 * var(--space));
}

.resource-pools td {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

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

/* Entrances fade and rise 5px from a hair under full size. */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.985);
  }
}

/* The same for something already moved into the middle of the screen. */
@keyframes rise-centred {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 5px)) scale(0.985);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* Motion is decoration here, never information: all of it stops on request. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
