/* bracket.css — public page: tabs, bracket layout, round view, team view */

/* ── Update notification bar ── */
.update-bar {
  background: var(--blue);
  color: #fff;
  text-align: center;
  padding: 0.35em 1em;
  font-family: 'Barlow', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  position: sticky;
  top: var(--hdr-h, 0px);
  z-index: 95;
  flex-shrink: 0;
}

/* ── Tabs ── */
.view-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 0.07em solid var(--border);
  position: sticky;
  top: calc(var(--hdr-h, 0px) + var(--bar-h, 0px));
  z-index: 90;
}
.view-tab {
  flex: 1;
  text-align: center;
  padding: 0.85em 0.3em;
  font-family: 'Oswald', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 0.18em solid transparent;
  transition: all 0.15s;
  min-height: 3em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon {
  width: 1.4em; height: 1.4em;
  flex-shrink: 0;
  display: none; /* shown only on mobile via media query */
}
.tab-label { line-height: 1; }
.view-tab.active { color: var(--blue-lt); border-bottom-color: var(--blue-lt); }
.view-tab:active { background: rgba(255,255,255,0.04); }

/* ── Panels ── */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* ── Selectors ── */
.selector-row {
  position: sticky;
  top: calc(var(--hdr-h, 0px) + var(--bar-h, 0px) + var(--tabs-h, 0px));
  z-index: 80;
  background: var(--surface);
  border-bottom: 0.15em solid var(--blue);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.selector-inner {
  max-width: 65em;
  margin: 0 auto;
  padding: 0.8em 1em;
  display: flex;
  gap: 0.6em;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Bucket Challenge leaderboard ── */
.bucket-status-wrap {
  flex-shrink: 0;
  padding: 0.9em 1em 0;
}
.bucket-status-bar {
  background: var(--surface2);
  border: 0.07em solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 0.55em 1.5em;
  font-family: 'Barlow', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-dim);
}
.bucket-panel {
  max-width: 42em;
  margin: 0 auto;
  padding: 0.35em 1em 3em;
}
.bucket-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}
.bucket-row {
  display: flex;
  align-items: center;
  gap: 0.75em;
  background: var(--surface);
  border: 0.07em solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75em 1em;
}
.bucket-rank {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-mute);
  min-width: 1.8em;
  text-align: center;
}
/* Medal backgrounds for top-3 rows */
.bucket-row--1 {
  background: var(--medal-gold-bg);
  border-color: var(--medal-gold-border);
}
.bucket-row--1 .bucket-rank,
.bucket-row--1 .bucket-team-name,
.bucket-row--1 .bucket-count { color: var(--medal-gold-text); }

.bucket-row--2 {
  background: var(--medal-silver-bg);
  border-color: var(--medal-silver-border);
}
.bucket-row--2 .bucket-rank,
.bucket-row--2 .bucket-team-name,
.bucket-row--2 .bucket-count { color: var(--medal-silver-text); }

.bucket-row--3 {
  background: var(--medal-bronze-bg);
  border-color: var(--medal-bronze-border);
}
.bucket-row--3 .bucket-rank,
.bucket-row--3 .bucket-team-name,
.bucket-row--3 .bucket-count { color: var(--medal-bronze-text); }

/* Frozen top-3 block — desktop: sticky below tabs/bar/header */
.bucket-frozen {
  position: sticky;
  top: calc(var(--hdr-h, 0px) + var(--bar-h, 0px) + var(--tabs-h, 0px));
  z-index: 70;
  background: var(--bg);
  max-width: 42em;
  margin: 0 auto;
  padding: 1em 1em 0.35em;
  border-bottom: 0.07em solid var(--border);
}
.bucket-leaderboard--top3 { gap: 0.35em; }
.bucket-team-name {
  flex: 1;
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.bucket-count {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-lt);
  min-width: 2.5em;
  text-align: right;
}
.bucket-icon-sm {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  opacity: 0.5;
  color: var(--text-dim);
}
.bucket-empty {
  text-align: center;
  color: var(--text-mute);
  padding: 3em 1em;
  font-style: italic;
}

/* ── Bucket edit mode (bucket-role users) ── */
.bucket-edit-wrap {
  max-width: 42em;
  margin: 0 auto;
  padding: 0.75em 1em 0.5em;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}
