/* ============================================================
   ESTARI — Shared Stylesheet
   Space magic aesthetic · 9th Era campaign setting
   ============================================================ */

/* --- Variables --- */
:root {
  --bg-0: #07131f;
  --bg-1: #0f2235;
  --bg-2: #15344f;
  --panel: rgba(7, 16, 28, 0.9);
  --line: rgba(120, 180, 235, 0.22);
  --text: #d8e7f5;
  --muted: #8ca4ba;
  --gold: #e6be6e;
  --arcane: #7cc0ff;
  --primal: #79d87f;
  --occult: #d58cff;
  --divine: #f2d26d;
  --danger: #ff6b6b;
  --nav-h: 58px;
  --radius: 10px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg-0);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Space Background --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(63, 121, 178, 0.25), transparent 32%),
    radial-gradient(circle at 20% 80%, rgba(41, 92, 71, 0.28), transparent 28%),
    linear-gradient(180deg, #15344f, #07131f);
  z-index: -2;
  pointer-events: none;
}

/* --- Star Particles Canvas --- */
#star-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
}

/* ============================================================
   NAVIGATION
   ============================================================ */

/* ── Nav bar ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  background: rgba(7, 16, 28, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-brand {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--arcane);
  text-decoration: none;
  margin-right: 12px;
  text-shadow: 0 0 18px rgba(124, 192, 255, 0.55);
  flex-shrink: 0;
}
.nav-brand:hover { color: #aad5ff; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  flex-wrap: nowrap;
}

/* Plain nav links */
.nav-links > li > a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 11px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  letter-spacing: 0.03em;
  display: block;
}
.nav-links > li > a:hover { color: var(--text); background: rgba(124, 192, 255, 0.1); }
.nav-links > li > a.active { color: var(--arcane); }

/* ── Top-level dropdown container ── */
.nav-dropdown {
  position: relative;
}

/* The clickable "Lore ▾" / "Rules ▾" button */
.nav-top-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 6px 11px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  letter-spacing: 0.03em;
  user-select: none;
  white-space: nowrap;
}
.nav-top-trigger:hover { color: var(--text); background: rgba(124, 192, 255, 0.1); }
.nav-top-trigger.active { color: var(--arcane); }

/* ── Level-1 dropdown panel ── */
.l1-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: rgba(7, 16, 28, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 0;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  list-style: none;
}

.l1-menu::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 10px;
}

.nav-dropdown:hover > .l1-menu,
.nav-dropdown:focus-within > .l1-menu { display: block; }
.nav-dropdown.open > .l1-menu         { display: block; }

.l1-menu > li > a {
  display: block;
  padding: 7px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.l1-menu > li > a:hover  { background: rgba(124, 192, 255, 0.08); color: var(--text); }
.l1-menu > li > a.active { color: var(--arcane); }

.l1-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* ── Category rows (level-1 items that spawn a flyout) ── */
.has-flyout {
  position: relative;
  list-style: none;
}

/* flyout-label is now a <button> — reset native button styles first */
button.flyout-label {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  font: inherit;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.flyout-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
  gap: 12px;
}
.has-flyout:hover > .flyout-label { background: rgba(124, 192, 255, 0.08); color: var(--text); }
.flyout-label.active              { color: var(--arcane); }

/* ── Level-2 flyout panel ── */
.flyout {
  display: none;
  position: absolute;
  top: -6px;
  left: 100%;
  min-width: 210px;
  background: rgba(7, 16, 28, 0.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 0;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  list-style: none;
}

.flyout::before {
  content: '';
  position: absolute;
  top: 0;
  left: -10px;
  width: 10px;
  height: 100%;
}

.has-flyout:hover > .flyout,
.has-flyout:focus-within > .flyout { display: block; }
.has-flyout.open > .flyout         { display: block; }

.flyout li { list-style: none; }
.flyout a {
  display: block;
  padding: 7px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.flyout a:hover  { background: rgba(124, 192, 255, 0.08); color: var(--text); }
.flyout a.active { color: var(--arcane); }

/* ── Grid flyout: >9 items laid out in a square-ish grid ── */
.flyout.flyout-grid {
  grid-template-columns: repeat(var(--flyout-cols, 4), 140px);
  padding: 6px 4px;
}
.has-flyout:hover > .flyout.flyout-grid,
.has-flyout:focus-within > .flyout.flyout-grid { display: grid; }
.has-flyout.open > .flyout.flyout-grid         { display: grid; }
.flyout.flyout-grid a {
  padding: 5px 12px;
  font-size: 0.83rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mobile hamburger toggle (hidden on desktop) ── */
.nav-mobile-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px) 80px;
}

/* --- Page Header --- */
.page-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
  position: relative;
}
.page-header::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 120px; height: 2px;
  background: var(--accent, var(--arcane));
  box-shadow: 0 0 12px var(--accent, var(--arcane));
}
.page-header .eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent, var(--arcane));
  margin-bottom: 8px;
}
.page-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  text-shadow: 0 0 32px rgba(124,192,255,0.2);
}
.page-header .subtitle {
  color: var(--muted);
  font-size: 0.97rem;
  margin-top: 8px;
  max-width: 680px;
}

