/* #539 Tournaments M4 "Hành trình" (DESIGN.md › Tournaments; mockup features/tournaments-redesign/mockups/m4-hanh-trinh.html).
   Shared by the list (index.html #panel-tournaments) and the detail page (tournament.html body.tm4-page).
   One accent per view (--c-brand / --c-brand-text); status = label + icon + position, never a second hue.
   Flat surfaces: separation by --tm-soft fills and hairlines, no card shadows. Sentence case, no tracking. */

.tm4, .tm4-page {
  --tm-soft: color-mix(in srgb, var(--c-ink) 6%, var(--c-surface));
  --tm-soft-2: color-mix(in srgb, var(--c-ink) 10%, var(--c-surface));
  --tm-brand-soft: color-mix(in srgb, var(--c-brand) 16%, var(--c-surface));
  --tm-dur-step: 320ms;
  --tm-ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --tm-h1: clamp(26px, 1.1rem + 1.6vw, 40px);
  --tm-h2: clamp(18px, 1rem + .4vw, 22px);
  --tm-gap: clamp(28px, 1.2rem + 1.6vw, 48px);
}

/* ── Hand-drawn ink stroke: the single organic accent, never on controls ── */
.tm4-stroke { display: block; width: min(220px, 60%); height: 14px; margin-top: 6px; color: var(--c-brand-text); }
.tm4-stroke path { fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; }
.tm4-stroke--hero { display: none; }
body.zen-lobby .lobby:has(#panel-tournaments.is-active) .tm4-stroke--hero { display: block; }

/* ── Lobby screen frame: one reading column (760px), flat on the page background ── */
body.zen-lobby .lobby:has(#panel-tournaments.is-active) { max-width: calc(760px + 48px); }
body.zen-lobby #panel-tournaments.tm4 { background: none; box-shadow: none; padding: 0; border-radius: 0; }
@media (max-width: 860px) {
  body.zen-lobby .lobby:has(#panel-tournaments.is-active) { max-width: none; padding-left: 16px; padding-right: 16px; }   /* gutter ≥ 16px (DESIGN.md › Fluid) */
}
body.zen-lobby .lobby:has(#panel-tournaments.is-active) .lobby-bar { flex-wrap: nowrap; align-items: flex-start; }
body.zen-lobby .lobby:has(#panel-tournaments.is-active) .lobby-bar > div:first-child { min-width: 0; }
/* One filled button per view: the hero's Sẵn sàng / first Đăng ký owns it, so Tạo giải đấu is an outline. */
body.zen-lobby .lobby:has(#panel-tournaments.is-active) .lobby-bar__actions { flex: none; }
body.zen-lobby #btn-create-tournament { white-space: nowrap; background: transparent; color: var(--c-ink); box-shadow: inset 0 0 0 1.5px var(--c-border-strong); border-radius: 999px; }
@media (hover: hover) { body.zen-lobby #btn-create-tournament:hover { background: var(--tm-soft, transparent); color: var(--c-ink); } }

/* ── Type + shared bits ── */
.tm4 h2, .tm4-page h2 { font-size: var(--tm-h2); font-weight: 800; line-height: 1.22; margin: 0 0 4px; color: var(--c-ink); }
.tm4 h3, .tm4-page h3 { font-size: 16px; font-weight: 800; line-height: 1.3; margin: 0; min-width: 0; }
.tm4-sub { color: var(--c-ink-2); font-size: 15px; }
.tm4-num { font-variant-numeric: tabular-nums; }
.tm4-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm4 .icon, .tm4-page .icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.tm4-mine { color: var(--c-brand-text); font-weight: 800; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tm4-live, .tm4-champ { display: inline-flex; gap: 6px; align-items: center; min-width: 0; font-weight: 700; color: var(--c-ink-2); }
.tm4-champ { color: var(--c-ink); font-weight: 800; max-width: 50%; }

/* ── Controls (widget-system heights: 40 desktop, 44 at ≤860) ── */
.tm4-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--ctl-h-md, 40px); padding: 0 20px;
  border: 0; border-radius: 999px; font: inherit; font-weight: 800; font-size: 16px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.tm4-btn:active { transform: scale(.97); }
.tm4-btn--primary { background: var(--c-brand); color: var(--c-on-brand); }
/* Never a filled brand button on --tm-brand-soft (2.9:1, DESIGN.md › Tokens): the tonal one is the outline tint. */
.tm4-btn--tonal { background: var(--tm-brand-soft); color: var(--c-brand-text); }
.tm4-btn--quiet { background: transparent; color: var(--c-ink); box-shadow: inset 0 0 0 1.5px var(--c-border-strong); }
.tm4-btn--lg { min-height: 52px; padding: 0 28px; font-size: 17px; }
.tm4-btn[aria-disabled="true"] { opacity: .55; cursor: progress; }
@media (hover: hover) { .tm4-btn--primary:hover { filter: brightness(1.08); } .tm4-btn--tonal:hover { background: color-mix(in srgb, var(--c-brand) 24%, var(--c-surface)); } }
.tm4-quiet { display: inline-flex; align-items: center; min-height: 44px; color: var(--c-ink-2); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.tm4 :focus-visible, .tm4-page :focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.tm4-cta { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
@media (max-width: 860px) {
  .tm4-btn { min-height: 44px; }
  .tm4-cta .tm4-btn--lg { flex: 1 1 100%; }
}

/* ── Sections ── */
.tm4-sec { margin-top: var(--tm-gap); }
.tm4-sec > .tm4-sub { margin: 0 0 14px; }
.tm4-nomatch { margin: 0; color: var(--c-ink-2); }

/* Next-match hero */
.tm4-now { padding: 18px; border-radius: 20px; background: var(--c-surface); display: grid; gap: 14px; }
.tm4-now__when { display: grid; gap: 2px; }
.tm4-now__vs { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tm4-now__who { display: grid; min-width: 0; }
.tm4-now__who b { font-size: 19px; font-weight: 800; }

/* Agenda: day label column + items */
.tm4-day { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 16px; padding: 14px 0; border-top: 1px solid var(--c-border-light); }
.tm4-day__d { font-weight: 900; line-height: 1.15; }
.tm4-day__d span { display: block; font-size: 13px; font-weight: 700; color: var(--c-ink-2); margin-top: 2px; }
.tm4-day__items { display: grid; gap: 16px; min-width: 0; }
.tm4-item { position: relative; display: grid; gap: 8px; min-width: 0; }
.tm4-item__t { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.tm4-item__link { color: inherit; text-decoration: none; }
.tm4-item__link::after { content: ""; position: absolute; inset: 0; }   /* the whole row opens the detail */
.tm4-item__t > :not(h3), .tm4-facts { position: relative; z-index: 1; }
.tm4-item__t > :not(h3) { flex: none; }
@media (hover: hover) { .tm4-item:hover .tm4-item__link { text-decoration: underline; text-underline-offset: 3px; } }
.tm4-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--c-ink-2); font-size: 15px; pointer-events: none; }
.tm4-facts b { color: var(--c-ink); font-weight: 800; }

/* Collapsed groups */
.tm4-sec--more { display: grid; }
details.tm4-more { border-top: 1px solid var(--c-border-light); }
details.tm4-more:last-of-type { border-bottom: 1px solid var(--c-border-light); }
details.tm4-more > summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 800; cursor: pointer; list-style: none; }
details.tm4-more > summary::-webkit-details-marker { display: none; }
.tm4-more__n { display: inline-flex; align-items: center; gap: 6px; color: var(--c-ink-2); font-weight: 700; }
details.tm4-more[open] > summary .icon { transform: rotate(180deg); }
details.tm4-more > div { display: grid; gap: 16px; padding: 4px 0 18px; }
details.tm4-more[open] > div { animation: tm4-fade var(--dur-fast) var(--ease-out) both; }

/* Empty state */
.tm4-empty { padding: 32px 0; }
.tm4-empty__t { margin: 0 0 4px; font-weight: 800; }

/* Undo toast: above the phone tab bar, out of the way of the primary */
.tm4-toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 16px;
  max-width: min(560px, calc(100vw - 32px)); padding: 8px 8px 8px 20px; border-radius: 999px; background: var(--c-ink); color: var(--c-on-ink); font-weight: 700; }
.tm4-toast[hidden] { display: none; }
.tm4-toast button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; font-weight: 800; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c-on-ink) 55%, transparent); }
.tm4-toast button[hidden] { display: none; }
.tm4-toast.is-in { animation: tm4-rise var(--dur-base) var(--ease-out) both; }
@media (max-width: 860px) { .tm4-toast { bottom: calc(64px + 16px + env(safe-area-inset-bottom, 0px)); } .tm4-toast button { min-height: 44px; } }

/* ── Detail page (tournament.html, body.tm4-page): one reading column, me first ── */
/* main.lobby: outranks platform-shell.css's body.pshell:not(.zen-lobby) .lobby (1180px), which loads later. */
body.tm4-page main.lobby.tm4-detail { max-width: calc(760px + 2 * clamp(16px, 1.2rem + 1.2vw, 40px)); margin: 0 auto;
  padding: clamp(12px, 1vw, 24px) clamp(16px, 1.2rem + 1.2vw, 40px) calc(var(--tm-gap) * 2); }
.tm4-back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; color: var(--c-ink-2); text-decoration: none; }
@media (hover: hover) { .tm4-back:hover { color: var(--c-ink); } }
.tm4-head { margin-top: 4px; }
.tm4-head__t { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; }
.tm4-head h1 { font-size: var(--tm-h1); font-weight: 900; line-height: 1.22; margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--c-ink); }
.tm4-head__tools { display: flex; flex: none; gap: 8px; align-items: center; margin-top: 4px; }
.tm4-head__facts { margin-top: 14px; pointer-events: auto; }
.tm4-status { display: inline-flex; align-items: center; gap: 6px; }
.tm4-head__facts .tm4-champ { max-width: 100%; white-space: nowrap; }
.tm4-status b, .tm4-head__facts .tm4-status { color: var(--c-ink); }
.manage-wrap { position: relative; }
.tm4-page .manage-btn { min-height: var(--ctl-h-md, 40px); padding: 0 16px; font-size: 15px; }
@media (max-width: 860px) { .tm4-page .manage-btn { min-height: 44px; } }

/* The state's primary, right under the header */
.tm4-primary:not(:empty) { margin-top: 20px; }
.tm4-primary__note { margin: 10px 0 0; }
.tm4-seats b { color: var(--c-ink); font-weight: 800; }
.tm4-status-btn { cursor: default; }
.tm4-status-btn:active { transform: none; }
.tm4-status-btn.is-pop { animation: tm4-pop var(--dur-base) var(--ease-out) both; }
@keyframes tm4-pop { from { opacity: 0; transform: scale(.95); } }

/* Organizer's open decision + cancelled notice: a quiet row, never a filled button */
#action-banner-slot:not(:empty) { margin-top: 20px; }
.tm4-attn { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--tm-soft); }
.tm4-attn__t { display: grid; min-width: 0; }
.tm4-attn__t b { font-weight: 800; }
@media (max-width: 520px) { .tm4-attn { grid-template-columns: auto minmax(0, 1fr); } .tm4-attn > .tm4-btn { grid-column: 1 / -1; } }
.tm4-notice { margin: 0; }

/* In-page anchors: a chip row that scrolls inside itself, never the page */
.tm4-anchors { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-top: 20px; padding: 2px; }
.tm4-anchors::-webkit-scrollbar { display: none; }
.tm4-anchors[hidden] { display: none; }
.tm4-chip { flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--tm-soft); color: var(--c-ink); font-weight: 800; text-decoration: none; white-space: nowrap; }
@media (hover: hover) { .tm4-chip:hover { background: var(--tm-soft-2); } }
@media (max-width: 860px) { .tm4-chip { min-height: 44px; } }
#team-panel-slot:not(:empty) { margin-top: var(--tm-gap); }

