/* ============================================================
   TopChess.org – Tournaments page styles (v5 – visual refresh)
   ============================================================ */

.tournaments-main {
  min-height: 100vh;
}

/* ---- Header ------------------------------------------------ */
.tournaments-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.75rem;
}

.tournaments-header h1 {
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--text-white, #fff);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  letter-spacing: -0.5px;
}

.tournaments-header p {
  color: rgba(255,255,255,0.8);
  font-size: 1rem;
  margin: 0;
}

.detail-header {
  padding: 1.25rem 1.5rem;
}

/* ---- Container --------------------------------------------- */
.tournaments-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  color: #1a1a2e;
}

/* ---- View toggle ------------------------------------------- */
.view-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.view-toggle button {
  padding: 9px 22px;
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 24px;
  background: rgba(255,255,255,0.12);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 0.2s;
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
}

.view-toggle button.active {
  border-color: white;
  background: white;
  color: #004C99;
  box-shadow: 0 2px 12px rgba(0,76,153,0.25);
}

.view-toggle button:hover:not(.active) {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.7);
}

/* ================================================================
   TOURNAMENT CARDS (list view)
   ================================================================ */
.tournaments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.tournament-card {
  background: #fff;
  border-radius: 14px;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  overflow: hidden;
  position: relative;
}

.tournament-card:hover {
  box-shadow: 0 8px 28px rgba(0,76,153,0.18);
  transform: translateY(-3px);
}

/* Accent top stripe */
.tournament-card::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, #004C99, #0078d4);
}

.tournament-card.status-card-registration::before {
  background: linear-gradient(90deg, #2e7d32, #43a047);
}

.tournament-card.status-card-finished::before {
  background: linear-gradient(90deg, #6a1b9a, #9c27b0);
}

.tournament-card-body {
  padding: 16px 18px 14px;
}

.tournament-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
}

.tournament-card-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a1a2e;
  flex: 1;
  line-height: 1.3;
}