/* Accent color variants */
.accent-arcane  { --accent: var(--arcane); }
.accent-primal  { --accent: var(--primal); }
.accent-occult  { --accent: var(--occult); }
.accent-divine  { --accent: var(--divine); }
.accent-gold    { --accent: var(--gold); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 10px 0 0;
}
.breadcrumb a { color: var(--arcane); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { opacity: 0.45; }

/* ============================================================
   PANELS & CARDS
   ============================================================ */
.panel {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  padding: 22px 26px;
  margin-bottom: 18px;
}
.panel h3 {
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  border-left: 4px solid var(--accent, var(--arcane));
  padding: 6px 16px;
  margin: 32px 0 18px;
  background: rgba(124,192,255,0.04);
  border-radius: 0 6px 6px 0;
}
.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}
.section-header p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

/* Color-coded section headers */
.section-header.arcane  { border-color: var(--arcane);  background: rgba(124,192,255,0.04); }
.section-header.primal  { border-color: var(--primal);  background: rgba(121,216,127,0.04); }
.section-header.occult  { border-color: var(--occult);  background: rgba(213,140,255,0.04); }
.section-header.divine  { border-color: var(--divine);  background: rgba(242,210,109,0.04); }
.section-header.gold    { border-color: var(--gold);    background: rgba(230,190,110,0.04); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
thead tr {
  background: rgba(124,192,255,0.12);
  border-bottom: 2px solid rgba(124,192,255,0.3);
}
thead th {
  padding: 10px 14px;
  text-align: left;
  color: var(--arcane);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
tbody tr {
  border-bottom: 1px solid rgba(120,180,235,0.08);
  transition: background 0.15s;
}
tbody tr:hover { background: rgba(124,192,255,0.05); }
tbody td {
  padding: 9px 14px;
  color: var(--text);
  vertical-align: top;
}
tbody td.muted { color: var(--muted); font-size: 0.88rem; }

/* ============================================================
   STAT BARS
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin: 12px 0;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 90px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.stat-track {
  flex: 1;
  height: 7px;
  background: rgba(120,180,235,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--arcane), rgba(124,192,255,0.5));
  transition: width 0.6s ease;
  box-shadow: 0 0 6px rgba(124,192,255,0.4);
}
.stat-fill.primal  { background: linear-gradient(90deg, var(--primal), rgba(121,216,127,0.5)); box-shadow: 0 0 6px rgba(121,216,127,0.4); }
.stat-fill.occult  { background: linear-gradient(90deg, var(--occult), rgba(213,140,255,0.5)); box-shadow: 0 0 6px rgba(213,140,255,0.4); }
.stat-fill.divine  { background: linear-gradient(90deg, var(--divine), rgba(242,210,109,0.5)); box-shadow: 0 0 6px rgba(242,210,109,0.4); }
.stat-fill.gold    { background: linear-gradient(90deg, var(--gold), rgba(230,190,110,0.5));   box-shadow: 0 0 6px rgba(230,190,110,0.4); }
.stat-fill.red     { background: linear-gradient(90deg, var(--danger), rgba(255,107,107,0.5)); box-shadow: 0 0 6px rgba(255,107,107,0.4); }
.stat-val {
  font-size: 0.8rem;
  color: var(--text);
  min-width: 22px;
  text-align: right;
  flex-shrink: 0;
}

/* ============================================================
   FACTION CARDS
   ============================================================ */
.faction-card {
  background: rgba(7, 16, 28, 0.75);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--arcane));
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.faction-card:hover { background: rgba(7, 16, 28, 0.92); }
.faction-card h4 {
  color: var(--text);
  font-size: 0.98rem;
  margin-bottom: 5px;
}
.faction-card p { color: var(--muted); font-size: 0.88rem; line-height: 1.6; }

/* ============================================================
   LINK CARDS / GRID
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.link-card {
  display: block;
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  backdrop-filter: blur(6px);
}
.link-card:hover {
  border-color: rgba(124,192,255,0.45);
  background: rgba(10, 22, 38, 0.95);
  transform: translateY(-2px);
}
.link-card .card-icon { font-size: 1.5rem; margin-bottom: 8px; display: block; }
.link-card .card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--arcane);
  margin-bottom: 5px;
}
.link-card .card-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.55; }

/* World cards with accent tint */
.world-card { border-left: 3px solid var(--arcane); }
.world-card:hover { border-left-color: rgba(124,192,255,0.7); }
.world-card .card-rim { font-size: 0.75rem; color: var(--muted); margin-top: 6px; letter-spacing: 0.06em; }

/* ============================================================
   QUICK REFERENCE BOX
   ============================================================ */
.qref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.qref-box {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent, var(--arcane));
  border-radius: var(--radius);
  padding: 18px 20px;
}
.qref-box h4 {
  font-size: 0.83rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, var(--arcane));
  margin-bottom: 10px;
}
.qref-box ul { list-style: none; padding: 0; }
.qref-box li {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 3px 0;
  border-bottom: 1px solid rgba(120,180,235,0.07);
  line-height: 1.5;
}
.qref-box li:last-child { border-bottom: none; }
.qref-box p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

