/* ───────────────────────────────────────────────────────────
   League Bracket — modern, hierarchical knockout view.

   Hierarchy strategy:
     • Each round increases card padding & font-weight.
     • Inter-card gap doubles per round so columns line up
       horizontally and there's no large empty space.
     • Final renders as a hero card (3× card) at the right.
     • align-items: center on the grid means short columns
       (QF, SF, F) sit centered against R16, eliminating slack.

   Token-only colors. No 1px solid borders for separation.
   ─────────────────────────────────────────────────────────── */

/* Page shell ------------------------------------------------ */
.lb-body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--te-font);
  margin: 0;
  min-height: 100vh;
}
.lb-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--primary-container) 5%, transparent), transparent 60%),
    var(--surface);
}
.lb-page--fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: auto;
}

/* ── HEADER STRIP ──────────────────────────────────────────── */
.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.875rem 1.75rem;
  background: var(--surface-container);
  position: relative;
  z-index: 5;
}
.lb-header__brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
}
.lb-header__logo {
  width: 44px;
  height: 44px;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.lb-header__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}
.lb-header__logo-fallback {
  font-weight: var(--te-data-weight);
  font-size: 0.875rem;
  color: var(--on-surface);
}
.lb-header__title {
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
  color: var(--on-surface);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-header__actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

/* Buttons (shared across header + sub-header) -------------- */
.lb-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--te-radius-md);
  background: transparent;
  color: var(--on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--te-transition-fast), color var(--te-transition-fast);
  white-space: nowrap;
}
.lb-btn:hover { background: var(--surface-container-high); }
.lb-btn[aria-pressed="true"] {
  background: var(--te-accent-tint);
  color: var(--primary-container);
}
.lb-btn--ghost { background: var(--surface-container-low); }
.lb-btn--ghost:hover { background: var(--surface-container-high); }
.lb-btn--text {
  padding: 0.5rem 0.625rem;
  color: var(--on-surface-variant);
}
.lb-btn--icon {
  padding: 0.5rem;
  width: 38px;
  height: 38px;
  justify-content: center;
}
.lb-btn--icon svg { width: 18px; height: 18px; }
.lb-btn__icon { width: 16px; height: 16px; }
.lb-btn__label { font-size: 0.8125rem; font-weight: 600; }

/* Season select -------------------------------------------- */
.lb-season-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  position: relative;
}
.lb-season-form::after {
  content: '';
  position: absolute;
  right: 0.625rem;
  top: 50%;
  width: 12px;
  height: 12px;
  pointer-events: none;
  transform: translateY(-50%);
  background-color: var(--on-surface-variant);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='black' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='black' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / contain no-repeat;
}
.lb-season-form__label {
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin: 0;
}
.lb-season {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-container-low);
  color: var(--on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  padding: 0.5rem 1.875rem 0.5rem 0.875rem;
  border-radius: var(--te-radius-md);
  cursor: pointer;
}
.lb-season:focus { outline: 2px solid var(--primary-container); outline-offset: 1px; }

/* ── SUB-HEADER STRIP ─────────────────────────────────────── */
.lb-subheader {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.75rem 1rem;
  background: transparent;
}
.lb-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  justify-self: start;
  transition: color var(--te-transition-fast);
}
.lb-back:hover { color: var(--on-surface); }
.lb-back__icon { width: 16px; height: 16px; }
.lb-subheader__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

/* "Now viewing" stage pill (with dropdown) ----------------- */
.lb-stage-pill { position: relative; justify-self: center; }
.lb-stage-pill__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem 0.5rem 0.75rem;
  border-radius: var(--te-radius-full);
  background: var(--surface-container);
  color: var(--on-surface);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: var(--te-shadow-sm);
  transition: background var(--te-transition-fast);
}
.lb-stage-pill__btn:hover { background: var(--surface-container-high); }
.lb-stage-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--te-radius-full);
  background: var(--te-win);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--te-win) 18%, transparent);
}
.lb-stage-pill__text { color: var(--on-surface-variant); }
.lb-stage-pill__text strong {
  color: var(--primary-container);
  font-weight: 700;
  margin-left: 0.1875rem;
}
.lb-stage-pill__chevron {
  width: 14px;
  height: 14px;
  color: var(--on-surface-variant);
  transition: transform var(--te-transition-fast);
}
.lb-stage-pill[data-open="true"] .lb-stage-pill__chevron { transform: rotate(180deg); }
.lb-stage-pill__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  margin: 0;
  padding: 0.375rem;
  list-style: none;
  background: var(--surface-container);
  border-radius: var(--te-radius-md);
  box-shadow: var(--te-shadow-lg);
  z-index: 50;
}
.lb-stage-pill__option {
  padding: 0.5rem 0.75rem;
  border-radius: var(--te-radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--on-surface);
  cursor: pointer;
  transition: background var(--te-transition-fast);
}
.lb-stage-pill__option:hover,
.lb-stage-pill__option:focus-visible {
  background: var(--surface-container-high);
  outline: none;
}
.lb-stage-pill__option.is-active {
  color: var(--primary-container);
  background: var(--te-accent-tint);
}

