:root {
  color-scheme: dark;
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --accent: #8b5cf6;
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.6);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --border: rgba(255, 255, 255, 0.05);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 16px 36px rgba(2, 6, 23, 0.34);
  --radius: 16px;
  --chart-cpu: #7c3aed;
  --chart-ram: #8b5cf6;
  --chart-grid: rgba(148, 163, 184, 0.18);
  --chart-ticks: #94a3b8;
  --chart-tooltip-bg: #111827;
  --chart-tooltip-border: rgba(148, 163, 184, 0.2);
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 20px;
  --space-xl: 24px;
}

body.light {
  color-scheme: light;
  --bg-dark: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.82);
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border: rgba(17, 24, 39, 0.08);
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  --chart-grid: rgba(107, 114, 128, 0.18);
  --chart-ticks: #4b5563;
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-border: rgba(107, 114, 128, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 50% -10%, rgba(139, 92, 246, 0.14), transparent 42%),
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.2), transparent 34%),
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.16), transparent 28%),
    var(--bg-dark);
}

.app-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: min(100vw - 12px, 1440px);
  margin: 0 auto;
  padding: var(--space-sm) 0 var(--space-lg);
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  top: 8px;
  bottom: 8px;
  left: 8px;
  width: min(280px, calc(100vw - 26px));
  min-height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.88);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  z-index: 20;
  transform: translateX(-120%);
  transition: transform 0.25s ease;
}

body.sidebar-open .sidebar {
  transform: translateX(0);
}

body.light .sidebar {
  background: rgba(248, 250, 252, 0.95);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 8px;
}

.sidebar-brand h2 {
  margin: 0;
  font-size: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-link__icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

.sidebar-link:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.34);
  color: var(--text-primary);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.18);
}

.sidebar-link.is-active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.4);
  color: #f5f3ff;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.22);
}

.sidebar-link.is-active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary-light);
}

.sidebar-footer {
  margin-top: auto;
  padding: 6px 4px 0;
}

.sidebar-footer .theme-toggle {
  width: 100%;
  justify-content: center;
}

.sidebar-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  opacity: 0;
  pointer-events: none;
  border: 0;
  z-index: 10;
  transition: opacity 0.2s ease;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.app-shell {
  width: 100%;
  margin: 0;
  padding: 0 0 16px;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.topbar-copy h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.4vw, 2.2rem);
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(139, 92, 246, 0.1);
  color: var(--text-primary);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.card,
.header-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease, background-color 0.25s ease;
}

.card:hover,
.header-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
  transform: translateY(-2px);
}

.header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-lg);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-brand:hover .brand-mark {
  transform: scale(1.04);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.36);
}

.eyebrow,
.stat-kicker {
  margin: 0 0 4px;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  font-weight: 700;
}

.header-card h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3.8vw, 2.5rem);
  color: var(--text-primary);
}

.header-copy {
  margin: 6px 0 0;
  color: var(--text-secondary);
  line-height: 1.45;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(139, 92, 246, 0.08);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.14);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.22);
}

:where(button, [role="button"], a, .sidebar-link, .leaderboard-row, .leaderboard-mini-row, .player-card) {
  cursor: pointer;
}

.theme-toggle__icon {
  width: 1rem;
  text-align: center;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.35);
  font-weight: 600;
}

.connection-pill__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--primary-light);
}

.connection-pill[data-state="online"] .connection-pill__dot {
  background: var(--success);
  animation: live-pulse 1.5s infinite;
}

.connection-pill[data-state="offline"] .connection-pill__dot,
.connection-pill[data-state="error"] .connection-pill__dot {
  background: var(--danger);
}

.connection-pill[data-state="online"] {
  color: #22c55e;
  text-shadow: 0 0 6px currentColor;
}

.connection-pill[data-state="offline"],
.connection-pill[data-state="error"] {
  color: #ef4444;
  text-shadow: 0 0 6px currentColor;
}

.online {
  color: #22c55e;
  text-shadow: 0 0 6px currentColor;
}

