/* Tournament bracket CSS — modern redesign */
:root {
  --track: 2.5rem;          /* 1 grid-row height */
  --card-w: 14rem;
  --gap-x: 4.5rem;          /* horizontal gap between rounds */
  --zoom: 1;

  /* Bracket palette */
  --win-color: #2563eb;     /* blue-600 */
  --win-bg:    #eff6ff;     /* blue-50  */
  --win-border:#93c5fd;     /* blue-300 */
  --los-color: #dc2626;     /* red-600  */
  --los-bg:    #fef2f2;     /* red-50   */
  --los-border:#fca5a5;     /* red-300  */
  --fin-color: #d97706;     /* amber-600 */
  --fin-bg:    #fffbeb;     /* amber-50  */
  --fin-border:#fcd34d;     /* amber-300 */

  --match-height: 8rem;     /* taller cards for richer info */
  --card-radius: .6rem;
}

/* ───── scroll shell ───── */
.bracket-shell {
  position: relative;
  width: 100%;
  height: calc(100vh - 80px);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: none;
  cursor: grab;
  background: #f8fafc;
}

.bracket-shell.grabbing {
  cursor: grabbing;
}

/* ───── zoom layer ───── */
.zoom-layer {
  position: relative;
  transform-origin: 0 0;
  transform: scale(var(--zoom));
  min-width: 100%;
  min-height: 100%;
}

/* ───── SVG overlay ───── */
#wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  fill: none;
  stroke-linecap: round;
  stroke-width: 2px;
}

/* ───── grid ───── */
.bracket {
  display: grid;
  grid-auto-flow: dense;
  grid-auto-columns: var(--card-w);
  grid-auto-rows: var(--track);
  column-gap: var(--gap-x);
  row-gap: 0;
  padding: 1.5rem;
  box-sizing: border-box;
  min-height: 100%;
  position: relative;
}

/* ═══════════════════════════════════════
   MATCH CARD
   ═══════════════════════════════════════ */
.match {
  /* Fixed height regardless of grid-row span */
  height: var(--match-height);
  min-height: var(--match-height);
  max-height: var(--match-height);

  position: relative;
  user-select: none;
  display: flex;
  flex-direction: column;
  padding: .45rem .65rem;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  border-radius: var(--card-radius);
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  transition: box-shadow .15s ease, transform .15s ease;
}

.match:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.08);
  transform: translateY(-1px);
}

/* Centre the fixed-height card within its (potentially tall) grid span */
.match { align-self: center; }

/* ── Bracket color themes ── */
.match.bracket-winner {
  background: var(--win-bg);
  border: 2px solid var(--win-border);
}
.match.bracket-loser {
  background: var(--los-bg);
  border: 2px solid var(--los-border);
}
.match.bracket-final {
  background: var(--fin-bg);
  border: 2px solid var(--fin-border);
}

/* ── State modifiers ── */
.match.state-finished {
  opacity: .75;
}
.match.state-finished:hover {
  opacity: 1;
}
.match.state-bye {
  opacity: .55;
  border-style: dashed;
}
.match.state-ready {
  box-shadow: 0 0 0 2px rgba(37,99,235,.25), 0 1px 3px rgba(0,0,0,.08);
}

/* ═══════════════════════════════════════
   CARD INTERNALS
   ═══════════════════════════════════════ */

/* ── Header: label + badge ── */
.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  margin-bottom: .25rem;
  flex-shrink: 0;
}

.match-label {
  font-weight: 700;
  font-size: .72rem;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bracket-badge {
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .1rem .35rem;
  border-radius: .25rem;
  text-transform: uppercase;
  flex-shrink: 0;
  line-height: 1.3;
}
.bracket-badge.bracket-winner {
  background: var(--win-color);
  color: #fff;
}
.bracket-badge.bracket-loser {
  background: var(--los-color);
  color: #fff;
}
.bracket-badge.bracket-final {
  background: var(--fin-color);
  color: #fff;
}

/* ── Source labels ── */
.match-sources {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .6rem;
  color: #9ca3af;
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.match-sources span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.source-sep {
  color: #d1d5db;
}

/* ── Players ── */
.match-players {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  justify-content: center;
  min-height: 0;
}

.player-slot {
  font-size: .72rem;
  font-weight: 500;
  padding: .2rem .5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .3rem;
  transition: all .15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  cursor: pointer;
  text-align: center;
}

.player-slot:not(:disabled):hover {
  background: #f0f9ff;
  border-color: var(--win-color);
  box-shadow: 0 0 0 1px var(--win-color);
}

.player-slot:disabled {
  cursor: default;
  opacity: .6;
  background: #f9fafb;
}

.player-slot.slot-winner {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
  font-weight: 700;
  opacity: 1;
}
.player-slot.slot-loser {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
  opacity: .65;
  text-decoration: line-through;
}

.vs-text {
  font-size: .55rem;
  color: #9ca3af;
  font-weight: 600;
  text-align: center;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Bye state ── */
.match-bye {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  flex: 1;
}
.bye-player {
  font-size: .72rem;
  font-weight: 600;
  color: #374151;
}
.bye-label {
  font-size: .6rem;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── Trophy icon inside winner button ── */
.trophy {
  font-size: .65rem;
  margin-right: .2rem;
}

/* ── Destination labels ── */
.match-destinations {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  font-size: .55rem;
  margin-top: auto;
  padding-top: .15rem;
  border-top: 1px solid rgba(0,0,0,.06);
  flex-shrink: 0;
}

.dest-winner {
  color: var(--win-color);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dest-loser {
  color: var(--los-color);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
  :root {
    --track: 2rem;
    --card-w: 11rem;
    --gap-x: 2.5rem;
    --match-height: 7rem;
  }

  .match-label { font-size: .65rem; }
  .player-slot { font-size: .68rem; padding: .15rem .35rem; }
  .match-sources { font-size: .55rem; }
  .match-destinations { font-size: .5rem; }
}

/* ───── zoom slider (desktop helper) ───── */
.zoom-ui {
  position: fixed;
  top: .5rem;
  right: .5rem;
  z-index: 1000;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  font: 13px/1 "Segoe UI", system-ui, sans-serif;
  padding: .35rem .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #6b7280;
}

.zoom-ui input {
  width: 7rem;
  accent-color: var(--win-color);
}

.zoom-ui span {
  min-width: 3.5ch;
  text-align: right;
  font-weight: 600;
  color: #374151;
}

/* ═══════════════════════════════════════
   STANDINGS
   ═══════════════════════════════════════ */
.standings-progress {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
}

.standings-progress-bar {
  flex: 1;
  height: .5rem;
  background: #e5e7eb;
  border-radius: .25rem;
  overflow: hidden;
}

.standings-progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: .25rem;
  transition: width .3s ease;
}

.standings-progress-text {
  font-size: .78rem;
  color: #6b7280;
  white-space: nowrap;
}

.standings-status {
  font-size: .7rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: .75rem;
}
.standings-status-active     { background: #d1fae5; color: #065f46; }
.standings-status-eliminated { background: #fee2e2; color: #991b1b; }
