/* Test against Tournament Teams (builder/tournament-view.js), loaded after builder.css.
   One colour language: good / mid / bad = Favoured / Even / Behind for matchups and
   Wins / Close / Loses for duels; plain facts (brought, leads) use the neutral line
   colour. Nothing here needs more width than the column it sits in; only the lead matrix
   with all 15 pairs shown scrolls sideways, inside its own box. */

/* --- how it works, controls, progress ---------------------------------------------------- */
.bd-tour-explain { display: grid; gap: 0.5rem; margin-bottom: 0.9rem; }
.bd-tour-how { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 0.5rem; }
.bd-tour-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.55rem; align-items: start; padding: 0.65rem 0.7rem; border: 1px solid var(--bd-line); border-radius: 10px; background: var(--bd-card-deep); }
.bd-tour-step-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #062010; background: var(--bd-good); font-family: var(--bd-mono); font-size: 0.78rem; font-weight: 800; }
.bd-tour-step strong { display: block; font-family: var(--bd-mono); font-size: 0.82rem; }
.bd-tour-step p { margin: 0.2rem 0 0; font-size: 0.76rem; line-height: 1.45; color: var(--muted); }
.bd-tour-limits { margin: 0; font-size: 0.74rem; line-height: 1.45; }
.bd-tour-howto { margin-bottom: 0.8rem; }
.bd-tour-howto > summary { width: max-content; max-width: 100%; cursor: pointer; color: var(--brand); font-size: 0.82rem; font-weight: 750; }
.bd-tour-howto[open] > summary { margin-bottom: 0.5rem; }
.bd-tour-controls { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 0.7rem 1rem; margin-bottom: 0.8rem; padding: 0.75rem 0.85rem; border: 1px solid var(--bd-line); border-radius: 10px; background: var(--bd-card-deep); }
.bd-tour-limit { display: grid; gap: 0.35rem; min-width: 0; }
.bd-tour-limit .bd-field-label { margin: 0; }
.bd-tour-progress { margin-bottom: 0.8rem; }
.bd-tour-host { min-width: 0; }

/* --- the results ------------------------------------------------------------------------ */
.bd-tr { display: grid; gap: 0.75rem; min-width: 0; }
.bd-tr-card { display: grid; gap: 0.65rem; min-width: 0; padding: 0.85rem 0.9rem; border: 1px solid var(--bd-line); border-radius: 12px; background: var(--bd-card-deep); }
.bd-tr-head { display: grid; gap: 0.15rem; }
.bd-tr-head h3 { margin: 0; font-family: var(--bd-mono); font-size: 0.92rem; color: var(--text); }
.bd-tr-head .bd-note { margin: 0; line-height: 1.4; }
.bd-tr h4 { margin: 0; font-family: var(--bd-mono); font-size: 0.82rem; color: var(--text); }
.bd-tr .bd-note { line-height: 1.4; }

/* Pills: Favoured / Even / Behind, High / Medium. */
.bd-tr-pill { display: inline-flex; align-items: center; justify-self: end; padding: 0.12rem 0.55rem; border-radius: 999px; font-family: var(--bd-mono); font-size: 0.7rem; font-weight: 800; white-space: nowrap; color: #07110b; background: var(--bd-line-strong); }
.bd-tr-pill.good { background: var(--bd-good); }
.bd-tr-pill.mid { background: var(--bd-mid); }
.bd-tr-pill.bad { background: var(--bd-bad); }

/* Stacked Favoured / Even / Behind bar (verdict and archetypes). */
.bd-tr-bands { display: flex; height: 18px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.14); }
.bd-tr-bands.small { height: 10px; }
.bd-tr-bands i { display: block; height: 100%; transition: width 300ms ease; }
.bd-tr-bands i + i { box-shadow: inset 2px 0 0 rgba(5, 13, 8, 0.85); }
.bd-tr-bands .good, .bd-tr-legend .good i { background: var(--bd-good); }
.bd-tr-bands .mid, .bd-tr-legend .mid i { background: var(--bd-mid); }
.bd-tr-bands .bad, .bd-tr-legend .bad i { background: var(--bd-bad); }
.bd-tr-legend { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; font-size: 0.72rem; color: var(--muted); }
.bd-tr-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.bd-tr-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