.offline {
  color: #ef4444;
  text-shadow: 0 0 6px currentColor;
}

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.dashboard-card {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
}

.chart-card .card-head {
  align-items: center;
}

.chart-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-title,
.compact-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.7;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  background: rgba(139, 92, 246, 0.14);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge[data-state="online"] {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

.status-badge[data-state="offline"] {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
}

.metric-block {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.22);
}

.metric-label {
  color: var(--text-secondary);
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.metric-value {
  font-size: clamp(1.72rem, 7vw, 2.45rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--accent);
  will-change: contents;
}

.stats-inline-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.info-chip {
  min-height: 76px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.info-chip span {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.value-label {
  font-size: 12px;
  opacity: 0.72;
}

.info-chip strong {
  color: var(--text-primary);
  font-size: 1rem;
  white-space: nowrap;

.value-label {
  font-size: 12px;
  opacity: 0.72;
}

.value-label {
  font-size: 12px;
  opacity: 0.72;
}
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.cpu-value,
.ram-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.05;
  transition: color 0.3s ease;
}

.cpu-value,
.ram-value {
  transition: color 0.3s ease;
}

.cpu-value,
.ram-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.05;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
}

.status-line {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  opacity: 0.6;
}

.settings-anchor {
  width: 1px;
  height: 1px;
  opacity: 0;
}

.players-card {
  min-width: 0;
}

.stat-count {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.player-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.24);
  min-height: 60px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
  will-change: transform, opacity;
}

.player-card--entering {
  animation: player-fade-in 0.18s ease;
}

.player-card--leaving {
  opacity: 0;
  transform: translateY(6px);
}

.player-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.player-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.45);
  background: rgba(15, 23, 42, 0.35);
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.player-avatar.loaded,
.mini-avatar.loaded,
.leaderboard-avatar.loaded {
  opacity: 1;
}

.player-identity {
  min-width: 0;
}

.player-name {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.player-status-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.player-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
}

.player-status-dot[data-state="afk"] {
  background: var(--warning);
}

.player-status-dot[data-state="offline"] {
  background: var(--danger);
}

.player-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-extra {
  display: none;
}

.player-card.is-expanded .player-extra {
  display: flex;
}

.player-expand {
  margin-left: auto;
  min-height: 30px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.32);
  background: rgba(139, 92, 246, 0.16);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  background: rgba(139, 92, 246, 0.08);
  color: var(--text-primary);
  font-size: 0.78rem;
  white-space: nowrap;
}

.empty-state {
  min-height: 180px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.2);
}

.chart-card {
  min-width: 0;
}

.chart-note {
  color: var(--text-secondary);
  font-size: 12px;
  opacity: 0.6;
}

.health-overall {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.24);
  font-size: 12px;
  font-weight: 700;
}

.health-overall__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary-light);
}

.health-overall[data-state="excellent"],
.health-overall[data-state="good"] {
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.35);
}

.health-overall[data-state="excellent"] .health-overall__dot,
.health-overall[data-state="good"] .health-overall__dot {
  background: #22c55e;
}

.health-overall[data-state="warning"] {
  color: #eab308;
  border-color: rgba(234, 179, 8, 0.35);
}

.health-overall[data-state="warning"] .health-overall__dot {
  background: #eab308;
}

.health-overall[data-state="critical"] {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}

.health-overall[data-state="critical"] .health-overall__dot {
  background: #ef4444;
}

.health-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.health-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.health-line--primary {
  padding: 8px 10px;
  border-left: 3px solid rgba(139, 92, 246, 0.65);
  border-radius: 0 10px 10px 0;
  background: rgba(139, 92, 246, 0.1);
}

.health-line__icon {
  width: 14px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
}

.health-line__text {
  font-size: 12px;
  color: var(--text-primary);
  opacity: 0.92;
}

.health-line[data-state="excellent"],
.health-line[data-state="good"] {
  color: #22c55e;
}

.health-line[data-state="excellent"] .health-line__icon,
.health-line[data-state="good"] .health-line__icon {
  color: #22c55e;
}

