/* ── Variables ────────────────────────────────────── */
:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --surface2:  #181818;
  --border:    #222222;
  --accent:    #c8f135;
  --accent2:   #f1c135;
  --text:      #e8e8e8;
  --muted:     #555555;
  --first:     #c8f135;
  --second:    #aaaaaa;
  --third:     #cd7f32;
  --danger:    #ff4444;
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --font-body:    'DM Sans', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Noise overlay ────────────────────────────────── */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ── Header ───────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  color: var(--accent);
  font-size: 18px;
  animation: spin 12s linear infinite;
}

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

.logo-text {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.15em;
  color: var(--text);
}

.header-meta {
  display: flex;
  gap: 16px;
  align-items: center;
}

.rounds-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--accent);
  color: #000;
  padding: 3px 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.last-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* ── Main layout ──────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

/* ── Section titles ───────────────────────────────── */
.section-title {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 0.1em;
  color: var(--text);
  line-height: 1;
}

.section-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ── Leaderboard ──────────────────────────────────── */
.leaderboard-section { display: flex; flex-direction: column; gap: 20px; }

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

.player-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  overflow: hidden;
  opacity: 0;
  transform: translateX(-20px);
  animation: slideIn 0.4s ease forwards;
  animation-delay: var(--delay);
  transition: border-color 0.2s, background 0.2s;
}

.player-card:hover {
  background: var(--surface2);
  border-color: var(--muted);
}

.player-card.first  { border-left-color: var(--first); }
.player-card.second { border-left-color: var(--second); }
.player-card.third  { border-left-color: var(--third); }

@keyframes slideIn {
  to { opacity: 1; transform: translateX(0); }
}

.rank {
  font-family: var(--font-display);
  font-size: 22px;
  text-align: center;
  grid-row: 1 / 3;
}

.player-info { grid-column: 2; grid-row: 1; }

.player-name {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.08em;
  line-height: 1;
}

.player-avg {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.player-score {
  grid-column: 3;
  grid-row: 1;
  text-align: right;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-number {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
}

.score-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.bar-wrap {
  grid-column: 2 / 4;
  grid-row: 2;
  height: 2px;
  background: var(--border);
  margin-top: 10px;
}

.bar {
  height: 100%;
  background: var(--accent);
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.player-card.first  .bar { background: var(--first); }
.player-card.second .bar { background: var(--second); }
.player-card.third  .bar { background: var(--third); }

/* ── History table ────────────────────────────────── */
.history-section { display: flex; flex-direction: column; gap: 16px; }

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.history-controls {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.ctrl-btn:hover, .ctrl-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}

.history-table th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table th:first-child,
.history-table th:nth-child(2) { text-align: left; }

.history-table td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.history-table td:first-child,
.history-table td:nth-child(2) { text-align: left; }

.history-table tbody tr:hover td { background: var(--surface2); }
.history-table tbody tr:last-child td { border-bottom: none; }

.round-num {
  color: var(--muted);
  font-size: 11px;
}

.round-date { color: var(--muted); }

.score-cell.best  { color: var(--accent); font-weight: 500; }
.score-cell.worst { color: var(--danger); }

.hidden-row { display: none; }

/* ── Chart ────────────────────────────────────────── */
.chart-section { display: flex; flex-direction: column; gap: 20px; }

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  height: 340px;
}

/* ── Footer ───────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 2rem;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 2rem 1rem; gap: 3rem; }
  .header-inner { padding: 0; }
  .last-updated { display: none; }
  .score-number { font-size: 24px; }
  .player-name  { font-size: 20px; }
  .section-title { font-size: 28px; }
}
