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

body {
  font-family: 'Nunito', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* Nav */
.topnav {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1.2rem;
  font-weight: 900;
  color: #7c3aed;
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  text-decoration: none;
}
.nav-link:hover { color: #7c3aed; }

.nav-user {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e293b;
}

.nav-logout {
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-logout:hover { background: #fecaca; }

/* Page */
.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.loading {
  text-align: center;
  color: #94a3b8;
  font-weight: 700;
  font-size: 1rem;
  padding: 60px 0;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 20px;
}

/* Overview cards */
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .cards-row { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-top: 4px solid transparent;
}

.stat-card.purple { border-color: #7c3aed; }
.stat-card.amber  { border-color: #f59e0b; }
.stat-card.green  { border-color: #059669; }
.stat-card.blue   { border-color: #0891b2; }

.sc-icon { font-size: 1.4rem; margin-bottom: 6px; }
.sc-num  { font-size: 1.8rem; font-weight: 900; color: #1e293b; line-height: 1; }
.sc-lbl  { font-size: 0.7rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

/* Charts */
.chart-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 16px;
}

.chart-wrap { height: 200px; position: relative; }
.chart-wrap.short { height: 220px; }

/* Tables */
.table-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.table-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  padding: 0 0 10px;
  border-bottom: 2px solid #f1f5f9;
}

tbody td {
  padding: 11px 0;
  border-bottom: 1px solid #f8fafc;
  font-weight: 600;
  color: #1e293b;
}

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

.grade-chip {
  background: #f5f3ff;
  color: #7c3aed;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.view-link {
  font-size: 0.8rem;
  font-weight: 800;
  color: #7c3aed;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.view-link:hover { opacity: 1; text-decoration: underline; }

.no-games {
  text-align: center;
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 20px 0;
}

/* Leaderboard rows */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.875rem;
  font-weight: 700;
}

.lb-row:last-child { border-bottom: none; }

.lb-row.lb-me {
  background: #f5f3ff;
  margin: 0 -20px;
  padding: 11px 20px;
  border-radius: 10px;
}

.lb-rank  { font-size: 1.1rem; width: 28px; text-align: center; flex-shrink: 0; }
.lb-name  { flex: 1; color: #1e293b; }
.lb-score { font-weight: 900; color: #7c3aed; }

/* Category grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  text-decoration: none;
  color: #1e293b;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.cat-card:hover { border-color: #7c3aed; background: #f5f0ff; transform: translateY(-2px); }
.cat-locked { opacity: 0.6; }
.cat-emoji  { font-size: 1.8rem; }
.cat-name   { font-size: 0.78rem; font-weight: 800; text-align: center; }
.cat-lock   { font-size: 0.7rem; font-weight: 700; color: #f59e0b; background: #fef3c7; border-radius: 6px; padding: 2px 6px; }

/* Archive grid */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.arch-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
}
.arch-played {
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  color: #15803d;
  cursor: default;
}
.arch-open {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  color: #7c3aed;
  transition: border-color 0.15s, background 0.15s;
}
.arch-open:hover { border-color: #7c3aed; background: #f5f0ff; }
.arch-date   { font-size: 0.7rem; color: #64748b; }
.arch-status { font-size: 0.72rem; font-weight: 800; }

@media (max-width: 500px) {
  .cat-grid     { grid-template-columns: repeat(3, 1fr); }
  .archive-grid { grid-template-columns: repeat(3, 1fr); }
}
.lb-correct { font-size: 0.78rem; color: #059669; font-weight: 800; }
