/* ============================================================
   PTMSI TOURNAMENT BRACKET — World-Class Visual
   Inspired by ITTF, Challonge, Battlefy
   ============================================================ */

/* ── Page layout ── */
.tnmt-page { background: var(--neutral,#f2f3f4); min-height:60vh; padding:2rem 0 5rem; }

/* ── Live badge ── */
.live-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #ef4444; color: #fff;
  font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  padding: .2rem .65rem; border-radius: 99px;
  animation: livePulse 1.5s ease-in-out infinite;
}
.live-badge::before { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: #fff; flex-shrink: 0; }
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: .7; } }

/* ── Bracket container ── */
.bracket-outer {
  overflow-x: auto;
  padding-bottom: 1rem;
  cursor: grab;
  user-select: none;
}
.bracket-outer:active { cursor: grabbing; }
.bracket-outer::-webkit-scrollbar { height: 6px; }
.bracket-outer::-webkit-scrollbar-track { background: rgba(0,0,0,.04); border-radius: 3px; }
.bracket-outer::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 3px; }

.bracket-wrap {
  display: flex;
  align-items: flex-start;
  gap: 0;
  min-width: max-content;
  padding: 1.5rem;
  position: relative;
}

/* ── Round column ── */
.bracket-round {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  flex-shrink: 0;
  position: relative;
}
.bracket-round + .bracket-round { margin-left: 48px; }