/* ============================================================
   WORLD STAT SHEET
   ============================================================ */
.world-stat-sheet {
  background: rgba(7, 16, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 24px;
}
.world-stat-sheet h3 {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.stat-divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

/* ============================================================
   FOOTER INFO BAR
   ============================================================ */
.world-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  background: rgba(7, 16, 28, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 22px;
  margin-top: 36px;
  font-size: 0.82rem;
  color: var(--muted);
}
.world-footer .wf-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.world-footer .wf-label { color: var(--arcane); font-weight: 600; }

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  padding: 24px 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer a { color: var(--arcane); text-decoration: none; }

/* ============================================================
   INLINE UTILITIES
   ============================================================ */
a { color: var(--arcane); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }
strong { color: var(--text); font-weight: 600; }
em { color: var(--muted); font-style: italic; }
.text-arcane  { color: var(--arcane); }
.text-primal  { color: var(--primal); }
.text-occult  { color: var(--occult); }
.text-divine  { color: var(--divine); }
.text-gold    { color: var(--gold); }
.text-muted   { color: var(--muted); }
.text-danger  { color: var(--danger); }
.italic { font-style: italic; }
.mb8 { margin-bottom: 8px; }
.mb16 { margin-bottom: 16px; }
.mb24 { margin-bottom: 24px; }
.tag {
  display: inline-block;
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(120,180,235,0.06);
}
.tag.tag-arcane  { border-color: rgba(124,192,255,0.3); color: var(--arcane); background: rgba(124,192,255,0.08); }
.tag.tag-primal  { border-color: rgba(121,216,127,0.3); color: var(--primal); background: rgba(121,216,127,0.08); }
.tag.tag-occult  { border-color: rgba(213,140,255,0.3); color: var(--occult); background: rgba(213,140,255,0.08); }
.tag.tag-divine  { border-color: rgba(242,210,109,0.3); color: var(--divine); background: rgba(242,210,109,0.08); }
.tagline-text {
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
  border-left: 3px solid var(--accent, var(--arcane));
  padding: 6px 16px;
  margin: 16px 0 24px;
  background: rgba(120,180,235,0.04);
  border-radius: 0 6px 6px 0;
}

/* two-column info panels */
.info-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 600px) { .info-cols { grid-template-columns: 1fr; } }

/* Magic wheel display */
.magic-wheel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 0 10px;
}
.magic-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.magic-node .mn-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.magic-node .mn-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 0 12px;
}
.magic-arrow { color: var(--muted); font-size: 1.3rem; align-self: center; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(124,192,255,0.3); }
  50% { box-shadow: 0 0 18px rgba(124,192,255,0.65); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-header { animation: fade-in 0.5s ease both; }
.panel, .link-card, .faction-card { animation: fade-in 0.4s ease both; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .page-header h1 { font-size: 1.6rem; }
  .card-grid, .card-grid-2, .qref-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    background: rgba(7, 16, 28, 0.97);
    border-bottom: 1px solid var(--line);
    padding: 8px 0 12px;
    z-index: 99;
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links.open > li { width: 100%; }
  .nav-links.open > li > a { display: block; padding: 10px 20px; }
  .nav-top-trigger { width: 100%; padding: 10px 20px; border-radius: 0; }

  .nav-dropdown:hover > .l1-menu,
  .nav-dropdown:focus-within > .l1-menu { display: none; }

  .nav-dropdown.open > .l1-menu {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid rgba(120, 180, 235, 0.08);
    background: rgba(124, 192, 255, 0.04);
    border-radius: 0;
    min-width: 0;
    padding: 0;
  }

  .nav-dropdown.open .l1-menu > li > a { padding-left: 36px; }
  .nav-dropdown.open .l1-divider { margin: 2px 0; }
  .nav-dropdown.open .flyout-label { padding: 10px 20px 10px 36px; }

  .has-flyout:hover > .flyout,
  .has-flyout:focus-within > .flyout { display: none; }

  .has-flyout.open > .flyout {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid rgba(120, 180, 235, 0.06);
    background: rgba(124, 192, 255, 0.03);
    border-radius: 0;
    min-width: 0;
    padding: 0;
  }
  .has-flyout.open > .flyout a { padding-left: 52px; }
}

/* ============================================================
   STAR PARTICLE SCRIPT (inline target styles)
   ============================================================ */

/* ============================================================
   WORLD PAGES  (worlds/*.html)
   ============================================================ */
.world-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px) 80px;
}

