/* --- 추가된 깜빡임 애니메이션 --- */
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.tournament-container {
  display: flex;
  flex-direction: row;
  font-family: var(--font-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  overflow-x: auto;
  height: 100%;
}
body.light-mode .tournament-container {
  background-color: var(--bg-surface-light);
  border-color: var(--border-color-light);
}

.round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex-grow: 1;
}

.match {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 10px;
  position: relative;
}

.match:not(:last-child) {
  margin-bottom: 50px; /* 경기 간 간격 */
}

.connector {
  width: 20px;
  height: 50%; /* This will be half the match height */
  border: 2px solid var(--border-color);
  border-left: none;
  position: absolute;
  right: -20px;
}

.connector.top {
  top: 0;
  border-top-right-radius: 10px;
  border-bottom: none;
}

.connector.bottom {
  bottom: 0;
  border-bottom-right-radius: 10px;
  border-top: none;
}

.match-line {
  height: 2px;
  width: 20px;
  background-color: var(--border-color);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.connector.bridge {
  width: 20px;
  height: 2px;
  background-color: var(--border-color);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
}

.player {
  padding: 10px 15px;
  background-color: var(--bg-surface-accent);
  border-radius: 5px;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 200px;
  font-size: 14px;
  border: 1px solid var(--border-color);
}
body.light-mode .player {
  background-color: var(--bg-surface-accent-light);
  border-color: var(--border-color-light);
}
.player.winner {
  font-weight: bold;
  border-left: 4px solid var(--accent-green);
}
.player.loser {
  opacity: 0.6;
}
.player-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-score {
  font-weight: bold;
  color: var(--accent-red);
}

.final-match {
  align-self: center;
}

/* --- Full Bracket Modal Styles --- */
#full-bracket-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
}

.modal-title {
  text-align: center;
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 12px;
  flex-shrink: 0;
  display: none; /* 브라켓 모달에서는 제목 숨김 */
}

.bracket-symmetrical-container {
  display: flex;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  flex-grow: 1;
  min-height: 0;
  padding: 0;
}

.bracket-side {
  display: flex;
  flex-direction: row;
  flex-grow: 1;
  min-width: 0;
}

.bracket-symmetrical-container .bracket-side:last-child {
  flex-direction: row-reverse;
}

.bracket-center {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  padding: 0 15px;
  height: 100%;
}

.bracket-final-match,
.bracket-third-place-match {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bracket-final-match {
  margin-bottom: 40px;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex-grow: 1;
  min-width: 120px;
  padding: 3px;
}

.round-title {
  text-align: center;
  color: var(--text-secondary);
  font-size: 11px;
  margin: 0 0 4px 0;
  font-weight: 600;
  flex-shrink: 0;
}

.matches-container {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex-grow: 1;
  gap: 2px;
}

.bracket-match {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  flex-grow: 1;
  padding: 2px 0;
}

/* <<-- 1. 선수 박스 정렬 방식 수정 -->> */
.bracket-player {
  padding: 4px 8px; /* 좌우 패딩 재조정 */
  background-color: var(--bg-surface-accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  text-align: left;
  width: 140px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  margin: 2px auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  gap: 4px;
}

.bracket-player.placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
  justify-content: center;
}

body.light-mode .bracket-player {
  background-color: var(--bg-surface-accent-light);
  border-color: var(--border-color-light);
}

/* <<-- 1. 순위(Rank) 영역 고정 너비 설정 -->> */
.player-rank {
  font-weight: bold;
  color: var(--accent-blue);
  width: 28px; /* 고정 너비 부여 */
  text-align: center; /* 고정 너비 안에서 중앙 정렬 */
  margin-right: 4px; /* 이름과의 간격 */
  flex-shrink: 0; /* 너비가 줄어들지 않도록 설정 */
  font-size: 11px;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1; /* 남는 공간을 모두 차지하도록 설정 */
}

.player-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  min-width: 35px;
  text-align: right;
}

/* --- Symmetrical Connectors --- */
.bracket-side .bracket-match::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 1px;
  background-color: var(--border-color);
}
.bracket-side:first-child .bracket-match::after {
  left: 100%;
}
.bracket-side:last-child .bracket-match::after {
  right: 100%;
}

.bracket-side .bracket-match::before {
  content: "";
  position: absolute;
  height: calc(50% + 2px);
  width: 1px;
  background-color: var(--border-color);
}
.bracket-side:first-child .bracket-match::before {
  left: calc(100% + 8px);
}
.bracket-side:last-child .bracket-match::before {
  right: calc(100% + 8px);
}

.matches-container .bracket-match:nth-child(2n-1)::before {
  top: 50%;
}
.matches-container .bracket-match:nth-child(2n)::before {
  bottom: 50%;
}

.bracket-side .bracket-round:last-child .bracket-match::before {
  display: none;
}

.bracket-side .bracket-round:last-child .bracket-match::after {
  width: 15px;
}
.bracket-side:first-child .bracket-round:last-child .bracket-match::after {
  left: 100%;
}
.bracket-side:last-child .bracket-round:last-child .bracket-match::after {
  right: 100%;
}

/* --- Modal Footer --- */
.modal-footer-info {
  text-align: center;
  flex-shrink: 0;
}

.live-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

/* <<-- 2. LIVE 배지에 애니메이션 속성 추가 -->> */
.live-badge {
  background-color: var(--accent-red);
  color: white;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  animation: blink 1.5s ease-in-out infinite; /* 깜빡임 애니메이션 적용 */
}

#current-time {
  font-size: 14px;
  font-weight: 500;
}

.notice {
  font-size: 13px;
  color: var(white);
  margin: 0;
}
