/* ============================================================
   Tournament Bracket — Styles
   Spielegesellschaft Design System
   ============================================================ */

/* ── Container ── */

.tournament-bracket-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  font-family: var(--font-primary);
  color: var(--text-primary);
}

/* ── Alerts (bracket page) ── */

.tournament-bracket-container .alert {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  animation: bracketAlertIn 0.35s ease-out;
}

.tournament-bracket-container .alert-success {
  background: rgba(56, 142, 60, 0.15);
  color: #4caf50;
  border: 1px solid rgba(56, 142, 60, 0.3);
}

.tournament-bracket-container .alert-danger {
  background: rgba(211, 47, 47, 0.15);
  color: #ef5350;
  border: 1px solid rgba(211, 47, 47, 0.3);
}

@keyframes bracketAlertIn {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */

.bracket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.bracket-header h2 {
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.bracket-nav {
  flex-shrink: 0;
}

.bracket-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Buttons (bracket-scoped) ── */

.tournament-bracket-container .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.25rem;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.tournament-bracket-container .btn-primary {
  background: #5c6bc0;
  color: #fff;
  border-color: #5c6bc0;
}

.tournament-bracket-container .btn-primary:hover {
  background: #3f51b5;
  border-color: #3f51b5;
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.75rem rgba(92, 107, 192, 0.3);
}

.tournament-bracket-container .btn-success {
  background: #388e3c;
  color: #fff;
  border-color: #388e3c;
}

.tournament-bracket-container .btn-success:hover {
  background: #2e7d32;
  border-color: #2e7d32;
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.75rem rgba(56, 142, 60, 0.3);
}

.tournament-bracket-container .btn-danger {
  background: #d32f2f;
  color: #fff;
  border-color: #d32f2f;
}

.tournament-bracket-container .btn-danger:hover {
  background: #c62828;
  border-color: #c62828;
}

.tournament-bracket-container .btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.tournament-bracket-container .btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
}

.tournament-bracket-container .btn-secondary {
  background: var(--background-lighter);
  color: var(--text-primary);
  border-color: var(--background-lighter);
}

.tournament-bracket-container .btn-secondary:hover {
  opacity: 0.85;
}

.tournament-bracket-container .btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

.tournament-bracket-container .btn-xs {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* ── Empty State ── */

.bracket-empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--background-darker);
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.bracket-empty-state .empty-state-icon {
  font-size: 3rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  opacity: 0.6;
}

.bracket-empty-state h3 {
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
}

.bracket-empty-state p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0 0 1.5rem;
  line-height: 1.5;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.bracket-participant-preview {
  margin-top: 1.5rem;
  text-align: center;
}

.bracket-participant-preview h4 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.participant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.participant-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  background: rgba(25, 118, 210, 0.12);
  border: 1px solid rgba(25, 118, 210, 0.3);
  border-radius: 1rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

.text-muted {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================================
   Elimination Bracket (Single & Double)
   ============================================================ */

.elimination-bracket {
  overflow-x: auto;
  padding-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.bracket-rounds {
  display: flex;
  gap: 2rem;
  min-width: max-content;
  padding: 1rem 0;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 260px;
}

.round-header {
  margin-bottom: 0.5rem;
}

.round-header h3 {
  font-family: var(--font-secondary);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  text-align: center;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.round-matches {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  justify-content: space-around;
  flex: 1;
}

/* ── Match Card ── */

.bracket-match {
  background: var(--background-darker);
  border-radius: 0.5rem;
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bracket-match:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2);
}

.bracket-match .match-wrapper {
  display: flex;
  flex-direction: column;
}

.bracket-match .match-players {
  display: flex;
  flex-direction: column;
}

.bracket-match .match-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  transition: background 0.2s ease;
}

.bracket-match .match-player + .match-player {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bracket-match .match-player .player-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bracket-match .match-player .player-tbd {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  font-style: italic;
  flex: 1;
}

.bracket-match .match-player .player-score {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 1.75rem;
  text-align: center;
  padding: 0.15rem 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0.2rem;
  margin-left: 0.5rem;
}

/* Winner highlight */
.bracket-match .match-player.winner {
  background: rgba(56, 142, 60, 0.12);
}

.bracket-match .match-player.winner .player-name {
  color: #4caf50;
  font-weight: 700;
}

.bracket-match .match-player.winner .player-score {
  background: rgba(56, 142, 60, 0.25);
  color: #4caf50;
}

/* Match details / record button */
.bracket-match .match-details {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 2rem;
}

.edit-result-btn {
  padding: 0.15rem 0.4rem !important;
  font-size: 0.7rem !important;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.edit-result-btn:hover {
  opacity: 1;
}

.match-details .match-score + .edit-result-btn,
.round-robin-match .match-score + .edit-result-btn,
.swiss-match .match-score + .edit-result-btn {
  margin-left: 0.35rem;
}

.bracket-match .match-score {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.bracket-match .record-result-btn {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
}

/* ============================================================
   Round Robin Bracket
   ============================================================ */

.round-robin-bracket {
  margin-top: 1rem;
}

.round-robin-tabs,
.swiss-tabs {
  background: var(--background-darker);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ── Tab System ── */

.tab-headers {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1.5rem;
}

.tab-header {
  padding: 0.75rem 1.25rem;
  border-radius: 0.25rem 0.25rem 0 0;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-primary);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  margin-bottom: -1px;
}

.tab-header:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-header.active {
  color: var(--text-primary);
  border-bottom-color: #5c6bc0;
}

.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: tabFadeIn 0.25s ease-out;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(0.25rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Round Robin / Swiss Round ── */

.round-robin-round,
.swiss-round {
  margin-bottom: 2rem;
}

.round-robin-round:last-child,
.swiss-round:last-child {
  margin-bottom: 0;
}

.round-robin-round .round-header h3,
.swiss-round .round-header h3 {
  font-family: var(--font-secondary);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.round-robin-round .round-matches,
.swiss-round .round-matches {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Round Robin / Swiss Match ── */

.round-robin-match,
.swiss-match {
  background: var(--background);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.round-robin-match:hover,
.swiss-match:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12);
}

.round-robin-match .match-wrapper,
.swiss-match .match-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  gap: 1rem;
}

.round-robin-match .match-players,
.swiss-match .match-players {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.round-robin-match .match-player,
.swiss-match .match-player {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: 0.25rem;
  background: var(--background-darker);
  flex: 1;
  min-width: 0;
}

.round-robin-match .match-player .player-name,
.swiss-match .match-player .player-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-robin-match .match-player.winner,
.swiss-match .match-player.winner {
  background: rgba(56, 142, 60, 0.12);
}

.round-robin-match .match-player.winner .player-name,
.swiss-match .match-player.winner .player-name {
  color: #4caf50;
  font-weight: 700;
}

.match-vs {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.round-robin-match .match-details,
.swiss-match .match-details {
  flex-shrink: 0;
}

.round-robin-match .match-score,
.swiss-match .match-score {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.2rem;
}

/* ============================================================
   Standings Table
   ============================================================ */

.standings-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.standings-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  background: var(--background);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.standings-table td {
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.standings-table tr:last-child td {
  border-bottom: none;
}

.standings-table tbody tr {
  transition: background 0.15s ease;
}

.standings-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.standings-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.standings-table td strong {
  color: #5c6bc0;
}

/* ============================================================
   Match Matrix
   ============================================================ */

.match-matrix-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.match-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: center;
}

.match-matrix th {
  padding: 0.6rem 0.5rem;
  background: var(--background);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.match-matrix td {
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.match-matrix .matrix-cell {
  min-width: 2.5rem;
}

.match-matrix .matrix-self {
  color: var(--text-secondary);
  opacity: 0.4;
}

.match-matrix .matrix-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.25rem;
  font-weight: 700;
  font-size: 0.75rem;
}

.match-matrix .matrix-w {
  background: rgba(56, 142, 60, 0.2);
  color: #4caf50;
}

.match-matrix .matrix-l {
  background: rgba(211, 47, 47, 0.2);
  color: #ef5350;
}

.match-matrix .matrix-pending {
  color: var(--text-secondary);
  opacity: 0.4;
  font-size: 1.2rem;
}

/* ============================================================
   Swiss Bracket
   ============================================================ */

.swiss-bracket {
  margin-top: 1rem;
}

/* ============================================================
   Modal (generic overlay)
   ============================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal[style*="display: none"] {
  opacity: 0;
  visibility: hidden;
}

.modal.show,
.modal[style*="display: flex"] {
  opacity: 1;
  visibility: visible;
}

.modal .modal-dialog {
  width: 100%;
  max-width: 560px;
  margin: 1rem;
}

.modal .modal-content {
  background: var(--background-darker);
  border-radius: 1rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transform: translateY(1.25rem);
  transition: transform 0.3s ease;
}

.modal.show .modal-content,
.modal[style*="display: flex"] .modal-content {
  transform: translateY(0);
}

.modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal .modal-header .modal-title,
.modal .modal-header h3 {
  font-family: var(--font-secondary);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal .modal-header .close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal .modal-header .close:hover {
  color: var(--text-primary);
}

.modal .modal-body {
  padding: 1.5rem;
}

.modal .modal-body h4 {
  font-family: var(--font-secondary);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 1rem;
}

.modal .modal-body hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 1.5rem 0;
}

.modal .modal-body .text-muted {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Player Management (inside modal) ── */

.modal .participants {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal .participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--background);
  border-radius: 0.25rem;
  transition: background 0.15s ease;
}

.modal .participant-item:hover {
  background: var(--background-lighter);
}

.modal .participant-item .participant-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* ============================================================
   Record Result Modal
   ============================================================ */

.record-result-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.record-result-modal[style*="display: none"] {
  opacity: 0;
  visibility: hidden;
}

.record-result-modal.show,
.record-result-modal[style*="display: flex"] {
  opacity: 1;
  visibility: visible;
}

.record-result-modal .modal-content {
  width: 100%;
  max-width: 500px;
  margin: 1rem;
  background: var(--background-darker);
  border-radius: 1rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transform: translateY(1.25rem);
  transition: transform 0.3s ease;
}

.record-result-modal.show .modal-content {
  transform: translateY(0);
}

.record-result-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.record-result-modal .modal-header h4 {
  font-family: var(--font-secondary);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.record-result-modal .close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.record-result-modal .close-btn:hover {
  color: var(--text-primary);
}

.record-result-modal .modal-body {
  padding: 1.5rem;
}

/* ── Match Players Display ── */

.match-players-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.match-player-display {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  background: var(--background);
  border-radius: 0.5rem;
}

.vs-display {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ── Score Inputs ── */

.score-inputs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.score-inputs .input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.score-inputs label {
  display: block;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.score-inputs .form-control,
.score-inputs input[type="number"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--background);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.25rem;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -moz-appearance: textfield;
}

.score-inputs input[type="number"]::-webkit-inner-spin-button,
.score-inputs input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.score-inputs .form-control:focus,
.score-inputs input[type="number"]:focus {
  border-color: #5c6bc0;
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.25);
}

/* ── Record Result Actions ── */

.record-result-modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ── Form inside modal ── */

.modal .form-group {
  margin-bottom: 0.75rem;
}

.modal .form-group label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.modal .form-control {
  width: 100%;
  padding: 0.75rem;
  background: var(--background);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.25rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal .form-control:focus {
  border-color: #5c6bc0;
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.25);
}

/* ============================================================
   Light Mode Overrides
   ============================================================ */

[data-theme="light"] .bracket-empty-state {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tournament-bracket-container .btn-outline {
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text-primary);
}

[data-theme="light"] .tournament-bracket-container .btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .bracket-match {
  box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bracket-match:hover {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .bracket-match .match-player + .match-player {
  border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bracket-match .match-details {
  background: rgba(0, 0, 0, 0.02);
  border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bracket-match .match-player .player-score {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .round-robin-tabs,
[data-theme="light"] .swiss-tabs {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tab-headers {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tab-header:hover {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .round-header h3 {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .round-robin-round .round-header h3,
[data-theme="light"] .swiss-round .round-header h3 {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .round-robin-match,
[data-theme="light"] .swiss-match {
  background: var(--background);
}

[data-theme="light"] .round-robin-match:hover,
[data-theme="light"] .swiss-match:hover {
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .standings-table th {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .standings-table td {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .standings-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .standings-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .match-matrix th {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .match-matrix td {
  border-bottom-color: rgba(0, 0, 0, 0.05);
  border-right-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .modal .modal-content,
[data-theme="light"] .record-result-modal .modal-content {
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .modal .modal-header,
[data-theme="light"] .record-result-modal .modal-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal .modal-footer {
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal .modal-body hr {
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal .participant-item:hover {
  background: var(--background);
}

[data-theme="light"] .score-inputs .form-control,
[data-theme="light"] .score-inputs input[type="number"] {
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .match-player-display {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .modal .form-control {
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .bracket-match .match-player.winner {
  background: rgba(56, 142, 60, 0.1);
}

[data-theme="light"] .bracket-match .match-player.winner .player-name,
[data-theme="light"] .round-robin-match .match-player.winner .player-name,
[data-theme="light"] .swiss-match .match-player.winner .player-name {
  color: #2e7d32;
}

[data-theme="light"] .bracket-match .match-player.winner .player-score {
  color: #2e7d32;
}

[data-theme="light"] .alert-success {
  color: #2e7d32;
}

[data-theme="light"] .alert-danger {
  color: #c62828;
}

/* Fallback for prefers-color-scheme */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .bracket-match {
    box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.06);
  }

  :root:not([data-theme="dark"]) .bracket-match:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
  }

  :root:not([data-theme="dark"]) .bracket-empty-state {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
  }

  :root:not([data-theme="dark"]) .round-robin-tabs,
  :root:not([data-theme="dark"]) .swiss-tabs {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
  }

  :root:not([data-theme="dark"]) .tournament-bracket-container .btn-outline {
    border-color: rgba(0, 0, 0, 0.15);
  }

  :root:not([data-theme="dark"]) .tournament-bracket-container .btn-outline:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.25);
  }

  :root:not([data-theme="dark"]) .tab-headers {
    border-bottom-color: rgba(0, 0, 0, 0.08);
  }

  :root:not([data-theme="dark"]) .standings-table th {
    border-bottom-color: rgba(0, 0, 0, 0.1);
  }

  :root:not([data-theme="dark"]) .standings-table td {
    border-bottom-color: rgba(0, 0, 0, 0.05);
  }

  :root:not([data-theme="dark"]) .standings-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
  }

  :root:not([data-theme="dark"]) .standings-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.04);
  }

  :root:not([data-theme="dark"]) .score-inputs .form-control,
  :root:not([data-theme="dark"]) .score-inputs input[type="number"] {
    border-color: rgba(0, 0, 0, 0.12);
  }

  :root:not([data-theme="dark"]) .modal .form-control {
    border-color: rgba(0, 0, 0, 0.12);
  }

  :root:not([data-theme="dark"]) .match-player-display {
    background: rgba(0, 0, 0, 0.04);
  }
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .tournament-bracket-container {
    padding: 1.5rem 0.75rem;
  }

  .bracket-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bracket-header h2 {
    font-size: 1.25rem;
  }

  .bracket-controls {
    width: 100%;
  }

  .bracket-round {
    min-width: 220px;
  }

  .round-robin-tabs,
  .swiss-tabs {
    padding: 1rem;
  }

  .tab-headers {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }

  .tab-header {
    padding: 0.6rem 1rem;
    white-space: nowrap;
    font-size: 0.8rem;
  }

  .match-players-display {
    flex-direction: column;
    gap: 0.5rem;
  }

  .score-inputs {
    flex-direction: column;
  }

  .standings-table th,
  .standings-table td {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }

  .round-robin-match .match-wrapper,
  .swiss-match .match-wrapper {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .round-robin-match .match-details,
  .swiss-match .match-details {
    text-align: center;
  }
}

/* ============================================================
   Tournament Winner Display
   ============================================================ */

.tournament-winner-display {
  text-align: center;
  padding: 4rem 2rem;
  margin-top: 2rem;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.08), rgba(255, 152, 0, 0.05), rgba(255, 193, 7, 0.08));
  border: 1px solid rgba(255, 193, 7, 0.2);
  border-radius: 1rem;
  position: relative;
  overflow: hidden;
}

.tournament-winner-display::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ffc107, #ff9800, #ffc107, transparent);
}

/* Laurel wreath background icon */
.tournament-winner-display .winner-wreath {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  font-size: 18rem !important;
  color: #4caf50 !important;
  opacity: 0.1 !important;
  pointer-events: none !important;
  z-index: 0 !important;
  line-height: 1 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}

.winner-trophy,
.winner-label,
.winner-name,
.winner-tournament,
.winner-podium {
  position: relative;
  z-index: 1;
}

.winner-trophy {
  font-size: 3.5rem;
  color: #ffc107;
  margin-bottom: 1rem;
  animation: trophyBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(255, 193, 7, 0.3));
}

@keyframes trophyBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.winner-label {
  font-family: var(--font-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #ffc107;
  margin-bottom: 0.5rem;
}

.winner-name {
  font-family: var(--font-secondary);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.winner-tournament {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* ── Podium (for round robin / swiss) ── */

.winner-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  min-width: 120px;
  transition: transform 0.2s ease;
}

.podium-place:hover {
  transform: translateY(-3px);
}

.podium-1 {
  background: linear-gradient(180deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.05));
  border: 1px solid rgba(255, 193, 7, 0.3);
  order: 2;
  padding-bottom: 2rem;
}

.podium-2 {
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.12), rgba(192, 192, 192, 0.04));
  border: 1px solid rgba(192, 192, 192, 0.25);
  order: 1;
}

.podium-3 {
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.12), rgba(205, 127, 50, 0.04));
  border: 1px solid rgba(205, 127, 50, 0.25);
  order: 3;
}

.podium-medal {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.podium-1 .podium-medal {
  color: #ffc107;
  font-size: 1.75rem;
}

.podium-2 .podium-medal {
  color: #c0c0c0;
}

.podium-3 .podium-medal {
  color: #cd7f32;
}

.podium-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  text-align: center;
}

.podium-points {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Light mode ── */

[data-theme="light"] .tournament-winner-display {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.06), rgba(255, 152, 0, 0.03), rgba(255, 193, 7, 0.06));
  border-color: rgba(255, 193, 7, 0.25);
}

[data-theme="light"] .winner-podium {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* ── Responsive ── */

@media (max-width: 480px) {
  .winner-name {
    font-size: 1.75rem;
  }

  .winner-podium {
    flex-direction: column;
    align-items: center;
  }

  .podium-1, .podium-2, .podium-3 {
    order: unset;
    width: 100%;
    max-width: 240px;
  }

  .podium-1 {
    padding-bottom: 1.25rem;
  }
}

/* ============================================================
   Multiplayer Series
   ============================================================ */

.multiplayer-series-bracket {
  margin-top: 1.5rem;
}

.multiplayer-tabs {
  margin-top: 1rem;
}

.mp-round {
  margin-bottom: 2rem;
}

.mp-tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.mp-table-card {
  background: var(--background-darker);
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mp-table-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mp-table-card[data-match-status="completed"] {
  border-color: rgba(56, 142, 60, 0.3);
}

.mp-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.table-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge-success {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(56, 142, 60, 0.15);
  color: #4caf50;
  border: 1px solid rgba(56, 142, 60, 0.3);
}

.mp-table-players {
  padding: 0.5rem 0;
}

.mp-player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.mp-player-row:last-child {
  border-bottom: none;
}

.mp-player-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.mp-player-row .player-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.mp-player-row .player-score {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  min-width: 2.5rem;
  text-align: right;
}

.mp-player-row .player-score.pending {
  color: var(--text-secondary);
  opacity: 0.4;
  font-weight: 400;
}

.mp-table-actions {
  padding: 0.75rem 1rem;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Multiplayer score input rows in the modal */
.mp-score-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.mp-score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mp-score-row label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin: 0;
}

.mp-score-row input {
  width: 100px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

/* ── Light mode ── */

[data-theme="light"] .mp-table-card {
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .mp-table-header {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .mp-player-row {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .mp-player-row:nth-child(odd) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .mp-table-actions {
  border-top-color: rgba(0, 0, 0, 0.06);
}

@media (max-width: 480px) {
  .mp-tables {
    grid-template-columns: 1fr;
  }

  .mp-score-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }

  .mp-score-row input {
    width: 100%;
  }
}
