:root {
  --bg: #0b0e14;
  --bg-alt: #10141d;
  --card: #141926;
  --border: #232a3a;
  --text: #d7dce5;
  --text-dim: #8a93a6;
  --accent: #4fc3f7;
  --accent-dim: #2b7ea1;
  /* Subsection headings. Body links took --accent, so headings need to sit
     clearly above it or they read as links you cannot click. */
  --accent-bright: #b3e5fc;
  --gold: #e0b25a;
  --warn: #e05a5a;
  --new: #ff1f3d;
  --zh: #7aa9d6;
  --reg: #6fcf97;
  --radius: 8px;
  /* 1475 = a 325px sidebar + 1150px of content: both 25% wider than the old 260 + 920. */
  --max-width: 1475px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, #0d1b2a 0%, #10141d 60%);
  border-bottom: 1px solid var(--border);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  color: #fff;
}

.header-inner h1 .subtitle {
  color: var(--accent);
  font-weight: 400;
}

.tagline {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.3rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}

/* Layout */
.layout {
  display: flex;
  max-width: var(--max-width);
  margin: 0 auto;
  align-items: flex-start;
}

.sidebar {
  width: 325px;
  flex-shrink: 0;
  position: sticky;
  top: 96px;
  padding: 28px 16px 60px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }

.nav-heading {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.sidebar a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 2px solid transparent;
}

.sidebar a:hover {
  background: var(--card);
  border-left-color: var(--accent);
  color: var(--accent);
}

/* Body links were never styled, so they fell back to the browser default
   (#0000EE) — a dark saturated blue that is barely legible on this background.
   They take the palette accent instead, which already carries h3 headings and
   table headers. :visited MUST be set alongside, or a followed link reverts to
   the default dark purple, which is worse than what we started with. */
.content a,
.content a:visited {
  color: var(--accent);
}

.content a:hover { color: #8fd8fb; }

/* Content */
.content {
  flex: 1;
  padding: 32px 32px 80px;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 24px;
  scroll-margin-top: 96px;
}

.card h2 {
  margin-top: 0;
  color: #fff;
  font-size: 1.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.card h3 {
  color: var(--accent-bright);
  font-size: 1.05rem;
  margin-top: 24px;
  margin-bottom: 10px;
}

.card h3:first-of-type { margin-top: 8px; }

/* Group labels above a table (weapon classes, missile Fox classes). Subordinate to
   h3 without falling back to unstyled body text. */
.card h4 {
  color: var(--gold);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 22px;
  margin-bottom: 6px;
}

.card p { color: var(--text); margin: 10px 0; }

.card ul, .card ol {
  margin: 10px 0;
  padding-left: 22px;
}

.card li { margin-bottom: 8px; }

.card strong { color: #fff; }

.card code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--gold);
}

.warning { color: var(--warn); font-weight: 600; }

.section-divider {
  max-width: var(--max-width);
  color: var(--gold);
  font-size: 1.5rem;
  text-align: center;
  margin: 48px 0 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

thead th {
  text-align: left;
  background: var(--bg-alt);
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

tbody tr:hover { background: rgba(79, 195, 247, 0.05); }

/* Roadmap list */
.roadmap-list {
  counter-reset: item;
  list-style: none;
  padding-left: 0;
}

.roadmap-list > li {
  counter-increment: item;
  position: relative;
  padding: 12px 16px 12px 48px;
  margin-bottom: 10px;
  background: var(--bg-alt);
  border-radius: 6px;
  border-left: 3px solid var(--gold);
}

.roadmap-list > li::before {
  content: counter(item);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Compare grid (Zero Hour vs Renegades) */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

.compare-box {
  border-radius: 6px;
  padding: 16px 18px;
  border: 1px solid var(--border);
}

.compare-box h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.compare-box.zh { border-left: 3px solid var(--zh); }
.compare-box.zh h4 { color: var(--zh); }

.compare-box.reg { border-left: 3px solid var(--reg); }
.compare-box.reg h4 { color: var(--reg); }

.compare-box p { margin: 0; color: var(--text); }
.compare-box p + p { margin-top: 10px; }

/* Footer */
.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* Search */
.guide-search {
  position: relative;
  margin-left: auto;
  width: 340px;
  flex-shrink: 0;
}

.guide-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 8px 12px;
}

.guide-search input:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  padding: 6px;
}

.search-count {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 10px;
}

.search-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.search-item:hover,
.search-item.active {
  background: var(--bg-alt);
  border-left-color: var(--accent);
}

.search-where {
  display: block;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.search-snippet {
  display: block;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.45;
}

.search-results mark {
  background: rgba(224, 178, 90, 0.25);
  color: var(--gold);
  border-radius: 2px;
  padding: 0 1px;
}

.search-flash { animation: search-flash 2.4s ease-out; }

@keyframes search-flash {
  0%, 30% { background: rgba(79, 195, 247, 0.18); box-shadow: 0 0 0 6px rgba(79, 195, 247, 0.18); }
  100% { background: transparent; box-shadow: 0 0 0 6px transparent; }
}

/* Responsive */
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }

  .layout { flex-direction: column; }

  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: none;
  }

  .sidebar.open { display: flex; }

  .content { padding: 20px 18px 60px; }

  .compare-grid { grid-template-columns: 1fr; }

  .site-header { padding: 20px; flex-wrap: wrap; gap: 12px; }

  .guide-search { order: 3; width: 100%; margin: 0; }

  .search-results { width: 100%; }
}