/* Timeline (my path / how the tournament runs) */
.tm4-path__sum { margin: 4px 0 10px; pointer-events: auto; }
.tm4-tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tm4-tl::before { content: ''; position: absolute; left: 15px; top: 18px; bottom: 18px; border-left: 2px dashed var(--c-border-strong); }
.tm4-tl > li { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; padding: 10px 0; }
.tm4-node { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; background: var(--c-bg); color: var(--c-ink-2); font-weight: 900; font-size: 14px;
  box-shadow: inset 0 0 0 2px var(--c-border-strong); position: relative; z-index: 1; }
.tm4-tl .is-done > .tm4-node { background: var(--c-ink); color: var(--c-on-ink, var(--c-bg)); box-shadow: none; }
.tm4-tl .is-now > .tm4-node { background: var(--c-brand); color: var(--c-on-brand); box-shadow: 0 0 0 5px var(--tm-brand-soft); }
.tm4-step { display: grid; gap: 4px; min-width: 0; align-content: start; padding-top: 4px; }
.tm4-step > small { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--c-ink-2); font-weight: 700; font-size: 14px; }
.tm4-step__main { font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.tm4-step__sub { color: var(--c-ink-2); }
.tm4-step__res { color: var(--c-ink-2); font-weight: 700; }
.tm4-step__res.is-won { color: var(--c-brand-text); }
.tm4-tl .is-now > .tm4-step { padding: 16px; border-radius: 18px; background: var(--c-surface); gap: 6px; }
.tm4-step__card { display: grid; gap: 10px; }
.tm4-step__card .tm4-facts { pointer-events: auto; }
.tm4-step__note { margin: 0; color: var(--c-ink-2); }
.tm4-tl .is-end > .tm4-step { padding-top: 5px; }
.tm4-tl > li.is-older { display: none; }
.tm4-tl.is-expanded > li.is-older { display: grid; }
.tm4-tl.is-expanded > li.is-more { display: none; }
.tm4-tl .is-more > .tm4-node { box-shadow: none; background: transparent; }
.tm4-tl .is-more > .tm4-step { padding-top: 0; }

/* Collapsed sections on the detail page */
.tm4-page details.tm4-more > div, .tm4-page details.tm4-more > dl, .tm4-page details.tm4-more > ul { padding: 4px 0 18px; }
.tm4-page details.tm4-more--main { border-top: 0; }
/* Wide brackets / cross tables scroll inside the section, never widen the page (the old .ui-core wrapper did this). */
.tm4-page #standings-container { min-width: 0; max-width: 100%; overflow-x: auto; }
.tm4-page details.tm4-more--main > summary { font-size: var(--tm-h2); }
.tm4-page details.tm4-more[hidden] { display: none; }
.tm4-page #bracket details.tm4-more:last-of-type { border-bottom: 0; }
.tm4-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 24px; margin: 0; }
.tm4-dl dt { color: var(--c-ink-2); font-weight: 700; }
.tm4-dl dd { margin: 0; font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.tm4-entrants { list-style: none; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 24px; }
.tm4-entrants li { display: flex; justify-content: space-between; gap: 12px; min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--c-border-light); }
.tm4-entrants li.is-me { font-weight: 800; color: var(--c-brand-text); }

