/**
 * Tournaments (player hub) — chalksta-app companion
 * body.chalksta-app.chalksta-page-tournaments
 *
 * Bracket / Survivors UI lives in survivors-admin-v2 + jQuery bracket; preserve IDs.
 */

.chalksta-page-tournaments .chalksta-ts-main {
  padding-top: 1rem;
  padding-bottom: 2rem;
}

.chalksta-page-tournaments .chalksta-tournaments-jumbo {
  color: var(--idx-fg);
  background: var(--idx-surface);
  border: 1px solid var(--idx-border);
  border-radius: 10px;
  padding: 1rem 1rem 1.25rem;
  margin-bottom: 0;
}

.chalksta-page-tournaments .chalksta-tournaments-jumbo .custom-control-label {
  color: var(--idx-fg);
}

/* Elimination bracket host — was hardcoded #3d3d3d */
.chalksta-page-tournaments #toplevel_manage_div {
  background: var(--idx-surface-alt) !important;
  border-radius: 8px;
  border: 1px solid var(--idx-border);
}

/* Lives 2 active jumbo (class toggled by tournaments.js) */
.chalksta-page-tournaments #main_jumbo.sv2-player-jumbo-lives2-active {
  background: var(--idx-surface);
}

.chalksta-page-tournaments #time_date_info_div {
  color: var(--idx-fg) !important;
}

.chalksta-page-tournaments #share_tourny p {
  color: var(--idx-muted);
}

.chalksta-page-tournaments #share_tourny:hover p {
  color: var(--espn-red);
}

@media (max-width: 767px) {
  .chalksta-page-tournaments .chalksta-tournaments-jumbo .row {
    flex-wrap: wrap;
  }

  .chalksta-page-tournaments .chalksta-tournaments-jumbo .col.text-right {
    text-align: left !important;
    margin-top: 0.5rem;
  }
}

/* =============================================================================
 * Tournament picker — #tourny_select lives in #selector_col (not inside .survivors-admin-v2),
 * so it only got legacy sitestyles .mainselectheaderstyle (#3d3d3d / #f4dbaa). Match idx-header select.
 * ============================================================================= */
body.chalksta-app.chalksta-page-tournaments #selector_col select#mainselectheaderstyle,
body.chalksta-app.chalksta-page-tournaments #selector_col select.mainselectheaderstyle,
body.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.35;
  padding: 0.5rem 2.35rem 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--idx-border) !important;
  /* Single layer replaces sitestyles multi-gradient .mainselectheaderstyle */
  background: var(--idx-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath stroke='%236e6e73' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 1rem 1rem !important;
  color: var(--idx-fg) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  margin: 0;
}

body.dark-theme.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle {
  background: var(--idx-surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none'%3E%3Cpath stroke='%23999999' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.65rem center / 1rem 1rem !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

body.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle:hover {
  border-color: var(--espn-red) !important;
}

body.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle:focus {
  outline: 2px solid var(--espn-red);
  outline-offset: 2px;
  border-color: var(--espn-red) !important;
}

body.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle option {
  background: var(--idx-surface);
  color: var(--idx-fg);
}

body.dark-theme.chalksta-app.chalksta-page-tournaments #tourny_select.mainselectheaderstyle option {
  background: var(--idx-surface-alt);
  color: var(--idx-fg);
}

body.chalksta-app.chalksta-page-tournaments #selector_col .sv2-tourny-select-label {
  color: var(--idx-muted);
  font-family: "Oswald", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Subtle label above injected #tourny_select (JS appends only the select) */
body.chalksta-app.chalksta-page-tournaments #selector_col:has(#tourny_select)::before {
  content: "this tournament";
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--idx-muted);
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

/* =============================================================================
 * Player tournament tab — survivors-admin-v2.css forces legacy #3d3d3d + cream on
 * #player-tournament-sv2.sv2-player-tournaments-view for BOTH light and dark (lines ~5200–5223).
 * Override for chalksta so #stats_tracker / lives area follow --idx-* when theme toggles.
 * ============================================================================= */
body.chalksta-app.chalksta-page-tournaments #player-tournament-sv2.sv2-player-tournaments-view.sv2-manage-tab {
  background: var(--idx-surface) !important;
  background-color: var(--idx-surface) !important;
  color: var(--idx-fg) !important;
  --sv2-bg: var(--idx-bg);
  --sv2-fg: var(--idx-fg);
  --sv2-muted: var(--idx-muted);
  --sv2-border: var(--idx-border);
  --sv2-surface: var(--idx-surface);
  --sv2-surface-alt: var(--idx-surface-alt);
  --sv2-espn-red: var(--espn-red);
  --sv2-espn-red-dark: var(--espn-red-dark);
}

/* =============================================================================
 * Lives 2 (sv2) player board — map Survivors v2 tokens to chalksta --idx-* so rails + board
 * match tournaments.html shell (survivors-admin-v2.css uses parallel --sv2-* values).
 * ============================================================================= */
.chalksta-page-tournaments #player-sv2-lives-board-shell.survivors-admin-v2.sv2-player-lives-board {
  --sv2-bg: var(--idx-bg);
  --sv2-fg: var(--idx-fg);
  --sv2-surface: var(--idx-surface);
  --sv2-surface-alt: var(--idx-surface-alt);
  --sv2-muted: var(--idx-muted);
  --sv2-border: var(--idx-border);
  --sv2-espn-red: var(--espn-red);
  --sv2-espn-red-dark: var(--espn-red-dark);
  background: var(--idx-surface);
  border-color: var(--idx-border);
  color: var(--idx-fg);
}

body.dark-theme.chalksta-app.chalksta-page-tournaments #player-sv2-lives-board-shell.survivors-admin-v2.sv2-player-lives-board {
  background: var(--idx-surface);
  border-color: var(--idx-border);
  color: var(--idx-fg);
}

/* Outer wrapper for Lives 2 rail + board (inherits themed parent once #player-tournament-sv2 is fixed) */
.chalksta-page-tournaments #main_jumbo.sv2-player-jumbo-lives2-active #stats_tracker.sv2-player-lives2-board-active {
  background: transparent;
  color: var(--idx-fg);
}

/* Inline legacy white on time strip — override so light/dark match tokens */
.chalksta-page-tournaments #lives_div #time_date_info_div {
  color: var(--idx-muted) !important;
}

