/* ==========================================================================
   LFU TRACKER · TACTICAL INTELLIGENCE COMMAND SYSTEM
   Design System & Unified Stylesheet
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Tactical Void Color Palette */
  --bg: #07090e;
  --bg-subtle: #0d1017;
  --bg-card: #121620;
  --bg-card-elev: #171d2a;
  --bg-card-hover: #1c2333;
  --bg-glass: rgba(13, 16, 23, 0.82);
  --bg-glass-card: rgba(18, 22, 32, 0.75);

  /* Borders & Grid */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);
  --border-hi: rgba(255, 255, 255, 0.22);
  --border-glow: rgba(255, 122, 24, 0.35);

  /* Typography Colors */
  --text: #f3f5f9;
  --text-dim: #9ba4b5;
  --text-faint: #636d82;

  /* Tactical Accent: High-Octane Amber / Copper */
  --hazard: #ff7a18;
  --hazard-hover: #ff9438;
  --hazard-dim: rgba(255, 122, 24, 0.14);
  --hazard-text: #ffaa5e;
  --hazard-glow: rgba(255, 122, 24, 0.28);

  /* Status Indicators */
  --good: #10b981;
  --good-dim: rgba(16, 185, 129, 0.15);
  --good-glow: rgba(16, 185, 129, 0.35);
  --danger: #f43f5e;
  --danger-dim: rgba(244, 63, 94, 0.15);
  --danger-glow: rgba(244, 63, 94, 0.35);
  --cyan: #38bdf8;
  --cyan-dim: rgba(56, 189, 248, 0.15);

  /* Geometry & Rhythm */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography Stacks */
  --display: "Barlow Condensed", "Inter", -apple-system, sans-serif;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;

  /* Layout Constants */
  --header-h: 72px;
  --wrap-max: 1380px;

  /* Transitions */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  overflow-y: scroll;
  scrollbar-gutter: stable;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(255, 122, 24, 0.08), transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 20%, rgba(56, 189, 248, 0.04), transparent 60%),
    linear-gradient(to bottom, transparent, rgba(7, 9, 14, 0.8));
  color: var(--text);
  font: 400 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-subtle);
}
::-webkit-scrollbar-thumb {
  background: #252b38;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a4356;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

button, input, select {
  font: inherit;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

svg.icon-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--hazard);
  outline-offset: 3px;
}

::selection {
  background: var(--hazard);
  color: #07090e;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 20px;
  z-index: 100;
  padding: 10px 18px;
  background: var(--hazard);
  color: #07090e;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease-spring);
}
.skip-link:focus {
  top: 14px;
}

/* ==========================================================================
   Header & Command Navigation (Unified Glassmorphism Shell)
   ========================================================================== */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  background: rgba(8, 11, 17, 0.88);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.45);
}

.header-inner {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 28px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Combined Sidebar / Nav bar elements */
.sidebar {
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
}

.side-brand small {
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--hazard);
  margin-top: -2px;
  text-transform: uppercase;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: none;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.side-brand:hover .brand-logo {
  transform: translateY(-1px) scale(1.04);
  filter: drop-shadow(0 0 10px rgba(30, 144, 255, 0.55));
}

.nav-label {
  display: none;
}

.sidebar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar nav a[aria-current] {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(255, 122, 24, 0.22), rgba(255, 122, 24, 0.1));
  border: 1px solid rgba(255, 122, 24, 0.45);
  box-shadow: 0 2px 12px rgba(255, 122, 24, 0.15);
}

.sidebar nav a[aria-current] svg {
  color: var(--hazard);
}

/* Search and Topbar right group */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  min-width: 0;
}

.breadcrumb {
  display: none; /* Replaced by sleek active nav pill state */
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  transition: width 0.25s var(--ease-spring);
}

.search:focus-within {
  width: 340px;
}

.search svg {
  position: absolute;
  left: 13px;
  color: var(--text-faint);
  pointer-events: none;
  transition: color 0.15s ease;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 8px 14px 8px 38px;
  background: rgba(18, 22, 32, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s var(--ease-spring);
}

.search input:hover {
  border-color: var(--border-hi);
  background: rgba(24, 29, 42, 0.95);
}

.search input:focus {
  outline: none;
  border-color: var(--hazard);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.15), 0 4px 16px rgba(0, 0, 0, 0.3);
  background: #141924;
}

