/* --- TOURNAMENTS PAGE --- */

.tournaments-page {
  width: 100%;
  padding: 30px;
  box-sizing: border-box;
}

.tournament-hero,
.tournament-listing-section {
  width: 90%;
  max-width: 1400px;
  margin: 20px auto;
  box-sizing: border-box;
}

/* --- HERO --- */

.listing-hero,
.tournament-hero {
  width: 90%;
  max-width: 1400px;
  margin: 20px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;

  background:
    linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(22, 27, 34, 0.96)),
    #161b22;
  border: 1px solid #30363d;
  border-radius: 18px;
  padding: clamp(24px, 4vw, 46px);
  box-sizing: border-box;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.listing-hero h2,
.tournament-hero h2 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1.05;
  text-transform: uppercase;
}

.listing-hero p,
.tournament-hero p {
  color: #8b949e;
  line-height: 1.55;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 10px 0;
}

.btn-main.secondary {
  background: #21262d;
  color: var(--primary);
  border: 1px solid #30363d;
}

.btn-main.secondary:hover {
  border-color: var(--primary);
}

/* --- LISTING HEADER / FILTERS --- */

.tournament-listing-section {
  background: transparent;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.upcoming-label {
  color: #ffffff;
  margin: 0;
  font-size: 1.2rem;
}

.listing-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter-btn {
  background: #21262d;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.filter-btn.active,
.filter-btn:hover {
  background: rgba(0, 212, 255, 0.14);
  color: var(--primary);
  border-color: var(--primary);
}

/* --- TOURNAMENT GRID --- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  max-width: 1400px;
  margin: 20px auto;
}

.tournament-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition:
    transform 0.2s,
    border-color 0.2s;
  box-sizing: border-box;
}

.tournament-card:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
}

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

.card-title {
  color: var(--primary);
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.tournament-status-badge {
  color: white;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.tournament-status-badge.open {
  background: rgba(35, 134, 54, 0.25);
  color: #00ff88;
  border: 1px solid rgba(0, 255, 136, 0.45);
}

.tournament-status-badge.closed {
  background: rgba(255, 193, 7, 0.15);
  color: #ffd166;
  border: 1px solid rgba(255, 209, 102, 0.45);
}

.tournament-status-badge.completed {
  background: rgba(0, 212, 255, 0.12);
  color: var(--primary);
  border: 1px solid rgba(0, 212, 255, 0.45);
}

.tournament-status-badge.full {
  background: rgba(255, 77, 77, 0.15);
  color: #ff7b72;
  border: 1px solid rgba(255, 123, 114, 0.45);
}

/* --- CARD DETAILS --- */

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: #8b949e;
  font-size: 0.86rem;
}

.meta-item {
  min-width: 0;
}

.meta-item a,
.location-box a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.meta-item a:hover,
.location-box a:hover {
  text-decoration: underline;
}

.location-box {
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 6px 10px;
  white-space: nowrap;
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.stat-label {
  color: #ffffff;
  font-weight: 700;
}

.stat-value {
  color: #8b949e;
}

/* --- SPONSOR --- */

.sponsored-card {
  border-color: rgba(0, 212, 255, 0.6);
}

.sponsor-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 900;
}

.sponsor-strip strong {
  color: #ffffff;
  font-size: 0.78rem;
}

.sponsor-message {
  margin: 0;
  color: #8b949e;
  font-size: 0.84rem;
  line-height: 1.45;
}

/* --- BUTTON STATES --- */

.join-btn {
  width: 100%;
  margin-top: auto;
}

.join-btn.joined {
  background: #238636;
  color: #ffffff;
  cursor: not-allowed;
  opacity: 1;
}

.view-bracket-btn {
  width: 100%;
  margin-top: auto;
}

.view-bracket-btn.completed {
  background: #21262d;
  color: var(--primary);
  border: 1px solid #30363d;
}

/* --- STATUS --- */

.status-msg {
  grid-column: 1 / -1;
  color: #8b949e;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 18px;
}

.status-msg a {
  color: var(--primary);
  font-weight: 800;
}

/* --- RESPONSIVE --- */

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .tournaments-page {
    padding: 18px;
  }

  .listing-hero,
  .tournament-hero,
  .tournament-listing-section {
    width: 96vw;
  }

  .listing-hero,
  .tournament-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .listing-filters {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .meta-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .location-box {
    width: fit-content;
  }
}

.join-btn.confirm-payment {
  background: #f97316;
  color: #ffffff;
  border: 1px solid #fb923c;
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.35);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  letter-spacing: 0.03em;
  padding-left: 12px;
  padding-right: 12px;
}

.join-btn.confirm-payment:hover {
  background: #ea580c;
  border-color: #fdba74;
  transform: translateY(-1px);
}

/* --- MOBILE TOURNAMENT DIRECTORY POLISH --- */