.bucket-edit-row {
  display: flex;
  align-items: center;
  gap: 0.75em;
  background: var(--surface);
  border: 0.07em solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6em 0.85em;
}
.bucket-edit-name {
  flex: 1;
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.bucket-edit-inp {
  width: 4.5em;
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
  background: var(--bg);
  border: 0.07em solid var(--border);
  border-radius: 0.25em;
  color: var(--blue-lt);
  padding: 0.2em 0.4em;
  font-size: 1rem; /* prevent iOS zoom */
}
.bucket-edit-actions {
  max-width: 42em;
  margin: 0 auto;
  padding: 0.75em 1em 3em;
  display: flex;
  align-items: center;
  gap: 0.65em;
}
.bucket-edit-save-btn,
.bucket-edit-cancel-btn {
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.4em 1.1em;
  border-radius: 0.25em;
  border: 0.07em solid var(--border);
  cursor: pointer;
}
.bucket-edit-save-btn {
  background: var(--blue-lt);
  color: #fff;
  border-color: var(--blue-lt);
}
.bucket-edit-save-btn:hover { opacity: 0.85; }
.bucket-edit-cancel-btn {
  background: transparent;
  color: var(--text-dim);
}
.bucket-edit-cancel-btn:hover { color: var(--text); border-color: var(--text-dim); }
.bucket-edit-status {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: 0.25em;
}

/* ── Round sections (By Round all-rounds layout) ── */
.round-section { max-width: 65em; margin: 0 auto; padding: 0 1em; }
.round-section-hdr {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-lt);
  padding: 1.2em 0 0.6em;
  border-bottom: 0.07em solid var(--border);
  margin-bottom: 1em;
}
.selector-row label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue-lt);
  flex-shrink: 0;
  font-weight: 600;
}
select.styled {
  font-family: 'Barlow', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75em 0.9em;
  border-radius: var(--radius-sm);
  border: 0.1em solid var(--blue);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  flex: 1;
  min-height: 3.2em;
}
select.styled:focus { outline: 0.13em solid var(--blue-lt); outline-offset: 0.07em; }

/* ════════════════════════════════════════════════════════════
   BRACKET LAYOUT
   ════════════════════════════════════════════════════════════ */

.bracket-outer {
  display: flex;
  align-items: flex-start;
  width: 100%;
  overflow-x: auto;
  padding: calc(var(--col-hdr-h) + 0.5em) 0 1em 0;
}

.bracket-side {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
}
.bracket-side.left-side  { justify-content: flex-end; }
.bracket-side.right-side { justify-content: flex-start; }

.rounds-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  position: relative;
  max-width: 65em;
  margin: 0 auto;
}

.round-col {
  position: relative;
  flex-shrink: 0;
  width: var(--col-w);
  height: calc(var(--slot-h) * 8);
}

.round-col-hdr {
  position: absolute;
  top: calc(var(--col-hdr-h) * -1.1);
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Oswald', sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  white-space: nowrap;
}

.round-gap {
  position: relative;
  flex-shrink: 0;
  width: var(--col-gap);
  height: calc(var(--slot-h) * 8);
}
.round-gap svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: visible;
}

/* ── Game card (bracket) ── */
.bc {
  position: absolute;
  left: 0;
  right: 0;
  min-height: var(--card-h);
  border: 0.07em solid var(--border);
  border-radius: var(--radius-sm);
  overflow: visible;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.bc-hdr {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.45em;
  background: var(--surface2);
  border-bottom: 0.07em solid var(--border);
  min-height: 0;
}
.bc-id {
  font-family: 'Oswald', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--blue-lt);
  white-space: nowrap;
}
.bc-time {
  font-size: 0.58rem;
  color: var(--gold-lt);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  text-align: right;
}
/* Desktop bracket team names: single line with ellipsis to prevent crowding */
.bc-team {
  flex: 1;
  padding: 0.2em 0.45em;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 0.07em solid var(--border);
  overflow: hidden;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 0.3em;
  min-height: var(--row-h);
}
.bc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-score {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 0.9em;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 2ch;
  text-align: right;
  letter-spacing: 0.02em;
}
.bc-team:last-child { border-bottom: none; }
.bc-team.tbd  { color: var(--text-mute); font-style: italic; font-weight: 400; font-size: 0.58rem; }
.bc-team.won  { color: var(--win-color); }
.bc-team.lost { color: var(--lose-color); text-decoration: line-through; opacity: 0.65; }