.search input:focus + svg,
.search:focus-within svg {
  color: var(--hazard);
}

.search input::placeholder {
  color: var(--text-faint);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 11px var(--mono);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.topbar-meta::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: pulse-dot 2.5s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.data-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  background: linear-gradient(90deg, rgba(255, 122, 24, 0.08), rgba(255, 122, 24, 0.14), rgba(255, 122, 24, 0.08));
  border-top: 1px solid rgba(255, 122, 24, 0.2);
  color: var(--hazard-text);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.wrap {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: calc(var(--header-h) + 28px) 28px 72px;
}

#app {
  margin-top: 0; /* Dynamic sync handled cleanly via CSS var */
}

/* Status dot in headings */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  background: var(--hazard);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--hazard);
  vertical-align: middle;
}

/* ==========================================================================
   Hero Section · Tactical Briefing & Interactive Radar Scope
   ========================================================================== */
.overview-heading {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 280px;
  padding: 42px 48px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 122, 24, 0.25);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 82% 50%, rgba(255, 122, 24, 0.12), transparent 50%),
    linear-gradient(135deg, rgba(18, 22, 32, 0.95) 0%, rgba(11, 14, 21, 0.98) 70%, rgba(25, 16, 10, 0.9) 100%);
  box-shadow:
    0 0 0 1px rgba(255, 122, 24, 0.15),
    0 16px 40px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 36px;
}

.overview-heading::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.6;
}

.overview-heading > div:first-child {
  position: relative;
  z-index: 2;
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--hazard-text);
  font: 600 11px/1.5 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}

.overview-heading h2 {
  margin: 0;
  font: 700 clamp(32px, 3.8vw, 54px)/1.08 var(--display);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: #ffffff;
}