/* The old pairing cards inside "Tất cả cặp đấu": flat rows, status = label, one accent (no warning/success hues) */
.tm4-page .pairing-card { box-shadow: none; }
.tm4-page .pairing-card__fact { display: inline-flex; align-items: center; gap: 6px; }
.tm4-page .pairing-card__meta { gap: 6px 16px; font-size: 14px; color: var(--c-ink-2); }
.tm4-page .state-pill { background: var(--tm-soft); color: var(--c-ink-2); font-size: 13px; }
.tm4-page .state-pill--inprogress, .tm4-page .state-pill--ready { background: var(--tm-brand-soft); color: var(--c-brand-text); }
.tm4-page .pairing-card__result .win { color: var(--c-ink); }
.tm4-page .pairing-card__actions .tm4-btn, .tm4-page .organizer-tools .tm4-btn { min-height: 36px; padding: 0 14px; font-size: 14px; }
@media (max-width: 860px) { .tm4-page .pairing-card__actions .tm4-btn, .tm4-page .organizer-tools .tm4-btn { min-height: 44px; } }
.tm4-btn--danger { color: var(--c-error, #EF4444); }
.tm4-page .bm__id { display: flex; justify-content: space-between; gap: 8px; letter-spacing: 0; }
.tm4-page .bm__live { color: var(--c-brand-text); }

/* ── "Quanh bạn" (#539 slice 3): my standing with two above and two below ── */
.tm4-around { list-style: none; margin: 0 0 4px; padding: 0; }
.tm4-around li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--c-border-light); }
.tm4-around li.is-me { font-weight: 900; color: var(--c-brand-text); }
.tm4-around__rank { color: var(--c-ink-2); font-weight: 800; }
.tm4-around__pts { color: var(--c-ink-2); font-weight: 700; white-space: nowrap; }
.tm4-around li.is-me .tm4-around__rank, .tm4-around li.is-me .tm4-around__pts { color: inherit; }