/* ── Championship center ── */
.champ-center {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 0.5em;
  background: rgba(196,154,26,0.04);
  border-left: 0.07em solid rgba(196,154,26,0.15);
  border-right: 0.07em solid rgba(196,154,26,0.15);
  width: var(--col-w);
  height: calc(var(--slot-h) * 8);
}
.champ-inner { width: 100%; text-align: center; }
.champ-trophy { font-size: 1.8em; margin-bottom: 0.3em; }
.champ-title {
  font-family: 'Oswald', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.3em;
}
.champ-gametime {
  font-size: 0.74rem;
  color: var(--gold-lt);
  font-weight: 600;
  margin-bottom: 0.5em;
}
.champ-bc { position: relative; height: var(--card-h); }
.champ-winner { font-family: 'Oswald', sans-serif; font-size: 0.95rem; color: var(--gold-lt); letter-spacing: 0.07em; margin-top: 0.5em; }

/* Bracket side label */
.bracket-side-label {
  display: block;
  width: fit-content;
  font-family: 'Oswald', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.15em 0.4em 0.15em 0;
  background: transparent;
  color: var(--text-dim);
  border-bottom: 0.1em solid var(--border);
  position: absolute;
  top: calc(var(--col-hdr-h) * -2);
  cursor: default;
  user-select: none;
}
.left-side  .bracket-side-label { left: 0; }
.right-side .bracket-side-label { right: 0; }

.bracket-side-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* ── Carousel round column header (tablet + mobile) ── */
.carousel-round-hdr {
  font-family: 'Oswald', sans-serif;
  font-size: 0.70rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-lt);
  text-align: center;
  padding: 0.3em 0 0.5em;
}

/* ── Mobile bracket (legacy classes, kept for compatibility) ── */
.mobile-bracket-wrap {
  width: 85vw;
  margin: 0 auto;
  overflow-x: auto;
  display: flex;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 0;
  scroll-padding-right: 15vw;
  padding-right: 15vw;
}
.mobile-bracket-section { flex: 0 0 85vw; width: 85vw; }
.mobile-bracket-label {
  padding: 0.5em 0 0.25em;
  font-family: 'Oswald', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.mobile-bracket-divider { margin: 0.5em 0; height: 0.07em; background: var(--border); }
.mobile-bracket-svg-wrap { overflow: visible; }

/* ── Round view ── */
.round-panel { padding: 0 0 1.5em; }
/* ── W/L legend ── */

/* ── Round games 2-column grid on desktop ── */
.round-games-grid { display: contents; }
@media (min-width: 1024px) {
  .round-games-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5em;
  }
}

.round-game-card {
  border: 0.07em solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 1.4em;
}
.round-game-card.upcoming {
  opacity: 0.75;
  border-style: dashed;
}
.round-game-header {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 1em;
  background: var(--surface2);
  border-bottom: 0.07em solid var(--border);
}
.round-game-id {
  font-family: 'Oswald', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--blue-lt);
  flex-shrink: 0;
}
.round-game-day-time { display: flex; align-items: baseline; gap: 0.45em; flex: 1; justify-content: flex-end; }
.round-game-day  { font-family: 'Oswald', sans-serif; font-size: 0.82rem; font-weight: 600; color: var(--text-dim); line-height: 1; }
.round-game-dow  { font-family: 'Oswald', sans-serif; font-size: 0.95rem; font-weight: 700; color: var(--gold-lt); line-height: 1; }
.round-game-time { font-family: 'Oswald', sans-serif; font-size: 0.95rem; font-weight: 700; color: var(--gold-lt); line-height: 1; }
.round-team-row {
  display: flex;
  align-items: center;
  padding: 0.75em 1em;
  border-bottom: 0.07em solid var(--border);
  min-height: 3.2em;
  gap: 0.6em;
}
.round-team-row:last-child { border-bottom: none; }
.round-team-name { font-size: clamp(1rem, 0.08vw + 0.98rem, 1.15rem); font-weight: 700; flex: 1; }
.round-team-name.tbd  { color: var(--text-mute); font-style: italic; font-weight: 400; }
.round-team-name.won  { color: var(--win-color); }
.round-team-name.lost { color: var(--lose-color); }
/* ── Team view ── */
.team-panel { max-width: 65em; margin: 0 auto; padding: 0 1em 1.5em; }
.team-no-games { padding: 1em; color: var(--text-mute); font-style: italic; }

