:root {
  --bg-deep: #0b0e1a;
  --bg-panel: #131829;
  --bg-panel-2: #171d33;
  --ink: #e8e9f3;
  --ink-dim: #8b90ac;
  --ink-faint: #565b7a;
  --accent: #7c6ff0;
  --accent-soft: #4a3fb0;
  --glow: #4fd8c4;
  --line: #232a44;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  position: relative;
  padding: 0 0 48px;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 2px;
}

/* subtle starfield behind everything */
.bg-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(232, 233, 243, 0.35) 0, transparent 100%),
    radial-gradient(1px 1px at 80% 10%, rgba(232, 233, 243, 0.25) 0, transparent 100%),
    radial-gradient(1.5px 1.5px at 60% 70%, rgba(124, 111, 240, 0.4) 0, transparent 100%),
    radial-gradient(1px 1px at 30% 85%, rgba(232, 233, 243, 0.2) 0, transparent 100%),
    radial-gradient(1px 1px at 90% 60%, rgba(79, 216, 196, 0.3) 0, transparent 100%),
    radial-gradient(1.5px 1.5px at 45% 40%, rgba(232, 233, 243, 0.3) 0, transparent 100%);
  background-repeat: no-repeat;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(124, 111, 240, 0.6);
}

.brand-sub {
  color: var(--ink-dim);
  font-weight: 500;
}

.search { position: relative; width: 260px; max-width: 100%; }

#player-search {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
}

#player-search::placeholder { color: var(--ink-faint); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  z-index: 10;
}

.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
}

.search-results button:hover,
.search-results button:focus-visible {
  background: var(--bg-panel);
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card--live {
  border-color: rgba(79, 216, 196, 0.35);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-dim);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 0 0 rgba(79, 216, 196, 0.6);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 216, 196, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(79, 216, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 216, 196, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-header h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  margin: 0;
  color: var(--ink);
}

.range-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-panel-2);
  border-radius: 8px;
  padding: 3px;
}

.range-toggle button {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

.range-toggle button.active {
  background: var(--accent);
  color: var(--ink);
}

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
}

table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.leaderboard th {
  text-align: left;
  color: var(--ink-dim);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
}

table.leaderboard td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

table.leaderboard tbody tr {
  cursor: pointer;
}

table.leaderboard tbody tr:hover {
  background: var(--bg-panel-2);
}

table.leaderboard td:first-child {
  font-family: var(--font-mono);
  color: var(--ink-dim);
  width: 40px;
}

table.leaderboard td:nth-child(3),
table.leaderboard td:nth-child(4) {
  font-family: var(--font-mono);
  text-align: right;
}

.close-btn {
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}

.close-btn:hover { color: var(--ink); }

.player-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-detail .detail-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.player-detail .detail-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-detail .detail-stat span:first-child {
  font-size: 12px;
  color: var(--ink-dim);
}

.player-detail .detail-stat span:last-child {
  font-family: var(--font-mono);
  font-size: 18px;
}

.session-list {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-dim);
}

.session-list .session-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
}

footer {
  max-width: 1080px;
  margin: 24px auto 0;
  padding: 0 32px;
  color: var(--ink-faint);
  font-size: 13px;
}

@media (max-width: 720px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  main { padding: 20px; }
  .topbar { padding: 20px; }
}