/* ── MAIN CONTENT AREA ────────────────────────────────────── */
.lb-main {
  flex: 1 1 auto;
  padding: 0.5rem 1.5rem 2.5rem;
  position: relative;
}
.lb-empty {
  text-align: center;
  padding: 3.5rem 1.25rem;
  max-width: 560px;
  margin: 1rem auto;
  background: var(--surface-container);
  border-radius: var(--te-radius-xl);
  box-shadow: var(--te-shadow-sm);
}
.lb-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: var(--te-radius-full);
  background: var(--te-accent-tint);
  color: var(--primary-container);
  margin: 0 auto 1.25rem;
}
.lb-empty__head {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}
.lb-empty__hint {
  margin: 0 0 1.25rem;
  color: var(--on-surface-variant);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.lb-empty__seasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0 0 1.5rem;
}
.lb-empty__season-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  color: var(--on-surface);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 700;
  transition: background var(--te-transition-fast), color var(--te-transition-fast);
}
.lb-empty__season-link:hover {
  background: var(--primary-container);
  color: var(--on-primary);
}
.lb-empty__cta {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: var(--te-radius-md);
  background: var(--primary-container);
  color: var(--on-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 700;
  transition: background var(--te-transition-fast);
}
.lb-empty__cta:hover {
  background: var(--primary);
  color: var(--on-primary);
}

.lb-banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: var(--te-accent-tint);
  color: var(--on-surface);
  border-radius: var(--te-radius-md);
  margin: 0 0 1rem;
  font-size: 0.875rem;
}
.lb-banner__icon {
  width: 18px;
  height: 18px;
  color: var(--primary-container);
  flex-shrink: 0;
}
.lb-banner strong {
  color: var(--primary-container);
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════════
   BRACKET VIEW
   ══════════════════════════════════════════════════════════ */
.lb-bracket-view { position: relative; }

/* Grid container — auto-flow columns. align-items:center
   makes shorter later-round columns sit vertically centered
   inside the longer R16 column → no empty space. */
.lb-rounds {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: 1.5rem;
  padding: 1.25rem 0.25rem 2rem;
  position: relative;
  z-index: 2;
  align-items: center;
  min-height: 540px;
}
/* Final card hero column — wider than the round columns. */
.lb-rounds > .lb-final {
  --lb-final-width: minmax(260px, 1.4fr);
  width: 100%;
}
.lb-rounds--collapsed .lb-round[data-collapsed="true"] { display: none; }

/* Round column --------------------------------------------- */
.lb-round {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  contain: layout;
  align-self: stretch;
  justify-content: center;
}
.lb-round__head {
  text-align: center;
  padding: 0 0.25rem 0.5rem;
}
.lb-round__name {
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
  margin: 0 0 0.375rem;
  color: var(--on-surface-variant);
  transition: color var(--te-transition-fast);
}
.lb-round--active .lb-round__name {
  color: var(--primary-container);
}
.lb-round--active .lb-round__head::after {
  content: '';
  display: block;
  width: 28px;
  height: 3px;
  margin: 0.25rem auto 0;
  background: var(--primary-container);
  border-radius: var(--te-radius-full);
}
.lb-round__dates {
  margin: 0;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  font-weight: 500;
}

/* Per-round vertical rhythm — gaps double per round so all
   columns visually align with the R16 pairs. */
.lb-round[data-round-index="0"] .lb-round__ties { gap: 0.875rem; }
.lb-round[data-round-index="1"] .lb-round__ties { gap: 4.25rem; }
.lb-round[data-round-index="2"] .lb-round__ties { gap: 11.25rem; }
.lb-round[data-round-index="3"] .lb-round__ties { gap: 25rem; }
.lb-round__ties {
  display: flex;
  flex-direction: column;
}

/* ── MATCH CARD ───────────────────────────────────────────── */
.lb-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  padding: 0.625rem 0.75rem 0.625rem 0.875rem;
  border-radius: var(--te-radius-lg);
  background: var(--surface-container);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--te-shadow-sm);
  transition:
    box-shadow var(--te-transition-base),
    transform var(--te-transition-fast),
    background var(--te-transition-base),
    opacity var(--te-transition-base);
  min-height: 76px;
  isolation: isolate;
}

