/* Tournament bracket — shared (protocol, protocol_view, judje) */

tournament-bracket {
  display: block;
}

.tb-hint {
  margin: 0 0 12px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: #546e7a;
  background: #fafafa;
  border-left: 3px solid #90caf9;
  border-radius: 0 8px 8px 0;
}

.tb-hint--judge {
  border-left-color: #ffb74d;
  background: #fff8e1;
  color: #5d4037;
}

.tb-round-sub {
  text-align: center;
  font-size: 11px;
  color: #78909c;
  margin: -6px 0 8px;
}

.tb-match-head {
  display: flex;
  justify-content: flex-end;
  padding: 4px 8px 0;
  background: #fafafa;
}

.tb-status {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 10px;
}

.tb-status--done {
  background: #e8f5e9;
  color: #2e7d32;
}

.tb-status--pending {
  background: #fff8e1;
  color: #f57f17;
}

.tb-status--wait {
  background: #eceff1;
  color: #607d8b;
}

.tb-match--open {
  border-style: dashed;
  border-color: #cfd8dc;
}

.tb-match-row--tbd .tb-team-name__main {
  color: #90a4ae;
  font-style: italic;
}

.tb-win-mark {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: #43a047;
  border-radius: 50%;
}

.tb-team-name {
  flex: 1;
  min-width: 0;
}

.tb-team-name__main {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-match-score-center__label {
  display: none;
}

.tb-root--vertical .tb-match-score-center__label {
  display: inline;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #90a4ae;
  margin-right: 8px;
}

.tb-match-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}

.tb-score-btn--primary {
  background: #1976d2 !important;
  color: #fff !important;
}

/* Редактирование счёта (стыковые матчи на protocol, судья) */
.tb-match-card-edit .tb-match,
.tb-root--vertical .tb-match {
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  min-width: 260px;
  max-width: 360px;
}

.tb-match--clickable {
  cursor: pointer;
}

.tb-match--clickable:hover {
  border-color: #90caf9;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.12);
}

.tb-match--editing {
  border: 2px solid #039be5;
  box-shadow: 0 0 0 3px rgba(3, 155, 229, 0.18);
  cursor: default;
}

.tb-score-editor {
  margin: 8px 10px;
  padding: 12px;
  background: #f5fbff;
  border: 2px solid #039be5;
  border-radius: 10px;
}

.tb-score-editor__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: #1565c0;
  margin-bottom: 8px;
  text-align: center;
}

.tb-score-editor__inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tb-score-editor__sep {
  font-size: 22px;
  font-weight: 700;
  color: #546e7a;
  line-height: 1;
}

.tb-match-card-edit .tb-score-input,
.tb-root--vertical .tb-score-input {
  width: 64px;
  min-height: 44px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  border: 2px solid #039be5;
  border-radius: 8px;
  background: #fff;
  flex-shrink: 0;
  box-sizing: border-box;
}

.tb-match-card-edit .tb-score-input:focus,
.tb-root--vertical .tb-score-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.25);
}