.world-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
  position: relative;
}
.world-header::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 120px; height: 2px;
  background: var(--accent, var(--arcane));
  box-shadow: 0 0 12px var(--accent, var(--arcane));
}

.world-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent, var(--arcane));
  margin-bottom: 8px;
}
.world-title {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  text-shadow: 0 0 32px rgba(124,192,255,0.2);
  margin-bottom: 6px;
}
.world-subtitle {
  color: var(--muted);
  font-size: 0.97rem;
  margin-bottom: 10px;
}
.world-tagline {
  color: var(--muted);
  font-style: italic;
  font-size: 0.92rem;
  border-left: 3px solid var(--accent, var(--arcane));
  padding: 6px 16px;
  margin: 12px 0 0;
  background: rgba(120,180,235,0.04);
  border-radius: 0 6px 6px 0;
  max-width: 700px;
}

.world-section {
  margin-bottom: 36px;
}

/* section-header used directly as h2 element in world pages */
h2.section-header {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  display: block;
}

.world-note {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 12px;
  border-left: 3px solid rgba(120,180,235,0.18);
  padding-left: 12px;
}

/* World stat blocks (inside .stat-grid) */
.stat-block {
  background: rgba(7,16,28,0.75);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.stat-value.arcane { color: var(--arcane); }
.stat-value.primal { color: var(--primal); }
.stat-value.occult { color: var(--occult); }
.stat-value.divine { color: var(--divine); }
.stat-value.gold   { color: var(--gold); }
.stat-value.red    { color: var(--danger); }

/* Faction list inside world sections */
.faction-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.faction {
  background: rgba(7,16,28,0.75);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--arcane));
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
}
.faction-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}

