:root {
  --bg: #0f1419;
  --surface: #1a2129;
  --surface-2: #232c37;
  --border: #2e3946;
  --text: #e8edf2;
  --muted: #8b97a5;
  --accent: #2ecf6f;
  --accent-dim: #1f7a45;
  --correct: #2ecf6f;
  --correct-bg: rgba(46, 207, 111, 0.14);
  --wrong: #ff5d5d;
  --wrong-bg: rgba(255, 93, 93, 0.12);
  --pending: #6b7785;
  --gold: #f5c451;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px 56px;
}

/* ---- Header ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .logo { font-size: 1.35rem; }
.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
  flex: 1;
}
.topbar .nav-link {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.topbar .nav-link:hover { color: var(--text); border-color: var(--accent-dim); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--accent); }

.subhead { color: var(--muted); font-size: 0.88rem; margin: 2px 0 18px; }

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

.row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.row-card:hover { border-color: var(--accent-dim); transform: translateY(-1px); }

.rank {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  width: 30px;
  text-align: center;
  color: var(--muted);
  flex-shrink: 0;
}
.rank.top1 { color: var(--gold); }
.rank.top2 { color: #cfd6dd; }
.rank.top3 { color: #d8954f; }

.who { flex: 1; min-width: 0; }
.who .name { font-weight: 650; font-size: 1.02rem; }
.who .pick-line { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.score-box { text-align: right; flex-shrink: 0; }
.score-box .pts {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}
.score-box .of { font-size: 0.72rem; color: var(--muted); }

.bar {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  margin-top: 10px;
  overflow: hidden;
}
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }

/* ---- Detail page ---- */
.person-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.person-head h2 { margin: 0; font-size: 1.5rem; }
.person-head .big-score { font-size: 1.6rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.person-head .big-score .of { font-size: 0.85rem; color: var(--muted); font-weight: 500; }

.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--muted); margin: 12px 0 20px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.correct { background: var(--correct); }
.dot.wrong { background: var(--wrong); }
.dot.pending { background: var(--pending); }

.round-block { margin-bottom: 22px; }
.round-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.round-title .pts-pill {
  margin-left: auto;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: none;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--text);
}
.round-title .pts-pill strong { color: var(--accent); }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .match-grid { grid-template-columns: 1fr; } }

.match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
.match.correct { border-left-color: var(--correct); background: var(--correct-bg); }
.match.wrong { border-left-color: var(--wrong); background: var(--wrong-bg); }
.match.pending { border-left-color: var(--pending); }

.match .pick {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
  font-size: 0.98rem;
}
.match .pick .ico { margin-left: auto; font-size: 0.95rem; }
.match .pick .ico.correct { color: var(--correct); }
.match .pick .ico.wrong { color: var(--wrong); }
.match .vs { font-size: 0.74rem; color: var(--muted); margin-top: 3px; }
.match .actual { font-size: 0.76rem; margin-top: 4px; color: var(--wrong); }
.match .actual b { color: var(--text); }
.flag { font-size: 1.05rem; line-height: 1; }

/* ---- Admin ---- */
.banner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.save-status {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.save-status.show { opacity: 1; }
.save-status.saved { color: var(--accent); }
.save-status.error { color: var(--wrong); }

.admin-match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-match.locked { opacity: 0.45; }
.team-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.1s ease, background 0.1s ease;
}
.team-btn:hover:not(:disabled) { border-color: var(--accent-dim); }
.team-btn:disabled { cursor: default; }
.team-btn.chosen { background: var(--correct-bg); border-color: var(--correct); color: var(--text); }
.team-btn.tbd { color: var(--muted); font-style: italic; font-weight: 500; }

.reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.reset-btn:hover { border-color: var(--wrong); color: var(--wrong); }

.muted { color: var(--muted); }
.center { text-align: center; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

.hint { font-size: 0.78rem; color: var(--muted); margin: -6px 0 18px; }

/* ---- "Who else picked this" modal ---- */
.match.clickable, .bcell.clickable { cursor: pointer; }
.match.clickable:hover { border-color: var(--accent-dim); }
.bcell.clickable:hover { outline: 1px solid var(--accent-dim); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  transition: transform 0.15s ease;
}
.modal-overlay.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head .flag { font-size: 1.5rem; }
.modal-head .txt { min-width: 0; }
.modal-head .ttl { font-weight: 700; font-size: 1.05rem; }
.modal-head .sub { font-size: 0.78rem; color: var(--muted); }
.modal-head .x {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-head .x:hover { color: var(--text); }
.modal-list { overflow-y: auto; padding: 6px; }
.modal-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
}
.modal-list a:hover { background: var(--surface-2); }
.modal-list .nm { font-weight: 600; flex: 1; min-width: 0; }
.modal-list .pts { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }
.modal-list .me { color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.modal-empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---- Points summary strip (both views) ---- */
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.summary .chip {
  font-size: 0.74rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
}
.summary .chip b { color: var(--accent); }
.summary .chip.zero b { color: var(--muted); }

/* ---- Bracket view (wide screens) ---- */
/* The bracket needs far more width than the standings/card layout, so this
   page widens to (almost) the viewport once the bracket view kicks in. */
@media (min-width: 920px) {
  .bracket-page { max-width: min(1380px, 96vw); }
}
.bkt { --bkt-col: 128px; --bkt-gap: 28px; }
.bkt-headers { --bkt-col: 128px; --bkt-gap: 28px; }

.bkt-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -14px;
  padding: 4px 14px 14px;
  -webkit-overflow-scrolling: touch;
}
.bkt-headers { display: flex; gap: var(--bkt-gap, 30px); width: max-content; margin-bottom: 10px; }
.bkt-headers .h {
  width: var(--bkt-col, 140px);
  text-align: center;
  font-size: 0.64rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.bkt {
  position: relative;
  display: flex;
  gap: var(--bkt-gap, 30px);
  width: max-content;
  height: 680px;
}
.bkt-col {
  width: var(--bkt-col, 140px);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}
.bkt-col.center { justify-content: center; gap: 10px; }
.bkt-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.bkt-svg path { fill: none; stroke: var(--border); stroke-width: 1.5; }

.bcell {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  min-height: 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.bcell .t { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.82rem; min-width: 0; }
.bcell .t .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcell .t .ic { margin-left: auto; flex-shrink: 0; }
.bcell .t .ic.correct { color: var(--correct); }
.bcell .t .ic.wrong { color: var(--wrong); }
.bcell.correct { border-left-color: var(--correct); background: var(--correct-bg); }
.bcell.wrong { border-left-color: var(--wrong); background: var(--wrong-bg); }
.bcell.pending { border-left-color: var(--pending); }
.bcell.neutral { color: var(--muted); }
.bcell .act { font-size: 0.66rem; color: var(--wrong); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcell .lbl { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.bcell.champ { border: 1px solid var(--gold); border-left: 3px solid var(--gold); background: rgba(245, 196, 81, 0.12); }
.bcell.champ.correct { border-color: var(--correct); border-left-color: var(--correct); background: var(--correct-bg); }
