/* Турнир: оболочка и тема как national_jumps_live.php + блоки турнира */

:root {
  --bg1: #f8fafc;
  --bg2: #eef2ff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent2: #16a34a;
  --danger: #ef4444;
}

.td-page * {
  box-sizing: border-box;
}

.td-page {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg2), transparent 60%),
    linear-gradient(135deg, var(--bg1), #ffffff);
  color: var(--text);
  min-height: 100vh;
  padding: 24px;
  margin: 0;
}

.td-page .wrap {
  max-width: 1280px;
  margin: 0 auto;
}

.td-page .topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

.td-page .title {
  font-size: 1.25rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: -0.02em;
}

.td-page .subtitle {
  margin: 2px 0 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.td-page .lefthead {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.td-page .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.td-page .btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 0.9rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
}

.td-page .btn:hover {
  transform: translateY(-1px);
  border-color: #c7d2fe;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}

.td-page .btn.ghost {
  background: #fff;
  color: var(--text);
}

.td-page .btn.good {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  border-color: #15803d;
}

.td-page .btn.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-color: #1d4ed8;
}

.td-page .card {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(8px);
}

.td-page .td-card-body {
  padding: 16px 18px 22px;
}

/* ——— Контент турнира ——— */
.td-page .loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-weight: 700;
}

.td-page .tournament-info {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 18px 16px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.td-page .tournament-info h2 {
  margin: 0 0 12px 0;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text);
}

.td-page .info-row {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.td-page .info-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.td-page .info-item i {
  color: var(--accent);
}

.td-page .tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.td-page .tab {
  background: none;
  border: none;
  padding: 11px 18px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  border-radius: 10px 10px 0 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.td-page .tab:hover {
  color: var(--text);
  background: rgba(37, 99, 235, 0.06);
}

.td-page .tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.td-page .tab-content {
  display: none;
}

.td-page .tab-content.active {
  display: block;
}

.td-page .results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-size: 0.93rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.td-page .results-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 900;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  text-align: left;
}

.td-page .results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
}

.td-page .results-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.td-page .results-table tbody tr:hover {
  background: #eef2ff;
}

.td-page .place-badge {
  display: inline-flex;
  min-width: 40px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 900;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 0.82rem;
}

.td-page .place-badge.first,
.td-page .place-badge.gold {
  background: #fef3c7;
  border-color: #f59e0b;
}

.td-page .place-badge.second,
.td-page .place-badge.silver {
  background: #e5e7eb;
  border-color: #94a3b8;
}

.td-page .place-badge.third,
.td-page .place-badge.bronze {
  background: #fde68a;
  border-color: #d97706;
}

/* Матрица группы (tournament_details) — те же размеры/сетка, что в admin_games_tournaments.php (+ колонка «№ п/п») */
.td-page:not(.agt-page) .td-matrix-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.td-page:not(.agt-page) .tournament-matrix-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 2px solid #166534;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  margin: 20px 0;
  font-size: 0.95rem;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-header {
  background: #166534;
  color: #ffffff;
  padding: 10px 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9em;
  border: 1px solid #14532d;
  width: 60px;
  min-width: 60px;
  vertical-align: middle;
  box-sizing: border-box;
}

/* № п/п — как узкие числовые колонки в админке */
.td-page:not(.agt-page) .tournament-matrix-table .matrix-header:first-child {
  border-left: 2px solid #166534;
  width: 60px;
  min-width: 60px;
  max-width: 72px;
  padding: 10px 6px;
  font-size: 0.82em;
}