.overview-heading h2 span {
  background: linear-gradient(135deg, #ffffff 30%, var(--hazard-text) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overview-heading .intro {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.7;
  margin: 14px 0 0;
}

.hero-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 28px;
  flex-wrap: wrap;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ff8c2b, #e05e00);
  color: #07090e;
  font: 700 13px var(--font);
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 18px rgba(255, 122, 24, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.2s var(--ease-spring);
}

.primary-action:hover {
  background: linear-gradient(135deg, #ffa048, #ff6c0a);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255, 122, 24, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 600 13px var(--font);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.secondary-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

/* Radar Scope Widget */
.hero-scope {
  position: relative;
  width: 260px;
  height: 260px;
  flex-shrink: 0;
  border-radius: 50%;
  background: url("hero-radar.png") center / cover no-repeat;
  border: 1px solid rgba(255, 122, 24, 0.2);
  box-shadow: inset 0 0 30px rgba(255, 122, 24, 0.12), 0 0 20px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

/* Rotating radar sweep line */
.hero-scope::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255, 122, 24, 0.35) 0deg, rgba(255, 122, 24, 0) 60deg, transparent 60deg);
  animation: radar-sweep 4s linear infinite;
  pointer-events: none;
}

@keyframes radar-sweep {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hero-radar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.scope-label, .scope-caption {
  margin: 0;
  text-align: center;
  color: var(--hazard-text);
  font: 600 12px var(--mono);
  letter-spacing: 0.16em;
}

.scope-label {
  margin-top: 16px;
}

.scope-caption {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 11px;
}

/* ==========================================================================
   Telemetry Stat Cards
   ========================================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.stat:first-child::before {
  background: linear-gradient(90deg, var(--hazard), transparent);
}

.stat:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 122, 24, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 122, 24, 0.15);
}

.stat > div {
  min-width: 0;
}

.stat svg {
  color: var(--hazard-text);
  width: 22px;
  height: 22px;
  padding: 11px;
  box-sizing: content-box;
  background: rgba(255, 122, 24, 0.1);
  border: 1px solid rgba(255, 122, 24, 0.25);
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: transform 0.2s var(--ease-spring);
}

.stat:hover svg {
  transform: scale(1.08);
  border-color: var(--hazard);
}

.stat .label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat .value {
  font: 700 clamp(26px, 2.4vw, 34px)/1.1 var(--mono);
  letter-spacing: -0.03em;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Section Headers
   ========================================================================== */
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 40px 0 20px;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.section-heading .eyebrow {
  margin-bottom: 4px;
}

.section-title {
  margin: 0;
  font: 700 24px/1.2 var(--display);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title svg {
  color: var(--hazard);
}

.section-caption {
  color: var(--text-faint);
  font: 500 12px var(--mono);
  letter-spacing: 0.05em;
}

.count-badge {
  font: 600 11px var(--mono);
  background: rgba(255, 122, 24, 0.12);
  border: 1px solid rgba(255, 122, 24, 0.35);
  color: var(--hazard-text);
  border-radius: 999px;
  padding: 3px 9px;
  margin-left: 8px;
}

/* ==========================================================================
   Leaderboards · Podium Rank Styling
   ========================================================================== */
.leaderboards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.board {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.board-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  font: 700 16px var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
}

.board-title svg {
  color: var(--hazard);
}

.board-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  text-decoration: none;
  transition: all 0.18s ease;
  min-height: 84px;
}

.board-row:first-of-type {
  border-top: 0;
}

.board-row:hover {
  background: rgba(255, 122, 24, 0.06);
  border-color: rgba(255, 122, 24, 0.25);
}

.board-row > div {
  flex: 1;
  min-width: 0;
}

.board-rank {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font: 700 13px var(--mono);
}

.board-rank.top1 {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 122, 24, 0.15));
  border-color: rgba(255, 215, 0, 0.5);
  color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

.board-rank.top2 {
  background: linear-gradient(135deg, rgba(226, 232, 240, 0.2), rgba(148, 163, 184, 0.1));
  border-color: rgba(226, 232, 240, 0.45);
  color: #f1f5f9;
}

.board-rank.top3 {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(180, 83, 9, 0.1));
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.board-name {
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
  overflow-wrap: anywhere;
}

.board-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.board-value {
  margin-left: auto;
  font: 700 15px var(--mono);
  color: var(--hazard-text);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   Alliance Directory & Cards
   ========================================================================== */
.directory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.directory-toolbar label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select {
  background: #0f131c;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 30px 8px 12px;
  font: 500 12.5px var(--font);
  min-height: 38px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ff7a18' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.15s ease;
}

select:hover {
  border-color: var(--border-hi);
  background-color: #151a26;
}

select:focus-visible {
  outline: 2px solid var(--hazard);
}

#directoryCount {
  margin-left: auto;
  font: 600 12px var(--mono);
  color: var(--hazard-text);
  letter-spacing: 0.02em;
}

.view-switch {
  display: flex;
  background: #0f131c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.view-switch button {
  display: grid;
  place-items: center;
  border: 0;
  width: 32px;
  height: 30px;
  background: transparent;
  color: var(--text-faint);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.view-switch button[aria-pressed="true"] {
  color: var(--hazard);
  background: rgba(255, 122, 24, 0.18);
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: 22px;
  margin-bottom: 40px;
}

/* Alliance Card (Interactive Glassmorphic Unit) */
.a-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 22px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  text-decoration: none;
  transition: transform 0.22s var(--ease-spring), border-color 0.22s ease, box-shadow 0.22s ease;
  overflow: hidden;
}

.a-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.a-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 122, 24, 0.5);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55), 0 0 20px rgba(255, 122, 24, 0.15);
}

.a-card.rank-1 {
  background: linear-gradient(145deg, rgba(38, 24, 12, 0.95), var(--bg-card) 75%);
  border-color: rgba(255, 122, 24, 0.45);
}

.a-card.rank-1::before {
  background: linear-gradient(90deg, var(--hazard), transparent);
}

.a-card .rank-tag {
  position: absolute;
  top: 20px;
  right: 20px;
  font: 700 11px var(--mono);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.a-card .rank-tag.top {
  color: var(--hazard-text);
  background: rgba(255, 122, 24, 0.12);
  border-color: rgba(255, 122, 24, 0.35);
}

.a-card .head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-right: 48px;
}

