/* ==========================================================================
   Score System - Design System
   Version 1.1.0
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #0284c7;
  --info-soft: #f0f9ff;

  --gold: #b8860b;
  --gold-soft: #fefce8;
  --silver: #64748b;
  --silver-soft: #f8fafc;
  --bronze: #b45309;
  --bronze-soft: #fef7ed;


  --nav-bg: #0f172a;
  --nav-bg-hover: #1e293b;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 14px rgba(15, 23, 42, .08);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, .18);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: 160ms ease;
  --transition-slow: 280ms cubic-bezier(.22, .9, .32, 1.1);
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 8px; }

a { color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Login page ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}
.login-container {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-container h1 { font-size: 22px; text-align: center; }
.login-container > p { text-align: center; color: var(--text-muted); margin-bottom: 20px; }
.login-container .btn.primary { width: 100%; justify-content: center; margin-top: 4px; }
.login-hero { text-align: center; margin-bottom: 20px; }
.login-hero .login-hero__icon {
  display: inline-grid;
  place-items: center;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 28px;
  margin-bottom: 12px;
}

/* ---------- Topbar & navigation ---------- */
.topbar {
  background: var(--nav-bg);
  color: #fff;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar .brand { justify-self: start; }
.topbar .nav { justify-self: center; justify-content: center; }
.topbar-actions { justify-self: end; }
.brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
}
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: rgba(255, 255, 255, .82);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: color var(--transition), background var(--transition);
}
.nav a:hover { color: #fff; background: var(--nav-bg-hover); }
.nav a.is-active { color: #fff; background: rgba(37, 99, 235, .35); }
.nav .btn.link {
  background: transparent;
  color: rgba(255, 255, 255, .82);
  text-decoration: none;
  padding: 7px 11px;
  font-weight: 500;
  font-size: 14px;
}
.nav .btn.link:hover { color: #fff; background: var(--nav-bg-hover); text-decoration: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px; height: 38px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.nav-toggle:hover { background: var(--nav-bg-hover); }
.nav-toggle.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-active span:nth-child(2) { opacity: 0; }
.nav-toggle.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Layout ---------- */
.container { padding: 24px 20px 48px; max-width: 1180px; margin: 0 auto; }

.page-header { margin-bottom: 20px; }
.page-header p { color: var(--text-muted); margin: 0; }

/* Page title with an action on the right (e.g. the Events "+ Create Event"
   button). Only applies to opt-in split headers so plain headers keep their
   original block layout. */
.page-header--split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header--split .page-header__main { flex: 1 1 260px; min-width: 0; }
.page-header--split .page-header__aside {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
@media (max-width: 640px) {
  .page-header--split { flex-direction: column; align-items: stretch; }
  .page-header--split .page-header__aside { justify-content: stretch; }
  .page-header--split .page-header__aside .btn { width: 100%; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}
.panel > h2 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }

/* ---------- Statistic cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}
.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--card-accent, var(--primary));
  opacity: .9;
}
.stat-card:hover, .stat-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--card-accent, var(--primary));
}
.stat-card__icon {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--card-accent-soft, var(--primary-soft));
  color: var(--card-accent, var(--primary));
}
.stat-card__body { min-width: 0; }
.stat-card__value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-card__label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
}
.stat-card__arrow {
  position: absolute;
  top: 14px; right: 14px;
  color: var(--border-strong);
  font-size: 15px;
  transition: color var(--transition), transform var(--transition);
}
.stat-card:hover .stat-card__arrow { color: var(--card-accent, var(--primary)); transform: translateX(3px); }

/* ---------- Quick actions ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.quick-action:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  transform: translateY(-2px);
}
.quick-action__icon {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 17px;
  color: var(--primary);
}
.quick-action strong { display: block; font-size: 14px; }
.quick-action small { color: var(--text-muted); font-size: 12px; }

/* ---------- Dashboard columns ---------- */
.dash-columns {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ---------- Activity feed ---------- */
.activity-feed { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: 0; }
.activity-item__dot {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}
.activity-item__dot--create { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.activity-item__dot--delete { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.activity-item__dot--warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.activity-item__dot--auth { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.activity-item__body { min-width: 0; font-size: 13.5px; }
.activity-item__body strong { font-weight: 700; }
.activity-item__meta { color: var(--text-faint); font-size: 12px; margin-top: 1px; }
.activity-verb { color: var(--text-muted); }

/* ---------- Status overview ---------- */
.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.status-row__label {
  flex: 0 0 108px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: capitalize;
}
.status-row__track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.status-row__bar {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  min-width: 4px;
  transition: width var(--transition-slow);
}
.status-row__bar[data-status="Draft"] { background: var(--text-faint); }
.status-row__bar[data-status="Published"] { background: var(--info); }
.status-row__bar[data-status="Live"] { background: var(--success); }
.status-row__bar[data-status="Completed"] { background: var(--primary); }
.status-row__bar[data-status="Cancelled"] { background: var(--danger); }
.status-row__count {
  flex: 0 0 34px;
  text-align: right;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.rank-item__pos {
  flex: 0 0 24px;
  font-weight: 800;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.rank-item__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-item__points {
  flex: 0 0 auto;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 12.5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Distribution view (read-only) ---------- */
.dist-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.dist-view__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.dist-view__pos {
  flex: 0 0 36px;
  font-weight: 700;
  color: var(--text-muted);
}
.dist-view__arrow { color: var(--text-faint); }
.dist-view__pts { font-weight: 500; }
.dist-view__pts strong { font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---------- Branding ---------- */
/* The upload box stays empty until an admin supplies a logo, in which case it
   shows the image and hides the text brand next to it. */
[data-brand-logo] { display: inline-flex; align-items: center; }
[data-brand-logo][hidden] { display: none; }
.brand-logo--inline .brand-logo__img { max-height: 30px; max-width: 160px; }
.brand-logo__img {
  display: block;
  max-height: 30px;
  max-width: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}
/* Current-asset row and previews in Settings > Branding & Messaging */
.brand-asset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.brand-asset-row[hidden] { display: none; }
.brand-preview {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand-preview[hidden] { display: none; }
.brand-preview img {
  display: block;
  max-height: 32px;
  max-width: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 3px 5px;
}
/* Message templates */
#smsTemplateForm textarea {
  min-height: 62px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}
#smsTemplateForm code {
  font-size: 11.5px;
  padding: 1px 5px;
  margin-right: 3px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}


@media (max-width: 640px) {
  .dist-view { grid-template-columns: 1fr 1fr; }
}

/* Wider still for the bracket tree, which needs room to breathe */
.modal--bracket { max-width: 860px; }
.modal--bracket .bk-wrap { padding: 16px 12px; }

/* ---------- Fixture rows in the Events list ----------
   A knockout's fixtures are top-level rows of the Events list, not nested ones:
   once an event has a bracket its fixtures ARE its representation. So the row
   looks like any other event row - only the left stripe and a slightly smaller
   title mark it as a fixture, without indenting it as a child. */
.fixture-row { border-left: 3px solid var(--border-strong); }
.fixture-row .list-item__main strong { font-size: 14px; }
.fixture-row__score { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.fixture-link { color: inherit; text-decoration: none; }
.fixture-link:hover strong { color: var(--primary); text-decoration: underline; }
/* A fixture awaiting qualification reads as a placeholder, not a broken row */
.fixture-row .badge--Scheduled { background: var(--surface-2); color: var(--text-muted); }
.fixture-row .badge--Live { background: rgba(239, 68, 68, .16); color: var(--danger); }
@media (max-width: 640px) {
  .fixture-row { margin-left: 0; }
}

/* ---------- Multi-select filters ---------- */
.filters {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.filters__group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filters__group--grow { flex: 1 1 180px; max-width: 260px; }
.filters__group--end { margin-left: auto; }
.filters__label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.chip-select { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- Knockout visual bracket (braket-view design) ---------- */

/* Same matches, two ways to read them: the tree or a flat fixture list */
.bracket-views {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
}
.bracket-views[hidden] { display: none; }
.bracket-views__btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.bracket-views__btn:hover { color: var(--text); }
.bracket-views__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.bracket-views__btn[hidden] { display: none; }

/* ---------- Fixture list (matches as first-class items) ---------- */
.fx-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.fx-card--final { border-color: #b45309; box-shadow: inset 3px 0 0 #b45309; }
.fx-card--third { border-color: #7c3aed; }
.fx-card--clickable {
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.fx-card--clickable:hover {
  transform: translateY(-2px);
  border-color: var(--bk-winner);
}
.fx-card--clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.fx-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

/* ---------- Fixture kick-off date ---------- */
.fx-kickoff {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  margin-bottom: 9px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.fx-kickoff__day { font-size: 12.5px; font-weight: 700; color: var(--text); }
.fx-kickoff__time { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fx-kickoff__time--none { font-style: italic; color: var(--text-faint); }
.fx-schedule {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.fx-schedule:hover { color: var(--text); border-color: var(--border-strong); }
.fx-schedule:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- Day grouping ---------- */
.fx-day {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.fx-day:first-child { margin-top: 0; }
.fx-day__label { font-size: 13px; font-weight: 800; color: var(--text); }
.fx-day__count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--surface-2);
}

/* ---------- Running order (who plays who before / after) ---------- */
.fx-seq {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
.fx-seq__row { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.fx-seq__row--empty { color: var(--text-faint); }
.fx-seq__row strong { color: var(--text); font-weight: 700; }
.fx-seq__teams { color: var(--text-faint); }

/* Match filter bar (kick-off / bracket order) */
.fx-sort { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.fx-sort__label { font-size: 12px; color: var(--text-faint); }
.fx-sort button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 99px;
  cursor: pointer;
}
.fx-sort button.is-active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.fx-card__title {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.fx-card__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.fx-status {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fx-status--success { background: rgba(34, 197, 94, .16); color: var(--bk-winner); }
.fx-status--danger { background: rgba(239, 68, 68, .16); color: var(--bk-loser); }
.fx-status--live { background: rgba(14, 165, 233, .16); color: var(--info); }
.fx-status--muted,
.fx-status--pending { background: var(--surface-2); color: var(--text-muted); }
.fx-cta,
.fx-note { font-size: 11.5px; color: var(--text-faint); }
.fx-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
}
.fx-team__name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fx-team__name--pending {
  font-style: italic;
  font-weight: 500;
  color: var(--bk-muted);
}
.fx-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.fx-team__score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: right;
}
.fx-team--won { color: var(--bk-winner); font-weight: 700; }
.fx-team--lost { color: var(--bk-loser); text-decoration: line-through; opacity: .85; }
.fx-team--forfeit { color: var(--bk-loser); }
.fx-team--tbd { color: var(--bk-muted); font-style: italic; }

@media (max-width: 640px) {
  .bracket-views { width: 100%; }
  .bracket-views__btn { flex: 1; }
}

.bk-wrap {
  --bk-bg: #0f172a;
  --bk-card: #1e293b;
  --bk-border: #334155;
  --bk-winner: #22c55e;
  --bk-loser: #ef4444;
  --bk-text: #f1f5f9;
  --bk-muted: #94a3b8;
  --bk-accent: #f59e0b;
  background: var(--bk-bg);
  border: 1px solid var(--bk-border);
  border-radius: var(--radius-lg);
  padding: 22px 18px;
  color: var(--bk-text);
}
.bk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.bk-stage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--bk-border);
  color: var(--bk-text);
  font-weight: 700;
  font-size: 12.5px;
}
.bk-stage__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bk-winner);
  animation: stage-pulse 1.6s ease-in-out infinite;
}
.bk-fs {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bk-border);
  background: rgba(255, 255, 255, .05);
  color: var(--bk-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.bk-fs:hover { background: rgba(255, 255, 255, .12); border-color: var(--bk-muted); }

/* Desktop: semis left/right, Final centre, 3rd place below */
.bk-desktop {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  gap: 24px 40px;
  align-items: center;
  width: 100%;
}
.bk-left  { grid-column: 1; grid-row: 1; justify-self: end;   display: flex; flex-direction: column; gap: 20px; }
.bk-right { grid-column: 3; grid-row: 1; justify-self: start; display: flex; flex-direction: column; gap: 20px; }
.bk-center { grid-column: 2; grid-row: 1; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.bk-third  { grid-column: 2; grid-row: 2; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 0; }

/* Mobile: clean vertical list */
.bk-mobile {
  display: none;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.bk-round-title {
  text-align: center;
  font-size: .74rem;
  font-weight: 700;
  color: var(--bk-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 9px;
}
.bk-match {
  background: var(--bk-card);
  border: 1px solid var(--bk-border);
  border-radius: 14px;
  width: 232px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
  font: inherit;
  color: inherit;
  text-align: left;
  display: block;
}
.bk-match--final {
  border: 1px solid var(--bk-accent);
  box-shadow: 0 8px 26px rgba(245, 158, 11, .28);
}
.bk-match--third { border-color: #7c3aed; }
.bk-match--actionable { cursor: pointer; transition: transform var(--transition), border-color var(--transition); }
.bk-match--actionable:hover { transform: translateY(-2px); border-color: var(--bk-winner); }
.bk-match--just-played { animation: bk-flash 900ms ease; }
@keyframes bk-flash {
  0% { box-shadow: 0 0 0 3px rgba(34, 197, 94, .6); }
  100% { box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
}

.bk-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--bk-border);
  font-size: .92rem;
  font-weight: 500;
  color: var(--bk-text);
}
.bk-team:last-child { border-bottom: none; }
.bk-team--winner { background: rgba(34, 197, 94, .13); color: var(--bk-winner); font-weight: 700; }
.bk-team--loser  { background: rgba(239, 68, 68, .09); color: var(--bk-loser); text-decoration: line-through; opacity: .85; }
.bk-team--forfeit { background: rgba(239, 68, 68, .18); }
.bk-team--forfeit.bk-team--loser { opacity: .95; }
.bk-team--tbd { color: var(--bk-muted); font-style: italic; }
.bk-team--advancing { animation: bk-advance 620ms cubic-bezier(.22, .9, .32, 1.15); }
@keyframes bk-advance {
  0% { opacity: 0; transform: translateX(-22px); box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .6); }
  60% { opacity: 1; transform: translateX(0); }
  100% { transform: translateX(0); }
}
.bk-team-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bk-team-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.bk-score { font-weight: 700; font-size: 1.02rem; min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.bk-chip { font-size: .6rem; font-weight: 800; padding: 2px 7px; border-radius: 6px; letter-spacing: .07em; text-transform: uppercase; }
.bk-chip--forfeit { background: var(--bk-loser); color: #fff; }
.bk-chip--winner { background: var(--bk-winner); color: #052e13; }
.bk-champion {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #111;
  font-weight: 800;
  font-size: .72rem;
  letter-spacing: .05em;
  padding: 5px 15px;
  border-radius: 20px;
}
.bk-hint { text-align: center; font-size: .68rem; color: var(--bk-muted); padding: 7px 8px 9px; }

.bk-wrap:fullscreen { background: var(--bk-bg); padding: 32px; overflow: auto; }
.bk-wrap:-webkit-full-screen { background: var(--bk-bg); padding: 32px; overflow: auto; }

@media (max-width: 900px) {
  .bk-desktop { display: none; }
  .bk-mobile { display: flex; }
  .bk-match { width: 100%; }
  .bk-round-title { font-size: .8rem; margin-bottom: 7px; }
  .bk-wrap { padding: 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .bk-match--actionable:hover { transform: none; }
  .bk-team--advancing, .bk-match--just-played { animation: none; }
}
/* ---------- Settings page ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}
.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  position: sticky;
  top: 84px;
  box-shadow: var(--shadow-sm);
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  width: 100%;
}
.settings-tab:hover { background: var(--surface-2); color: var(--text); }
.settings-tab.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}
.settings-tab__icon {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 15px;
}
.settings-tab.is-active .settings-tab__icon {
  background: var(--surface);
  border-color: rgba(37, 99, 235, .3);
}
.settings-content { min-width: 0; }
.settings-panel { animation: settings-fade 220ms ease; }
.settings-panel[hidden] { display: none; }

/* The hidden attribute is applied by the UA stylesheet as display:none, which
   any component rule (e.g. .event-blocks { display:flex }) would override.
   This guard makes [hidden] win everywhere. */
[hidden] { display: none !important; }

@keyframes settings-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* The arrows only matter when the tabs are a horizontal strip; on the desktop's
   vertical list everything is visible, so they stay hidden. */
.settings-tabs-nav { display: contents; }
.settings-tabs-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.settings-tabs-arrow:hover:not(:disabled) { background: var(--surface-2); }
.settings-tabs-arrow:disabled { opacity: .4; cursor: default; }
.settings-tabs-arrow[hidden] { display: none !important; }

/* ---------- Floating action bar (Event page) ----------
   The page-header__aside moves into .fab-bar once the header scrolls away, so
   these two actions stay reachable at any scroll depth. The bar sits below the
   sticky topbar and above page content, but below modals. */
.fab-bar {
  position: fixed;
  top: 58px;
  right: 20px;
  z-index: 90;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.fab-bar.is-visible { display: inline-flex; }
/* The aside keeps its inline shape until it is moved, so its own rules apply in
   both places without a second copy of them here. */
.fab-bar .page-header__aside { margin: 0; }

/* Narrow screens: bottom-right, where a thumb reaches and where it cannot cover
   the top of the list the admin is scanning. */
@media (max-width: 760px) {
  .fab-bar {
    top: auto;
    bottom: 18px;
    right: 14px;
    gap: 6px;
    padding: 6px;
  }
  .fab-bar .btn { padding: 8px 12px; font-size: 12.5px; }
}

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-tabs-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .settings-tabs-arrow { display: inline-flex; }
  .settings-tabs {
    position: static;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: row;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding: 8px;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab { flex: 0 0 auto; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .settings-panel { animation: none; }
}

/* ---------- Grouped lists (events by type) ---------- */
.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.group-header:first-child { margin-top: 0; }
.btn.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Top teams ranking (team-coloured bars) ---------- */
.top-team-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
}
.top-team-row__rank {
  flex: 0 0 18px;
  font-weight: 800;
  font-size: 12px;
  color: var(--text-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.top-team-row__color {
  flex: 0 0 auto;
  width: 12px; height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.top-team-row__name {
  flex: 0 0 auto;
  max-width: 34%;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-team-row__track {
  flex: 1;
  height: 10px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}
.top-team-row__bar {
  display: block;
  height: 100%;
  border-radius: 99px;
  min-width: 6px;
  transition: width var(--transition-slow);
}
.top-team-row__pts {
  flex: 0 0 auto;
  min-width: 30px;
  text-align: right;
  font-weight: 800;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Completed events & results (dashboard) ---------- */
.completed-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 8px;
}
.completed-event__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 180px; }
.completed-event__results { display: flex; flex-wrap: wrap; gap: 16px; }
.completed-event__result { white-space: nowrap; }
@media (max-width: 640px) {
  .completed-event { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  .top-team-row__name { max-width: 40%; font-size: 12.5px; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--active, .badge--success, .badge--Published, .badge--Live { background: var(--success-soft); color: var(--success); }
.badge--inactive, .badge--Draft { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge--suspended, .badge--Cancelled, .badge--danger, .badge--error { background: var(--danger-soft); color: var(--danger); }
.badge--warning, .badge--locked { background: var(--warning-soft); color: var(--warning); }
.badge--info, .badge--Completed, .badge--Scheduled { background: var(--info-soft); color: var(--info); }
.badge--gold { background: var(--gold-soft); color: var(--gold); }
.badge--silver { background: var(--silver-soft); color: var(--silver); }
.badge--bronze { background: var(--bronze-soft); color: var(--bronze); }

/* ---------- Event results (reps) ---------- */
.reps-team { transition: border-color .15s ease; }
.reps-team--podium { background: linear-gradient(90deg, var(--primary-soft), transparent 55%); }
.reps-team__pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--primary);
}

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  transition: border-color var(--transition), background var(--transition);
}
.list-item:hover { border-color: var(--border-strong); background: var(--surface); }
.list-item__main { flex: 1; min-width: 180px; }
.list-item__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ---------- Drag & drop reordering (Events list) ----------
   A dedicated handle drives reordering via Pointer Events, so it works on touch
   as well as mouse (HTML5 drag never fires on a phone). It draws the classic
   six-dot grip. */
.drag-handle {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  cursor: grab;
  touch-action: none;
  color: var(--text-faint);
  user-select: none;
  -webkit-user-select: none;
}
.drag-handle::before {
  content: "";
  width: 10px;
  height: 16px;
  background-image: radial-gradient(currentColor 1px, transparent 1.3px);
  background-size: 5px 5px;
  opacity: .7;
}
.list-item.is-dragging { opacity: .55; }
.list-item.is-dragging .drag-handle { cursor: grabbing; }
.list-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft, rgba(37, 99, 235, .2)); }
/* On a phone the row stacks, so the handle becomes a slim full-width grabber. */
@media (max-width: 640px) {
  .drag-handle {
    width: 100%;
    height: 20px;
    align-self: stretch;
    background: var(--surface-2);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin: -2px -2px 2px;
  }
  .drag-handle::before { width: 44px; height: 10px; }
}

/* ---------- Row action menu (collapsed on narrow screens) ----------
   Wide screens: the extra actions render inline, exactly as before. Narrow
   screens: they drop into a kebab menu so the sort arrows keep the row to one
   tidy line instead of a tall stack of buttons. */
.row-more { display: inline-flex; align-items: center; gap: 8px; }
.row-more__inner { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-more__toggle { display: none; }
@media (max-width: 760px) {
  .row-more { position: relative; }
  /* A centered popup, not an absolute dropdown: it can't clip off-screen or
     hide behind the page the way a right/top-anchored box did, so the actions
     are always fully visible regardless of which row was tapped. */
  .row-more__inner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    z-index: 4200;
    width: min(88vw, 360px);
    max-height: 78vh;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }
  .row-more.is-open .row-more__inner { display: flex; }
  .row-more__toggle { display: inline-flex; }
  .row-more__inner .btn { width: 100%; justify-content: center; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); box-shadow: 0 3px 10px rgba(37, 99, 235, .35); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; box-shadow: 0 3px 10px rgba(220, 38, 38, .3); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn.subtle { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.btn.subtle:hover { color: var(--text); border-color: var(--border-strong); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13.5px; }
.form-group .hint { font-weight: 400; color: var(--text-faint); font-size: 12px; }

/* ---------- Roster split (starters + substitutes) ---------- */
.roster-split {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}
.roster-split__field { flex: 0 0 108px; min-width: 0; }
.roster-split__field label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.roster-split__op {
  flex: 0 0 auto;
  padding-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-faint);
}
.roster-split__total {
  flex: 0 0 auto;
  padding-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.roster-split__total strong {
  font-size: 21px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.roster-nosubs { margin-top: 2px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.form-group textarea { resize: vertical; min-height: 72px; }

.form-group.is-invalid input,
.form-group.is-invalid select,
.form-group.is-invalid textarea { border-color: var(--danger); background: var(--danger-soft); }
.form-group.is-invalid input:focus,
.form-group.is-invalid select:focus,
.form-group.is-invalid textarea:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.form-group.is-valid input,
.form-group.is-valid select,
.form-group.is-valid textarea { border-color: var(--success); }
.field-error { display: none; color: var(--danger); font-size: 12.5px; margin-top: 5px; font-weight: 500; }
.form-group.is-invalid .field-error { display: block; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Alerts (legacy inline) ---------- */
.alert {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

/* ---------- Toast notifications ---------- */
/* Toasts must float above every modal/overlay (modal-overlay is 3000, confetti
   3500), so the region sits on top of all of them. */
.toast-region {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(92vw, 440px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--toast-accent, var(--info));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: toast-in var(--transition-slow);
}
.toast--success { --toast-accent: var(--success); }
.toast--error { --toast-accent: var(--danger); }
.toast--warning { --toast-accent: var(--warning); }
.toast--info { --toast-accent: var(--info); }

.toast__icon {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--toast-accent);
  margin-top: 1px;
}
.toast__content { flex: 1; min-width: 0; }
.toast__message { margin: 0; font-size: 14px; font-weight: 500; word-wrap: break-word; }
.toast__close {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition), color var(--transition);
}
.toast__close:hover { background: var(--surface-2); color: var(--text); }
.toast__progress {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--toast-accent);
  transform-origin: left center;
  animation: toast-progress linear forwards;
}
.toast.is-leaving { animation: toast-out 220ms ease forwards; }
.toast:hover .toast__progress { animation-play-state: paused; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-14px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(.97); }
}
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ---------- Confirmation modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade-in 160ms ease;
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: modal-in var(--transition-slow);
}
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }
/* Forms with a grid need more room than a confirm dialog */
.modal--wide { max-width: 660px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* The bracket tree is a wide fixed grid, so a modal holding one has to scroll
   both ways and stay inside the overlay instead of pushing the panel out. */
.modal--bracket {
  max-width: 860px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal--bracket h2,
.modal--bracket > p { flex: 0 0 auto; }
.modal--bracket .form-group { flex: 0 0 auto; }
.modal--bracket .bk-scroller {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.modal--bracket .bk-wrap,
.modal--bracket #bgFinalArea { flex: 0 0 auto; }
.modal--bracket .modal__actions { flex: 0 0 auto; margin-top: 14px; }
/* The toolbar sits outside bk-wrap; keep it visible while the bracket scrolls */
.modal--bracket .bk-toolbar { position: sticky; top: 0; z-index: 2; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Skeletons ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--border);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: shimmer 1.5s infinite;
}
.skeleton-card { height: 88px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.skeleton-line { height: 13px; margin: 9px 0; border-radius: 4px; }
.skeleton-line--short { width: 45%; }

@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 34px 18px;
  color: var(--text-muted);
}
.empty-state__icon {
  display: inline-grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 22px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.empty-state p { margin: 0; font-size: 14px; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }

/* ---------- Info callout ---------- */
.info-callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--info-soft);
  border: 1px solid #bae6fd;
  color: #075985;
  font-size: 13.5px;
}
.info-callout__icon { flex: 0 0 auto; font-size: 17px; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .dash-columns { grid-template-columns: 1fr; }
  .topbar { display: flex; flex-wrap: wrap; padding: 10px 14px; }
  .nav-toggle { display: flex; }
  .nav {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .14);
  }
  .nav.nav-open { display: flex; animation: nav-slide 180ms ease; }
  .nav a, .nav .btn.link {
    margin: 0;
    padding: 12px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    border-radius: 0;
    font-size: 15px;
    text-align: left;
    width: 100%;
  }
  .nav a:last-of-type { border-bottom: 0; }
}

@keyframes nav-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; }
  h1 { font-size: 22px; }
  .panel { padding: 15px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 15px; }
  .stat-card__value { font-size: 26px; }
  .grid { grid-template-columns: 1fr; }
  .list-item { flex-direction: column; align-items: flex-start; }
  .list-item__actions { margin-left: 0; width: 100%; }
  .quick-grid { grid-template-columns: 1fr; }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
  .status-row__label { flex-basis: 84px; font-size: 11.5px; }
  /* The split page header (e.g. Events) reclaims the vertical gap its wrapped
     subtitle and stacked actions used to leave on a phone. */
  .page-header--split { gap: 12px; margin-bottom: 14px; }
  .page-header--split .page-header__main p { font-size: 12.5px; }
  .page-header--split .page-header__aside { gap: 8px; }
  .page-header--split .page-header__aside .btn { padding: 9px 12px; font-size: 13px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .toast__progress { display: none; }
}

/* ==========================================================================
   Version 1.6.0 - Premium bracket experience, dark mode, drawer, confetti
   ========================================================================== */

/* ---------- Dark / light theme ---------- */
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #0f1729;
  --border: #1e2a44;
  --border-strong: #33415c;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, .16);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, .16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, .16);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, .16);
  --info: #0ea5e9;
  --info-soft: rgba(14, 165, 233, .16);

  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, .16);
  --silver: #cbd5e1;
  --silver-soft: rgba(203, 213, 225, .16);
  --bronze: #d97706;
  --bronze-soft: rgba(217, 119, 6, .16);

  --nav-bg: #0b1220;
  --nav-bg-hover: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, .6);
}
.topbar { transition: background var(--transition); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.theme-toggle:hover { background: var(--nav-bg-hover); transform: rotate(15deg); }

/* ---------- Bracket toolbar / fullscreen ---------- */
.bracket-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.stage-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid rgba(37, 99, 235, .25);
}
.stage-indicator__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: stage-pulse 1.6s ease-in-out infinite;
}
@keyframes stage-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.75); }
}



/* ---------- Match cards: avatars, champion, eliminated, forfeit ---------- */
.match-team {
  position: relative;
  overflow: hidden;
}
.match-team__avatar {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  margin-right: 9px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.match-team__name { display: inline-flex; align-items: center; min-width: 0; }
.match-team__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-team--winner {
  box-shadow: 0 0 0 1px rgba(34, 197, 94, .35), 0 0 16px rgba(34, 197, 94, .28);
}
.match-team--champion {
  background: linear-gradient(135deg, rgba(34, 197, 94, .22), rgba(34, 197, 94, .08));
  border-color: var(--success);
  animation: champion-pulse 2s ease-in-out infinite;
}
@keyframes champion-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(34, 197, 94, .4), 0 0 14px rgba(34, 197, 94, .3); }
  50% { box-shadow: 0 0 0 1px rgba(34, 197, 94, .6), 0 0 26px rgba(34, 197, 94, .45); }
}
.match-team__champion-badge {
  margin-left: 8px;
  font-size: 14px;
  animation: trophy-bounce 1.8s ease-in-out infinite;
}
@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-3px) rotate(4deg); }
}
.match-team__eliminated-stamp {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%) rotate(-12deg);
  border: 2px solid var(--danger);
  color: var(--danger);
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: .12em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(239, 68, 68, .08);
  text-transform: uppercase;
  pointer-events: none;
}
.match-team__forfeit-chip {
  margin-left: 8px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  background: var(--danger);
  border-radius: 4px;
  padding: 2px 6px;
}
.match-team--advancing { animation: advance-in 620ms cubic-bezier(.22, .9, .32, 1.15); }
@keyframes advance-in {
  0% { opacity: 0; transform: translateX(-26px) scale(.96); box-shadow: 0 0 0 3px rgba(37, 99, 235, .5); }
  60% { opacity: 1; transform: translateX(0) scale(1.02); }
  100% { transform: translateX(0) scale(1); }
}
.match-card--just-played { animation: card-flash 900ms ease; }
@keyframes card-flash {
  0% { box-shadow: 0 0 0 3px rgba(34, 197, 94, .55); }
  100% { box-shadow: var(--shadow-sm); }
}


/* ---------- Side drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  z-index: 3000;
  animation: fade-in 160ms ease;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 100vw);
  background: var(--surface);
  color: var(--text);
  z-index: 3001;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: drawer-in 300ms cubic-bezier(.22, .9, .32, 1.1);
}
.drawer.is-leaving { animation: drawer-out 200ms ease forwards; }
@keyframes drawer-in {
  from { transform: translateX(46px); opacity: .3; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes drawer-out {
  to { transform: translateX(46px); opacity: 0; }
}
.drawer__header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer__title { font-size: 16px; font-weight: 800; margin: 0 0 4px; }
.drawer__subtitle { font-size: 12.5px; color: var(--text-muted); margin: 0; }
.drawer__close {
  border: 0; background: transparent; color: var(--text-faint);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.drawer__close:hover { background: var(--surface-2); color: var(--text); }
.drawer__body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.drawer__footer .btn { flex: 1; }
.winner-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  margin-bottom: 12px;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.winner-pick:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.winner-pick.is-selected {
  border-color: var(--success);
  background: var(--success-soft);
}
.winner-pick__avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.winner-pick__name { font-weight: 700; font-size: 15px; }
.winner-pick__meta { font-size: 12px; color: var(--text-muted); }
.winner-pick__check {
  margin-left: auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 13px;
  color: transparent;
  flex: 0 0 auto;
}
.winner-pick.is-selected .winner-pick__check {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}
.drawer__score-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer__hint { font-size: 12.5px; color: var(--text-muted); margin: 0 0 14px; }

/* ---------- Confetti ---------- */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3500;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -14px;
  width: 9px; height: 14px;
  border-radius: 2px;
  opacity: .95;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(108vh) rotate(720deg); opacity: .2; }
}

/* ---------- Dark-mode refinements ---------- */
:root[data-theme="dark"] .login-body { background: linear-gradient(135deg, #060b16, #0f172a); }
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .08), transparent); }
:root[data-theme="dark"] .match-team__eliminated-stamp { background: rgba(239, 68, 68, .14); }

@media (max-width: 640px) {
  .drawer { width: 100vw; }
  .drawer__footer .btn { flex: 1 1 100%; }
  .match-team__eliminated-stamp { font-size: 8.5px; right: 5px; }
}