@media (max-width: 700px) {
  .main-content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tournament-directory-hero,
  .tournaments-hero,
  .directory-hero {
    width: 100%;
    padding: 26px 24px;
    border-radius: 18px;
    box-sizing: border-box;
  }

  .tournament-directory-hero h1,
  .tournaments-hero h1,
  .directory-hero h1 {
    font-size: 1.75rem;
    line-height: 1.12;
  }

  .tournament-directory-hero p,
  .tournaments-hero p,
  .directory-hero p {
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .tournament-listing-section,
  .tournaments-section,
  .competition-board {
    width: 100%;
    box-sizing: border-box;
  }

  .tournament-filter-tabs,
  .filter-tabs,
  .tournament-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .tournament-filter-tabs button,
  .filter-tabs button,
  .tournament-tabs button {
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .tournament-card,
  .public-tournament-card,
  .tournament-list-card {
    width: 100%;
    padding: 20px;
    border-radius: 16px;
    box-sizing: border-box;
  }

  .tournament-card h3,
  .public-tournament-card h3,
  .tournament-list-card h3 {
    font-size: 1.45rem;
    line-height: 1.15;
    margin-bottom: 14px;
  }

  .tournament-card-meta,
  .tournament-meta,
  .tournament-info-row {
    gap: 8px;
  }

  .tournament-details-grid,
  .tournament-stats-grid,
  .tournament-card-details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tournament-card .btn-main,
  .public-tournament-card .btn-main,
  .tournament-list-card .btn-main,
  .join-tournament-btn {
    width: 100%;
    min-height: 42px;
    margin-top: 14px;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  .status-badge,
  .tournament-status-badge {
    font-size: 0.7rem;
    padding: 6px 10px;
  }
}


/* --- PAGE SHELL CENTERING FIX: TOURNAMENTS --- */
main.tournaments-page,
.main-content.tournaments-page {
  width: min(94vw, 1400px) !important;
  max-width: 1400px !important;
  margin: 140px auto 40px auto !important;
  padding: 0 24px !important;
  box-sizing: border-box !important;
  align-items: center !important;
}

.tournament-hero,
.listing-hero,
.tournament-listing-section {
  width: 100% !important;
  max-width: 1400px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 720px) {
  main.tournaments-page,
  .main-content.tournaments-page {
    width: 100% !important;
    margin: 120px auto 30px auto !important;
    padding: 0 14px !important;
  }
}

/* --- DESKTOP ADAPTIVE WIDTH UPGRADE --- */
:root { --tournaments-content-max: 1400px; }
.main-content.tournaments-page,
.tournaments-page,
.tournament-hero,
.listing-hero,
.tournament-listing-section,
.grid {
  width: min(94vw, var(--tournaments-content-max)) !important;
  max-width: var(--tournaments-content-max) !important;
}
@media (min-width: 1500px) {
  :root { --tournaments-content-max: 1640px; }
  .main-content.tournaments-page,
  .tournaments-page,
  .tournament-hero,
  .listing-hero,
  .tournament-listing-section,
  .grid { width: min(92vw, var(--tournaments-content-max)) !important; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1900px) {
  :root { --tournaments-content-max: 1840px; }
  .main-content.tournaments-page,
  .tournaments-page,
  .tournament-hero,
  .listing-hero,
  .tournament-listing-section,
  .grid { width: min(90vw, var(--tournaments-content-max)) !important; }
}
@media (min-width: 2300px) { :root { --tournaments-content-max: 2040px; } .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1100px) { :root { --tournaments-content-max: 1400px; } }

/* --- TOURNAMENTS BILINGUAL / RTL SUPPORT --- */
html[dir="rtl"] .tournaments-page,
html[dir="rtl"] .listing-hero,
html[dir="rtl"] .tournament-listing-section,
html[dir="rtl"] .tournament-card {
  text-align: right;
}

html[dir="rtl"] .listing-hero,
html[dir="rtl"] .section-heading-row,
html[dir="rtl"] .card-header,
html[dir="rtl"] .meta-row,
html[dir="rtl"] .sponsor-strip {
  direction: rtl;
}

html[dir="rtl"] .listing-filters {
  justify-content: flex-start;
  direction: rtl;
}

html[dir="rtl"] .card-stats {
  direction: rtl;
}

html[dir="rtl"] .location-box a,
html[dir="rtl"] .meta-item,
html[dir="rtl"] .stat-box,
html[dir="rtl"] .status-msg {
  direction: rtl;
}

html[dir="rtl"] .banner-title,
html[dir="rtl"] .footer-brand-mark {
  direction: ltr;
}

/* =========================================================
   64.1 PRE-LAUNCH MOBILE TOURNAMENTS CENTERING
   Normalize the tournament directory rail on phone/tablet widths.
   ========================================================= */
@media (max-width: 1023px) {
  main.tournaments-page,
  .main-content.tournaments-page {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: clamp(14px, 3.8vw, 24px) !important;
    padding-right: clamp(14px, 3.8vw, 24px) !important;
    box-sizing: border-box !important;
  }

  .tournament-hero,
  .listing-hero,
  .tournament-listing-section,
  .grid {
    width: 100% !important;
    max-width: 900px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
  }
}
