/* Классическая печатная сетка TOP-32 — фиксированные высоты рядов */

.cb-sheet {
  --ink: #111;
  --line: #111;
  --r32: #9ecae8;
  --r16: #cbb6e0;
  --r8: #a8d994;
  --r4: #f0dea0;
  --final: #fff;
  --paper: #f4f2eb;
  --slot-h: 22px;
  --slot-w: 148px;
  --gap: 4px;
  --tree-h: 860px;
  --line-w: 14px;

  display: grid;
  grid-template-columns: 1fr 220px 1fr;
  gap: 0;
  width: 100%;
  min-width: 1280px;
  padding: 16px 12px 20px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  font-family: "Manrope", Arial, sans-serif;
}

/* ——— стороны ——— */
.cb-side {
  display: flex;
  height: var(--tree-h);
  min-width: 0;
}

.cb-side--left {
  flex-direction: row;
}

.cb-side--right {
  flex-direction: row;
}

.cb-round {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  padding: 0;
}

.cb-round--r32 { flex: 1.2 1 0; }
.cb-round--r16 { flex: 1.05 1 0; }
.cb-round--r8 { flex: 0.95 1 0; }
.cb-round--r4 { flex: 0.85 1 0; }

/* ячейка матча: высота пропорциональна units (flex-grow) */
.cb-cell {
  display: flex;
  align-items: center;
  position: relative;
  min-height: 0;
  box-sizing: border-box;
}

.cb-cell-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
}

.cb-side--left .cb-cell-inner {
  justify-content: flex-start;
  padding-right: var(--line-w);
}

.cb-side--right .cb-cell-inner {
  justify-content: flex-end;
  padding-left: var(--line-w);
}

.cb-duel {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: min(100%, calc(var(--slot-w) + 22px));
}

.cb-entry {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
}

.cb-entry.is-mirror {
  flex-direction: row;
}

.cb-seed {
  flex: 0 0 16px;
  width: 16px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  line-height: 1;
  color: #222;
}

.cb-box {
  flex: 1 1 auto;
  height: var(--slot-h);
  min-height: var(--slot-h);
  max-width: var(--slot-w);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px 0 5px;
  background: #fff;
  cursor: default;
}

.cb-box[data-pick] {
  cursor: pointer;
}

.cb-box[data-pick]:hover {
  outline: 2px solid rgba(225, 6, 0, 0.5);
  outline-offset: 0;
}

.cb-box.is-empty .cb-text {
  color: transparent;
}

.cb-box.is-winner {
  box-shadow: inset 0 0 0 2px #186a34;
}

.cb-tone-r32 { background: var(--r32); }
.cb-tone-r16 { background: var(--r16); }
.cb-tone-r8 { background: var(--r8); }
.cb-tone-r4 { background: var(--r4); }
.cb-tone-final { background: var(--final); }

.cb-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  color: #111;
  line-height: 1.1;
}

.cb-win {
  appearance: none;
  border: 1px solid #222;
  background: #fff;
  color: #111;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 3px;
  cursor: pointer;
  line-height: 1;
}

.cb-win.is-on {
  background: #186a34;
  border-color: #0f4a24;
  color: #fff;
}

/* ——— соединительные линии ———
   Горизонталь от матча + вертикаль между соседними ячейками пары.
*/
.cb-side--left .cb-round.has-lines .cb-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: var(--line-w);
  height: 1px;
  background: var(--line);
  z-index: 1;
}

.cb-side--right .cb-round.has-lines .cb-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--line-w);
  height: 1px;
  background: var(--line);
  z-index: 1;
}

/* вертикальные скобки: нечётная ячейка тянет линию вниз до следующей */
.cb-side--left .cb-round.has-lines .cb-cell:nth-child(odd)::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: var(--line-w);
  height: 100%;
  border-right: 1px solid var(--line);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 0;
}

.cb-side--right .cb-round.has-lines .cb-cell:nth-child(odd)::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--line-w);
  height: 100%;
  border-left: 1px solid var(--line);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 0;
}

/* вход в следующий раунд: короткая линия от середины пары */
.cb-side--left .cb-round.has-lines .cb-cell:nth-child(odd)::after {
  /* перекрываем простую горизонталь у нечётных: линия у края скобки */
  width: var(--line-w);
}

/* линия от полуфинала к центру */
.cb-side--left .cb-round--r4 .cb-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -8px;
  width: 16px;
  height: 1px;
  background: var(--line);
  z-index: 1;
}

.cb-side--right .cb-round--r4 .cb-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -8px;
  width: 16px;
  height: 1px;
  background: var(--line);
  z-index: 1;
}

/* ——— центр ——— */
.cb-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 4px 6px 8px;
  height: var(--tree-h);
  box-sizing: border-box;
}

.cb-center-head {
  text-align: center;
  margin-bottom: 4px;
}

.cb-center-sub {
  font-size: 12px;
  font-weight: 700;
  color: #333;
}

.cb-center-title {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 44px;
  letter-spacing: 0.06em;
  line-height: 1;
  color: #111;
}

.cb-final-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.cb-final-label {
  font-size: 12px;
  font-weight: 700;
  color: #222;
}

.cb-center .cb-duel {
  width: 170px;
}

.cb-center .cb-box {
  max-width: 170px;
}

.cb-places {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 190px;
}

.cb-place-row {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

.cb-place-box {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 22px;
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ——— страницы ——— */
.bracket-scroll {
  overflow: auto;
  padding: 0.75rem 1rem 1.5rem;
}

.bracket.is-classic {
  display: block !important;
  min-width: 1280px;
}

.vmix-body .cb-sheet {
  --tree-h: 920px;
  --slot-h: 24px;
  --slot-w: 162px;
  --gap: 4px;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 8px 10px 10px;
  box-shadow: none;
  border: none;
}

.vmix-body .cb-center-title {
  font-size: 48px;
}

.vmix-body .cb-text {
  font-size: 11.5px;
}

.vmix-bracket.is-classic {
  flex: 1;
  min-height: 0;
  display: block !important;
  overflow: hidden;
}

.vmix-bracket.is-classic .cb-sheet {
  height: 100%;
}

@media (max-width: 1200px) {
  .cb-sheet {
    min-width: 1200px;
  }
}