.round-header {
  text-align: center;
  padding: .5rem .75rem .85rem;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted,#6b7280);
  position: relative;
  white-space: nowrap;
}
.round-header.is-final {
  color: var(--warning,#f59e0b);
  font-size: .75rem;
}
.round-header.has-live { color: #ef4444; }

/* ── Match card ── */
.match-card {
  background: var(--surface,#fff);
  border: 1.5px solid var(--border,#e5e7eb);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  transition: border-color .18s, box-shadow .18s;
  cursor: default;
}
.match-card:hover { border-color: #c0c8d6; box-shadow: 0 4px 20px rgba(8,34,73,.1); }
.match-card.is-live { border-color: #ef4444 !important; box-shadow: 0 0 0 2px rgba(239,68,68,.2); }
.match-card.is-finished { border-color: rgba(16,185,129,.3); background: #fafffe; }
.match-card.is-bye { opacity: .45; }

/* ── Player rows ── */
.match-player {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border-light,#f3f4f6);
  min-height: 42px;
  position: relative;
  transition: background .12s;
}
.match-player:last-of-type { border-bottom: none; }
.match-player.is-winner { background: rgba(16,185,129,.06); }
.match-player.is-loser  { opacity: .55; }
.match-player.is-tbd    { opacity: .4; }
.match-card.is-live .match-player.is-winner { background: rgba(239,68,68,.04); }

/* Seed badge */
.player-seed {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary,#082249); color: #fff;
  font-size: .58rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.player-seed.bye { background: var(--border,#e5e7eb); color: var(--text-muted,#6b7280); }

/* Player info */
.player-info { flex: 1; min-width: 0; }
.player-name {
  font-size: .8rem; font-weight: 700; color: var(--text-dark,#082249);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.player-name.winner-name { color: #059669; }
.player-club {
  font-size: .62rem; color: var(--text-muted,#6b7280);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-div {
  display: inline-block; font-size: .57rem; font-weight: 700;
  background: rgba(8,34,73,.07); color: var(--primary,#082249);
  padding: 0 5px; border-radius: 99px; margin-left: .2rem;
}

/* Score */
.player-score {
  font-size: .95rem; font-weight: 900; min-width: 20px; text-align: right;
  color: var(--text-muted,#6b7280); flex-shrink: 0;
}
.player-score.winner-score { color: #059669; }

/* Win check */
.player-win { font-size: .7rem; flex-shrink: 0; color: #10b981; }

/* Match footer */
.match-footer {
  background: var(--neutral,#f2f3f4);
  padding: .2rem .7rem;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .6rem; color: var(--text-muted,#6b7280);
  border-top: 1px solid var(--border-light,#f3f4f6);
}
.match-status-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #94a3b8; flex-shrink: 0;
}
.match-status-dot.live   { background: #ef4444; animation: livePulse 1s infinite; }
.match-status-dot.done   { background: #10b981; }
.match-status-dot.bye    { background: #d1d5db; }

/* ── SVG connector lines between rounds ── */
.bracket-connectors {
  position: absolute;
  top: 0; left: calc(100% - 24px);
  width: 48px;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
.connector-line { stroke: var(--border,#e5e7eb); stroke-width: 2; fill: none; }
.connector-line.active { stroke: rgba(16,185,129,.4); }
.connector-line.live   { stroke: rgba(239,68,68,.5); }

/* ── Final trophy card ── */
.bracket-champion {
  min-width: 180px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  margin-left: 48px; padding-top: 40px;
  gap: .75rem;
}
.champion-trophy {
  font-size: 3.5rem;
  animation: trophySpin 6s ease-in-out infinite;
}
@keyframes trophySpin {
  0%,100% { transform: rotate(-5deg) scale(1); }
  50%      { transform: rotate(5deg) scale(1.05); }
}
.champion-card {
  background: linear-gradient(135deg,#f59e0b,#d97706);
  border-radius: 14px; padding: 1.1rem 1.25rem; text-align: center; color: #fff;
  min-width: 160px; box-shadow: 0 8px 24px rgba(245,158,11,.4);
}
.champion-card.empty {
  background: var(--neutral,#f2f3f4); color: var(--text-muted,#6b7280);
  box-shadow: none; border: 2px dashed var(--border,#e5e7eb);
}
.champion-name { font-size: .95rem; font-weight: 900; margin-bottom: .2rem; }
.champion-club { font-size: .72rem; opacity: .8; }

/* ── Participants sidebar ── */
.tnmt-participants {
  display: flex; flex-direction: column;
}
.participant-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border-light,#f3f4f6);
  transition: background .12s; cursor: default;
}
.participant-row:last-child { border-bottom: none; }
.participant-row:hover { background: var(--neutral,#f2f3f4); }
.participant-row.can-swap { cursor: grab; }
.participant-row.dragging { opacity: .4; background: #eff6ff; }
.participant-row.drag-over { background: rgba(16,185,129,.1); border-top: 2px solid #10b981; }

.participant-seed-badge {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary,#082249); color: #fff;
  font-size: .7rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.participant-seed-badge.rank-1 { background: #f59e0b; }
.participant-seed-badge.rank-2 { background: #94a3b8; }
.participant-seed-badge.rank-3 { background: #b45309; }

/* ── Stats strip ── */
.tnmt-stats {
  display: grid; grid-template-columns: repeat(4,1fr); gap: .75rem;
  margin-bottom: 1.5rem;
}
.tnmt-stat {
  background: var(--surface,#fff); border: 1px solid var(--border,#e5e7eb);
  border-radius: 10px; padding: .9rem 1rem; text-align: center;
}
.tnmt-stat-num { font-family: var(--font-display,'Poppins'),sans-serif; font-size: 1.6rem; font-weight: 900; color: var(--text-dark,#082249); }
.tnmt-stat-lbl { font-size: .62rem; color: var(--text-muted,#6b7280); text-transform: uppercase; letter-spacing: .07em; margin-top: .15rem; }

/* ── Loading spinner ── */
.tnmt-loading {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; padding: 3rem; color: var(--text-muted,#6b7280); font-size: .85rem;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border,#e5e7eb);
  border-top-color: var(--accent,#c0392b);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Last updated indicator ── */
.tnmt-updated {
  font-size: .68rem; color: var(--text-muted,#6b7280);
  display: flex; align-items: center; gap: .35rem;
}
.tnmt-updated-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }

/* ── Swap mode (manager) ── */
.swap-btn {
  padding: .35rem .75rem; border-radius: 99px; font-size: .72rem; font-weight: 700;
  border: 1.5px solid var(--border,#e5e7eb);
  background: var(--neutral,#f2f3f4); color: var(--text-muted,#6b7280);
  cursor: pointer; transition: all .15s;
}
.swap-btn.selected {
  background: var(--accent,#c0392b); color: #fff; border-color: var(--accent,#c0392b);
}
.swap-btn:hover:not(.selected) {
  border-color: var(--accent,#c0392b); color: var(--accent,#c0392b);
}
.swap-bar {
  background: rgba(192,57,43,.06); border: 1.5px solid rgba(192,57,43,.2);
  border-radius: 10px; padding: .75rem 1.1rem;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ── Verified badge ── */
.verified-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(5,150,105,.1); color: #065f46;
  font-size: .65rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; padding: .2rem .65rem; border-radius: 99px;
  border: 1px solid rgba(5,150,105,.2);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .tnmt-stats { grid-template-columns: repeat(2,1fr); }
  .bracket-round { min-width: 185px; }
  .bracket-round + .bracket-round { margin-left: 28px; }
}