.tb-match-card-edit .tb-score-btn,
.tb-root--vertical .tb-score-btn {
  min-height: 40px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.tb-match-card-edit .tb-score-btn:hover,
.tb-root--vertical .tb-score-btn:hover {
  background: #bbdefb;
}

.tb-match-card-edit .tb-score-btn:disabled,
.tb-root--vertical .tb-score-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tb-match-card-edit .tb-match-actions,
.tb-root--vertical .tb-match-actions {
  margin-top: 10px;
  padding: 0;
  border-top: none;
  background: transparent;
  justify-content: center;
}

.tb-match-score-center--clickable {
  cursor: pointer;
  background: #fafafa;
  border-top: 1px solid #eeeeee;
  border-bottom: 1px solid #eeeeee;
}

.tb-match-score-center--clickable:hover {
  background: #e3f2fd;
}

.tb-match-score-center__hint {
  display: block;
  font-size: 11px;
  color: #1976d2;
  margin-top: 4px;
  font-weight: 600;
}

.tb-match-card-edit .tb-match-row,
.tb-root--vertical .tb-match-row {
  min-height: 44px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.tb-match-card-edit .tb-match-score-center,
.tb-root--vertical .tb-match-score-center {
  padding: 10px 12px;
  text-align: center;
}

.tb-match-card-edit .tb-match-score-center__label,
.tb-root--vertical .tb-match-score-center__label {
  display: inline;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #90a4ae;
  margin-right: 8px;
}

.tb-match-card-edit .tb-match-score-center__value,
.tb-root--vertical .tb-match-score-center__value {
  font-size: 18px;
  font-weight: 700;
}

.tb-vertical-phase-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.tb-vertical-phase-progress {
  font-size: 12px;
  color: #78909c;
}

/* Компактные карточки в групповом этапе */
.tb-group-matches {
  padding: 8px 10px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tb-group-matches__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: #78909c;
  margin: 0 0 2px;
}

.tb-group-matches .tb-match {
  font-size: 12px;
}

.tb-group-matches .tb-match-row {
  min-height: 32px;
  padding: 5px 8px;
}

.tb-standings-hint {
  font-size: 11px;
  color: #78909c;
  padding: 4px 14px 8px;
  border-bottom: 1px solid #f0f0f0;
}

.tb-standings-hint kbd {
  font-family: inherit;
  background: #eceff1;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10px;
}

.tb-root--bracket {
  --tb-line: #78909c;
  --tb-line-w: 2px;
  --tb-join-w: 40px;
  --tb-col-gap: 16px;
  --tb-gap: 20px;
  --tb-round-gap: 20px;
}

.tb-root--bracket .tb-bracket {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--tb-round-gap);
  overflow-x: auto;
  padding: 12px 16px 28px;
  -webkit-overflow-scrolling: touch;
}

.tb-root--bracket .tb-round {
  position: relative;
  flex: 0 0 auto;
  min-width: 232px;
  max-width: 288px;
  padding: 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.tb-root--bracket .tb-round-label {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #e3f2fd;
  color: #1565c0;
  white-space: nowrap;
  width: 100%;
  max-width: 248px;
  box-sizing: border-box;
}

.tb-round-label {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #e3f2fd;
  color: #1565c0;
  white-space: nowrap;
}

.tb-round-label--final {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}

.tb-round-label--third {
  background: #f3e5f5;
  color: #7b1fa2;
}

.tb-round-label--winners {
  background: #c8e6c9;
  color: #2e7d32;
}

.tb-round-label--losers {
  background: #ffcdd2;
  color: #c62828;
}

.tb-round-label--grand {
  background: #ffe0b2;
  color: #e65100;
}

.tb-round-body {
  position: relative;
  min-height: 48px;
}

.tb-root--bracket .tb-round-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tb-root--bracket .tb-round-sub {
  width: 100%;
  max-width: 248px;
  text-align: center;
}

.tb-match-wrap {
  position: relative;
  z-index: 2;
}

/* Парный блок: карточки + линии поверх (одна система координат) */
.tb-root--bracket .tb-match-pair {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 268px;
  margin-left: auto;
  margin-right: auto;
  padding-right: calc(var(--tb-join-w) + var(--tb-col-gap));
}

.tb-root--bracket .tb-match-pair--connect-in {
  padding-left: calc(var(--tb-round-gap) / 2 + 4px);
}

.tb-root--bracket .tb-match-pair__games {
  position: relative;
  min-width: 0;
  z-index: 2;
}

.tb-root--bracket .tb-match-pair__games--dual {
  display: flex;
  flex-direction: column;
  gap: var(--tb-gap);
  justify-content: center;
}

.tb-root--bracket .tb-match-pair__games--dual .tb-match-slot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
}

.tb-root--bracket .tb-match-pair__games--solo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.tb-root--bracket .tb-match-slot {
  position: relative;
  width: 100%;
}

.tb-root--bracket .tb-match-wrap {
  width: 100%;
}

.tb-root--bracket .tb-match {
  width: 100%;
}

/* Линии — слой поверх блока карточек, те же координаты */
.tb-root--bracket .tb-bracket-join {
  position: absolute;
  top: 0;
  left: 100%;
  margin-left: var(--tb-col-gap);
  width: var(--tb-join-w);
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.tb-root--bracket .tb-join-spine {
  position: absolute;
  left: 0;
  top: var(--spine-top, 0);
  height: var(--spine-height, 0);
  width: var(--tb-line-w);
  background: var(--tb-line);
  border-radius: 1px;
}

.tb-root--bracket .tb-join-arm {
  position: absolute;
  right: 100%;
  margin-right: var(--tb-col-gap);
  height: var(--tb-line-w);
  background: var(--tb-line);
  border-radius: 1px;
  width: var(--tb-col-gap);
  margin-top: calc(var(--tb-line-w) / -2);
}

.tb-root--bracket .tb-join-arm--top {
  top: var(--arm-top, 0);
}

.tb-root--bracket .tb-join-arm--bottom {
  top: var(--arm-bottom, 0);
}

.tb-root--bracket .tb-join-exit {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--exit-y, 0);
  height: 0;
  margin-top: calc(var(--tb-line-w) / -2);
  pointer-events: none;
}

.tb-root--bracket .tb-join-exit::before {
  content: '';
  position: absolute;
  left: 0;
  right: 10px;
  top: 0;
  height: var(--tb-line-w);
  background: var(--tb-line);
  border-radius: 1px;
}

.tb-root--bracket .tb-join-arrow {
  position: absolute;
  right: 0;
  top: calc(var(--tb-line-w) / -2);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--tb-line);
}