/* Per-round card emphasis: later rounds get bigger padding
   and stronger surface tier. */
.lb-round[data-round-index="1"] .lb-card { padding: 0.75rem 0.875rem; min-height: 84px; }
.lb-round[data-round-index="2"] .lb-card { padding: 0.875rem 1rem;     min-height: 96px; background: var(--surface-container-high); }
.lb-round[data-round-index="3"] .lb-card { padding: 1rem 1.125rem;     min-height: 108px; background: var(--surface-container-high); }

.lb-card:hover {
  background: var(--surface-container-high);
  box-shadow: var(--te-shadow-md);
  transform: translateY(-1px);
}
.lb-round--active .lb-card {
  box-shadow: 0 0 0 2px var(--primary-container), var(--te-shadow-md);
}

/* ── Card states (visual distinction) ───────────────────── */
.lb-card--upcoming {
  background: var(--surface-container-low);
}
.lb-card--upcoming::before {
  content: '';
  position: absolute;
  left: 0; top: 14%; bottom: 14%;
  width: 3px;
  border-radius: 0 var(--te-radius-full) var(--te-radius-full) 0;
  background: var(--outline-variant);
  opacity: 0.7;
}
.lb-card--live {
  background: linear-gradient(180deg, color-mix(in srgb, var(--tertiary) 8%, var(--surface-container)), var(--surface-container));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tertiary) 35%, transparent), var(--te-shadow-sm);
}
.lb-card--live::before {
  content: '';
  position: absolute;
  left: 0; top: 14%; bottom: 14%;
  width: 3px;
  border-radius: 0 var(--te-radius-full) var(--te-radius-full) 0;
  background: var(--tertiary);
}
.lb-card--finished::before {
  content: '';
  position: absolute;
  left: 0; top: 14%; bottom: 14%;
  width: 3px;
  border-radius: 0 var(--te-radius-full) var(--te-radius-full) 0;
  background: var(--te-win);
  opacity: 0.85;
}
.lb-card--inplay::before {
  content: '';
  position: absolute;
  left: 0; top: 14%; bottom: 14%;
  width: 3px;
  border-radius: 0 var(--te-radius-full) var(--te-radius-full) 0;
  background: var(--te-draw);
}

/* ── Card status strip (top-right meta) ─────────────────── */
.lb-card__status {
  position: absolute;
  top: 0.4375rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 1;
  pointer-events: none;
}
.lb-card__live {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.4375rem 0.125rem 0.375rem;
  border-radius: var(--te-radius-full);
  background: var(--tertiary);
  color: var(--on-tertiary);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.lb-card__live-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--te-radius-full);
  background: var(--on-tertiary);
  animation: lb-pulse 1.6s ease-in-out infinite;
}
@keyframes lb-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}
.lb-card__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--te-radius-full);
  color: var(--te-win);
  background: color-mix(in srgb, var(--te-win) 18%, transparent);
}
.lb-card__chip {
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.125rem 0.375rem;
  border-radius: var(--te-radius-full);
  text-transform: uppercase;
}
.lb-card__chip--pen {
  background: color-mix(in srgb, var(--tertiary) 20%, transparent);
  color: var(--tertiary);
}
.lb-card__chip--aet {
  background: color-mix(in srgb, var(--te-draw) 20%, transparent);
  color: var(--te-draw);
}
.lb-card__kickoff {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--on-surface-variant);
  background: var(--surface-container-high);
  padding: 0.1875rem 0.4375rem;
  border-radius: var(--te-radius-full);
}