.health-line[data-state="warning"] {
  color: #eab308;
}

.health-line[data-state="warning"] .health-line__icon {
  color: #eab308;
}

.health-line[data-state="critical"] {
  color: #ef4444;
}

.health-line[data-state="critical"] .health-line__icon {
  color: #ef4444;
}

.health-line--primary[data-state="excellent"],
.health-line--primary[data-state="good"] {
  border-left-color: rgba(34, 197, 94, 0.8);
  background: rgba(34, 197, 94, 0.09);
}

.health-line--primary[data-state="warning"] {
  border-left-color: rgba(234, 179, 8, 0.8);
  background: rgba(234, 179, 8, 0.1);
}

.health-line--primary[data-state="critical"] {
  border-left-color: rgba(239, 68, 68, 0.8);
  background: rgba(239, 68, 68, 0.1);
}

.health-overall__dot {
  animation: status-pulse 1.8s infinite;
}

.health-line__text.is-updating,
.health-subtitle.is-updating {
  animation: text-fade-in 0.25s ease;
}

@keyframes text-fade-in {
  from {
    opacity: 0.55;
    transform: translateY(1px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes status-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.health-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.22);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.health-item__icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.health-item__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.health-item__label {
  font-size: 12px;
  opacity: 0.72;
}

.health-item__value {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
}

.health-item__meta {
  font-size: 12px;
  opacity: 0.65;
}

.health-item[data-state="good"] {
  border-color: rgba(34, 197, 94, 0.32);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.12);
}

.health-item[data-state="warning"] {
  border-color: rgba(234, 179, 8, 0.32);
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.12);
}

.health-item[data-state="critical"] {
  border-color: rgba(239, 68, 68, 0.34);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.14);
}

.chart-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  align-self: center;
}

.chart-expand {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.34);
  background: rgba(139, 92, 246, 0.14);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.chart-expand:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.theme-toggle:hover,
.player-expand:hover {
  background: rgba(139, 92, 246, 0.25);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

#usageChart {
  width: 100% !important;
  height: 100% !important;
}

.dashboard-leaderboards {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.dashboard-card,
.leaderboard-mini-card,
.leaderboard-card,
.analytics-graph-card {
  animation: panel-fade-in 0.28s ease;
}

/* Analytics page */
.analytics-shell {
  min-height: calc(100dvh - 24px);
}

.analytics-topbar {
  margin-bottom: 12px;
}

.analytics-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.analytics-graph-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analytics-controls-head {
  align-items: center;
}

.analytics-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.analytics-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.24);
  background: rgba(139, 92, 246, 0.08);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.analytics-toggle input {
  accent-color: var(--primary);
}

.analytics-btn {
  min-height: 30px;
  padding: 0 10px;
}

.analytics-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.analytics-chart-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 140px);
  min-height: 360px;
}

#analyticsChart {
  width: 100% !important;
  height: 100% !important;
}

.leaderboard-mini-card {
  padding: 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compact-head {
  align-items: center;
}

.compact-head a {
  color: var(--primary-light);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
}

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

.leaderboard-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
}

.leaderboard-mini-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.2);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.leaderboard-mini-row:hover {
  border-color: rgba(139, 92, 246, 0.36);
  background: rgba(139, 92, 246, 0.09);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.mini-rank {
  color: var(--primary-light);
  font-size: 0.78rem;
  font-weight: 700;
}

.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.45);
  object-fit: cover;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mini-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.mini-value {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}

.mini-empty {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

/* Leaderboard page */
.leaderboard-shell {
  padding-top: 18px;
}

.leaderboard-header {
  margin-bottom: 14px;
}

.leaderboard-actions {
  gap: 10px;
}

.leaderboard-back-link {
  text-decoration: none;
}

.leaderboard-status {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.leaderboard-status[data-state="ready"] {
  color: var(--text-primary);
}

.leaderboard-status[data-state="error"] {
  border-color: rgba(239, 68, 68, 0.3);
  color: #fecaca;
}

.leaderboard-toolbar {
  margin-bottom: 14px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.leaderboard-search-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.leaderboard-search {
  width: min(340px, 100%);
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.2);
  color: var(--text-primary);
  padding: 0 12px;
  font: inherit;
}

.leaderboard-search:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.45);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.leaderboard-card {
  min-height: 0;
  padding: 14px;
}

.leaderboard-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.leaderboard-card__tag {
  min-width: 56px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.1);
  color: var(--primary-light);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-row,
.leaderboard-loading {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas:
    "rank avatar identity"
    "rank avatar value";
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.2);
}

