* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0f1117;
  color: #e1e4e8;
  min-height: 100vh;
}

a {
  color: #58a6ff;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* --- Header --- */

.header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #f0f6fc;
}

.header .badge {
  background: #238636;
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.header .badge.ended {
  background: #6e7681;
}

/* --- Status indicator --- */

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #8b949e;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6e7681;
}
.status-dot.connected {
  background: #3fb950;
}

/* --- Tournament List (index page) --- */

.tournament-list {
  max-width: 700px;
  margin: 40px auto;
  padding: 0 24px;
}

.tournament-list h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #f0f6fc;
}

.tournament-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.15s;
}
.tournament-card:hover {
  border-color: #58a6ff;
}

.tournament-card .info h3 {
  font-size: 16px;
  color: #f0f6fc;
  margin-bottom: 4px;
}

.tournament-card .info span {
  font-size: 13px;
  color: #8b949e;
}

.tournament-card .view-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.tournament-card.live {
  border-color: #238636;
}

.tournament-card .view-btn.live {
  background: #238636;
  border-color: #238636;
  color: #fff;
}
.tournament-card .view-btn.live:hover {
  background: #2ea043;
}

.tournament-card .view-btn:hover {
  background: #30363d;
}

.tournament-meta-detail {
  display: block;
  font-size: 12px;
  color: #6e7681;
  margin-top: 2px;
}

/* --- Pagination --- */

.pagination {
  max-width: 700px;
  margin: 0 auto 40px;
  padding: 0 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.page-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.page-btn:hover:not(:disabled) {
  background: #30363d;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-info {
  font-size: 13px;
  color: #8b949e;
}

.empty-state {
  text-align: center;
  color: #8b949e;
  padding: 60px 20px;
  font-size: 15px;
}

/* --- Bracket --- */

.bracket-container {
  padding: 24px;
  overflow-x: auto;
  min-height: calc(100vh - 60px);
}

.bracket {
  display: inline-flex;
  flex-direction: column;
  min-width: fit-content;
}

/* --- Headers row --- */

.bracket-headers {
  display: flex;
  align-items: stretch;
}

.bracket-header {
  width: 200px;
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 0 12px;
  border-bottom: 1px solid #30363d;
}

.bracket-header.active {
  color: #f0883e;
}

.bracket-header-spacer {
  width: 32px;
  flex-shrink: 0;
  border-bottom: 1px solid #30363d;
}

/* --- Bracket body --- */

.bracket-body {
  display: flex;
  align-items: stretch;
  padding-top: 16px;
}

/* --- Round column --- */

.bracket-round {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

/* --- Matchup --- */

.matchup {
  display: flex;
  flex-direction: column;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 4px;
}

.matchup.active {
  border-color: #f0883e;
  box-shadow: 0 0 8px rgba(240, 136, 62, 0.15);
}

.matchup-team {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.matchup-team + .matchup-team {
  border-top: 1px solid #21262d;
}

.matchup-team .name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.members-preview {
  font-size: 11px;
  color: #6e7681;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  cursor: help;
}

/* --- Team Tooltip --- */

.team-tooltip {
  position: absolute;
  z-index: 1000;
  background: #1c2128;
  border: 1px solid #444c56;
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.team-tooltip-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b949e;
  margin-bottom: 4px;
}

.team-tooltip-member {
  font-size: 13px;
  color: #e1e4e8;
  padding: 1px 0;
}

.matchup-team {
  cursor: default;
}

.matchup-team.winner {
  background: rgba(63, 185, 80, 0.08);
  border-left-color: #3fb950;
}
.matchup-team.winner .name {
  color: #3fb950;
  font-weight: 600;
}

.matchup-team.loser {
  border-left-color: #da3633;
}
.matchup-team.loser .name {
  color: #6e7681;
  text-decoration: line-through;
}

.matchup-team.active {
  border-left-color: #f0883e;
}
.matchup-team.active .name {
  color: #f0883e;
}

.matchup-team.pending {
  border-left-color: #30363d;
}
.matchup-team.pending .name {
  color: #8b949e;
}

.matchup-team.tbd {
  border-left-color: #21262d;
}
.matchup-team.tbd .name {
  color: #484f58;
  font-style: italic;
}

/* --- Connector lines --- */

.bracket-connectors {
  width: 32px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.connector-pair {
  flex: 1;
  position: relative;
  min-height: 40px;
}

/* Right bracket: top half connects to top matchup, bottom to bottom */
.connector-pair::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 50%;
  border: 1px solid #30363d;
  border-left: none;
  border-radius: 0 6px 6px 0;
}

/* Horizontal line from bracket to next round */
.connector-pair::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50%;
  border-top: 1px solid #30363d;
}

/* --- Champion --- */

.bracket-champion {
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
}

.champion-card {
  background: linear-gradient(135deg, #1a1e2a, #161b22);
  border: 2px solid #f0883e;
  border-radius: 8px;
  padding: 20px 24px;
  text-align: center;
  box-shadow: 0 0 20px rgba(240, 136, 62, 0.1);
}

.champion-card .trophy {
  font-size: 28px;
  margin-bottom: 8px;
}

.champion-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #f0883e;
  margin-bottom: 4px;
}

.champion-card .team-name {
  font-size: 18px;
  font-weight: 700;
  color: #f0f6fc;
}

.champion-card.empty .trophy {
  color: #484f58;
}
.champion-card.empty .team-name {
  color: #484f58;
  font-style: italic;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  .bracket-container {
    padding: 12px;
  }
  .bracket-round {
    width: 150px;
  }
  .bracket-header {
    width: 150px;
  }
  .matchup-team {
    padding: 6px 8px;
  }
  .matchup-team .name {
    font-size: 13px;
  }
}