/* ── Card team rows ─────────────────────────────────────── */
.lb-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0;
  min-height: 26px;
  border-radius: var(--te-radius-sm);
  margin: 0 -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  transition: background var(--te-transition-fast);
}
.lb-card__row--loser .lb-card__name,
.lb-card__row--loser .lb-card__score,
.lb-card__row--loser .lb-card__agg {
  color: var(--on-surface-variant);
  font-weight: 500;
  opacity: 0.7;
}
.lb-card__row--winner .lb-card__name {
  font-weight: 700;
  color: var(--on-surface);
}
.lb-card__row--winner .lb-card__score {
  font-weight: 800;
  color: var(--on-surface);
}
.lb-card__row--winner::after {
  content: '';
  position: absolute;
  /* small inline winner accent dot — unobtrusive */
}
.lb-card__team {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}
.lb-card__logo {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  flex-shrink: 0;
  overflow: hidden;
}
.lb-round[data-round-index="2"] .lb-card__logo,
.lb-round[data-round-index="3"] .lb-card__logo {
  width: 26px;
  height: 26px;
}
.lb-card__logo img { width: 100%; height: 100%; object-fit: contain; }
.lb-card__logo-fallback { font-size: 0.625rem; font-weight: 700; color: var(--on-surface-variant); }
.lb-card__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lb-round[data-round-index="2"] .lb-card__name { font-size: 0.9375rem; }
.lb-round[data-round-index="3"] .lb-card__name { font-size: 1rem; font-weight: 700; }
.lb-card__scores {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  flex-shrink: 0;
}
.lb-card__agg {
  font-variant-numeric: tabular-nums;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  letter-spacing: 0.01em;
}
.lb-card__score {
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--on-surface);
  min-width: 14px;
  text-align: right;
}
.lb-round[data-round-index="2"] .lb-card__score { font-size: 1.0625rem; }
.lb-round[data-round-index="3"] .lb-card__score { font-size: 1.125rem; }
.lb-card__score--empty { color: var(--outline-variant); font-weight: 500; }

/* ── Card 3-column grid (reference layout) ──────────────────
   Col 1 = stacked team rows
   Col 2 = leg breakdown ("1st leg (H) 2-1" etc.)
   Col 3 = aggregate winner number + chevron
   ──────────────────────────────────────────────────────── */
.lb-card__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  column-gap: 0.875rem;
  align-items: center;
  width: 100%;
}
.lb-card__teams {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  min-width: 0;
}

/* Winner row tint (replaces the old empty ::after rule with a real cue). */
.lb-card__row--winner {
  background: color-mix(in srgb, var(--te-win) 12%, transparent);
  box-shadow: inset 2px 0 0 var(--te-win);
}

/* ── Leg breakdown column ───────────────────────────────── */
.lb-card__legs {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.lb-card__leg {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4375rem;
  justify-content: space-between;
}
.lb-card__leg-label {
  font-weight: 600;
}
.lb-card__leg-score {
  font-weight: 700;
  color: var(--on-surface);
}
.lb-card__leg--agg {
  margin-top: 0.1875rem;
  padding-top: 0.1875rem;
  border-top: 0;
  background: linear-gradient(to bottom, var(--outline-variant) 0 1px, transparent 1px);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: top;
}
.lb-card__leg--agg .lb-card__leg-label {
  color: var(--on-surface);
  font-weight: 700;
}
.lb-card__leg--agg .lb-card__leg-score {
  color: var(--te-win);
  font-weight: 800;
}

/* ── Aggregate / chevron column ─────────────────────────── */
.lb-card__agg-block {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  flex-shrink: 0;
}
.lb-card__agg-stack {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 1.5rem;
  font-variant-numeric: tabular-nums;
}
.lb-card__agg-winner {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--te-win);
  line-height: 1;
}
.lb-card__agg-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 0.1875rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--on-surface);
}
.lb-card__agg-sep {
  color: var(--on-surface-variant);
  font-weight: 500;
}
.lb-card__agg-empty {
  color: var(--outline-variant);
  font-size: 1rem;
  font-weight: 500;
}
.lb-card__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  flex-shrink: 0;
}
.lb-card:hover .lb-card__chevron {
  color: var(--primary-container);
  transform: translateX(1px);
  transition: transform var(--te-transition-fast), color var(--te-transition-fast);
}

