/* Dedicated tournament page shell.
   Kept separate from the home/game responsive rules on purpose. */

body.tournament-page-view {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  background-attachment: scroll;
}

body.tournament-page-view > .app,
body.tournament-page-view > .site-footer,
body.tournament-page-view > .beta-banner {
  display: none !important;
}

body.tournament-page-view > #tournamentLobbyPanel.tournament-lobby-panel {
  position: relative;
  z-index: 2;
  width: min(1480px, calc(100% - 32px)) !important;
  max-width: 1480px !important;
  min-width: 0 !important;
  min-height: calc(100dvh - 32px) !important;
  max-height: none !important;
  margin: 16px auto !important;
  padding: clamp(20px, 2.5vw, 36px) !important;
  overflow: visible !important;
  border-radius: 24px !important;
}

body.tournament-page-view .tournament-page-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: start !important;
  gap: 20px !important;
}

body.tournament-page-view .tournament-page-head > div {
  min-width: 0;
}

body.tournament-page-view .tournament-page-head .back-nav-btn {
  width: auto !important;
  min-width: 118px !important;
  min-height: 44px !important;
  margin: 0 !important;
}

body.tournament-page-view .tournament-list,
body.tournament-page-view .tournament-card,
body.tournament-page-view .tournament-details-grid,
body.tournament-page-view .tournament-duration-section,
body.tournament-page-view .tournament-community-card {
  min-width: 0;
  max-width: 100%;
}

body.tournament-page-view .tournament-card {
  overflow: hidden;
}

body.tournament-page-view .tournament-bracket-shell {
  width: 100%;
  max-width: 100%;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 760px) {
  body.tournament-page-view {
    background-color: #0b111a;
    background-image:
      linear-gradient(180deg, rgba(4, 8, 14, 0.42), rgba(5, 8, 10, 0.92)),
      radial-gradient(circle at 50% 0%, rgba(44, 116, 220, 0.2), transparent 42%),
      var(--season-bg);
  }

  body.tournament-page-view > #tournamentLobbyPanel.tournament-lobby-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    padding:
      max(14px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left)) !important;
    border-width: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body.tournament-page-view .tournament-page-head {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }

  body.tournament-page-view .tournament-page-head .eyebrow {
    margin: 0 0 4px;
    font-size: 0.62rem;
  }

  body.tournament-page-view .tournament-page-head h2 {
    font-size: clamp(1.35rem, 7vw, 2rem) !important;
    line-height: 1 !important;
  }

  body.tournament-page-view .tournament-page-head > div > p:last-child {
    margin-top: 6px;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  body.tournament-page-view .tournament-page-head .back-nav-btn {
    width: 88px !important;
    min-width: 88px !important;
    min-height: 40px !important;
    padding: 7px 10px !important;
    font-size: 0.76rem !important;
  }

  body.tournament-page-view .tournament-explainer {
    grid-template-columns: 1fr !important;
    gap: 7px !important;
    margin: 14px 0 22px !important;
  }

  body.tournament-page-view .tournament-explainer article {
    gap: 3px;
    padding: 11px 12px;
  }

  body.tournament-page-view .tournament-explainer article span {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  body.tournament-page-view .tournament-section-title,
  body.tournament-page-view .tournament-card-head {
    align-items: flex-start !important;
    gap: 8px !important;
  }

  body.tournament-page-view .tournament-section-title {
    flex-direction: column !important;
  }

  body.tournament-page-view .tournament-list {
    gap: 14px;
    margin: 12px 0 22px;
  }

  body.tournament-page-view .tournament-card {
    padding: 13px !important;
    border-radius: 15px;
  }

  body.tournament-page-view .tournament-card-head h3 {
    font-size: clamp(1.08rem, 5.5vw, 1.45rem);
  }

  body.tournament-page-view .tournament-capacity {
    min-width: 58px;
  }

  body.tournament-page-view .tournament-details-grid,
  body.tournament-page-view .tournament-admin-form,
  body.tournament-page-view .tournament-sponsor-input-row,
  body.tournament-page-view .tournament-community-card {
    grid-template-columns: 1fr !important;
  }

  body.tournament-page-view .tournament-details-grid {
    gap: 8px;
    margin: 13px 0;
  }

  body.tournament-page-view .tournament-details-grid > div,
  body.tournament-page-view .tournament-duration-section,
  body.tournament-page-view .tournament-community-card,
  body.tournament-page-view .tournament-admin-panel {
    padding: 12px;
  }

  body.tournament-page-view .tournament-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body.tournament-page-view .tournament-actions button {
    width: 100%;
    min-height: 42px;
  }

  body.tournament-page-view .tournament-bracket-shell {
    margin: 16px 0 0;
    padding: 6px 0 14px;
    scroll-snap-type: x mandatory;
  }

  body.tournament-page-view .tournament-bracket {
    grid-template-columns: repeat(var(--round-count), minmax(0, calc(100vw - 48px))) !important;
    min-width: calc(var(--round-count) * (100vw - 28px)) !important;
    gap: 20px;
  }

  body.tournament-page-view .tournament-bracket-round {
    min-width: 0;
    scroll-snap-align: start;
  }

  body.tournament-page-view .tournament-duration-table {
    overflow-x: auto;
  }

  body.tournament-page-view .tournament-duration-table > div {
    min-width: 390px;
    grid-template-columns: 72px 64px minmax(210px, 1fr);
    gap: 8px;
  }

  body.tournament-page-view .tournament-prize-row {
    grid-template-columns: minmax(92px, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  body.tournament-page-view > #tournamentLobbyPanel.tournament-lobby-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
    padding:
      max(10px, env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left)) !important;
    overflow: visible !important;
    border-width: 0 !important;
    border-radius: 0 !important;
  }

  body.tournament-page-view .tournament-page-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    margin-bottom: 10px !important;
  }

  body.tournament-page-view .tournament-page-head h2 {
    font-size: clamp(1.25rem, 4vw, 1.8rem) !important;
  }

  body.tournament-page-view .tournament-explainer {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 10px 0 18px !important;
  }

  body.tournament-page-view .tournament-explainer article {
    padding: 9px 10px;
  }

  body.tournament-page-view .tournament-details-grid {
    grid-template-columns: 1.35fr 1fr !important;
  }

  body.tournament-page-view .tournament-community-card {
    grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.5fr) !important;
  }

  body.tournament-page-view .tournament-community-card .tournament-official-chip {
    grid-column: 1 / -1;
  }
}