/* Команда — как первая колонка «Команда» в админке */
.td-page:not(.agt-page) .tournament-matrix-table .matrix-header:nth-child(2) {
  min-width: 150px;
  width: auto;
  max-width: 22rem;
  text-align: left;
  padding-left: 12px;
  padding-right: 10px;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-header:last-child {
  border-right: 2px solid #166534;
}

.td-page:not(.agt-page) .tournament-matrix-table tbody tr {
  border-bottom: 1px solid #d1d5db;
}

.td-page:not(.agt-page) .tournament-matrix-table tbody tr:last-child {
  border-bottom: 2px solid #166534;
}

.td-page:not(.agt-page) .tournament-matrix-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.td-page:not(.agt-page) .tournament-matrix-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.td-page:not(.agt-page) .tournament-matrix-table tbody tr:hover {
  background: #f3f4f6;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-number {
  padding: 10px 8px;
  text-align: center;
  font-weight: 700;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid #d1d5db;
  width: 60px;
  min-width: 60px;
  max-width: 72px;
  box-sizing: border-box;
  vertical-align: middle;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-team {
  padding: 10px 12px;
  font-weight: 600;
  color: #1e293b;
  border: 1px solid #d1d5db;
  min-width: 150px;
  max-width: 22rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: middle;
  box-sizing: border-box;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-header:nth-child(n + 3):nth-last-child(n + 5),
.td-page:not(.agt-page) .tournament-matrix-table tbody tr > td:nth-child(n + 3):nth-last-child(n + 5) {
  width: 60px;
  min-width: 60px;
  max-width: 72px;
  box-sizing: border-box;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-diagonal {
  padding: 10px 8px;
  text-align: center;
  background: #fef3c7;
  border: 1px solid #d1d5db;
  font-size: 1.3em;
  width: 60px;
  min-width: 60px;
  height: 60px;
  vertical-align: middle;
  box-sizing: border-box;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-result {
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d1d5db;
  font-weight: 600;
  font-size: 0.95em;
  width: 60px;
  min-width: 60px;
  height: 60px;
  vertical-align: middle;
  box-sizing: border-box;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-points {
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d1d5db;
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
  font-size: 1.1em;
  width: 70px;
  min-width: 70px;
  box-sizing: border-box;
  vertical-align: middle;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio {
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d1d5db;
  width: 100px;
  min-width: 100px;
  box-sizing: border-box;
  vertical-align: middle;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio-value {
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  width: 100px;
  min-width: 100px;
  box-sizing: border-box;
  vertical-align: middle;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-place {
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d1d5db;
  background: #f1f5f9;
  font-weight: 700;
  font-size: 1.1em;
  width: 70px;
  min-width: 70px;
  box-sizing: border-box;
  vertical-align: middle;
}

.td-page:not(.agt-page) .tournament-matrix-table thead .matrix-header:nth-last-child(4) {
  width: 70px;
  min-width: 70px;
}

.td-page:not(.agt-page) .tournament-matrix-table thead .matrix-header:nth-last-child(3),
.td-page:not(.agt-page) .tournament-matrix-table thead .matrix-header:nth-last-child(2) {
  width: 100px;
  min-width: 100px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.15;
  font-size: 0.78em;
  padding-left: 6px;
  padding-right: 6px;
}

.td-page:not(.agt-page) .tournament-matrix-table thead .matrix-header:nth-last-child(1) {
  width: 70px;
  min-width: 70px;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio,
.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio-value {
  white-space: normal;
  word-break: break-word;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio > div,
.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-ratio-value > div {
  max-width: 100%;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-result.match-win {
  background: #dcfce7;
  color: #166534;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-result.match-loss {
  background: #fee2e2;
  color: #991b1b;
}

.td-page:not(.agt-page) .tournament-matrix-table .matrix-cell-result.match-pending {
  background: #fef3c7;
  color: #92400e;
}

/* Матчи круга */
.td-page .round-section {
  margin-bottom: 24px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.td-page .round-header {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.td-page .round-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--text);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.td-page .round-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

.td-page .matches-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.td-page .match-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  position: relative;
}

.td-page .match-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.1);
}

.td-page .match-card.completed {
  border-color: #86efac;
  background: linear-gradient(135deg, #ffffff, #f0fdf4);
}

.td-page .match-round-info {
  font-size: 0.72rem;
  font-weight: 800;
  color: #475569;
  background: #f1f5f9;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
}

.td-page .match-header {
  margin-top: 20px;
}

.td-page .match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.td-page .match-team-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

.td-page .match-score {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  text-align: center;
}

.td-page .match-status {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent2);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.td-page .match-status.pending {
  color: #d97706;
}

/* Плейофф — крупные аккуратные карточки */
.td-page .playoff-bracket {
  padding: 20px 18px 24px;
  overflow: auto;
  max-height: calc(100vh - 200px);
  cursor: grab;
  user-select: none;
  border-radius: 16px;
  background: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 40%, #ffffff 100%);
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.td-page .playoff-bracket:active {
  cursor: grabbing;
}

.td-page .bracket-wrapper {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  min-width: fit-content;
  padding: 8px 4px 20px;
}

.td-page .bracket-round {
  min-width: 288px;
  width: 288px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.td-page .bracket-round-title {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  margin: 0 0 2px 0;
  padding: 10px 14px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.td-page .bracket-match {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
  min-height: 148px;
  min-width: 0;
  width: 100%;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.td-page .bracket-match:hover {
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.14), 0 4px 10px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
}

.td-page .bracket-match.completed {
  border-color: #6ee7b7;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
}

.td-page .bracket-match.completed:not(.bye) {
  cursor: pointer;
}

.td-page .bracket-match.bye {
  border-style: dashed;
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 55%);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.12);
}

.td-page .bracket-match.bye:hover {
  transform: none;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.18);
}

.td-page .bracket-match-number {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  padding: 8px 14px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 1px solid #e2e8f0;
}

.td-page .bracket-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}

.td-page .bracket-match > .bracket-player:last-of-type {
  border-bottom: none;
}

.td-page .bracket-player-name {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  word-break: break-word;
}

.td-page .bracket-score-display {
  flex-shrink: 0;
  font-size: 1.05rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
}

.td-page .bracket-player.winner {
  background: linear-gradient(90deg, #ecfdf5 0%, #f0fdf4 100%);
  color: #14532d;
}

.td-page .bracket-player.winner .bracket-score-display {
  color: #15803d;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border-color: #86efac;
}

.td-page .bracket-player.empty {
  color: var(--muted);
  font-style: italic;
  font-weight: 700;
  font-size: 0.9rem;
}

.td-page .bracket-player.empty .bracket-player-name {
  opacity: 0.85;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
  max-width: min(92vw, 720px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Модалка «Поделиться» (как live) */
#modal-share.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10050;
}

#modal-share.modal-overlay.active {
  display: flex;
}

.share-qr-block {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 12px;
  background: #f8fafc;
  border-radius: 14px;
  border: 1px solid var(--line);
}

@media (hover: hover) and (pointer: fine) {
  .share-qr-block {
    display: flex;
  }
}

.share-qr-block img {
  display: block;
  width: 220px;
  height: 220px;
  max-width: min(220px, 70vw);
  max-height: min(220px, 70vw);
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
}

.share-url-block .share-url-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  display: block;
}

.share-url-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.8rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  word-break: break-all;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
}

#modal-share .modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
}

#modal-share .modal-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}

#modal-share .modal-title {
  font-weight: 900;
  letter-spacing: -0.01em;
}

#modal-share .modal-body {
  padding: 14px;
  overflow: auto;
}

#modal-share .modal-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
}

#modal-share .modal-footer .btn {
  width: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.td-page .small {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 800;
}

/* Модалка матча */
#match-details-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10040;
  padding: 18px;
}

#match-details-modal.active {
  display: flex;
}

#match-details-modal .modal {
  background: #fff;
  border-radius: 16px;
  padding: 0;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
}

#match-details-modal .modal-header {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: 18px 20px;
  border-radius: 16px 16px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#match-details-modal .modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
}

#match-details-modal .modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#match-details-modal .modal-body {
  padding: 22px;
}