/* Cards in the team panel show a lose-destination sidebar on the right */
.team-panel .round-game-card { display: flex; flex-direction: row; align-items: stretch; }
.round-game-main { flex: 1; min-width: 0; }
.round-lose-side {
  flex-shrink: 0;
  max-width: 25%;
  border-left: 0.07em solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  padding: 0.4em 0.25em;
  background: rgba(192,80,80,0.06);
}
.round-lose-tag {
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--lose-color);
}
.round-lose-arrow {
  font-size: 0.7rem;
  color: var(--lose-color);
  line-height: 1;
  opacity: 0.75;
}
.round-lose-dest {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-align: center;
}
.round-lose-dest.out { color: var(--lose-color); }
.round-lose-arrow--cont { color: var(--win-color); opacity: 1; }

/* ── Victory sidebar (shown when team won the game) ── */
.round-win-side {
  flex-shrink: 0;
  max-width: 25%;
  border-left: 0.07em solid var(--win-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  padding: 0.4em 0.2em;
  background: rgba(60, 160, 80, 0.10);
}
.round-win-img {
  width: 100%;
  height: auto;
  max-height: 60%;
  object-fit: contain;
  display: block;
}
.round-win-tag {
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--win-color);
  line-height: 1;
}

/* ── Team chip grid (empty state) ── */
.team-chips-prompt {
  max-width: 42em;
  margin: 1.2em auto 0.3em;
  padding: 0 1em;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.team-chips-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  padding: 1em 1em 2em;
  max-width: 42em;
  margin: 0 auto;
}
.team-chip {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 0.07em solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75em 1em;
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.team-chip:hover, .team-chip:active { background: var(--surface2); border-color: var(--blue-lt); color: var(--blue-lt); }
.team-chip.elim { opacity: 0.45; }
.team-view-name {
  padding: 0.5em 0 0.25em;
  font-family: 'Oswald', sans-serif;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.team-elim-inline {
  max-width: 42em;
  margin: 0.5em auto 0.5em;
  padding: 0 1em;
  text-align: center;
}
.team-elim-inline-img {
  width: 65%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-md);
  object-fit: contain;
}
.team-path-annotation {
  padding: 0.18em 0 0 0.5em;
  font-family: 'Oswald', sans-serif;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex;
  gap: 0.25em;
  align-items: center;
}
.team-path-annotation--terminal { padding-bottom: 0.5em; }
.team-path-connector {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0 0 0 0.5em;
  margin: 0.1em 0 0.6em;
}
.team-path-connector-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 1em;
  padding-left: 0.4em;
}
.team-path-connector-line {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--win-color);
  width: auto;
  height: auto;
  background: none;
}
.team-path-connector-line::before {
  content: '↓';
}
.team-path-connector-line.lose {
  background: none;
  border-left: none;
  color: var(--lose-color);
}
.team-path-win-label {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--win-color);
}
.color-win  { color: var(--win-color); }
.color-lose { color: var(--lose-color); }
.color-gold { color: var(--gold-lt); }
.team-path-label {
  padding: 0.6em 0.75em;
  font-size: 1.15rem;
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 0.2em solid currentColor;
  margin: 0.5em 0 1.4em;
  text-align: center;
}
.team-path-label.win-label  { color: var(--win-color); }
.team-path-label.lose-label { color: var(--lose-color); }
.team-path-divider { margin: 1.4em 0; height: 0.07em; background: var(--border); }

/* ── Championship bar (mobile/rounds) ── */
.champ-bar { margin: 0.4em 0 0.75em; padding: 0.65em 0.9em; background: var(--surface2); border-radius: var(--radius-sm); border: 0.07em solid var(--border); }
.champ-bar-label { font-family: 'Oswald', sans-serif; font-size: 0.68rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.5em; }
.champ-bar-teams { display: flex; gap: 0.5em; align-items: center; }
.champ-team-slot { flex: 1; border: 0.07em solid var(--border); border-radius: 0.25em; padding: 0.5em 0.75em; font-size: 0.96rem; font-weight: 600; color: var(--text); background: var(--surface); }
.champ-team-slot.tbd { color: var(--text-mute); font-style: italic; font-weight: 400; }
.champ-winner-display { margin-top: 0.6em; text-align: center; font-family: 'Oswald', sans-serif; font-size: 0.95rem; color: var(--gold-lt); letter-spacing: 0.07em; }