/* ── Tables (#541): standings, cross table, games history in the M4 type. Me = brand-text weight, no row fills;
   Vô địch / Á quân = trophy + label; one accent (wins by weight, never --c-success / --c-accent). ── */
.tm4-page .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tm4-page .standings-table { font-size: 15px; }
.tm4-page .standings-table th { font-size: 13px; font-weight: 700; color: var(--c-ink-2); padding: 10px 12px; border-bottom: 1px solid var(--c-border-light); }
.tm4-page .standings-table td { padding: 12px; border-bottom: 1px solid var(--c-border-light); }
.tm4-page .standings-table tr:last-child td { border-bottom: 0; }
.tm4-page .standings-table th:first-child, .tm4-page .standings-table td:first-child { padding-left: 0; }
.tm4-page .standings-table th:last-child, .tm4-page .standings-table td:last-child { padding-right: 0; }
.tm4-page .standings-table .rank-cell { color: var(--c-ink-2); font-weight: 800; font-variant-numeric: tabular-nums; }
.tm4-page .standings-table .name-cell { font-weight: 700; }
.tm4-page .standings-table .num-cell { color: var(--c-ink-2); }
.tm4-page .standings-table tr.is-me { background: none; }
.tm4-page .standings-table tr.is-me td, .tm4-page .standings-table tr.is-me .rank-cell, .tm4-page .standings-table tr.is-me .num-cell { color: var(--c-brand-text); font-weight: 800; }
.tm4-page .standings-table tr.is-me .name-cell, .tm4-page .standings-table tr.is-me .name-cell a { color: var(--c-brand-text); font-weight: 900; }
.tm4-place { margin-left: 8px; color: var(--c-ink-2); font-size: 13px; font-weight: 700; white-space: nowrap; }
.tm4-place--champion { color: var(--c-ink); font-weight: 800; }
.tm4-page .tm4-place .icon { width: 14px; height: 14px; margin-right: 3px; vertical-align: -2px; }
.tm4-th-short { display: none; }
.tm4-page .standings-table .name-cell a { color: inherit; text-underline-offset: 3px; }
@media (max-width: 520px) {
  .tm4-page .standings-table th, .tm4-page .standings-table td { padding-left: 6px; padding-right: 6px; }
  .tm4-page .standings-table .num-cell { font-size: 14px; width: 1%; white-space: nowrap; }
  .tm4-page .standings-table .rank-cell { width: auto; }
  .tm4-page .tm4-th-full { display: none; }
  .tm4-page .tm4-th-short { display: inline; text-decoration: none; }
  .tm4-page .standings-table .tm4-place { display: block; margin: 2px 0 0; }
  body.tm4-page #standings-container .standings-table .name-cell { white-space: normal; overflow-wrap: anywhere; }   /* outranks the slice-3 nowrap below */
}
/* Podium under the Swiss table: flat soft row, trophies in ink (no --c-accent) */
.tm4-page .podium { background: var(--tm-soft); border-radius: 14px; font-size: 15px; }
.tm4-page .podium__label { font-size: 13px; color: var(--c-ink-2); }
.tm4-page .podium__item--champion .icon { color: var(--c-ink); }
.tm4-page .podium__item--runner-up .icon { color: var(--c-ink-2); }

