:root {
  --bg: #0a0e14;
  --surface: #11161f;
  --surface-2: #161c28;
  --surface-3: #1c2433;
  --border: #2a3444;
  --divider: #1f2838;
  --text: #d5dde8;
  --text-muted: #7a8699;
  --text-faint: #4a5568;
  --accent: #00b4d8;
  --accent-dim: #0096b7;
  --accent-glow: rgba(0, 180, 216, 0.15);

  --dmg-em: #4dabf7;
  --dmg-therm: #ff6b6b;
  --dmg-kin: #ced4da;
  --dmg-exp: #ffa94d;

  --tier-short: #ff6b6b;
  --tier-mid: #ffd43b;
  --tier-long: #51cf66;

  --hybrid: #4dabf7;
  --laser: #ff6b6b;
  --projectile: #51cf66;
  --precursor: #ffa94d;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  --font-display: 'Chakra Petch', 'Inter', sans-serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eaeef3;
  --border: #d0d6e0;
  --divider: #e0e5ed;
  --text: #1a2332;
  --text-muted: #5a6478;
  --text-faint: #9aa4b8;
  --accent: #0096b7;
  --accent-dim: #007a98;
  --accent-glow: rgba(0, 150, 183, 0.08);
}

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

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 180, 216, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 180, 216, 0.04), transparent);
  background-attachment: fixed;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] header {
  background: rgba(240, 242, 245, 0.85);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.logo svg {
  flex-shrink: 0;
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.site-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Nav */
.tabs-wrap {
  position: relative;
}

@media (max-width: 640px) {
  .tabs-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg) 85%);
  }
}

nav.tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

nav.tabs::-webkit-scrollbar {
  height: 3px;
}