.tb-root--bracket .tb-match-pair--solo .tb-join-exit::before {
  left: calc(-1 * var(--tb-col-gap));
  right: 10px;
}

/* Входящая линия слева */
.tb-root--bracket .tb-bracket-in {
  position: absolute;
  left: 0;
  width: calc(var(--tb-round-gap) / 2 + 4px);
  height: var(--tb-line-w);
  margin-top: calc(var(--tb-line-w) / -2);
  background: var(--tb-line);
  pointer-events: none;
  z-index: 1;
  border-radius: 1px;
}

.tb-match {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tb-match--final {
  border: 2px solid #ff9800;
}

.tb-match--winners {
  border-color: #a5d6a7;
}

.tb-match--losers {
  border-color: #ef9a9a;
}

.tb-match-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.25;
  min-height: 36px;
}

.tb-match-row + .tb-match-row {
  border-top: 1px solid #f0f0f0;
}

.tb-match-row--winner {
  background: #e8f5e9;
  font-weight: 600;
}

.tb-match-score-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  background: #fafafa;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 800;
  font-size: 14px;
  color: #333;
  letter-spacing: 0.5px;
}

.tb-match-score-center--pending {
  color: #bbb;
  font-weight: 600;
}

.tb-id-badge {
  display: inline-block;
  background: #e3f2fd;
  color: #1565c0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
}

.tb-team-sub {
  font-size: 10px;
  color: #888;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Double-elim tracks */
.tb-track {
  margin-bottom: 20px;
}

.tb-track-title {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 5px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.tb-track-title--winners {
  background: #e8f5e9;
  color: #2e7d32;
}

.tb-track-title--losers {
  background: #ffebee;
  color: #c62828;
}

.tb-track-title--grand {
  background: #fff3e0;
  color: #e65100;
}

/* Vertical layout (judge) */
.tb-root--vertical .tb-vertical-phase {
  margin-bottom: 18px;
}

.tb-root--vertical .tb-vertical-phase-label {
  font-weight: 700;
  font-size: 14px;
  color: #444;
  margin-bottom: 10px;
  padding: 6px 12px;
  background: #fff3e0;
  border-radius: 8px;
  display: inline-block;
}

.tb-root--vertical .tb-vertical-matches {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tb-root--vertical .tb-match {
  max-width: 520px;
}

.tb-root--vertical .tb-match-row {
  min-height: 44px;
  padding: 10px 12px;
}

.tb-root--vertical .tb-score-input {
  width: 56px;
  min-height: 40px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  border: 2px solid #039be5;
  border-radius: 8px;
  flex-shrink: 0;
}

.tb-root--vertical .tb-score-btn {
  min-height: 40px;
  min-width: 44px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.tb-root--vertical .tb-score-btn:hover {
  background: #bbdefb;
}

.tb-root--vertical .tb-score-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tb-root--vertical .tb-score-display {
  min-width: 48px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
  background: #f5f5f5;
  cursor: pointer;
  flex-shrink: 0;
}

.tb-root--vertical .tb-score-display--empty {
  color: #bbb;
}

.tb-root--vertical .tb-score-display--locked {
  cursor: default;
}

@media (max-width: 720px) {
  .tb-root--bracket .tb-bracket {
    flex-direction: column;
    align-items: stretch;
  }

  .tb-round {
    min-width: unset;
    max-width: none;
    padding: 0 0 16px;
  }

  .tb-root--bracket .tb-bracket-join,
  .tb-root--bracket .tb-bracket-in {
    display: none;
  }

  .tb-root--bracket .tb-match-pair {
    margin-top: 0 !important;
    padding-right: 0;
    padding-left: 0;
  }

  .tb-round-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
}
