/* A tournament's TV mode (src/tournament-tv.ts): a screen at the venue, read
   from metres away — dark, large type, high contrast, no controls. Sized by
   the viewport so a projector and a TV look alike. No web fonts. */
:root {
  color-scheme: dark;
  --bg: #050a12;
  --card: #0f172a;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: #1e293b;
  --a: #60a5fa;
  --live: #f87171;
  /* The bracket's (public/tournament-bracket.css). */
  --soft: #111c2e;
  --mine: #3f3a12;
  --bline: #475569;
}
* { box-sizing: border-box; }
body.tv {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* --fit (public/tournament-tv.js): below 1 when a busy screen would run past the bottom — a TV has no scrolling. */
  font-size: calc(clamp(16px, 1.6vw, 34px) * var(--fit, 1));
  line-height: 1.25;
}
.tv-main { padding: 1.2em 2em; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1em; min-height: 100vh; align-content: start; }
.tv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; border-bottom: 2px solid var(--line); padding-bottom: 0.4em; }
.tv-head h1 { margin: 0; font-size: 2em; }
.tv-sample { display: inline-block; vertical-align: middle; margin-left: 0.4em; padding: 0.1em 0.5em; border-radius: 999px; background: var(--a); color: var(--bg, #0b1220); font-size: 0.45em; font-weight: 700; }
/* «Reconectando…» over the last content while the data cannot be refreshed (public/tournament-tv.js). */
.tv-reconnect { position: fixed; top: 0.6em; left: 50%; transform: translateX(-50%); z-index: 10; margin: 0; padding: 0.35em 1em; border-radius: 999px; background: #78350f; color: #fef3c7; font-size: 1.1em; font-weight: 600; box-shadow: 0 2px 12px rgb(0 0 0 / 0.5); }
.tv-reconnect[hidden] { display: none; }
.tv-reconnect small { font-weight: 400; opacity: 0.85; margin-left: 0.4em; }
.tv-clock { margin: 0; font-size: 1.6em; font-variant-numeric: tabular-nums; color: var(--a); }
.tv-clock span { color: var(--muted); font-size: 0.6em; margin-right: 0.3em; }
h2 { margin: 0 0 0.4em; font-size: 1.3em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
h3 { margin: 0 0 0.3em; font-size: 1em; color: var(--a); }
.tv-dot { display: inline-block; width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--live); margin-right: 0.4em; animation: tv-pulse 1.4s infinite; }
@keyframes tv-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .tv-dot { animation: none; } }
/* A game: a grid — lead (time, or the field while live) | home | score or «vs» | away,
   the category and round under the teams. Every track can shrink (minmax(0, …),
   min-width: 0), so a card never gets wider than its column; a long name wraps
   to two lines and is cut after that. */
.tv-games { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; min-width: 0; }
.tv-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 24em), 1fr)); column-gap: 0.8em; }
.tv-game {
  --lead: 3.2em;
  display: grid;
  grid-template-columns: var(--lead) minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "lead home score away" "lead meta meta meta";
  align-items: center;
  column-gap: 0.5em;
  min-width: 0;
  background: var(--card);
  border-radius: 0.4em;
  padding: 0.35em 0.6em;
}
.tv-lead { grid-area: lead; min-width: 0; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); overflow-wrap: break-word; line-height: 1.1; }
.tv-side {
  min-width: 0;
  font-weight: 600;
  font-size: 1.1em;
  line-height: 1.15;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.tv-home { grid-area: home; text-align: right; }
.tv-away { grid-area: away; text-align: left; }
.tv-tbd { color: var(--muted); font-weight: 400; font-style: italic; }
.tv-score { grid-area: score; font-variant-numeric: tabular-nums; font-weight: 800; min-width: 2.2em; text-align: center; white-space: nowrap; }
.tv-game[data-state="scheduled"] .tv-score, .tv-game[data-state="pending"] .tv-score { color: var(--muted); font-weight: 500; font-size: 0.85em; }
.tv-meta { grid-area: meta; min-width: 0; font-size: 0.68em; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Live: the field on the left, the teams and the score in the middle, large. */
.tv-live .tv-game { --lead: 5em; border-left: 0.25em solid var(--live); padding: 0.5em 0.7em; }
.tv-live .tv-side { font-size: 1.25em; }
.tv-live .tv-score { color: var(--live); font-size: 1.6em; min-width: 2.6em; }
.tv-pending .tv-game { background: transparent; border: 1px dashed var(--line); }
.tv-pending h2 { font-size: 1em; }

/* The next games: a column per field (--cols, from the page), never wider than it. */
.tv-fields { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 0.8em; }
.tv-field { min-width: 0; }
.tv-field h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Four columns (or a narrow screen): the teams one under the other, the whole width for the names. */
.tv-fields[data-cols="4"] .tv-game {
  grid-template-columns: var(--lead) minmax(0, 1fr);
  grid-template-areas: "lead home" "lead away" "lead meta";
}
.tv-fields[data-cols="4"] .tv-score { display: none; }
.tv-fields[data-cols="4"] .tv-home, .tv-fields[data-cols="4"] .tv-away, .tv-fields[data-cols="4"] .tv-meta { text-align: left; -webkit-line-clamp: 1; line-clamp: 1; }
@media (max-width: 1000px) {
  .tv-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17em), 1fr)); }
  .tv-fields .tv-game {
    grid-template-columns: var(--lead) minmax(0, 1fr);
    grid-template-areas: "lead home" "lead away" "lead meta";
  }
  .tv-fields .tv-score { display: none; }
  .tv-fields .tv-home, .tv-fields .tv-away, .tv-fields .tv-meta { text-align: left; }
}
.tv-empty { margin: 0; color: var(--muted); font-size: 1.1em; }

