/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 900px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--neutral);
  cursor: pointer;
  line-height: 1;
  padding: .1rem .3rem;
  border-radius: 4px;
  transition: background .1s;
}
.modal-close:hover { background: var(--neutral-light); color: var(--neutral-dark); }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.modal-footer {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-shrink: 0;
}

/* ===== LEAGUE DETAIL ===== */
.league-detail { display: flex; flex-direction: column; gap: 1.25rem; }

.standings-table, .fixtures-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.standings-table th, .fixtures-table th {
  background: var(--neutral-light);
  padding: .5rem .75rem;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .3px;
  border-bottom: 2px solid var(--border);
}
.standings-table td, .fixtures-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.standings-table tr:last-child td,
.fixtures-table tr:last-child td { border-bottom: none; }
.standings-table tbody tr:hover,
.fixtures-table tbody tr:hover { background: var(--neutral-light); }
.standings-table .school-color { width: 6px; padding: 0; }

.fixture-result { display: flex; align-items: center; gap: .5rem; }
.score-input { width: 40px; padding: .25rem .35rem; border: 1px solid var(--border); border-radius: 4px; text-align: center; font-size: .85rem; }

/* ===== DRAW VIEWS ===== */
.draw-container { display: flex; flex-direction: column; gap: 1.25rem; }
.draw-meta { display: flex; flex-wrap: wrap; gap: .75rem; }

/* Knockout bracket */
.knockout-bracket {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: .5rem;
}
.bracket-round {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 160px;
  position: relative;
}
.bracket-round-title {
  font-size: .75rem;
  font-weight: 700;
  text-align: center;
  color: var(--neutral);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .4rem;
  margin-bottom: .5rem;
  background: var(--neutral-light);
  border-radius: var(--radius);
}
.bracket-matches {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.bracket-match-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  padding: .25rem .5rem;
  position: relative;
}
.bracket-match {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.bracket-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .35rem .6rem;
  font-size: .8rem;
  gap: .5rem;
}
.bracket-player:first-child { border-bottom: 1px solid var(--border); }
.bracket-player.winner { background: var(--primary-light); font-weight: 700; color: var(--primary-dark); }
.bracket-player.bye { color: var(--neutral); font-style: italic; }
.bracket-player .score { font-weight: 700; min-width: 20px; text-align: right; }
.bracket-court { font-size: .65rem; color: var(--neutral); text-align: center; padding: .1rem; background: #fafafa; border-top: 1px solid var(--border); }

/* Round Robin table */
.rr-container { overflow-x: auto; }
.rr-table {
  border-collapse: collapse;
  font-size: .8rem;
  min-width: 500px;
}
.rr-table th, .rr-table td {
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  text-align: center;
}
.rr-table th { background: var(--neutral-light); font-weight: 700; }
.rr-table .rr-row-header { text-align: left; font-weight: 600; max-width: 120px; word-break: break-word; }
.rr-table .rr-self { background: #f3f4f6; }
.rr-table .rr-win { background: #dcfce7; }
.rr-table .rr-loss { background: #fef2f2; }

/* Spider draw */
.spider-draw { display: flex; flex-direction: column; gap: 1rem; }
.spider-group {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.spider-group-header {
  background: var(--neutral-light);
  padding: .5rem .75rem;
  font-weight: 700;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.spider-matches { display: flex; flex-direction: column; }
.spider-match {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: .4rem .75rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.spider-match:last-child { border-bottom: none; }
.spider-match .vs { color: var(--neutral); font-size: .75rem; font-weight: 700; }
.spider-match .court-info { font-size: .72rem; color: var(--neutral); white-space: nowrap; }

/* Schedule table */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.schedule-table th {
  background: var(--primary);
  color: white;
  padding: .5rem .75rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
}
.schedule-table td { padding: .45rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.schedule-table tbody tr:hover { background: var(--neutral-light); }
.schedule-table .match-num { color: var(--neutral); font-size: .75rem; }

/* Tabs inside modal */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin: -.85rem -1.25rem .85rem;
  padding: 0 1.25rem;
}
.modal-tab {
  padding: .55rem 1rem;
  border: none;
  background: none;
  font-size: .875rem;
  font-weight: 500;
  color: var(--neutral);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.modal-tab:hover { color: var(--neutral-dark); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Player list in tournament */
.players-list { display: flex; flex-direction: column; gap: .4rem; }
.player-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.player-row input[type=text] {
  flex: 1;
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
}
.player-row input[type=number] {
  width: 70px;
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
}
.player-row .remove-player { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: .1rem .3rem; }
.seed-badge {
  min-width: 24px;
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--neutral);
}

/* Score editing */
.score-cell { display: flex; align-items: center; gap: .25rem; justify-content: center; }
.editable-score {
  background: none;
  border: none;
  font-size: .85rem;
  font-weight: 700;
  width: 30px;
  text-align: center;
  cursor: text;
  border-bottom: 1px dashed var(--border);
}
.editable-score:focus { outline: none; border-bottom-color: var(--primary); }

@media (max-width: 640px) {
  .modal-overlay                { padding: .5rem; }
  .modal, .modal-lg, .modal-xl { max-width: calc(100vw - 1rem); }
}