/* ════════════════════════════════════════════════════════════
   MOBILE LAYOUT (phones + tablets under 1024px)
   Snap-scroll carousel: one round visible at a time.
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1023px) {
  .update-bar { flex-shrink: 0; position: static; }

  .bracket-outer { display: none; }

  .bracket-side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .bracket-side.left-side,
  .bracket-side.right-side { justify-content: unset; }

  .bracket-side-label { position: static; margin-bottom: 0.5em; display: inline-block; font-size: 0.72rem; }

  .rounds-wrap {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    padding: 0.5em 0.5em 0.5em 0;
  }

  .round-col {
    flex-shrink: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    width: var(--col-w);
    height: auto;
    min-height: auto;
    position: relative;
    padding-right: 0.5em;
  }
  .round-col:last-child { padding-right: 1.5em; }

  .round-col-hdr {
    position: static;
    text-align: center;
    font-size: 0.70rem;
    color: var(--gold-lt);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.4em 0.2em;
    margin-bottom: 0.4em;
  }

  .round-gap { display: none; }

  .bc {
    position: relative;
    margin-bottom: 0.5em;
    border-radius: var(--radius-sm);
    min-height: auto;
  }
  .bc-hdr { padding: 0.33em 0.33em; font-size: 0.62rem; }
  .bc-id  { font-size: 0.58rem; }
  .bc-time { font-size: 0.58rem; }
  .bc-team {
    padding: 0.18em 0.33em;
    font-size: 0.65rem;
    min-height: 1.9em;
    line-height: 1.15;
    white-space: normal;
    word-break: break-word;
  }

  .champ-center {
    position: relative;
    width: auto;
    flex-shrink: 0;
    padding: 0.6em 0.5em;
    border-left: 0.07em solid rgba(196,154,26,0.15);
    border-right: none;
    border-top: none;
    border-bottom: none;
    margin: 0;
  }
  .champ-inner   { width: 100%; text-align: center; }
  .champ-title   { font-size: 0.62rem; margin-bottom: 0.2em; }
  .champ-gametime { font-size: 0.65rem; margin-bottom: 0.35em; }
  .champ-trophy  { font-size: 1.2em; margin-bottom: 0.15em; }
  .champ-bc      { position: relative; height: auto; margin-bottom: 0; }
  .champ-winner  { font-size: 0.80rem; margin-top: 0.3em; }
  .bracket-side-wrap { position: static; flex: 1; min-width: 0; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE BRACKET — two-column peek layout
   Current round (80vw) fully visible + next round peeks 20vw.
   Cards match By Round card style. Convergence is animated via
   JS-driven translateY blend as the user swipes between rounds.
   ════════════════════════════════════════════════════════════ */

/* Horizontal column container — JS-driven snap via scrollLeft */
.mbc-outer {
  display: flex;
  flex-direction: row;
  overflow-x: scroll;
  overflow-y: hidden;
  overscroll-behavior: none;
  width: 100%;
  scrollbar-width: none;
}
.mbc-outer::-webkit-scrollbar { display: none; }

/* One column per round — no CSS snap (JS handles it) */
.mbc-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Full-width vertical scroll overlay — the ONLY scroll container.
   Positioned below .mbc-hdr so the dot-navigation bar stays tappable.
   touch-action:pan-y lets iOS handle vertical with native momentum;
   horizontal swipes are detected in JS and forwarded to .mbc-outer. */
.mbc-scroll-cap {
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  scrollbar-width: none;
}
.mbc-scroll-cap::-webkit-scrollbar { display: none; }

/* Round name + progress dots — above the scroll area */
.mbc-hdr {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5em 1em 0.45em;
  background: var(--surface);
  border-bottom: 0.07em solid var(--border);
}
.mbc-hdr-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-lt);
}
.mbc-dots { display: flex; gap: 5px; align-items: center; }
.mbc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}
.mbc-dot.active { background: var(--blue-lt); transform: scale(1.35); }

/* Column scroll area — overflow:hidden; .mbc-scroll-cap overlay drives scroll */
.mbc-scroll {
  flex: 1;
  overflow: hidden;
}

/* Absolutely-positioned card container — width + height set by JS, centred horizontally */
.mbc-inner {
  position: relative;
  flex-shrink: 0;
  margin: 0 auto;
}

