:root {
  --bg: #0f1613;
  --panel: #17211d;
  --panel2: #1e2b25;
  --line: #2b3a33;
  --ink: #e8f0ec;
  --muted: #93a89e;
  --accent: #c6f24e; /* pickleball yellow-green */
  --accent-ink: #16210a;
  --blue: #57b6ff;
  --win: #6ee7a8;
  --loss: #ff8a8a;
  --warn: #ffcf5c;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1c2a22 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 22, 19, 0.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand .ball { filter: drop-shadow(0 2px 6px rgba(198, 242, 78, 0.4)); }
#nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.navlink {
  color: var(--muted); text-decoration: none; padding: 7px 13px; border-radius: 999px;
  font-weight: 600; font-size: 14px; transition: 0.15s;
}
.navlink:hover { color: var(--ink); background: var(--panel2); }
.navlink.active { color: var(--accent-ink); background: var(--accent); }

/* ---------- layout ---------- */
#view { max-width: 1040px; width: 100%; margin: 0 auto; padding: 22px 18px 40px; flex: 1; }
footer {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 16px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.01em; }
.card h3 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.muted { color: var(--muted); }
.err { color: var(--loss); }
.ok { color: var(--win); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.pill.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pill.blue { background: rgba(87,182,255,.16); color: var(--blue); border-color: transparent; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
input, select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 11px; border-radius: 10px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"] { width: auto; }
.field { margin-bottom: 12px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline label { margin: 0; }

.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; font-size: 14px; cursor: pointer; transition: 0.12s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--panel2); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--loss); border: 1px solid var(--loss); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.cut { background: linear-gradient(90deg, rgba(198,242,78,.06), transparent); }
tbody tr:hover, tbody tr:hover { background: rgba(255,255,255,0.02); }
.qual-line td { border-bottom: 2px dashed var(--accent); }

/* ---------- schedule ---------- */
.dayhead { margin: 18px 0 8px; font-weight: 800; font-size: 15px; color: var(--accent); }
.match {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  margin-bottom: 8px;
}
.match .when { font-size: 12px; color: var(--muted); line-height: 1.3; }
.match .teams { font-weight: 600; }
.match .teams .vs { color: var(--muted); font-weight: 400; padding: 0 6px; }
.match .score { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; }
.winner { color: var(--win); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.done { background: rgba(110,231,168,.16); color: var(--win); }
.badge.sched { background: rgba(87,182,255,.14); color: var(--blue); }
.badge.unsched { background: rgba(255,138,138,.14); color: var(--loss); }
.badge.stage { background: var(--panel2); color: var(--warn); }

/* ---------- bracket ---------- */
.bracket { display: flex; gap: 22px; overflow-x: auto; padding-bottom: 6px; }
.bcol { min-width: 210px; display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.bcol .roundlabel { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.bmatch { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.bmatch .bhead { font-size: 11px; font-weight: 800; padding: 6px 10px; background: var(--panel2); color: var(--warn); text-transform: uppercase; letter-spacing: .05em; }
.bside { display: flex; justify-content: space-between; padding: 9px 11px; border-top: 1px solid var(--line); }
.bside.win { background: rgba(110,231,168,.10); }
.bside .nm { font-weight: 600; }
.bside .sc { font-variant-numeric: tabular-nums; color: var(--muted); }
.bside.win .sc { color: var(--win); font-weight: 800; }

/* ---------- champion banner ---------- */
.champ {
  background: linear-gradient(120deg, var(--accent), #8fd63a);
  color: var(--accent-ink); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.champ .trophy { font-size: 34px; }
.champ .lbl { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }
.champ .nm { font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }

/* ---------- misc ---------- */
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 2px; }
.rowitem { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rowitem > input, .rowitem > select { flex: 1; }
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #222; color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: 0.25s; box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #1f6f47; }
.toast.err { background: #7a2b2b; }

.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.subnavlink {
  color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 9px; font-weight: 600;
  font-size: 13px; border: 1px solid var(--line); background: var(--panel);
}
.subnavlink:hover { color: var(--ink); }
.subnavlink.active { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

@media (max-width: 560px) {
  .match { grid-template-columns: 76px 1fr; }
  .match .score { grid-column: 2; }
  #nav { width: 100%; }
}
