:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --panel: #1a1d24;
  --border: #2a2e37;
  --text: #e6e8eb;
  --muted: #9aa2ad;
  --accent: #6ea8fe;
  --gold: #d4af37;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --good: #4caf7d;
  --bad: #e0715a;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --border: #e2e5ea;
    --text: #1a1d24;
    --muted: #5b6572;
    --accent: #2f6fed;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.1rem;
  margin: 0;
  white-space: nowrap;
}

nav { display: flex; gap: 0.25rem; }

nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

nav a:hover { background: var(--panel); color: var(--text); }
nav a.active { background: var(--accent); color: #fff; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
}

.stat-tile .value { font-size: 1.5rem; font-weight: 600; }
.stat-tile .label { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

button:disabled { opacity: 0.6; cursor: default; }

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  min-width: 220px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }

.medal { font-size: 1.1rem; }
.muted { color: var(--muted); }
.log {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.chain-node {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 500;
}
.chain-arrow { color: var(--muted); }
.chain-arrow a { color: var(--accent); text-decoration: none; font-size: 0.75rem; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--border);
  color: var(--muted);
  margin-left: 0.4rem;
}