/* ── Championship card ── */
.mbc-champ-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, var(--surface2) 0%, #1e2e18 100%);
  border: 0.15em solid var(--gold);
  border-radius: var(--radius-md);
  box-shadow: 0 0 32px rgba(196,154,26,0.3), inset 0 1px 0 rgba(232,184,42,0.12);
  overflow: hidden;
}
/* Top info block */
.mbc-champ-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9em 1em 0.7em;
  gap: 0.2em;
  flex-shrink: 0;
}
.mbc-champ-trophy {
  font-size: calc(var(--mbc-card-h, 120px) * 0.22);
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(232,184,42,0.6));
}
.mbc-champ-label {
  font-family: 'Oswald', sans-serif;
  font-size: calc(var(--mbc-card-h, 120px) * 0.115);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.mbc-champ-time {
  font-size: calc(var(--mbc-card-h, 120px) * 0.085);
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
/* Separator */
.mbc-champ-sep {
  height: 0.07em;
  background: var(--gold);
  opacity: 0.35;
  flex-shrink: 0;
  margin: 0 1.2em;
}
/* Teams block fills remaining height */
.mbc-champ-teams {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5em 1.2em;
  gap: 0.15em;
  min-height: 0;
}
.mbc-champ-team {
  font-family: 'Barlow', sans-serif;
  font-size: calc(var(--mbc-card-h, 120px) * 0.155);
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4em;
  max-width: 100%;
}
.mbc-champ-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mbc-champ-team.tbd  { color: var(--text-mute); font-style: italic; font-weight: 400; font-size: calc(var(--mbc-card-h, 120px) * 0.115); }
.mbc-champ-team.won  { color: var(--win-color); }
.mbc-champ-team.lost { color: var(--lose-color); }
.mbc-champ-vs {
  font-size: calc(var(--mbc-card-h, 120px) * 0.075);
  color: var(--text-mute);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.mbc-champ-winner {
  flex-shrink: 0;
  padding: 0.5em 1.2em 0.6em;
  font-family: 'Oswald', sans-serif;
  font-size: calc(var(--mbc-card-h, 120px) * 0.10);
  font-weight: 700;
  color: var(--gold-lt);
  letter-spacing: 0.1em;
  text-align: center;
  border-top: 0.07em solid rgba(196,154,26,0.3);
}

/* Each card: absolute position, translateY driven by JS scroll blend */
.mbc-card {
  position: absolute;
  left: 0;
  right: 0;
}
.mbc-card .round-game-card { margin-bottom: 0; height: 100%; box-sizing: border-box; }

/* ── Mobile bracket: game card — top 25% header, bottom 75% teams ── */
.mbc-game-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 0.07em solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  box-sizing: border-box;
  transition: opacity 0.15s;
}
.mbc-game-card.upcoming {
  opacity: 0.65;
  border-style: dashed;
}
/* Each team row gets 3 flex-units = 37.5% of card (×2 = 75%) */
.mbc-game-team {
  flex: 3;
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0 0.7em;
  font-family: 'Barlow', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  min-height: 0;
  min-width: 0;
}
.mbc-game-team.tbd  {
  color: var(--text-mute);
  font-style: italic;
  font-weight: 400;
  font-size: 0.88rem;
}
.mbc-game-team.won  { color: var(--win-color); }
.mbc-game-team.lost { color: var(--lose-color); }
/* Name span: takes all space, truncates with ellipsis */
.mbc-team-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Header row gets 2 flex-units = 25% of card */
.mbc-game-mid {
  flex: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.9em;
  background: var(--surface2);
  border-bottom: 0.07em solid var(--border);
  min-height: 0;
}
.mbc-game-lbl {
  font-family: 'Oswald', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--blue-lt);
  flex-shrink: 0;
}
.mbc-game-datetime { display: flex; align-items: baseline; gap: 0.3em; }
.mbc-game-day {
  font-family: 'Oswald', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}
.mbc-game-dow {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-lt);
}
.mbc-game-time {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-lt);
}