.leaderboard-row {
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.leaderboard-row:hover {
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.09);
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.leaderboard-row--top {
  border-color: rgba(167, 139, 250, 0.46);
  background: rgba(167, 139, 250, 0.15);
}

.leaderboard-row--entering {
  animation: fade-up 0.2s ease;
}

.leaderboard-row--leaving {
  opacity: 0;
  transform: translateY(4px);
}

.leaderboard-row--rank-shift {
  outline: 1px solid rgba(139, 92, 246, 0.46);
}

.leaderboard-rank {
  grid-area: rank;
  min-width: 42px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.12);
  color: var(--primary-light);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-avatar {
  grid-area: avatar;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.36);
  background: rgba(15, 23, 42, 0.3);
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.leaderboard-identity {
  grid-area: identity;
  min-width: 0;
}

.leaderboard-name {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-meta {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.leaderboard-value {
  grid-area: value;
  justify-self: end;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.leaderboard-empty {
  min-height: 88px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.leaderboard-loading__rank,
.leaderboard-loading__avatar,
.leaderboard-loading__text,
.leaderboard-loading__value {
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.26), rgba(148, 163, 184, 0.15));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.leaderboard-loading__rank {
  width: 42px;
  height: 24px;
}

.leaderboard-loading__avatar {
  width: 36px;
  height: 36px;
}

.leaderboard-loading__text {
  height: 14px;
}

.leaderboard-loading__value {
  width: 56px;
  height: 14px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes player-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@media (min-width: 768px) {
  .app-layout {
    width: min(100vw - 20px, 1440px);
    padding-top: 14px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
  }

  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .chart-card {
    grid-column: span 2;
  }

  .stats-inline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-wrap {
    height: 260px;
  }

  .player-extra {
    display: flex;
  }

  .player-expand {
    display: none;
  }

  .dashboard-leaderboards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .leaderboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .leaderboard-row,
  .leaderboard-loading {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: none;
  }

  .leaderboard-rank,
  .leaderboard-avatar,
  .leaderboard-identity,
  .leaderboard-value {
    grid-area: auto;
  }

  .leaderboard-toolbar {
    flex-direction: row;
    align-items: center;
  }

  .leaderboard-search {
    width: min(340px, 100%);
  }

  .analytics-topbar {
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 1024px) {
  .app-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
    width: min(1440px, calc(100vw - 24px));
  }

  .sidebar {
    position: sticky;
    top: 12px;
    left: auto;
    bottom: auto;
    width: auto;
    min-height: calc(100vh - 24px);
    transform: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-toggle {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas: "stats players health";
    gap: var(--space-xl);
  }

  .stats-card {
    grid-area: stats;
  }

  .players-card {
    grid-area: players;
  }

  .chart-card {
    grid-area: health;
  }

  .chart-card {
    grid-column: span 1;
  }

  .dashboard-card {
    padding: 16px;
  }

  .chart-wrap {
    height: clamp(320px, 46vh, 520px);
  }

  .leaderboard-mini-card,
  .leaderboard-card {
    padding: 16px;
  }

  .analytics-graph-card {
    padding: 16px;
  }
}

@media (max-width: 767px) {
  .chart-head-actions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .analytics-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .analytics-chart-wrap {
    height: calc(100vh - 210px);
    min-height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .header-card,
  .theme-toggle,
  .chart-expand,
  .player-card,
  .leaderboard-row,
  .leaderboard-mini-row {
    transition: none;
    animation: none;
  }
}