/* The categories in turn: tables and results side by side where they fit; the bracket across. */
.tv-slides { border-top: 2px solid var(--line); padding-top: 0.6em; min-width: 0; }
.tv-slide { min-width: 0; }
.tv-slide h2 { color: var(--text); font-size: 1.5em; text-transform: none; }
.tv-slide-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20em), 1fr)); gap: 1em; }
.tv-slide-body > * { min-width: 0; }
.tv-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14em), 1fr)); gap: 0.8em; }
.tv-table { min-width: 0; }
.tv-table table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tv-c-pos { width: 1.8em; }
.tv-c-n { width: 2.4em; }
.tv-c-gd { width: 2.8em; }
.tv-table th, .tv-table td { padding: 0.15em 0.3em; text-align: right; border-bottom: 1px solid var(--line); }
.tv-table th[scope="row"], .tv-table thead th:nth-child(2) { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-table thead th { color: var(--muted); font-weight: 500; font-size: 0.8em; }
.tv-pos { color: var(--muted); }
.tv-pts { font-weight: 800; color: var(--a); }
/* «Mejores terceros»: those going through marked; the group after the name. */
.tv-table tr.tv-qualifies td.tv-pos { color: var(--a); font-weight: 800; box-shadow: inset 0.2em 0 0 var(--a); }
.tv-table th small { color: var(--muted); font-weight: 400; }
.tv-results .tv-game { --lead: 2.8em; }

/* The bracket (public/tournament-bracket.css) at TV size: no scrolling on a screen. */
.tv-slide-bracket { display: block; }
.tv .tp-bracket { font-size: 0.75em; overflow: hidden; --bw: 9em; --bmax: 20em; }
.tv .tp-badge { padding: 0.05em 0.5em; border-radius: 999px; font-weight: 700; text-transform: uppercase; }
.tv .tp-badge-live { background: var(--live); color: #fff; }
.tv .tp-badge-pending { border: 1px dashed var(--muted); color: var(--muted); }
.tv-foot { color: var(--muted); font-size: 0.7em; text-align: right; }

/* Phase 6: the tournament's logo and the sponsors' strip, rolling when it does not fit. */
.tv-logo { height: 1.2em; width: auto; max-width: 4em; object-fit: contain; vertical-align: middle; margin-right: 0.3em; border-radius: 0.15em; background: #fff; padding: 0.05em; }
.tv-sponsors { overflow: hidden; border-top: 2px solid var(--line); padding-top: 0.4em; }
.tv-sponsors h2 { font-size: 0.8em; }
/* Still and centred while the sponsors fit (the copy for the loop hidden); rolling only once the script finds they do not (.tv-rolling). */
.tv-sponsors ul { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; row-gap: 0.4em; margin: 0; padding: 0; list-style: none; }
.tv-sponsors li { flex: none; padding: 0 1em; }
.tv-sponsors li[aria-hidden] { display: none; }
.tv-sponsors.tv-rolling ul { flex-wrap: nowrap; justify-content: flex-start; width: max-content; }
/* The space after each item (not a gap) keeps both halves the same width, so the loop has no jump. */
.tv-sponsors.tv-rolling li { padding: 0 2em 0 0; }
.tv-sponsors.tv-rolling li[aria-hidden] { display: block; }
.tv-sponsors img { height: 2.4em; width: auto; max-width: 7em; object-fit: contain; background: #fff; border-radius: 0.2em; padding: 0.15em; }
.tv-sponsors span { font-size: 1.1em; font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .tv-sponsors.tv-rolling ul { animation: tv-roll 40s linear infinite; }
}
@keyframes tv-roll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