#match-details-modal .modal-match-info {
  text-align: center;
  margin-bottom: 20px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#match-details-modal .modal-match-teams {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

#match-details-modal .modal-team-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

#match-details-modal .modal-vs {
  color: var(--muted);
  font-weight: 800;
}

#match-details-modal .set-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
}

#match-details-modal .set-detail-score {
  font-weight: 900;
  color: var(--accent);
}

@media (max-width: 640px) {
  .td-page {
    padding: 12px;
  }

  body.has-site-bottom-nav .td-page {
    padding-bottom: calc(7.5rem + env(safe-area-inset-bottom, 18px));
  }

  .td-page .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .td-page .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .td-page .btn {
    width: 100%;
  }

  .td-page .matches-list {
    grid-template-columns: 1fr;
  }

  .td-page .bracket-wrapper {
    flex-direction: column;
    gap: 20px;
  }

  .td-page .bracket-round {
    width: 100%;
    min-width: 0;
  }

  #match-details-modal .modal-match-teams {
    flex-direction: column;
  }
}

@media print {
  .td-page {
    padding: 0;
    background: #fff;
  }

  .td-page .topbar {
    box-shadow: none;
    backdrop-filter: none;
  }
}

/* ——— tournaments_view.php: список и архив ——— */

.td-page .tv-page .filters {
  display: flex;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.td-page .tv-page .filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.td-page .tv-page .filter-group label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.td-page .tv-page .filter-group select,
.td-page .tv-page .filter-group input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  min-width: 150px;
  font-family: inherit;
}

.td-page .tv-page .filter-group select:focus,
.td-page .tv-page .filter-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.td-page .tournaments-grid,
.td-page .tournaments-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 18px;
}

.td-page .tournaments-list {
  margin-bottom: 8px;
}

.td-page .tournament-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 20px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.td-page .tournament-card:hover {
  border-color: #c7d2fe;
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.12);
}