.tournament-status-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.status-registration { background: #e8f5e9; color: #2e7d32; }
.status-active       { background: #e3f2fd; color: #1565c0; }
.status-finished     { background: #f3e5f5; color: #6a1b9a; }
.status-cancelled    { background: #fce4ec; color: #880e4f; }

.tournament-card-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #666;
  margin-top: 4px;
}

.tournament-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tournament-card-desc {
  font-size: 0.85rem;
  color: #555;
  margin-top: 10px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Player count progress bar */
.tc-progress-wrap {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tc-progress-bar {
  flex: 1;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.tc-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #004C99, #0078d4);
  transition: width 0.4s ease;
}

.tc-progress-label {
  font-size: 0.78rem;
  color: #888;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Create tournament form -------------------------------- */
.create-tournament-card {
  background: #fff;
  border-radius: 14px;
  border: none;
  padding: 28px;
  margin-bottom: 32px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}

.create-tournament-card h2 {
  font-size: 1.35rem;
  margin-bottom: 20px;
  color: #1a1a2e;
  font-weight: 800;
}

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 160px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  background: #fafbfc;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #004C99;
  box-shadow: 0 0 0 3px rgba(0,76,153,0.1);
  background: #fff;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ---- Buttons ----------------------------------------------- */
.btn-primary {
  padding: 11px 28px;
  background: linear-gradient(135deg, #004C99, #0065cc);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,76,153,0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #003d7a, #004C99);
  box-shadow: 0 4px 14px rgba(0,76,153,0.35);
  transform: translateY(-1px);
}

.btn-primary:disabled { background: #bbb; box-shadow: none; cursor: not-allowed; transform: none; }

.btn-secondary {
  padding: 10px 24px;
  background: white;
  color: #004C99;
  border: 2px solid #d0dff0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: #f0f4ff; border-color: #004C99; }

.btn-danger {
  padding: 8px 18px;
  background: #fff5f5;
  color: #c62828;
  border: 2px solid #ef9a9a;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { background: #ffebee; border-color: #c62828; }

.btn-sm {
  padding: 7px 16px;
  font-size: 0.85rem;
}

/* ================================================================
   DETAIL VIEW
   ================================================================ */
.detail-section {
  background: #fff;
  border-radius: 14px;
  border: none;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.detail-section h3 {
  font-size: 1.05rem;
  margin-bottom: 14px;
  color: #1a1a2e;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-section h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: #004C99;
  border-radius: 2px;
}

/* ---- Tournament detail card -------------------------------- */
.tournament-detail {
  background: #fff;
  border-radius: 14px;
  border: none;
  padding: 0;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  overflow: hidden;
}

.tournament-detail-top {
  background: linear-gradient(135deg, #003d7a, #0065cc);
  padding: 24px 28px 20px;
  color: white;
}

.tournament-detail-bottom {
  padding: 18px 28px 22px;
}

.tournament-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.tournament-detail-header h2 {
  font-size: 1.6rem;
  color: white;
  font-weight: 900;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.tournament-meta-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.85);
}

.tournament-meta-row span {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.12);
  padding: 4px 12px;
  border-radius: 20px;
}

.tournament-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tournament-desc-text {
  color: rgba(255,255,255,0.9);
  font-size: 0.92rem;
  margin-bottom: 12px;
  line-height: 1.45;
}

/* Streak info banner */
.streak-info-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #888;
  margin-top: 6px;
  padding: 8px 14px;
  background: #fffaf0;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
}

/* Your game CTA */
.your-game-cta {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 3px 12px rgba(46,125,50,0.3);
}

.your-game-cta span {
  font-weight: 700;
  color: white;
  font-size: 0.95rem;
}

.your-game-cta .btn-primary {
  background: white;
  color: #2e7d32;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.your-game-cta .btn-primary:hover {
  background: #f0f0f0;
}

/* ================================================================
   STANDINGS TABLE
   ================================================================ */
.standings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.standings-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: #f8f9fa;
  border-bottom: 2px solid #e8e8e8;
  font-weight: 700;
  font-size: 0.78rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.standings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f3f3;
  vertical-align: middle;
}

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

.standings-table tbody tr:hover td {
  background: #f6f9ff;
}

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

/* My row highlight */
.standings-table tbody tr.my-standings-row td {
  background: #eef4ff;
}

.standings-table tbody tr.my-standings-row:hover td {
  background: #e3edff;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.78rem;
  background: #f0f0f0;
  color: #666;
}

.rank-1 { background: linear-gradient(135deg, #FFD700, #FFC107); color: #5d4200; box-shadow: 0 2px 6px rgba(255,193,7,0.3); }
.rank-2 { background: linear-gradient(135deg, #e0e0e0, #bdbdbd); color: #333; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #D4914B); color: white; box-shadow: 0 2px 6px rgba(205,127,50,0.3); }

.player-name {
  font-weight: 700;
  color: #1a1a2e;
}

.points-cell {
  font-weight: 800;
  color: #004C99;
  font-size: 1.08rem;
}

/* ================================================================
   ROUNDS ACCORDION
   ================================================================ */
.round-item {
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.round-item:has(.round-content.open) {
  border-color: #c8d8ec;
}

.round-header {
  padding: 14px 18px;
  background: #f9fafb;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  transition: background 0.2s;
  user-select: none;
}

.round-header:hover { background: #f0f4ff; }

.round-status-badge {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
}

.round-active   { background: #e3f2fd; color: #1565c0; }
.round-complete { background: #e8f5e9; color: #2e7d32; }

.round-content {
  padding: 14px 18px;
  display: none;
  background: #fafbfc;
}

.round-content.open { display: block; }

.pairing-row {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  gap: 8px;
  background: #fafafa;
}

.pairing-player {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pairing-vs {
  color: #999;
  font-size: 0.8rem;
  font-weight: 600;
}

.pairing-result {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

.result-white_wins { background: #fff9c4; color: #6d4c41; }
.result-black_wins { background: #263238; color: white; }
.result-draw       { background: #f3e5f5; color: #6a1b9a; }
.result-bye        { background: #e8f5e9; color: #2e7d32; }
.result-pending    { background: #e8e8e8; color: #666; }
.result-forfeit    { background: #fff3e0; color: #e65100; }

.btn-play-pairing {
  padding: 5px 14px;
  background: linear-gradient(135deg, #004C99, #0065cc);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,76,153,0.25);
  transition: all 0.2s;
}

.btn-play-pairing:hover {
  background: linear-gradient(135deg, #003d7a, #004C99);
  transform: translateY(-1px);
}

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 60px 32px;
  color: rgba(255,255,255,0.85);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.empty-state p {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.empty-state p:last-child {
  font-size: 0.9rem;
  opacity: 0.75;
}

/* ---- Status messages --------------------------------------- */
.status-message {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.9rem;
}

.status-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.status-error   { background: #fce4ec; color: #880e4f; border: 1px solid #f8bbd0; }
.status-info    { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ---- My pairing highlight ---------------------------------- */
.my-pairing {
  border: 2px solid #004C99;
  background: #f0f4ff;
}

/* ---- Back link --------------------------------------------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.back-link:hover { color: white; text-decoration: underline; }

/* ---- Loading spinner --------------------------------------- */
.loading-spinner {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 0.95rem;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
  .tournaments-header h1 { font-size: 1.75rem; }
  .tournaments-container { padding: 0 0.75rem 3rem; }
  .tournaments-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .tournament-detail-header { flex-direction: column; }
  .tournament-detail-top { padding: 18px 16px 14px; }
  .tournament-detail-bottom { padding: 14px 16px 18px; }
  .tournament-meta-row { gap: 8px; }
  .tournament-meta-row span { font-size: 0.8rem; padding: 3px 8px; }
  .hide-mobile { display: none; }
  .detail-section { padding: 16px; }
  .standings-table { font-size: 0.82rem; }
  .standings-table thead th,
  .standings-table td { padding: 8px 6px; }
}

@media (max-width: 600px) {
  .tournaments-main {
    padding-bottom: 80px;
  }
  .detail-section {
    overflow-x: auto;
  }
  .standings-table tbody tr:last-child td {
    padding-bottom: 12px;
  }
  .standings-table {
    margin-bottom: 16px;
  }
}

/* ================================================================
   AVATAR
   ================================================================ */
.p-avatar {
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  object-fit: cover;
}

/* ================================================================
   MATCHUP CARD (round-robin pairings)
   ================================================================ */
.matchup-card {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid #ebebeb;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  gap: 6px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.matchup-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); border-color: #d0d0d0; }
.matchup-card.my-game {
  border-color: #004C99;
  background: linear-gradient(135deg, #f0f4ff, #e8efff);
  box-shadow: 0 0 0 3px rgba(0,76,153,0.08);
}
.mc-player {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.mc-player.right { flex-direction: row-reverse; }
.mc-player-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a2e;
}
.mc-player-name.me { color: #004C99; font-weight: 800; }
.mc-center {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 52px;
}
.mc-result {
  font-weight: 800;
  font-size: 0.85rem;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.mc-vs {
  font-size: 0.72rem;
  color: #bbb;
  font-weight: 700;
  letter-spacing: 1.5px;
}

/* ================================================================
   PODIUM
   ================================================================ */
.podium-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 0 4px;
  margin-bottom: 20px;
}
.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.podium-avatar-ring {
  position: relative;
  display: inline-flex;
}
.podium-medal {
  position: absolute;
  bottom: -3px;
  right: -3px;
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.podium-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: #1a1a2e;
  max-width: 92px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-platform {
  border-radius: 8px 8px 0 0;
  width: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.podium-place.first .podium-platform { width: 96px; }
.podium-pts {
  font-weight: 700;
  font-size: 0.8rem;
  color: #333;
}

/* ================================================================
   BRACKET (single elimination)
   ================================================================ */
.bracket-wrap {
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}
.bracket {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: max-content;
  padding: 0 4px;
}
.br-round {
  display: flex;
  flex-direction: column;
  min-width: 148px;
  max-width: 180px;
}
.br-round-label {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.5px;
  padding-bottom: 6px;
}
.br-round-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-around;
}
.br-matchup {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin: 4px 6px;
}
.br-participant {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
  border-bottom: 1px solid #f0f0f0;
  min-height: 33px;
}
.br-participant:last-child { border-bottom: none; }
.br-participant.winner { background: #e8f5e9; color: #1b5e20; }
.br-participant.loser  { color: #bbb; background: #fafafa; text-decoration: line-through; }
.br-participant.pending { color: #555; }
.br-participant.is-me .br-pname { color: #004C99; font-weight: 800; }
.br-pname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.br-score { font-size: 0.76rem; color: #2e7d32; font-weight: 800; margin-left: 2px; flex-shrink: 0; }
.br-participant.loser .br-score { color: #ccc; }

/* Connector lines between rounds */
.br-connectors {
  display: flex;
  flex-direction: column;
  width: 18px;
  flex-shrink: 0;
  align-self: stretch;
}
.br-conn-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.br-conn-top {
  flex: 1;
  border-right: 2px solid #d0d0d0;
  border-bottom: 2px solid #d0d0d0;
  border-bottom-right-radius: 5px;
}
.br-conn-bot {
  flex: 1;
  border-right: 2px solid #d0d0d0;
  border-top: 2px solid #d0d0d0;
  border-top-right-radius: 5px;
}

/* Bracket divider */
.bracket-divider {
  margin: 20px 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #888;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bracket-divider::before,
.bracket-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e8e8e8;
}
