.tournament-round-flow {
  --round-flow-match-width: var(--client-bracket-slot-width, 186px);
  --round-flow-column-gap: 20px;
}

.tournament-admin-form[data-tournament-type="5"] .tournament-round-flow {
  --round-flow-match-width: 320px;
}

.wrap-tournament-table:has(> .tournament-round-flow),
.client-bracket-view .wrap-tournament-table:has(> .tournament-round-flow),
.client-bracket-view .wrap-tournament-result.is-client-bracket-expanded .wrap-tournament-table:has(> .tournament-round-flow),
.tournament-admin-form #bracket_content > .wrap-tournament-table:has(> .tournament-round-flow) {
  box-sizing: border-box;
  max-height: none;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  width: 100% !important;
}

.tournament-admin-form #bracket_content ._ntournament:has(.tournament-round-flow) {
  max-height: none;
  overflow: visible;
}

.wrap-tournament-table .tournament-round-flow > .tab.active,
.client-bracket-view .wrap-tournament-table .tournament-round-flow > .tab.active {
  overflow: visible;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .wrap-block {
  display: flex;
  min-width: 100%;
  width: max-content !important;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .block-content.active {
  align-items: flex-start;
  column-gap: 32px;
  display: flex;
  flex: 1 0 auto;
  justify-content: flex-start;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .block-content > .wrap-title {
  display: none;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .wrap-round {
  flex: 0 0 auto;
  min-width: var(--round-flow-match-width);
  width: max-content !important;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .round-number,
.wrap-tournament-table .tournament-round-flow .winners-tab .bracket-round-details {
  box-sizing: border-box;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
}

.wrap-tournament-table .tournament-round-flow .winners-tab .round-number {
  text-align: left;
}

.bracket-round-matches {
  column-gap: var(--round-flow-column-gap);
  display: grid;
  grid-auto-columns: var(--round-flow-match-width);
  grid-auto-flow: column;
  grid-template-rows: repeat(5, max-content);
  row-gap: 16px;
  width: max-content;
}

/* The legacy wrappers group two matches; each complete match must fill one grid cell. */
.wrap-tournament-table .tournament-round-flow .bracket-round-matches > .wrap-4-slots,
.wrap-tournament-table .tournament-round-flow .bracket-round-matches > .wrap-4-slots > .slots {
  display: contents;
}

.wrap-tournament-table .tournament-round-flow .bracket-round-matches .wrap-2-slots {
  height: auto !important;
  margin: 0 !important;
  width: var(--round-flow-match-width);
}

.tournament-round-flow:focus-visible {
  outline: 3px solid #6f63f6;
  outline-offset: -3px;
}