.tm4-page .cross-table { font-size: 15px; }
.tm4-page .cross-table th, .tm4-page .cross-table td { border: 0; border-bottom: 1px solid var(--c-border-light); padding: 10px 12px; }
.tm4-page .cross-table thead th { background: none; font-size: 13px; font-weight: 700; color: var(--c-ink-2); }
.tm4-page .cross-table tbody tr:last-child th, .tm4-page .cross-table tbody tr:last-child td { border-bottom: 0; }
.tm4-page .cross-table th.cross-table__name-col { background: var(--c-bg); padding-left: 0; font-weight: 700; }
.tm4-page .cross-table thead th.cross-table__name-col { font-weight: 700; }
.tm4-page .cross-table tbody .cross-table__name-col .tm4-name { display: inline-block; max-width: 16ch; vertical-align: bottom; }
.tm4-page .cross-table tr.is-me td, .tm4-page .cross-table tr.is-me th,
.tm4-page .cross-table tr.is-champion td, .tm4-page .cross-table tr.is-champion th,
.tm4-page .cross-table tr.is-runner-up td, .tm4-page .cross-table tr.is-runner-up th { background: none; }
.tm4-page .cross-table tr th.cross-table__name-col { background: var(--c-bg); }
.tm4-page .cross-table tr.is-me th.cross-table__name-col, .tm4-page .cross-table tr.is-me .cross-table__total { color: var(--c-brand-text); font-weight: 900; }
.tm4-page .cross-table td.cross-table__total { font-weight: 800; color: var(--c-ink); }
.tm4-page .cross-table .cross-table__win { color: var(--c-ink); font-weight: 800; }
.tm4-page .cross-table .cross-table__loss { color: var(--c-ink-2); font-weight: 400; }
.tm4-page .cross-table .cross-table__diag, .tm4-page .cross-table .cross-table__empty { color: var(--c-ink-2); opacity: .5; }
.tm4-page .cross-table .cross-table__live { color: var(--c-brand-text); font-weight: 800; }