.abbr {
  background: rgba(255, 122, 24, 0.14);
  border: 1px solid rgba(255, 122, 24, 0.35);
  color: var(--hazard-text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font: 700 12px var(--mono);
  letter-spacing: 0.04em;
}

.a-card .lvl {
  font: 600 11px var(--mono);
  color: var(--text-faint);
}

.a-card .name {
  flex: 1 1 100%;
  order: 3;
  margin-top: 4px;
  font: 700 20px/1.2 var(--display);
  letter-spacing: 0.01em;
  color: #ffffff;
  overflow-wrap: anywhere;
}

.power-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.power-row .num {
  font: 700 24px/1 var(--mono);
  color: #ffffff;
  letter-spacing: -0.03em;
}

.power-row .lbl {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}

.power-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.power-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff7a18, #ffaa5e);
  border-radius: inherit;
  box-shadow: 0 0 8px rgba(255, 122, 24, 0.5);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
}

.meta-row b {
  color: #ffffff;
  font-weight: 600;
}

canvas.spark {
  width: 100%;
  height: 32px;
  display: block;
}

.rank-change {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font: 600 11px var(--mono);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.rank-change.up {
  color: var(--good);
  background: var(--good-dim);
  border-color: rgba(16, 185, 129, 0.3);
}

.rank-change.down {
  color: var(--danger);
  background: var(--danger-dim);
  border-color: rgba(244, 63, 94, 0.3);
}

.rank-change.steady {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
}

.movement-detail {
  color: var(--text-faint);
  font-size: 11px;
}

.card-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: auto -22px 0;
  padding: 12px 22px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.18s ease;
}

.card-link > span {
  font-size: 14px;
  color: var(--hazard);
  transition: transform 0.18s ease;
}

.a-card:hover .card-link {
  background: rgba(255, 122, 24, 0.08);
  color: var(--hazard-text);
}

.a-card:hover .card-link > span {
  transform: translate(2px, -2px);
}

/* List View Variant */
.list-view {
  grid-template-columns: 1fr;
}

.list-view .a-card {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 120px;
  align-items: center;
  gap: 20px;
  padding: 18px 24px;
}

.list-view .a-card .rank-tag {
  position: static;
  order: -1;
  width: fit-content;
}

.list-view .a-card .head {
  padding: 0;
}

.list-view .a-card .name {
  margin-top: 0;
}

.list-view .card-link {
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent !important;
}

/* ==========================================================================
   Detail View · Alliance Dossier
   ========================================================================== */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 36px;
  background:
    radial-gradient(ellipse at 90% 10%, rgba(255, 122, 24, 0.12), transparent 60%),
    linear-gradient(135deg, rgba(18, 22, 32, 0.95), rgba(11, 14, 21, 0.98));
  border: 1px solid rgba(255, 122, 24, 0.3);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  margin-bottom: 28px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-dim);
  font: 600 13px var(--font);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--hazard);
  color: var(--hazard-text);
  transform: translateX(-2px);
}

.detail-title {
  flex: 1;
  min-width: 0;
}

.detail-title h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 8px;
  font: 700 clamp(28px, 3.5vw, 42px)/1.1 var(--display);
  letter-spacing: 0.01em;
  color: #ffffff;
  overflow-wrap: anywhere;
}

.detail-title .sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 6px;
}

.player-history-note {
  color: var(--text-faint);
  font-size: 12px;
  margin: 4px 0 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 12.5px;
}

.chip b {
  color: var(--hazard-text);
  font: 600 13.5px var(--mono);
  margin-left: 6px;
}

/* Trend Box */
.trend-box {
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  margin-bottom: 32px;
}

.trend-box .label {
  color: var(--text-dim);
  font: 600 12px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

canvas#trendChart {
  display: block;
  width: 100%;
  height: 180px;
}

/* Roster Filter & Table */
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.filter {
  min-height: 42px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  width: 100%;
  max-width: 320px;
  transition: all 0.15s ease;
}

.filter:hover {
  border-color: var(--border-hi);
}

.filter:focus {
  outline: none;
  border-color: var(--hazard);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.15);
}

table {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

th, td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
  overflow-wrap: anywhere;
}

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font: 600 11.5px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

th:hover, th.sorted {
  color: var(--hazard-text);
}

th.sorted::after { content: " ↓"; }
th[data-asc="true"]::after { content: " ↑"; }

