/* A tournament's public page (src/tournament.ts): made for a phone at the
   field first — a compact header, category chips, tabs, tables that scroll
   sideways when narrow, the bracket in columns that scroll sideways. Light by
   default, dark with the system; the neutral tokens are the site's
   (styles.css, club.css). No web fonts. */
:root {
  color-scheme: light dark;
  --bg: #f6f8f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  /* Tournaments are blue (clubs green): docs/marketing/POSITIONING.md. */
  --a: #1d4ed8;
  --a-deep: #172554;
  --a-ink: #1d4ed8;
  --mine: #fef9c3;
  --live: #b91c1c;
  /* The bracket's lines. */
  --bline: #cbd5e1;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 8px 24px rgb(15 23 42 / 0.06);
  --radius: 14px;
  /* «Sin conexión»: the copy's note. */
  --warn-bg: #fef3c7;
  --warn-ink: #78350f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070b14;
    --card: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --line: #1e293b;
    --soft: #111c2e;
    --a-ink: #60a5fa;
    --mine: #3f3a12;
    --live: #f87171;
    --bline: #3b4a61;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --warn-bg: #422006;
    --warn-ink: #fde68a;
  }
}

* { box-sizing: border-box; }
body.tp {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.tp a { color: inherit; }
.tp :focus-visible { outline: 3px solid var(--a-ink); outline-offset: 2px; border-radius: 6px; }
.tp-hero :focus-visible { outline-color: #fff; }
.tp [hidden] { display: none !important; }
.tp-wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* The header: the tournament, its days and place, the organizer and the language. */
.tp-hero { background: linear-gradient(140deg, var(--a), var(--a-deep)); color: #fff; padding: 12px 0 20px; }
.tp-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.875rem; }
.tp-org { opacity: 0.9; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-hero h1 { margin: 10px 0 6px; font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.15; overflow-wrap: anywhere; }
.tp-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 0.95rem; }
.tp-meta a { text-decoration: none; }
.tp-map { text-decoration: underline; opacity: 0.9; white-space: nowrap; }
.tp-sample { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 10px; border-radius: 999px; background: #fff; color: #1d4ed8; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em; }
.tp-sample-note { margin: 4px 0 0; font-size: 0.85rem; opacity: 0.9; }
.tp-finished { display: inline-block; margin: 10px 0 0; padding: 2px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.18); font-size: 0.85rem; font-weight: 600; }
.tp-lang { position: relative; flex: none; }
.tp-lang summary { cursor: pointer; list-style: none; padding: 6px 10px; border: 1px solid rgb(255 255 255 / 0.45); border-radius: 999px; font-weight: 600; font-size: 0.8rem; min-height: 32px; }
.tp-lang summary::-webkit-details-marker { display: none; }
.tp-lang ul { position: absolute; right: 0; z-index: 5; margin: 6px 0 0; padding: 6px; list-style: none; background: var(--card); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); min-width: 150px; }
.tp-lang a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.tp-lang a:hover, .tp-lang a[aria-current] { background: var(--soft); }

.tp-main { padding-top: 16px; padding-bottom: 32px; }
.tp-empty { color: var(--muted); }

/* Category chips: a row that scrolls sideways rather than wrapping into many lines. */
.tp-chips ul, .tp-tabs ul { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.tp-chips ul::-webkit-scrollbar, .tp-tabs ul::-webkit-scrollbar { display: none; }
.tp-chips a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-weight: 600; white-space: nowrap; }
.tp-chips a[aria-current] { background: var(--a); border-color: var(--a); color: #fff; }

/* «Ahora en los campos» (4.19): a card per field, its game now and the next; the visitor's team marked. */
.tp-now { margin: 14px 0 6px; }
.tp-now h2 { margin: 0 0 8px; font-size: 1.05rem; }
.tp-nowfields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px; }
.tp-nowfield { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px; }
.tp-nowfield h3 { margin: 0 0 4px; font-size: 0.9rem; color: var(--muted); }
.tp-fmap { color: var(--a-ink); text-decoration: none; white-space: nowrap; margin-left: 4px; font-weight: 400; }
.tp-fmap:hover { text-decoration: underline; }
.tp-nowfield ol { margin: 0; padding: 0; list-style: none; }
.tp-nowgame { display: grid; gap: 1px; padding: 4px 0; }
.tp-nowgame + .tp-nowgame { border-top: 1px solid var(--line); }
.tp-nowgame small { color: var(--muted); }
.tp-nowgame.tp-mine { background: var(--mine); border-radius: 6px; padding-inline: 6px; }
.tp-nowlabel { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.tp-now-mine { margin: 0 0 8px; padding: 8px 12px; background: var(--mine); border-radius: var(--radius); }
.tp-now-mine .tp-match-meta, .tp-now-mine .tp-match-row { margin: 2px 0 0; }

/* «Mi equipo». */
/* «Mi equipo» and «Campos»: side by side where there is room, one under the other on a phone. */
.tp-pickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 8px 16px; margin: 14px 0 4px; align-items: start; }
.tp-myteam { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tp-myteam label { font-weight: 600; }
.tp-myteam select { flex: 1 1 200px; min-height: 44px; padding: 0 10px; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; max-width: 100%; }
.tp-filtering { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 0.9rem; }
.tp-clear { margin-left: 4px; padding: 4px 10px; min-height: 32px; font: inherit; color: var(--a-ink); background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }

/* A category with its tabs; without the script every panel shows with its heading. */
.tp-cat { margin-top: 18px; }
.tp-cat > h2 { margin: 0 0 10px; font-size: 1.25rem; }
.tp-tabs { margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tp-tabs ul { gap: 4px; }
.tp-tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tp-js .tp-tabs a[aria-current] { color: var(--a-ink); border-bottom-color: var(--a-ink); }
.tp-panel { margin-bottom: 18px; }
.tp-panel > h3 { margin: 0 0 8px; font-size: 1.05rem; }
.tp-js .tp-panel > h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tp h4 { margin: 14px 0 8px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }

/* Tables. */
.tp-table { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 0 6px; margin-bottom: 14px; }
.tp-table h4 { margin: 8px 14px 4px; color: var(--text); }
.tp-table.tp-mygroup { outline: 2px solid var(--a-ink); }
.tp-scroll { overflow-x: auto; }
.tp table { width: 100%; border-collapse: collapse; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.tp th, .tp td { padding: 8px 6px; text-align: left; border-top: 1px solid var(--line); }
.tp thead th { border-top: 0; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.tp abbr { text-decoration: none; }
.tp .tp-num { text-align: center; width: 2.6em; }
.tp .tp-pos { width: 2.2em; text-align: center; color: var(--muted); padding-left: 12px; }
.tp th.tp-team { font-weight: 600; overflow-wrap: anywhere; }
.tp .tp-pts { font-weight: 700; }
.tp tr.tp-mine { background: var(--mine); }
/* «Mejores terceros»: those going through marked on the left edge; provisional while groups play. */
.tp tr.tp-qualifies td.tp-pos { box-shadow: inset 3px 0 0 var(--a-ink); color: var(--a-ink); font-weight: 700; }
.tp-provisional { font-size: 0.75rem; font-weight: 400; color: var(--muted); font-style: italic; }
.tp-note { margin: 6px 14px 4px; font-size: 0.78rem; color: var(--muted); }
/* A season league's division: the teams going up (green) and down (red) on the left edge, with a key under the table. */
.tp tr.tp-up td.tp-pos { box-shadow: inset 3px 0 0 #16a34a; }
.tp tr.tp-down td.tp-pos { box-shadow: inset 3px 0 0 #dc2626; }
.tp-zones { display: flex; flex-wrap: wrap; gap: 12px; }
.tp-zone-up, .tp-zone-down { padding-left: 6px; border-left: 3px solid #16a34a; }
.tp-zone-down { border-left-color: #dc2626; }
@media (max-width: 479px) { .tp .tp-wide { display: none; } }

/* Games. */
.tp-day h4 { position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 6px 0; margin: 10px 0 4px; }
/* A league's rounds («Jornada 5»): each folded but the current one; the heading opens it. */
.tp-round > summary { list-style: none; cursor: pointer; }
.tp-round > summary::-webkit-details-marker { display: none; }
.tp-round > summary h4 { display: flex; align-items: baseline; gap: 8px; }
.tp-round > summary h4::before { content: '▸'; color: var(--muted); }
.tp-round[open] > summary h4::before { content: '▾'; }
.tp-round-count { font-weight: 400; color: var(--muted); }
.tp-rest { margin: 6px 0 0; }
.tp-matches { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tp-match { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; }
.tp-match[data-state="live"] { box-shadow: inset 4px 0 0 var(--live), var(--shadow); }
.tp-match-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin: 0 0 6px; font-size: 0.8rem; color: var(--muted); }
.tp-match-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 0; }
.tp-side { font-weight: 600; overflow-wrap: anywhere; }
.tp-home { text-align: right; }
.tp-tbd { font-weight: 400; color: var(--muted); font-style: italic; }
.tp-won { font-weight: 800; }
.tp-score { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px; min-width: 64px; padding: 4px 8px; border-radius: 10px; background: var(--soft); font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.tp-score-none { font-weight: 600; font-size: 0.95rem; color: var(--muted); }
.tp-pens { flex-basis: 100%; text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.tp-badge { margin-left: auto; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.tp-badge-live { background: var(--live); color: #fff; }
.tp-badge-final { background: var(--soft); color: var(--muted); }
.tp-badge-pending { background: transparent; color: var(--muted); border: 1px dashed var(--muted); }

/* «MVP» of a finished game; the category's «Equipo ideal» (a pitch for the organizer's, a list for the automatic one) and «Mejor jugador». */
.tp-mvp { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.tp-awards { margin: 14px 0 0; padding: 12px 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.tp-awards h3 { margin: 0 0 10px; font-size: 1rem; }
.tp-pitch { display: grid; gap: 8px; padding: 12px 8px; border-radius: 10px; background: linear-gradient(#2f8f4e, #237a40); }
.tp-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tp-line .tp-player { width: 7.5rem; background: var(--card); text-align: center; }
.tp-ideal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.tp-player { padding: 6px 8px; border-radius: 8px; background: var(--soft); font-size: 0.85rem; overflow-wrap: anywhere; }
.tp-player small { display: block; color: var(--muted); font-size: 0.72rem; }
.tp-player-empty { color: var(--muted); }
.tp-best { margin: 10px 0 0; font-size: 0.9rem; }
.tp-best small { color: var(--muted); }

/* The bracket: public/tournament-bracket.css (shared with the TV mode). */

/* Shown from a copy while the server cannot be reached (src/tournament.ts), or after two failed refreshes (public/tournament.js). */
.tp-stale { margin: 12px 0; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 0.9rem; }
.tp-updated { margin: 18px 0 0; font-size: 0.85rem; color: var(--muted); text-align: center; }

.tp-footer { border-top: 1px solid var(--line); padding: 18px 0 28px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.tp-footer p { margin: 4px 0; }
.tp-footer a { font-weight: 600; color: var(--a-ink); }
.tp-organize { font-weight: 500 !important; }

@media (min-width: 720px) {
  .tp-hero { padding: 18px 0 28px; }
  .tp-matches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .tp-bracket { scroll-behavior: smooth; }
}

/* «Inscribir equipo» (phase 5a): the button in the header and the form page (src/tournament-registration.ts). */
.tp-register { margin: 14px 0 0; }
/* .tp-register-button with .tp: stronger than «.tp a { color: inherit }», which made its text white on white in the header. */
.tp .tp-register-button {
  display: inline-block;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--a-deep);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.tp-hero .tp-register-button:hover { background: #dbeafe; }
.tp .tp-form .tp-register-button { background: var(--a); color: #fff; }
.tp-form .tp-register-button:hover { background: var(--a-deep); }
.tp-form .tp-register-button:disabled { opacity: 0.6; cursor: default; }
.tp-form-intro { color: var(--muted); margin: 0 0 12px; }
.tp-form {
  display: grid;
  gap: 14px;
  max-width: 640px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.tp-form label { display: grid; gap: 4px; font-size: 0.95rem; font-weight: 600; }
.tp-form input:not([type="checkbox"]),
.tp-form select,
.tp-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.tp-form textarea { min-height: 88px; resize: vertical; }
.tp-form-row { display: grid; gap: 14px; }
@media (min-width: 560px) {
  .tp-form-row { grid-template-columns: 1fr 1fr; }
}
.tp-optional { color: var(--muted); font-weight: 400; }
.tp-form-note { margin: -6px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 0.9rem; }
.tp-form .tp-consent { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 0.9rem; }
.tp-consent input { margin-top: 4px; }
.tp-consent a { color: var(--a-ink); }
.tp-policy { display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.tp-policy-title { margin: 0; font-weight: 600; font-size: 0.9rem; }
.tp-policy-text { margin: 0; color: var(--muted); font-size: 0.9rem; white-space: pre-line; }
.tp-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.tp-form-status { margin: 0; min-height: 1.5em; font-size: 0.95rem; }
.tp-form-status.error { color: var(--live); }
.tp-form-done { max-width: 640px; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.tp-form-done-text { font-weight: 600; margin-top: 0; }
/* Online entry fees (phase 5b-2): the hold after the form, the thanks back from Stripe, the payment link page. */
.tp-form-hold { color: var(--muted); }
.tp-form-paid { max-width: 640px; padding: 12px 16px; border-radius: var(--radius); background: var(--soft); font-weight: 600; }
.tp-pay-amount { font-size: 1.4rem; font-weight: 700; margin: 8px 0; }
.tp-main > .tp-form { margin: 12px 0; }
.tp-form-done a,
.tp-main > p a { color: var(--a-ink); }

/* Phase 6: a paid tier's logo in the header and the sponsors' strip above the footer. */
.tp-logo { height: 40px; width: auto; max-width: 120px; object-fit: contain; vertical-align: middle; margin-right: 8px; border-radius: 6px; background: #fff; padding: 2px; }
.tp-sponsors { margin: 24px 0 8px; text-align: center; }
.tp-sponsors h2 { margin: 0 0 10px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted, #64748b); }
.tp-sponsors ul { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 20px; margin: 0; padding: 0; list-style: none; }
.tp-sponsors li { display: flex; align-items: center; }
.tp-sponsors img { height: 48px; width: auto; max-width: 140px; object-fit: contain; border-radius: 6px; background: #fff; padding: 4px; }
.tp-sponsors span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line, #e2e8f0); border-radius: 999px; font-weight: 600; font-size: 0.9rem; }
.tp-sponsors a { color: inherit; text-decoration: none; }

/* Martial arts and chess (16.11.2026): the medals of a category, the medal table, a bout's winner and how, chess results. */
.tp-medals { margin: 8px 14px; padding: 0; list-style: none; display: grid; gap: 6px; }
.tp-medals li { display: flex; align-items: baseline; gap: 8px; }
.tp-medals small, .tp-team small { color: var(--muted); font-weight: 400; }
.tp-bout small { font-weight: 600; }
.tp-chess > span { letter-spacing: 0.02em; }
.tp-medal-table h2 { margin-bottom: 8px; }