/* Games history: desktop = compact table, phone = one list row per game */
.tm4-games { width: 100%; border-collapse: collapse; font-size: 15px; }
.tm4-games th { text-align: left; font-size: 13px; font-weight: 700; color: var(--c-ink-2); padding: 10px 12px; border-bottom: 1px solid var(--c-border-light); white-space: nowrap; }
.tm4-games td { padding: 10px 12px; border-bottom: 1px solid var(--c-border-light); vertical-align: middle; }
.tm4-games tr > :first-child { padding-left: 0; }
.tm4-games tr > :last-child { padding-right: 0; text-align: right; }
.tm4-games tbody tr:last-child td { border-bottom: 0; }
.tm4-games__match, .tm4-games__time { color: var(--c-ink-2); white-space: nowrap; }
.tm4-games__time { font-size: 14px; }
.tm4-games__match { font-weight: 700; }
.tm4-games__players { font-weight: 800; min-width: 0; white-space: nowrap; }
.tm4-games__players .tm4-name { display: inline-block; max-width: 13ch; vertical-align: bottom; }
.tm4-games__vs { color: var(--c-ink-2); font-weight: 700; padding: 0 2px; }
.tm4-games__result { min-width: 0; }
.tm4-games__out, .tm4-games__why { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm4-games__out { color: var(--c-ink); font-weight: 700; }
.tm4-games__why { color: var(--c-ink-2); font-size: 13px; }
.tm4-games__result { max-width: 15em; }
.tm4-games__replay { display: inline-flex; align-items: center; min-height: 40px; color: var(--c-ink); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
@media (hover: hover) { .tm4-games__replay:hover { color: var(--c-brand-text); } }
@media (max-width: 860px) {
  .tm4-games, .tm4-games tbody { display: block; }
  .tm4-games thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tm4-games tr.tm4-games__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "match time" "players players" "result act";
    gap: 2px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--c-border-light); }
  .tm4-games tbody tr.tm4-games__row:last-child { border-bottom: 0; }
  .tm4-games tr.tm4-games__row > td { display: block; padding: 0; border: 0; text-align: left; }
  .tm4-games__match { grid-area: match; font-size: 13px; }
  .tm4-games__time { grid-area: time; font-size: 13px; text-align: right; }
  .tm4-games__players { grid-area: players; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tm4-games__players .tm4-name { max-width: 42%; }
  .tm4-games tr.tm4-games__row > .tm4-games__result { grid-area: result; max-width: none; }

  .tm4-games tr.tm4-games__row > .tm4-games__act { grid-area: act; }
  .tm4-games__replay { min-height: 44px; }
}

/* Pagination: quiet buttons; current = ink outline + aria-current; transform-only motion */
.tm4-pages { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; }
.tm4-pages:empty { display: none; }
.tm4-pages button { min-width: 40px; min-height: 40px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: var(--c-ink-2); font: inherit; font-weight: 800; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out); }
.tm4-pages button:active:not(:disabled) { transform: scale(.94); }
.tm4-pages button[aria-current="page"] { color: var(--c-ink); box-shadow: inset 0 0 0 1.5px var(--c-ink); cursor: default; }
.tm4-pages button:disabled { opacity: .4; cursor: default; }
.tm4-pages__step { font-size: 20px; line-height: 1; }
.tm4-pages__gap { min-width: 24px; text-align: center; color: var(--c-ink-2); }
@media (hover: hover) { .tm4-pages button:not(:disabled):not([aria-current]):hover { background: var(--tm-soft); color: var(--c-ink); } }
@media (max-width: 860px) { .tm4-pages button { min-width: 44px; min-height: 44px; } }