/* Per-round emphasis for the aggregate winner number. */
.lb-round[data-round-index="2"] .lb-card__agg-winner { font-size: 1.75rem; }
.lb-round[data-round-index="3"] .lb-card__agg-winner { font-size: 1.875rem; }

/* ── TBD placeholder card ──────────────────────────────── */
.lb-card--tbd {
  opacity: 0.55;
  background: var(--surface-container-low);
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.lb-card--tbd:hover { background: var(--surface-container-low); transform: none; }
.lb-card__logo--tbd {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  font-weight: 700;
}
.lb-card__name--tbd {
  color: var(--on-surface-variant);
  font-style: italic;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ── TEAM PATH HIGHLIGHTING (hover) ─────────────────────── */
.lb-rounds[data-highlight-team] .lb-card,
.lb-rounds[data-highlight-team] .lb-final {
  opacity: 0.32;
  transform: scale(0.985);
  transition: opacity var(--te-transition-base), transform var(--te-transition-base);
}
.lb-rounds[data-highlight-team] .lb-card.is-on-path,
.lb-rounds[data-highlight-team] .lb-final.is-on-path {
  opacity: 1;
  transform: none;
}
.lb-rounds[data-highlight-team] .lb-card.is-on-path {
  box-shadow: 0 0 0 2px var(--primary-container), var(--te-shadow-md);
}
.lb-card[data-locked="true"] {
  box-shadow: 0 0 0 2px var(--primary-container), var(--te-shadow-md) !important;
}
.lb-card__row.is-on-team {
  background: var(--te-accent-tint);
}

/* ══════════════════════════════════════════════════════════
   FINAL CARD — hero treatment at the right edge
   ══════════════════════════════════════════════════════════ */
.lb-final {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  align-self: center;
  contain: layout;
}
.lb-final__head {
  text-align: center;
  padding-bottom: 0.25rem;
}
.lb-final__round-label {
  display: inline-block;
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
  color: var(--primary-container);
  margin: 0 0 0.25rem;
  position: relative;
  padding-bottom: 0.25rem;
}
.lb-final__round-label::after {
  content: '';
  display: block;
  width: 24px;
  height: 3px;
  margin: 0.25rem auto 0;
  background: var(--primary-container);
  border-radius: var(--te-radius-full);
}
.lb-final__date {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: 0.01em;
}
.lb-final__date--tbd {
  color: var(--on-surface-variant);
  font-weight: 600;
}
.lb-final__venue {
  margin: 0.125rem 0 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  letter-spacing: 0.01em;
}
/* ── Final match card (the actual match between Semis & Champion) ── */
.lb-final-match {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.875rem 1rem 1rem;
  border-radius: var(--te-radius-lg);
  background: var(--surface-container);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--te-shadow-sm);
  transition: box-shadow var(--te-transition-base), transform var(--te-transition-fast), background var(--te-transition-base);
  min-width: 240px;
}
.lb-final-match:hover {
  background: var(--surface-container-high);
  box-shadow: var(--te-shadow-md);
  transform: translateY(-1px);
}
.lb-final-match--decided {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-container) 25%, transparent), var(--te-shadow-sm);
}
.lb-final-match--live {
  background: linear-gradient(180deg, color-mix(in srgb, var(--tertiary) 8%, var(--surface-container)), var(--surface-container));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tertiary) 35%, transparent), var(--te-shadow-sm);
}
.lb-final-match--placeholder {
  background:
    repeating-linear-gradient(135deg, color-mix(in srgb, var(--primary-container) 5%, transparent) 0 6px, transparent 6px 14px),
    var(--surface-container);
}

.lb-final-match__status {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.125rem;
}
.lb-final-match__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.1875rem 0.4375rem;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}
.lb-final-match__pill--ft     { background: color-mix(in srgb, var(--te-win) 16%, transparent); color: var(--te-win); }
.lb-final-match__pill--pen    { background: color-mix(in srgb, var(--tertiary) 18%, transparent); color: var(--tertiary); }
.lb-final-match__pill--aet    { background: color-mix(in srgb, var(--te-draw) 20%, transparent); color: var(--te-draw); }
.lb-final-match__pill--live   { background: var(--tertiary); color: var(--on-tertiary); }
.lb-final-match__pill--upcoming {
  background: color-mix(in srgb, var(--primary-container) 14%, transparent);
  color: var(--primary-container);
}
.lb-final-match__pill--tbd {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}
.lb-final-match__pill--awaiting {
  background: color-mix(in srgb, var(--te-draw) 18%, transparent);
  color: var(--te-draw);
  cursor: help;
}
.lb-final-match__live-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--te-radius-full);
  background: var(--on-tertiary);
  animation: lb-pulse 1.6s ease-in-out infinite;
}