/* The verdict */
.bd-tr-verdict { --tone: var(--bd-mid); display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem 1.2rem; padding: 1rem; border: 1px solid var(--bd-line-strong); border-left: 4px solid var(--tone); border-radius: 12px; background: linear-gradient(120deg, rgba(114, 255, 171, 0.08), rgba(7, 17, 11, 0.6)); }
.bd-tr-verdict.good { --tone: var(--bd-good); }
.bd-tr-verdict.bad { --tone: var(--bd-bad); }
.bd-tr-verdict-main { display: grid; gap: 0.55rem; min-width: 0; align-content: start; }
.bd-tr-kicker { margin: 0; font-family: var(--bd-mono); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }
.bd-tr-verdict h3 { margin: 0; font-size: clamp(1.05rem, 2.2vw, 1.35rem); line-height: 1.2; color: var(--tone); }
.bd-tr-sub { margin: 0; font-size: 0.84rem; color: var(--text); }
.bd-tr-bandlabels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.bd-tr-bandlabels span { display: grid; gap: 0.05rem; min-width: 0; }
.bd-tr-bandlabels b { font: 800 1.35rem/1.1 var(--bd-mono); font-variant-numeric: tabular-nums; }
.bd-tr-bandlabels small { font-size: 0.72rem; color: var(--muted); }
.bd-tr-bandlabels .good b { color: var(--bd-good); }
.bd-tr-bandlabels .mid b { color: var(--bd-mid); }
.bd-tr-bandlabels .bad b { color: var(--bd-bad); }
.bd-tr-verdict-score { display: grid; align-content: center; justify-items: start; gap: 0.1rem; min-width: 0; padding: 0.7rem 0.8rem; border: 1px solid var(--bd-line); border-radius: 10px; background: rgba(5, 13, 8, 0.6); }
.bd-tr-verdict-score small { font-family: var(--bd-mono); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }
.bd-tr-verdict-score > b { font: 800 2.2rem/1 var(--bd-mono); font-variant-numeric: tabular-nums; }
.bd-tr-verdict-score > span { font-size: 0.76rem; color: var(--muted); }
.bd-tr-verdict-score .bd-note { margin: 0.35rem 0 0; font-size: 0.72rem; }
.bd-tr b.good { color: var(--bd-good); }
.bd-tr b.mid { color: var(--bd-mid); }
.bd-tr b.bad { color: var(--bd-bad); }