/* ---- "Mayhem 4" exclusivity tag ----------------------------------------
   Marks a feature that is new in Mayhem 4 rather than inherited from
   Litcube's Universe, Mayhem 3, Zero Hour or Renegades. Used sparingly: one
   tag per genuinely new feature, on the heading that owns it. Bright red on
   purpose so it reads as a flag rather than as decoration, but small, and
   sized in rem so it stays identical on an h2 and an h3 instead of scaling
   with the heading. */
.m4 {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -0.12em;
  margin-left: 0.6em;
  padding: 0.18em 0.5em 0.16em;
  background: var(--new);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 4px;
  /* The heading it sits in may be a link colour; pin the text colour. */
  text-shadow: none;
}

/* The "What's new" list in the introduction. Its links share one colour so the
   list reads as a single block of new features rather than as ordinary body
   links that happen to be gathered together. Deliberately NOT the tag red
   above — that red is a flag, and a whole list of it shouts. */
.whats-new a,
.whats-new a:visited {
  color: var(--reg);
  font-weight: 700;
}

.whats-new a:hover { color: #9ae5bb; }

/* Inline form, for prose and list items rather than headings. */
.m4-inline {
  font-size: 0.58rem;
  margin-left: 0.4em;
  top: -0.08em;
}

/* Laser research tables (Weapons Research). Sortable on every column: the reader
   is asking one of two different questions -- "what hits hardest" or "what is the
   best value for my research time" -- and each is a different column. The race
   markers use Mayhem.GetPlayerRaceColor's own palette, so a colour here means the
   same thing it means in the menus. */
.lasertable th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.lasertable th[data-sort]::after {
  content: "\2195";
  opacity: 0.35;
  margin-left: 0.45em;
  font-size: 0.9em;
}

.lasertable th[aria-sort="descending"]::after { content: "\2193"; opacity: 1; }
.lasertable th[aria-sort="ascending"]::after  { content: "\2191"; opacity: 1; }
.lasertable th[data-sort]:hover { color: var(--accent-bright); }
.lasertable th[data-sort]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.lasertable .num,
.lasertable .fitcol { text-align: right; }

.lasertable td.num {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Best value in that size class, within 15% of the class leader. */
.lasertable td.good { color: var(--reg); font-weight: 700; }

.lasertable td.fitcol i {
  font-style: normal;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  padding-left: 0.1em;
}

.lasertable td.fitcol i.off { color: #1e2534; }

.lasertable .freetag {
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.45em;
}

.race-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 10px 0 4px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.race-key i {
  font-style: normal;
  font-size: 1.05rem;
  vertical-align: -1px;
  margin-right: 0.3em;
}

/* Shield/hull split. The larger of the two is emphasised, because which one a gun
   leans toward is the actual decision -- an ion weapon strips shields and barely
   marks hull, a mass driver does the reverse, and average DPS hides both. */
.lasertable td.lean { color: var(--accent-bright); font-weight: 700; }
