:root {
  --bg-page: #090b10;
  --bg-panel: #0e1015;
  --bg-card: #15181f;
  --accent: #5168ff;
  --accent-light: #7896ff;
  --text-primary: #f2f4f8;
  --text-muted: #8089a0;
  --border: #1f232e;
  --good: #62d17a;
  --bad: #ff6f61;
  --warn: #f6c453;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-primary);
  background:
    linear-gradient(180deg, rgba(81, 104, 255, 0.08), rgba(81, 104, 255, 0) 360px),
    var(--bg-page);
  font-family: "Inter", "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--text-primary);
  background: var(--accent);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-light);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

input {
  min-height: 42px;
  width: min(100%, 340px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text-primary);
  background: #0b0d12;
}

input::placeholder {
  color: var(--text-muted);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero,
.auth-panel,
.panel,
.metric-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  background: var(--bg-panel);
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--accent-light);
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 10px;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.current-date {
  margin-bottom: 0;
  color: var(--text-muted);
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--text-muted);
  background: rgba(21, 24, 31, 0.72);
  font-size: 0.85rem;
  white-space: nowrap;
}

.status-pill.is-loading {
  color: var(--text-primary);
  border-color: rgba(81, 104, 255, 0.52);
}

.status-pill.is-error {
  color: var(--bad);
  border-color: rgba(255, 111, 97, 0.5);
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(128, 137, 160, 0.35);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  opacity: 0;
}

.is-loading .spinner {
  opacity: 1;
  animation: spin 780ms linear infinite;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
  background: rgba(14, 16, 21, 0.88);
}

.auth-panel h2 {
  margin-bottom: 4px;
}

.auth-panel p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.auth-panel.needs-token {
  border-color: rgba(246, 196, 83, 0.55);
}

.token-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ghost-button {
  border-color: var(--border);
  color: var(--text-muted);
  background: transparent;
}

.ghost-button:hover {
  color: var(--text-primary);
  background: rgba(242, 244, 248, 0.06);
}

main {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.metric-card,
.panel {
  background: var(--bg-card);
}

.metric-card {
  min-width: 0;
  padding: 18px;
}

.metric-topline,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.metric-topline h2 {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.delta-badge,
.panel-total {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text-muted);
  background: rgba(14, 16, 21, 0.68);
  font-size: 0.8rem;
  white-space: nowrap;
}

.delta-badge.is-up {
  color: var(--good);
  border-color: rgba(98, 209, 122, 0.38);
}

.delta-badge.is-down {
  color: var(--bad);
  border-color: rgba(255, 111, 97, 0.38);
}

.metric-value {
  margin: 14px 0 10px;
  font-family: "Manrope", "Inter", sans-serif;
  font-size: clamp(2rem, 7vw, 3.8rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0;
}

.sparkline {
  display: block;
  width: 100%;
  height: 54px;
}

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

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-header {
  margin-bottom: 16px;
}

.players-header {
  align-items: center;
}

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

.segmented-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  background: rgba(14, 16, 21, 0.7);
}

.player-filter {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text-muted);
  background: transparent;
  font-size: 0.82rem;
}

.player-filter:hover,
.player-filter.is-active {
  color: var(--text-primary);
  background: rgba(81, 104, 255, 0.72);
  transform: none;
}

.chart-wrap {
  position: relative;
  min-height: 300px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--text-muted);
  pointer-events: none;
}

.empty-state.is-hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 14px 10px;
  text-align: left;
}

th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--text-primary);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.coord,
.last-seen,
.mod-version {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.player-name {
  font-weight: 700;
}

.player-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.player-status::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  content: "";
}

.player-status.is-online {
  color: var(--good);
}

.player-status.is-online::before {
  background: var(--good);
  box-shadow: 0 0 12px rgba(98, 209, 122, 0.55);
}

.player-status.is-offline::before {
  background: #5d6577;
}

.table-empty {
  color: var(--text-muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.fade-card {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeIn 200ms ease forwards;
}

.fade-card:nth-child(2) {
  animation-delay: 40ms;
}

.fade-card:nth-child(3) {
  animation-delay: 80ms;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .hero,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .status-stack,
  .token-form {
    justify-content: flex-start;
  }

  .players-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    justify-content: flex-start;
    width: 100%;
  }

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

@media (max-width: 760px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .token-form {
    align-items: stretch;
    flex-direction: column;
  }

  .token-form input,
  .token-form button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(1180px, calc(100% - 20px));
    padding-top: 10px;
  }

  .hero,
  .auth-panel,
  .panel,
  .metric-card {
    padding: 14px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .status-stack {
    width: 100%;
  }

  .status-pill {
    flex: 1 1 120px;
    justify-content: center;
  }

  .segmented-control {
    width: 100%;
  }

  .player-filter {
    flex: 1 1 0;
    padding: 0 6px;
  }
}