/* Bring: the recommended choice and the other strong ones, sprites with the leads marked */
.bd-tr-options { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.bd-tr-option { display: grid; grid-template-columns: 1.4rem auto minmax(0, 1fr); gap: 0.4rem 0.7rem; align-items: center; min-width: 0; padding: 0.5rem 0.65rem; border: 1px solid transparent; border-radius: 10px; background: rgba(7, 17, 11, 0.55); }
.bd-tr-option.first { border-color: rgba(114, 255, 171, 0.35); background: linear-gradient(120deg, rgba(114, 255, 171, 0.08), rgba(7, 17, 11, 0.55)); }
.bd-tr-option-rank { display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; font-family: var(--bd-mono); font-size: 0.72rem; font-weight: 800; color: var(--text); background: rgba(148, 163, 184, 0.16); }
.bd-tr-option.first .bd-tr-option-rank { color: #062010; background: var(--bd-good); }
.bd-tr-option-mons { display: flex; flex-wrap: nowrap; gap: 0.25rem; min-width: 0; }
.bd-tr-option-mon { display: grid; justify-items: center; gap: 0.05rem; padding: 0.15rem 0.1rem 0.1rem; border-radius: 8px; }
.bd-tr-option-mon small { font-family: var(--bd-mono); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.1; color: var(--soft); }
.bd-tr-option-mon.lead { background: rgba(114, 255, 171, 0.1); box-shadow: inset 0 0 0 1px rgba(114, 255, 171, 0.4); }
.bd-tr-option-mon.lead small { color: var(--bd-good); }
.bd-tr-option-text { display: grid; gap: 0.1rem; min-width: 0; }
.bd-tr-option-text strong { font-family: var(--bd-mono); font-size: 0.8rem; color: var(--text); }
.bd-tr-option-text p { margin: 0; font-size: 0.8rem; line-height: 1.35; color: var(--text); }
.bd-tr-option-text small { font-size: 0.72rem; color: var(--muted); }
.bd-tr-options-label { margin: 0.2rem 0 -0.1rem; font-family: var(--bd-mono); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }

/* Biggest threats */
.bd-tr-threats, .bd-tr-archs { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.bd-tr-threat { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0.6rem; align-items: start; padding: 0.5rem 0.6rem; border-radius: 10px; background: rgba(7, 17, 11, 0.55); }
.bd-tr-threat-main { display: grid; gap: 0.15rem; min-width: 0; }
.bd-tr-threat-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-width: 0; }
.bd-tr-threat-top strong { font-family: var(--bd-mono); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-tr-threat p { margin: 0; font-size: 0.76rem; line-height: 1.4; color: var(--muted); }
.bd-tr-threat p b { color: var(--text); }

/* Your Pokémon: a table on wide screens, cards on phones */
.bd-tr-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
/* The site's table styles tint every th (styles.css); this table stays on the card colour. */
.bd-tr-table th, .bd-tr-table td { padding: 0.45rem 0.4rem; border-bottom: 1px solid rgba(148, 163, 184, 0.14); background: transparent !important; text-align: right; vertical-align: middle; }
.bd-tr-table thead th { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); white-space: nowrap; }
.bd-tr-table thead th:first-child { text-align: left; }
.bd-tr-table tbody tr:last-child > * { border-bottom: 0; }
.bd-tr-table td { color: var(--text); font-family: var(--bd-mono); white-space: nowrap; }
.bd-tr-table .bd-tr-mon { width: 40%; text-align: left; text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--text); }
.bd-tr-mon > div { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0.5rem; align-items: center; }
.bd-tr-mon > div > span { display: grid; min-width: 0; }
.bd-tr-mon strong { font-family: var(--bd-mono); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-tr-mon small { font-size: 0.7rem; font-weight: 600; color: var(--muted); white-space: normal; }
.bd-tr-fact { display: inline-grid; justify-items: end; gap: 0.2rem; min-width: 3.2rem; }
.bd-tr-fact > i { display: block; width: 100%; height: 4px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.14); }
.bd-tr-fact > i > i { display: block; height: 100%; border-radius: 999px; background: var(--bd-line-strong); }
.bd-tr-win { font-weight: 800; }
.bd-tr-win.good { color: var(--bd-good); }
.bd-tr-win.mid { color: var(--bd-mid); }
.bd-tr-win.bad { color: var(--bd-bad); }
.bd-tr-partner { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0.3rem; }
.bd-tr-partner small { font-family: "Segoe UI", Inter, Roboto, sans-serif; font-size: 0.72rem; color: var(--muted); }

/* By archetype */
.bd-tr-arch { display: grid; gap: 0.3rem; padding: 0.45rem 0.6rem 0.55rem; border-radius: 10px; background: rgba(7, 17, 11, 0.55); }
.bd-tr-arch-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.2rem 0.6rem; }
.bd-tr-arch-top strong { font-family: var(--bd-mono); font-size: 0.82rem; }
.bd-tr-arch-top small { font-size: 0.72rem; color: var(--muted); }