.td-page .tournament-card h3 {
  margin: 0 0 10px 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.td-page .tournament-card .date {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.td-page .tournament-card .format {
  display: inline-block;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.td-page .tournament-card .participants {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.td-page .tournament-card .participants i {
  color: var(--accent);
}

.td-page .tournament-card .nj-public-info {
  color: #475569;
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 10px 0 10px 0;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.td-page .tournament-card.unified-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.td-page .tournament-card .nj-card-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 14px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.td-page .tournament-card .nj-foot-date {
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  font-weight: 600;
}

.td-page .tournament-card .nj-foot-date i {
  color: var(--accent);
}

.td-page .tournament-card .nj-foot-venue {
  color: #475569;
  font-size: 0.88rem;
  text-align: right;
  max-width: 58%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  line-height: 1.35;
  font-weight: 700;
}

.td-page .tournament-card .nj-foot-venue i {
  margin-top: 2px;
  color: var(--accent2);
  flex-shrink: 0;
}

.td-page .empty-state {
  text-align: center;
  padding: 48px 22px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.td-page .empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: #cbd5e1;
  display: block;
}

.td-page .empty-state h2 {
  margin: 0 0 8px 0;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text);
}

.td-page .empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

.td-page .btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.9rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.td-page .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.td-page .pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  align-items: center;
  flex-wrap: wrap;
}

.td-page .pagination button {
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.88rem;
  transition: border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.td-page .pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.1);
}

.td-page .pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.td-page .pagination .page-info {
  padding: 9px 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
}

.td-page .tv-page .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px 12px;
  margin-top: 6px;
}

.td-page .tv-page .section-title h2 {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}

.td-page .tv-page .section-title .hint {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .td-page .tv-page .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .td-page .tv-page .filter-group,
  .td-page .tv-page .filter-group select,
  .td-page .tv-page .filter-group input {
    width: 100%;
    min-width: 0;
  }

  .td-page .tournaments-grid,
  .td-page .tournaments-list {
    grid-template-columns: 1fr;
  }

  .td-page .tournament-card .nj-foot-venue {
    max-width: 100%;
    text-align: left;
    justify-content: flex-start;
  }
}

@media (min-width: 1441px) {
  .td-page .tournaments-grid,
  .td-page .tournaments-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }
}

/* ——— tournaments/admin.php — хаб видов спорта ——— */

.td-page.admin-php-page .wrap {
  max-width: 760px;
}

.td-page.admin-php-page .admin-php-body {
  padding-top: 4px;
}

.td-page.admin-php-page .content {
  padding: 18px 8px 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.td-page.admin-php-page .section {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.td-page.admin-php-page .section-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.td-page.admin-php-page .section-title {
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.td-page.admin-php-page .section-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.td-page.admin-php-page .section-body {
  padding: 14px 14px 16px;
  display: grid;
  gap: 12px;
}

.td-page.admin-php-page .pill {
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  white-space: nowrap;
}

.td-page.admin-php-page .pill.gray {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
}

.td-page.admin-php-page .continue-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
}

.td-page.admin-php-page .select-shell {
  flex: 1 1 260px;
  min-width: 0;
  position: relative;
}

.td-page.admin-php-page .select-shell::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #64748b;
  pointer-events: none;
}

.td-page.admin-php-page select.admin-select {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 42px 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.td-page.admin-php-page select.admin-select:hover:not(:disabled) {
  border-color: #c7d2fe;
}

.td-page.admin-php-page select.admin-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.td-page.admin-php-page select.admin-select:disabled {
  opacity: 0.65;
  cursor: wait;
  background: #f8fafc;
}

.td-page.admin-php-page .btn-continue {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}

.td-page.admin-php-page .btn-continue:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.32);
}

.td-page.admin-php-page .btn-continue:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.td-page.admin-php-page .continue-hint {
  margin: 0 0 10px 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}

.td-page.admin-php-page .continue-err {
  margin: 10px 0 0 0;
  font-size: 0.88rem;
  color: #b91c1c;
  font-weight: 700;
}

.td-page.admin-php-page .continue-foot {
  margin: 12px 0 0 0;
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 600;
}

.td-page.admin-php-page .continue-foot a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.td-page.admin-php-page .continue-foot a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .td-page.admin-php-page .continue-controls {
    flex-direction: column;
  }

  .td-page.admin-php-page .btn-continue {
    width: 100%;
  }
}

/* ——— tournaments/admin_games_tournaments.php ——— */

.td-page.agt-page .td-card-body.agt-body {
  padding: 0;
}

.td-page.agt-page .agt-body > .content {
  padding: 22px 20px 28px;
}

@media (max-width: 640px) {
  .td-page.agt-page .agt-body > .content {
    padding: 16px 14px 22px;
  }
}

/* admin_games_tournaments: матрица группы — другой порядок колонок, широкая таблица */
.td-page.agt-page .card {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.td-page.agt-page .tournament-matrix-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}

.td-page.agt-page .tournament-matrix-table .matrix-header:first-child {
  width: 60px;
  min-width: 60px;
  max-width: 72px;
  text-align: center;
  padding: 10px 6px;
  font-size: 0.82em;
}

.td-page.agt-page .tournament-matrix-table .matrix-header:nth-child(2) {
  min-width: 150px;
  width: auto;
  text-align: left;
  padding-left: 12px;
}

.td-page.agt-page .tournament-matrix-table .matrix-cell-team {
  min-width: 150px;
}

.td-page.agt-page .agt-matrix-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