/* ── Bracket (#539 slice 3): desktop = M5 canvas with SVG wires, phone = one round behind a pager ── */
.tm4-page #standings-container:has(.tm4-br) { overflow: visible; }
.tm4-page .tm4-br { display: block; padding: 0; min-width: 0; }   /* the old .bracket rule sets min-width: max-content */
.tm4-page .bracket--swiss.tm4-br { margin-top: 28px; }
.tm4-page .tm4-br .round-group__title { font-size: 16px; font-weight: 800; color: var(--c-ink); margin: 0 0 12px; }
.tm4-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--tm-soft); margin: 4px 0 18px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tm4-seg button { flex: none; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--c-ink-2); font: inherit; font-weight: 800; white-space: nowrap; cursor: pointer; }
.tm4-seg button[aria-selected="true"] { background: var(--c-surface); color: var(--c-ink); box-shadow: inset 0 0 0 1.5px var(--c-border-strong); }
.tm4-br__pane[hidden] { display: none; }
.tm4-br__pane.is-fresh { animation: tm4-fade var(--dur-fast) var(--ease-out) both; }   /* tab change only, not live re-renders */
.tm4-page #standings-container .standings-table .name-cell { white-space: nowrap; }
.tm4-pager__btn { width: 40px; height: 40px; border: 0; border-radius: 999px; background: var(--tm-soft); color: var(--c-ink); display: grid; place-items: center; cursor: pointer; font: inherit; font-size: 20px; font-weight: 900; line-height: 1; }
.tm4-pager__btn:disabled { opacity: .4; cursor: default; }
@media (hover: hover) { .tm4-pager__btn:not(:disabled):hover { background: var(--tm-soft-2); } }
.tm4-pager { display: none; }
.tm4-canvas__tools { display: flex; gap: 8px; justify-content: flex-end; margin: -6px 0 8px; }
.tm4-canvas__tools[hidden] { display: none; }
.tm4-canvas { position: relative; overflow-x: auto; padding: 4px 0 12px; }
.tm4-canvas.is-panning { cursor: grabbing; user-select: none; }
.tm4-canvas__sizer { position: relative; overflow: hidden; }
.tm4-page .tm4-canvas .bracket__cols { position: relative; display: flex; gap: 40px; width: max-content; min-width: 100%; padding: 0; overflow: visible; background: none; transform-origin: 0 0; }
.tm4-page .tm4-canvas .bracket__col { position: relative; z-index: 1; flex: 0 0 240px; min-width: 0; }
.tm4-page .tm4-canvas__tree .bracket__slot { min-height: 124px; padding: 8px 0; }
.tm4-page .tm4-canvas .bracket__col-title { text-align: left; font-size: 14px; font-weight: 800; color: var(--c-ink-2); padding-bottom: 10px; }
.tm4-page .tm4-canvas .bracket__slot::before, .tm4-page .tm4-canvas .bracket__slot::after { display: none; }
.tm4-wires { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.tm4-wires path { fill: none; stroke: var(--c-border-strong); stroke-width: 2; }
.tm4-wires path.is-me { stroke: var(--c-brand-text); stroke-width: 3; }
/* Match card, M5 look: flat surface, status by label and an inset ring (mine = brand, live = strong edge), winner by weight */
.tm4-page .bm { border: 0; border-radius: 14px; background: var(--c-surface); font-size: 14px; padding-bottom: 4px; }
.tm4-page .bm.is-mine { box-shadow: inset 0 0 0 2px var(--c-brand); }
.tm4-page .bm.is-live { box-shadow: inset 0 0 0 2px var(--c-border-strong); }
.tm4-page .bm.is-mine.is-live { box-shadow: inset 0 0 0 2px var(--c-brand); }
.tm4-page .bm__id { background: none; font-size: 13px; font-weight: 800; color: var(--c-ink-2); padding: 8px 12px 2px; }
.tm4-page .bm__row { border-top: 0; padding: 6px 12px; color: var(--c-ink); }
.tm4-page .bm__row.is-winner { background: none; font-weight: 900; }
.tm4-page .bm__row.is-winner .bm__score { color: inherit; }
.tm4-page .bm__row.is-loser, .tm4-page .bm__row--tbd { color: var(--c-ink-2); }
.tm4-page .bm__row.is-me .bm__name { color: var(--c-brand-text); }
.tm4-page .bm__row.is-tracked { background: var(--tm-soft); }
.tm4-page .bm[data-pairing]:hover, .tm4-page .bm[data-pairing]:focus-visible { box-shadow: inset 0 0 0 2px var(--c-ink-2); }
.tm4-page .bm[data-pairing]:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
/* Wide screens (>= 1100px): drawWires sizes .tm4-br to the tree (columns 240px), clamped between the reading column and
   min(1240px, 100vw - 120px), and centres it on the column; 861-1099px keeps the column and scrolls inside the canvas. */
@media (max-width: 860px) {
  .tm4-seg { display: flex; }
  .tm4-seg button { min-height: 44px; flex: 1 1 auto; padding: 0 10px; font-size: 14px; }
  .tm4-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
  .tm4-pager__btn { width: 44px; height: 44px; }
  .tm4-pager__mid { display: grid; justify-items: center; gap: 6px; min-width: 0; }
  .tm4-pager__label { font-weight: 800; }
  .tm4-pager__dots { display: flex; gap: 6px; }
  .tm4-pager__dots i { width: 6px; height: 6px; border-radius: 9px; background: var(--tm-soft-2); }
  .tm4-pager__dots i.on { background: var(--c-ink); }
  .tm4-canvas__tools { display: none; }
  .tm4-canvas { overflow: visible; padding: 0; }
  .tm4-page .tm4-canvas .bracket__cols { display: block; width: auto; min-width: 0; transform: none !important; }
  .tm4-page .tm4-canvas .bracket__col { display: none; min-width: 0; }
  .tm4-page .tm4-canvas .bracket__col.is-on { display: flex; gap: 10px; }
  .tm4-page .tm4-canvas .bracket__col.is-on.is-fresh { animation: tm4-fade var(--dur-fast) var(--ease-out) both; }   /* pager move only */
  .tm4-page .tm4-canvas .bracket__col-title, .tm4-wires { display: none; }
  .tm4-page .tm4-canvas .bracket__slot { min-height: 0; flex: none; padding: 0; }
  .tm4-page .tm4-canvas .bracket__slot.is-empty { display: none; }
}

/* ── Motion (DESIGN.md › Tournaments › Motion): transform + opacity only ── */
@keyframes tm4-rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes tm4-item-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes tm4-fade { from { opacity: 0; } }
.tm4-enter > * { animation: tm4-item-rise var(--dur-base) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
@media (prefers-reduced-motion: reduce) {
  .tm4 *, .tm4-page *, .tm4-toast { animation: none !important; transition: none !important; }
}