/* Hardest / easiest teams: all six Pokémon, then the story */
.bd-tr-games { display: grid; gap: 0.4rem; }
.bd-tr-game { border-radius: 10px; background: rgba(7, 17, 11, 0.55); }
.bd-tr-game > summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 0.7rem; gap: 0.55rem; align-items: center; padding: 0.45rem 0.6rem; list-style: none; cursor: pointer; }
.bd-tr-game > summary::-webkit-details-marker { display: none; }
.bd-tr-game > summary::after { content: "▸"; color: var(--soft); font-size: 0.8rem; text-align: center; transition: transform 160ms ease; }
.bd-tr-game[open] > summary::after { transform: rotate(90deg); }
.bd-tr-game[open] > summary { border-bottom: 1px solid var(--bd-line); }
.bd-tr-game > summary:hover { background: rgba(114, 255, 171, 0.05); }
.bd-tr-game > summary:focus-visible { outline: 2px solid var(--bd-on-line); outline-offset: 2px; }
.bd-tr-six { display: flex; flex-wrap: nowrap; gap: 0.1rem; min-width: 0; }
.bd-tr-six img { flex: none; }
.bd-tr-game-title { display: grid; min-width: 0; }
.bd-tr-game-title strong { font-family: var(--bd-mono); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-tr-game-title small { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-tr-game-body { display: grid; gap: 0.4rem; padding: 0.6rem 0.75rem 0.75rem; font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
.bd-tr-game-body p { margin: 0; }
.bd-tr-game-body b { color: var(--text); }
.bd-tr-game-label { font-family: var(--bd-mono); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }
.bd-tr-story { display: grid; gap: 0.2rem; margin: 0; padding-left: 1.1rem; color: var(--text); }
.bd-tr-story li::marker { color: var(--soft); }
.bd-tr-result { color: var(--text) !important; font-weight: 650; }

/* The lead matrix: their pairs (or Pokémon) down, yours across as sprites only. */
.bd-tr-mx-block { display: grid; gap: 0.55rem; min-width: 0; }
.bd-tr-mx-scroll { min-width: 0; }
.bd-tr-mx-scroll.wide { overflow-x: auto; padding-bottom: 0.2rem; }
.bd-tr-mx { --name: minmax(150px, 2.1fr); display: grid; gap: 3px; min-width: 0; }
.bd-tr-mx-scroll.wide .bd-tr-mx { min-width: calc(170px + var(--cols) * 42px); }
.bd-tr-mx-row { display: grid; grid-template-columns: var(--name) repeat(var(--cols, 6), minmax(0, 1fr)); gap: 3px; align-items: stretch; }
.bd-tr-mx-corner { align-self: end; padding-bottom: 0.2rem; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }
.bd-tr-mx-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0; min-width: 0; padding: 0.15rem 0 0.2rem; border-radius: 6px; background: rgba(148, 163, 184, 0.07); }
.bd-tr-mx-col img { max-width: 100%; height: auto; }
.bd-tr-mx-name { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.35rem; align-items: center; min-width: 0; }
.bd-tr-mx-sprites { display: flex; flex-wrap: nowrap; }
.bd-tr-mx-sprites img { flex: none; }
.bd-tr-mx-sprites img + img { margin-left: -6px; }
.bd-tr-mx-name > span:last-child { display: grid; min-width: 0; }
.bd-tr-mx-name strong { font-size: 0.74rem; line-height: 1.25; overflow-wrap: anywhere; }
.bd-tr-mx-name small { font-size: 0.64rem; line-height: 1.25; color: var(--soft); }
.bd-tr-mx-cell { display: grid; place-items: center; align-content: center; min-width: 0; min-height: 34px; border-radius: 6px; font-family: var(--bd-mono); font-size: 0.7rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #07110b; }
.bd-tr-mx-cell span { font-size: 0.56rem; line-height: 1; }
.bd-tr-mx-cell.good { background: rgba(114, 255, 171, 0.82); }
.bd-tr-mx-cell.mid { background: rgba(242, 207, 91, 0.82); }
.bd-tr-mx-cell.bad { background: rgba(255, 122, 102, 0.82); }
.bd-tr-mx-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.8rem; }
.bd-tr-mx-foot .bd-note { margin: 0; }
.bd-tr-mx-foot .bd-actions { margin: 0; }

/* The most similar tournament team (the member tiles come from builder.css .bd-similar-*) */
.bd-tr-similar { padding: 0.7rem; }
.bd-tr-similar-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem 0.6rem; margin-bottom: 0.55rem; }
.bd-tr-similar-head .bd-similar-verdict { margin: 0; }
.bd-tr-similar-score { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--muted); }
.bd-tr-similar-score b { font-family: var(--bd-mono); }
.bd-tr-similar .bd-actions { margin: 0; flex-wrap: wrap; }