.lb-final-match__row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 0.625rem;
  padding: 0.3125rem 0.25rem;
  border-radius: var(--te-radius-sm);
  margin: 0 -0.25rem;
  transition: background var(--te-transition-fast);
}
.lb-final-match__row--loser .lb-final-match__name,
.lb-final-match__row--loser .lb-final-match__score {
  color: var(--on-surface-variant);
  font-weight: 500;
  opacity: 0.7;
}
.lb-final-match__row--winner .lb-final-match__name { font-weight: 800; color: var(--on-surface); }
.lb-final-match__row--winner .lb-final-match__score { font-weight: 900; color: var(--on-surface); }
.lb-final-match__logo {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  overflow: hidden;
  flex-shrink: 0;
}
.lb-final-match__logo img { width: 100%; height: 100%; object-fit: contain; }
.lb-final-match__logo span { font-size: 0.6875rem; font-weight: 800; color: var(--on-surface-variant); }
.lb-final-match__logo--tbd { background: var(--surface-container-low); }
.lb-final-match__name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lb-final-match__name--tbd {
  color: var(--on-surface-variant);
  font-style: italic;
  font-weight: 600;
  font-size: 0.8125rem;
}
.lb-final-match__score {
  font-variant-numeric: tabular-nums;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--on-surface);
  min-width: 18px;
  text-align: right;
}

/* ── Champion card (sits BELOW the final match card) ── */
.lb-final-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.125rem 1.25rem 1.25rem;
  border-radius: var(--te-radius-xl);
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--primary-container) 14%, transparent), transparent 70%),
    var(--surface-container);
  box-shadow:
    0 0 0 2px var(--primary-container),
    0 30px 60px color-mix(in srgb, var(--primary-container) 14%, transparent),
    var(--te-shadow-lg);
  min-width: 240px;
  text-align: center;
}
.lb-final-card__shield,
.lb-final-card__crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.125rem;
  color: var(--on-surface-variant);
}
.lb-final-card--champion .lb-final-card__crown { color: var(--primary-container); }
.lb-final-card__label {
  font-size: var(--te-label-size);
  font-weight: var(--te-label-weight);
  letter-spacing: var(--te-label-spacing);
  text-transform: uppercase;
  color: var(--primary-container);
  margin: 0;
}

/* Champion hero ------------------------------------------- */
.lb-final-card__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.lb-final-card__hero-logo {
  width: 76px;
  height: 76px;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--te-shadow-md);
}
.lb-final-card__hero-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.lb-final-card__hero-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--on-surface);
  margin: 0;
  letter-spacing: -0.01em;
}

/* Upcoming matchup ---------------------------------------- */
.lb-final-card__matchup {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.25rem;
  width: 100%;
}
.lb-final-card__side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}
.lb-final-card__side-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.lb-final-card__side-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.lb-final-card__side-logo span {
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--on-surface-variant);
}
.lb-final-card__side-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--on-surface);
  margin: 0;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
}
.lb-final-card__vs {
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  background: var(--surface-container-high);
  padding: 0.25rem 0.4375rem;
  border-radius: var(--te-radius-full);
}
.lb-final-card__chip {
  margin-top: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3125rem 0.75rem;
  border-radius: var(--te-radius-full);
  background: color-mix(in srgb, var(--te-draw) 20%, transparent);
  color: var(--te-draw);
}

/* Placeholder Final card — Final exists in the bracket map but the
   tie hasn't been built yet (TBD teams, sometimes TBD date). */
.lb-final-card--placeholder {
  background:
    repeating-linear-gradient(135deg, color-mix(in srgb, var(--primary-container) 5%, transparent) 0 6px, transparent 6px 14px),
    var(--surface-container);
}
.lb-final-card__side-logo--tbd {
  background: var(--surface-container-low);
  color: var(--on-surface-variant);
  font-size: 1.25rem;
  font-weight: 800;
}
.lb-final-card__side-name--tbd {
  color: var(--on-surface-variant);
  font-style: italic;
  font-weight: 600;
  font-size: 0.8125rem;
}

