:root {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --card-bg-2: #273549;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --good: #22c55e;
  --warn: #eab308;
  --orange: #f97316;
  --bad: #ef4444;
  --border: #334155;
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
}

.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
}
.topbar nav a:hover { color: var(--text); }

.user-pill {
  background: var(--card-bg-2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.logout-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}
.logout-link:hover { color: var(--text); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.login-card { max-width: 360px; margin: 60px auto; }
.discord-login-btn {
  display: block;
  text-align: center;
  background: #5865f2;
  color: white;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 8px;
}
.discord-login-btn:hover { opacity: 0.9; }
.login-divider { text-align: center; color: var(--text-dim); margin: 12px 0; }

form label {
  display: block;
  margin-bottom: 12px;
}

input, select, button {
  font-family: inherit;
  font-size: 1rem;
}

input[type=text], input[type=password], select {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { opacity: 0.9; }

.flashes { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.flash-error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--bad); }
.flash-success { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--good); }

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.content-wide {
  max-width: none;
}

.banner {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.banner-open { background: #1e3a5f; border: 1px solid #2563eb; }
.banner-locked { background: #3f2a12; border: 1px solid #b45309; }

.hint { color: var(--text-dim); }

.division-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.division-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.division-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--text);
}

.team-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.team-list.sortable .team-item { cursor: grab; }
.team-item.sortable-ghost { opacity: 0.4; }

.team-item .rank {
  font-weight: 700;
  color: var(--text-dim);
  width: 1.2em;
}
.team-item .rank::before { content: counter(rank-counter); }

.team-list { counter-reset: rank-counter; }
.team-item { counter-increment: rank-counter; }

.team-name { flex: 1; }
.drag-handle { color: var(--text-dim); }
.record { color: var(--text-dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.team-item.locked { opacity: 0.85; }

.save-status {
  min-height: 1.2em;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--good);
}

.user-pick-block {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.user-pick-block:last-child { border-bottom: none; margin-bottom: 0; }

.user-pick-name {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent);
}

.pick-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.no-pick {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.leaderboard th {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.all-predictions {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.all-predictions th, .all-predictions td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
}
.all-predictions th:last-child, .all-predictions td:last-child { border-right: none; }

.all-predictions .actual-col, .all-predictions .user-col {
  min-width: 170px;
}

.all-predictions thead th {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  background: var(--card-bg-2);
  white-space: nowrap;
}

.all-predictions .division-name {
  color: var(--text);
  font-weight: 700;
  background: var(--card-bg-2);
  white-space: nowrap;
}

.all-predictions .pick-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.all-predictions .actual-list {
  color: var(--text);
}

.all-predictions tfoot th, .all-predictions tfoot td {
  border-bottom: none;
  font-weight: 700;
  background: var(--card-bg-2);
}

.totals-cell {
  font-variant-numeric: tabular-nums;
}

.penalty-0 { color: var(--good); }
.penalty-1 { color: var(--warn); }
.penalty-2 { color: var(--orange); }
.penalty-3 { color: var(--bad); }