/* ════════════════════════════════════════════════════════════
   MOBILE — flex-body layout: body is a locked column,
   tabs sit naturally at the bottom (no position:fixed needed),
   selector is fixed above tabs with no body-scroll jitter.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  /* Compact the header to reclaim vertical space */
  .header-timestamp { display: none !important; }
  .site-subtitle { font-size: 0.58em; margin-top: 0.05em; letter-spacing: 0.08em; }

  /* Viewport-locked flex column — body never scrolls, so position:fixed is rock-solid.
     Use height:100% (initial containing block) rather than 100dvh — on iOS, dvh can
     start from behind the notch/address bar and break safe-area layout. --app-h is set
     synchronously from window.innerHeight before first paint as a JS correction. */
  html { height: 100%; height: 100svh; height: var(--app-h, 100svh); }
  body { height: 100%; height: 100svh; height: var(--app-h, 100svh); overflow: hidden; display: flex; flex-direction: column; }
  /* position:sticky inside overflow:hidden body is a no-op and can break WebKit flex
     layout (content starts at y=0 behind the floating header). Use relative instead. */
  .site-header { flex-shrink: 0; position: relative; top: auto; }

  /* Tab bar: last flex item → naturally sits at the bottom, no position:fixed needed */
  .view-tabs {
    order: 10;
    flex-shrink: 0;
    position: relative; top: auto; bottom: auto;
    background: var(--bg);
    border-top: 0.22em solid var(--gold);
    border-bottom: none;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.55);
    padding-bottom: max(1em, env(safe-area-inset-bottom, 0px));
    padding-left: max(env(safe-area-inset-left, 0px), 1.2em);
    padding-right: max(env(safe-area-inset-right, 0px), 1.2em);
    z-index: 90;
  }
  .view-tab {
    min-height: 0;
    padding: 0.75em 0.5em 0.9em;
    border-bottom: none;
    border-top: 0.25em solid transparent;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    gap: 0.3em;
  }
  .tab-icon {
    display: block;
    width: 1.8em;
    height: 1.8em;
  }
  .view-tab.active {
    color: var(--gold-lt);
    border-top-color: var(--gold);
  }
  .view-tab.active .tab-icon {
    color: var(--gold-lt);
  }

  /* Active panels fill remaining space between header and tab bar */
  .view-panel.active { flex: 1; min-height: 0; overflow: hidden; }
  /* Schedule and teampath: flex column so selector row can sit naturally above tab bar */
  #view-schedule.active, #view-teampath.active {
    display: flex;
    flex-direction: column;
  }
  /* Content scrolls within the flex column; selector row is a static sibling below */
  #view-schedule.active .round-panel,
  #view-teampath.active .team-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;

    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }
  #view-schedule.active .round-panel::-webkit-scrollbar,
  #view-teampath.active .team-panel::-webkit-scrollbar { display: none; }

  #view-buckets.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  /* On mobile the frozen top-3 is a non-scrolling flex sibling */
  #view-buckets.active .bucket-frozen {
    position: static;
    flex-shrink: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0.75em 1em 0.35em;
    box-sizing: border-box;
    background: var(--bg);
    border-bottom: 0.07em solid var(--border);
  }
  #view-buckets.active .bucket-panel {
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
    overflow-y: auto;

    overscroll-behavior-y: contain;
    scrollbar-width: none;
  }
  #view-buckets.active .bucket-panel::-webkit-scrollbar { display: none; }

  /* Selector row: flex item at the bottom of its view panel — no position:fixed needed.
     Sits naturally above the tab bar via the outer body flex layout.
     Avoids iOS Safari safe-area timing issues that caused gaps with position:fixed. */
  #view-schedule.active .selector-row,
  #view-teampath.active .selector-row {
    position: static;
    top: auto;
    bottom: auto;
    background: var(--surface);
    border-top: 0.3em solid var(--gold);
    border-bottom: none;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
    z-index: 85;
    order: 10;
    flex-shrink: 0;
  }

  /* ── Team view mobile overrides ── */
  .team-path-label {
    font-size: 1.05rem;
    padding: 0.7em 1em;
  }
  .round-game-card {
    margin-bottom: 1em;
  }
  .round-game-header {
    padding: 0.6em 0.9em;
  }
  .round-team-row {
    padding: 0.85em 0.9em;
    min-height: 3.6em;
  }
  .round-team-name {
    font-size: 1.05rem;
  }
  .team-view-name {
    font-size: 1rem;
    padding: 0.6em 0 0.3em;
  }
}

@print {
  .site-header, .view-tabs, .header-controls, .theme-toggle, .selector-row { display: none; }
  body { background: #fff; color: #000; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