/* ══════════════════════════════════════════════════════════
   SVG CONNECTORS
   ══════════════════════════════════════════════════════════ */
.lb-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
.lb-connectors path {
  fill: none;
  stroke: var(--outline-variant);
  stroke-width: 2;
  opacity: 0.5;
  transition: opacity var(--te-transition-fast), stroke var(--te-transition-fast);
}
.lb-connectors path[data-active="true"] {
  stroke: var(--primary-container);
  stroke-width: 2.5;
  opacity: 1;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--primary-container) 35%, transparent));
}
.lb-rounds[data-highlight-team] ~ .lb-connectors path,
.lb-bracket-view:has(.lb-rounds[data-highlight-team]) .lb-connectors path {
  opacity: 0.18;
}
.lb-bracket-view:has(.lb-rounds[data-highlight-team]) .lb-connectors path[data-team-path="true"] {
  stroke: var(--primary-container);
  stroke-width: 2.5;
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════
   COMPACT (LIST) VIEW
   ══════════════════════════════════════════════════════════ */
.lb-list-view {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 1rem;
}
.lb-list-round {
  background: var(--surface-container);
  border-radius: var(--te-radius-lg);
  box-shadow: var(--te-shadow-sm);
  overflow: hidden;
}
.lb-list-round__summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  user-select: none;
}
.lb-list-round__summary::-webkit-details-marker { display: none; }
.lb-list-round__name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--on-surface);
}
.lb-list-round__dates {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  font-weight: 500;
  flex: 1 1 auto;
}
.lb-list-round__count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--on-surface-variant);
  padding: 0.1875rem 0.5rem;
  border-radius: var(--te-radius-full);
  background: var(--surface-container-high);
}
.lb-list-round__body {
  padding: 0.5rem 0.625rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lb-card--compact { background: var(--surface-container-low); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  .lb-rounds { grid-auto-columns: minmax(260px, 1fr); gap: 1.25rem; }
  .lb-rounds > .lb-final { --lb-final-width: minmax(260px, 1.4fr); }
}
@media (max-width: 992px) {
  .lb-header, .lb-subheader { padding-left: 1rem; padding-right: 1rem; }
  .lb-header__title { font-size: 1.125rem; }
  .lb-rounds {
    grid-auto-columns: 280px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
    align-items: start;
    min-height: 0;
  }
  .lb-round { scroll-snap-align: start; }
  .lb-final { scroll-snap-align: start; }
  /* On smaller screens we collapse the per-round explosive gaps so columns
     don't become 2000px tall. The bracket becomes more list-like. */
  .lb-round[data-round-index="1"] .lb-round__ties { gap: 1.25rem; }
  .lb-round[data-round-index="2"] .lb-round__ties { gap: 1.25rem; }
  .lb-round[data-round-index="3"] .lb-round__ties { gap: 1.25rem; }
  .lb-connectors { display: none; }
  .lb-subheader { grid-template-columns: auto 1fr auto; }
}
@media (max-width: 768px) {
  .lb-header { flex-wrap: wrap; gap: 0.75rem; }
  .lb-header__brand { flex: 1 1 100%; }
  .lb-header__actions { flex: 1 1 100%; justify-content: space-between; }
  .lb-btn .lb-btn__label { display: none; }
  .lb-btn--text .lb-btn__label { display: inline; }
  .lb-subheader { grid-template-columns: 1fr; text-align: center; }
  .lb-back, .lb-subheader__actions, .lb-stage-pill { justify-self: center; }
  /* Below 768 the list view is a much better experience — the JS
     auto-switches if the user hasn't manually picked a view. */
}

/* ── Theme dark — most tokens already invert. ─────────────── */
html.theme-dark .lb-connectors path { opacity: 0.4; }
html.theme-dark .lb-card__check { background: color-mix(in srgb, var(--te-win) 26%, transparent); }
html.theme-dark .lb-final-card {
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--primary-container) 22%, transparent), transparent 70%),
    var(--surface-container);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lb-card__live-dot { animation: none; }
  .lb-card, .lb-final, .lb-round, .lb-card__row, .lb-connectors path {
    transition: none;
  }
}