tr:hover td {
  background: rgba(255, 122, 24, 0.03);
}

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

.rank-cell {
  width: 56px;
  text-align: center !important;
  font: 600 13px var(--mono);
  color: var(--text-faint);
}

.name-cell {
  display: flex;
  align-items: center;
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin-right: 10px;
  border-radius: 50%;
}

.dot.on {
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
}

.dot.off {
  background: var(--text-faint);
  opacity: 0.4;
}

.power-cell {
  text-align: right !important;
  min-width: 180px;
}

.roster-power-num {
  font: 600 15px var(--mono);
  color: #ffffff;
  letter-spacing: -0.02em;
}

.roster-power-bar {
  height: 4px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.roster-power-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff7a18, #ffaa5e);
  border-radius: inherit;
}

.player-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font: 600 11px var(--mono);
}

.player-change.up { color: var(--good); }
.player-change.down { color: var(--danger); }
.player-change.steady { color: var(--text-faint); }
.player-change small { font-size: 9px; opacity: 0.7; margin-left: 4px; }

/* ==========================================================================
   Full Database Intelligence Table (`#all-alliances` & `#all-players`)
   ========================================================================== */
.database-heading {
  padding: 10px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.database-heading h1 {
  margin: 8px 0;
  font: 700 clamp(36px, 5vw, 64px)/1.05 var(--display);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: #ffffff;
}

.database-heading h1 > span:first-child {
  color: var(--hazard);
}

.database-dot {
  color: var(--hazard-text);
}

.database-heading p:last-child,
.database-footnote {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 800px;
  margin: 6px 0 0;
}

.database-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 18px;
}

.database-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 200px;
}