/* World page bottom nav (prev / next world) */
.world-footer-stats {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  flex: 1;
}
.world-footer-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}
.footer-nav-link {
  font-size: 0.82rem;
  color: var(--arcane);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-nav-link:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 600px) {
  .world-title { font-size: 1.7rem; }
  .world-footer-nav { margin-top: 8px; }
}

/* ============================================================
   ECONOMY PANELS (rendered by economy.js)
   ============================================================ */
.eco-faction-panel,
.eco-world-panel { padding: 4px 0; }

.eco-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 20px;
  margin-bottom: 18px;
}
@media (max-width: 600px) { .eco-stats-grid { grid-template-columns: 1fr; } }

.eco-stat { display: flex; flex-direction: column; gap: 6px; }

.eco-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.eco-bar-wrap { display: flex; align-items: center; gap: 8px; }
.eco-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent, var(--arcane)), rgba(124,192,255,0.35));
  box-shadow: 0 0 6px rgba(124,192,255,0.25);
  transition: width 0.5s ease;
  flex: none;
}
.eco-bar-val { font-size: 0.8rem; color: var(--text); min-width: 18px; }

/* Faction stat categories */
.eco-categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 24px;
  margin-bottom: 20px;
}
@media (max-width: 600px) { .eco-categories-grid { grid-template-columns: repeat(2, 1fr); } }

.eco-category-title {
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--arcane);
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(124,192,255,0.15);
}

.eco-stats-subgrid { display: flex; flex-direction: column; gap: 5px; }

.eco-produces,
.eco-demands,
.eco-monopolies { margin-bottom: 12px; }

.eco-tag {
  display: inline-block;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  text-transform: capitalize;
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(120,180,235,0.05);
  margin: 2px 3px 2px 0;
}
.eco-tag--none { font-style: italic; opacity: 0.6; }

.eco-relationships { margin-top: 16px; }
.eco-relationships h4 {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.eco-relationships ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.eco-relationships li {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(7,16,28,0.5);
  font-size: 0.85rem;
  line-height: 1.55;
}
.eco-relationships li small { color: var(--muted); font-size: 0.8rem; }
.eco-rel--good    { border-left: 3px solid var(--primal)  !important; }
.eco-rel--bad     { border-left: 3px solid var(--danger)  !important; }
.eco-rel--neutral { border-left: 3px solid var(--muted)   !important; }

/* Store price table */
.eco-store-table { margin-bottom: 12px; }
.eco-store-table td.eco-price { color: var(--gold); font-weight: 600; }
.eco-store-table td.eco-unit  { color: var(--muted); font-size: 0.82rem; }
.eco-store-table td.eco-notes { color: var(--muted); font-size: 0.82rem; }

.eco-badge {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.eco-badge--monopoly {
  background: rgba(230,190,110,0.15);
  border: 1px solid rgba(230,190,110,0.4);
  color: var(--gold);
}
.eco-price-note { font-size: 0.78rem; color: var(--muted); font-style: italic; margin-top: 8px; }
.eco-notable    { font-size: 0.88rem; color: var(--muted); font-style: italic; margin-top: 10px; }

/* ============================================================
   SHIP STAT BLOCKS (used by ship-embed.js and quick builder)
   ============================================================ */
.ship-stat-block {
  background: rgba(7,16,28,0.92);
  border: 1px solid rgba(230,190,110,0.25);
  border-top: 3px solid var(--gold);
  border-radius: 8px;
  overflow: hidden;
}
.ssb-header {
  padding: 12px 16px;
  background: rgba(230,190,110,0.07);
  border-bottom: 1px solid rgba(230,190,110,0.15);
}
.ssb-name { font-size: 1.05rem; font-weight: 700; color: var(--gold); letter-spacing: 0.04em; }
.ssb-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.ssb-body { padding: 14px 16px; }
.ssb-row-group { display: flex; flex-direction: column; gap: 6px; }
.ssb-divider { height: 1px; background: rgba(120,180,235,0.1); margin: 10px 0; }
.sb-row { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; font-size: 0.87rem; }
.sb-k { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.07em; text-transform: uppercase; font-weight: 600; }
.sb-v { color: var(--text); font-weight: 600; }