nav.tabs::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.tab-btn {
  padding: 0.625rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Main */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.tab-content {
  display: none;
  animation: fadeIn 300ms ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section headers */
.section-intro {
  margin-bottom: 2rem;
}

.section-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.section-intro h1 span {
  color: var(--accent);
}

.section-intro p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  max-width: 70ch;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

h2 .badge {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(0, 180, 216, 0.2);
}

h2 .badge.t1 {
  background: rgba(206, 212, 218, 0.1);
  color: var(--dmg-kin);
  border-color: rgba(206, 212, 218, 0.2);
}

h2 .badge.t2 {
  background: rgba(77, 171, 247, 0.1);
  color: var(--dmg-em);
  border-color: rgba(77, 171, 247, 0.2);
}

h2 .badge.shield {
  background: rgba(206, 212, 218, 0.1);
  color: var(--dmg-kin);
  border-color: rgba(206, 212, 218, 0.2);
}

h2 .badge.armor {
  background: rgba(255, 107, 107, 0.1);
  color: var(--dmg-therm);
  border-color: rgba(255, 107, 107, 0.2);
}

h2 .badge.omni {
  background: rgba(255, 169, 77, 0.1);
  color: var(--dmg-exp);
  border-color: rgba(255, 169, 77, 0.2);
}

h2 .badge.hybrid { background: rgba(77, 171, 247, 0.1); color: var(--hybrid); border-color: rgba(77, 171, 247, 0.2); }
h2 .badge.laser { background: rgba(255, 107, 107, 0.1); color: var(--laser); border-color: rgba(255, 107, 107, 0.2); }
h2 .badge.projectile { background: rgba(81, 207, 102, 0.1); color: var(--projectile); border-color: rgba(81, 207, 102, 0.2); }
h2 .badge.precursor { background: rgba(255, 169, 77, 0.1); color: var(--precursor); border-color: rgba(255, 169, 77, 0.2); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8125rem;
}

thead {
  background: var(--surface-2);
}

th {
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th.dmg-col {
  text-align: center;
  min-width: 3rem;
}

th.center {
  text-align: center;
}

td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  white-space: normal;
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface-2);
}

td.name {
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

td.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  min-width: 3.5rem;
}

td.center {
  text-align: center;
}

/* Damage values */
.dmg {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dmg-em { color: var(--dmg-em); }
.dmg-therm { color: var(--dmg-therm); }
.dmg-kin { color: var(--dmg-kin); }
.dmg-exp { color: var(--dmg-exp); }

.dmg-zero {
  color: var(--text-faint);
  opacity: 0.4;
}

.total-dmg {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Damage type pills (turrets) */
.dmg-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.dmg-pill.em { background: rgba(77,171,247,0.1); color: var(--dmg-em); border: 1px solid rgba(77,171,247,0.2); }
.dmg-pill.therm { background: rgba(255,107,107,0.1); color: var(--dmg-therm); border: 1px solid rgba(255,107,107,0.2); }
.dmg-pill.kin { background: rgba(206,212,218,0.1); color: var(--dmg-kin); border: 1px solid rgba(206,212,218,0.2); }
.dmg-pill.exp { background: rgba(255,169,77,0.1); color: var(--dmg-exp); border: 1px solid rgba(255,169,77,0.2); }

/* Yes/No indicators */
.yes { color: #51cf66; font-weight: 600; }
.no { color: var(--text-faint); }
.partial { color: #ffa94d; font-weight: 500; }

/* Priority pills (factions) */
.prio {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.prio-1 { background: rgba(77, 171, 247, 0.12); color: var(--dmg-em); border: 1px solid rgba(77, 171, 247, 0.25); }
.prio-2 { background: rgba(255, 107, 107, 0.12); color: var(--dmg-therm); border: 1px solid rgba(255, 107, 107, 0.25); }
.prio-3 { background: rgba(206, 212, 218, 0.12); color: var(--dmg-kin); border: 1px solid rgba(206, 212, 218, 0.25); }
.prio-4 { background: rgba(255, 169, 77, 0.12); color: var(--dmg-exp); border: 1px solid rgba(255, 169, 77, 0.25); }
.prio-omni { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }

.prio-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: currentColor; }

/* Tier indicators */
.tier {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.tier::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-short::before { background: var(--tier-short); }
.tier-mid::before { background: var(--tier-mid); }
.tier-long::before { background: var(--tier-long); }
.tier-shield::before { background: var(--dmg-kin); }
.tier-armor::before { background: var(--dmg-therm); }
.tier-omni::before { background: var(--dmg-exp); }

/* Modifier styling */
.mod-neg { color: #ff6b6b; }
.mod-pos { color: #51cf66; }
.mod-zero { color: var(--text-faint); }

/* Stat bars (turrets) */
.stat-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-track {
  width: 60px;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.stat-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.stat-fill.low { background: #ff6b6b; width: 25%; }
.stat-fill.med-low { background: #ffa94d; width: 40%; }
.stat-fill.med { background: #4dabf7; width: 60%; }
.stat-fill.med-high { background: #74c0fc; width: 75%; }
.stat-fill.high { background: #51cf66; width: 90%; }
.stat-fill.max { background: #51cf66; width: 100%; }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Comparison cards (turrets) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.turret-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent);
  transition: border-color 180ms;
}

.turret-card.hybrid { border-left-color: var(--hybrid); }
.turret-card.laser { border-left-color: var(--laser); }
.turret-card.projectile { border-left-color: var(--projectile); }
.turret-card.precursor { border-left-color: var(--precursor); }

.turret-card:hover { border-color: var(--accent); }

.turret-card .tc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.turret-card .tc-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
}

.turret-card .tc-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.turret-card .tc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  padding: 0.3125rem 0;
}

.turret-card .tc-row + .tc-row { border-top: 1px solid var(--divider); }

.turret-card .tc-label {
  color: var(--text-muted);
  font-weight: 500;
}

.turret-card .tc-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.turret-card .tc-desc {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--divider);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Quick-ref cards (factions) */
.quickref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.875rem;
  margin-bottom: 2rem;
}

.quickref-card {
  padding: 1rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 180ms;
}

.quickref-card:hover {
  border-color: var(--accent);
}

.quickref-card .qr-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.quickref-card .qr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.quickref-card .qr-row + .qr-row {
  border-top: 1px solid var(--divider);
}

.quickref-card .qr-label {
  color: var(--text-muted);
}

/* Color utilities (inline style migration) */
.color-em { color: var(--dmg-em); }
.color-therm { color: var(--dmg-therm); }
.color-kin { color: var(--dmg-kin); }
.color-exp { color: var(--dmg-exp); }
.color-hybrid { color: var(--hybrid); }
.color-laser { color: var(--laser); }
.color-projectile { color: var(--projectile); }
.color-precursor { color: var(--precursor); }

.dot-em { background: var(--dmg-em); }
.dot-therm { background: var(--dmg-therm); }
.dot-kin { background: var(--dmg-kin); }
.dot-exp { background: var(--dmg-exp); }
.dot-hybrid { background: var(--hybrid); }
.dot-laser { background: var(--laser); }
.dot-projectile { background: var(--projectile); }
.dot-precursor { background: var(--precursor); }

.table-note {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Notes */
.notes {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.notes strong {
  color: var(--text);
}

.notes a {
  color: var(--accent);
  text-decoration: none;
}

.notes a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--divider);
  margin-top: 2rem;
}

footer h3 {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
}

footer ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color 180ms;
}

footer a:hover {
  color: var(--accent);
}

footer .disclaimer {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  max-width: 70ch;
}

/* Responsive */
@media (max-width: 768px) {
  main {
    padding: 1.25rem 0.75rem 3rem;
  }

  .header-inner {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
  }

  .site-link span.site-link-text {
    display: none;
  }

  nav.tabs {
    padding: 0 0.75rem;
  }

  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  th, td {
    padding: 0.4375rem 0.5rem;
    font-size: 0.75rem;
  }

  .section-intro h1 {
    font-size: 1.375rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