.database-filter span {
  font: 600 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.database-filters .filter {
  max-width: none;
}

.clear-filters {
  align-self: flex-end;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font: 600 13px var(--font);
  cursor: pointer;
}

.clear-filters:hover {
  border-color: var(--hazard);
  color: var(--hazard-text);
}

.clear-filters[hidden] {
  display: none;
}

.export-button:disabled,
.export-button:disabled:hover {
  background: linear-gradient(135deg, #ff8c2b, #e05e00);
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.database-toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  flex-wrap: wrap;
}

#databaseCount {
  font: 700 13px var(--mono);
  color: var(--hazard-text);
}

.database-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 250px;
  min-height: 44px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 10px 20px;
  background: linear-gradient(135deg, #ff8c2b, #e05e00);
  color: #07090e;
  font: 700 13px var(--font);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 122, 24, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.export-button:hover:not(:disabled),
.export-button:focus-visible {
  background: linear-gradient(135deg, #ffd09a, #ff942e);
  border-color: #ffe0bd;
  transform: translateY(-3px) scale(1.035);
  box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.22), 0 9px 28px rgba(255, 122, 24, 0.55);
}

.export-button:active:not(:disabled) {
  background: #d95800;
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 1px 5px rgba(255, 122, 24, 0.25);
  transition-duration: 0s;
}

.export-button.download-started,
.export-button.download-started:hover {
  background: linear-gradient(135deg, #6ee7b7, #10b981);
  border-color: #a7f3d0;
  color: #07120e;
  transform: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 5px 18px rgba(16, 185, 129, 0.32);
}

.export-button.download-error,
.export-button.download-error:hover {
  background: linear-gradient(135deg, #fda4af, #f43f5e);
  border-color: #fecdd3;
  color: #25080c;
  transform: none;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.database-scroll {
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.database-mobile-hint {
  display: none;
}

.database-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
  color: var(--text-dim);
  font: 600 12px var(--mono);
}

.database-pagination > div {
  display: flex;
  gap: 8px;
}

.database-pagination button {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-dim);
  font: 600 12px var(--font);
  cursor: pointer;
}

.database-pagination button:hover:not(:disabled) {
  border-color: var(--hazard);
  color: var(--hazard-text);
}

.database-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.database-table {
  display: table;
  width: 100%;
  table-layout: fixed;
  border: 0;
  border-radius: 0;
  margin: 0;
}

.database-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #151a26;
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.database-table th button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: 0;
  color: var(--text-dim);
  font: 600 11.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s ease;
}

.database-table th button:hover {
  color: #ffffff;
}

.database-table th[aria-sort]:not([aria-sort="none"]) button {
  color: var(--hazard-text);
}

.database-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13.5px;
  text-align: center;
}

.database-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.database-table tbody tr:hover {
  background: rgba(255, 122, 24, 0.05);
}

.database-table td.numeric {
  font: 600 13px var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.database-table .power-peak {
  color: var(--text-faint);
  font-weight: 400;
}

.database-table a {
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
}

.database-table a:hover {
  color: var(--hazard-text);
  text-decoration: underline;
}

/* ==========================================================================
   Site Footer & Back to Top
   ========================================================================== */
.site-footer {
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--text-faint);
  font-size: 12px;
}

.site-footer a {
  color: var(--hazard-text);
}

.site-footer a:hover {
  text-decoration: underline;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(135deg, #ff8c2b, #e05e00);
  color: #07090e;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 122, 24, 0.35);
  transition: all 0.2s var(--ease-spring);
}

.back-to-top:hover {
  transform: translateY(-3px) scale(1.05);
  background: linear-gradient(135deg, #ffa048, #ff6c0a);
}

/* Utility / Status */
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 24px;
  font-size: 15px;
}

.hidden {
  display: none !important;
}

.error {
  padding: 16px 20px;
  margin-bottom: 24px;
  background: var(--danger-dim);
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: var(--radius);
  color: #fecdd3;
  font-size: 14px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1100px) {
  .header-inner {
    padding: 0 20px;
  }
  .sidebar nav a {
    padding: 7px 10px;
    font-size: 12px;
  }
  .search {
    width: 220px;
  }
  .search:focus-within {
    width: 260px;
  }
  .wrap {
    padding: calc(var(--header-h) + 20px) 20px 48px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .site-header {
    position: sticky;
  }
  .wrap {
    padding-top: 28px;
  }
  .header-inner {
    min-height: unset;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .sidebar {
    width: 100%;
    justify-content: space-between;
  }
  .sidebar nav {
    overflow-x: auto;
    width: 100%;
    justify-content: flex-start;
  }
  .topbar {
    width: 100%;
    justify-content: space-between;
  }
  .search {
    width: 100%;
    max-width: none;
  }
  .search:focus-within {
    width: 100%;
  }
  .overview-heading {
    flex-direction: column;
    padding: 32px 24px;
    align-items: flex-start;
  }
  .hero-radar {
    align-self: center;
  }
  .hero-scope {
    width: 220px;
    height: 220px;
  }
  .leaderboards {
    grid-template-columns: 1fr;
  }
  .detail-header {
    flex-direction: column;
    padding: 24px;
  }
  .list-view .a-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .database-mobile-hint {
    display: block;
    margin: 0 0 10px;
    color: var(--text-dim);
    font-size: 12px;
  }
  .database-table {
    min-width: 850px;
  }
}

@media (max-width: 540px) {
  .stats {
    grid-template-columns: 1fr;
  }
  .stat {
    padding: 18px 20px;
  }
  .stat .value {
    font-size: 26px;
  }
  .directory-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .directory-toolbar label,
  .directory-toolbar select {
    width: 100%;
  }
  #directoryCount {
    margin-left: 0;
  }
  .site-footer {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .a-card:hover, .stat:hover, .primary-action:hover {
    transform: none !important;
  }
}

/* Password gate (vault.js) */
.login-card {
  max-width: 380px;
  margin: 12vh auto 0;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.login-card > .icon { align-self: center; width: 28px; height: 28px; color: var(--hazard); }
.login-card h2 { margin: 0; font-size: 1.15rem; color: var(--text); }
.login-card p { margin: 0; color: var(--text-dim); }
.login-card input[type="password"] {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}
.login-card input[type="password"]:focus { outline: 2px solid var(--hazard); outline-offset: 1px; }
.login-remember { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--text-dim); font-size: 0.9rem; }
.login-card button { justify-content: center; border: 0; cursor: pointer; }
.login-card button:disabled { opacity: 0.6; cursor: progress; }
.login-error { min-height: 1.2em; color: var(--danger) !important; font-size: 0.9rem; }
.lock-button { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