.bd-tr.running .bd-tr-verdict { box-shadow: inset 0 0 0 1px rgba(114, 255, 171, 0.12); }

@media (max-width: 760px) {
  .bd-tr-verdict { grid-template-columns: minmax(0, 1fr); padding: 0.85rem; }
  .bd-tr-card { padding: 0.75rem; }
  /* Your Pokémon: one card per Pokémon, the numbers in a 3-column grid under its name. */
  .bd-tr-table thead { display: none; }
  .bd-tr-table, .bd-tr-table tbody { display: grid; gap: 0.45rem; }
  .bd-tr-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.35rem 0.5rem; padding: 0.55rem 0.6rem; border-radius: 10px; background: rgba(7, 17, 11, 0.55); }
  .bd-tr-table th, .bd-tr-table td { padding: 0; border: 0; }
  .bd-tr-table .bd-tr-mon { grid-column: 1 / -1; width: auto; }
  .bd-tr-table td { display: grid; gap: 0.05rem; text-align: left; font-size: 0.82rem; }
  .bd-tr-table td::before { content: attr(data-label); font-family: "Segoe UI", Inter, Roboto, sans-serif; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--soft); }
  .bd-tr-fact { justify-items: start; }
  .bd-tr-partner { justify-content: flex-start; }
}

@media (max-width: 560px) {
  /* A bring option: the sprites get their own row. */
  .bd-tr-option { grid-template-columns: 1.4rem minmax(0, 1fr); }
  .bd-tr-option-mons { grid-column: 2; }
  .bd-tr-option-text { grid-column: 1 / -1; }
  /* A team row: six sprites on top, the name and the pill under them. */
  .bd-tr-game > summary { grid-template-columns: minmax(0, 1fr) auto 0.7rem; row-gap: 0.3rem; }
  .bd-tr-six { grid-column: 1 / 3; }
  .bd-tr-game > summary::after { grid-column: 3; grid-row: 1; }
  .bd-tr-game-title { grid-column: 1; grid-row: 2; }
  .bd-tr-game > summary .bd-tr-pill { grid-column: 2 / 4; grid-row: 2; }
  /* The lead matrix: each row's name on its own line above its cells. */
  .bd-tr-mx-row { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); }
  .bd-tr-mx-scroll.wide .bd-tr-mx { min-width: calc(var(--cols) * 40px); }
  .bd-tr-mx-name { grid-column: 1 / -1; margin-top: 0.3rem; }
  .bd-tr-mx-corner { display: none; }
  .bd-tr-mx-cell { min-height: 32px; font-size: 0.64rem; }
}

@media (max-width: 420px) {
  .bd-tr-bandlabels b { font-size: 1.1rem; }
  .bd-tr-option-mon img { width: 34px; height: 34px; }
  .bd-tr-six img { width: 26px; height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .bd-tr-bands i, .bd-tr-game > summary::after { transition: none; }
}
