/* ============================================================
   Sport Portal — современная светлая тема поверх движка Fencing Poule.
   Подключается ПОСЛЕ styles.css. Меняем только цвета/поверхности через
   CSS-переменные + добавляем общую навигацию. Разметку и логику app.js
   НЕ трогаем — никаких рисков «съехавшей» вёрстки.
   ============================================================ */

:root {
  /* Светлая палитра в фирменных тонах Sport Portal (брендовый синий + сланцевые серые). */
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --border-gold: rgba(31, 78, 234, 0.30);
  --text: #1e293b;
  --muted: #475569;
  --muted2: #64748b;
  /* «Золото» движка переосмыслено как фирменный акцент-синий. */
  --gold: #1f4eea;
  --gold-dim: #1a3dc7;
  --accent: #1f4eea;
  --accent-bright: #356cf6;
  --accent-dim: #1a3dc7;
  --ok: #16a34a;
  --warn: #d97706;
  --glow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

/* Светлый фон страницы (в styles.css он задан жёстко тёмным градиентом). */
body {
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(53, 108, 246, 0.10), transparent 55%),
    linear-gradient(180deg, #eef5ff 0%, var(--bg) 45%, #eef2f7 100%) !important;
  color: var(--text);
}

/* Диагональ матрицы — светлая, а не почти чёрная. */
.poule-table td.dash {
  background: #e2e8f0 !important;
  color: var(--muted2) !important;
}

/* Тени помягче — под светлый дизайн. */
.match-card { box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important; }
.card { box-shadow: var(--glow); }

/* Заголовок-карточка чуть «приподнята» цветной полоской сверху. */
.card { border-top-color: var(--border-gold); }

/* Кнопка-«primary» — чистый брендовый градиент без золотой рамки. */
.btn.primary { border-color: var(--accent-dim) !important; }

/* ====================== Общая навигация ====================== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 1500;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-nav__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: #0f172a;
  text-decoration: none;
}

.site-nav__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.site-nav__logo svg { width: 18px; height: 18px; }

.site-nav__back {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.site-nav__back:hover { color: var(--accent); }

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-nav__link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.site-nav__link:hover { color: var(--accent-bright); }

.site-nav__link--active {
  color: var(--accent);
  font-weight: 800;
}

/* Бой с BYE — обычная карточка, соперник подписан BYE */
.match-side--bye {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--muted2);
  background: var(--surface2);
  border-style: dashed;
  cursor: default;
}

.match-card--bye .match-side--bye:disabled {
  opacity: 0.85;
}

.match-card--bye .match-side.winner:not(.match-side--bye) {
  opacity: 1;
}

.print-bracket-side--bye {
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted2);
  font-style: italic;
}

/* Пулькa: выбор счёта 0–5 + ориентация в большой таблице */
.matrix-wrap {
  max-height: min(75vh, 38rem);
}

.poule-table {
  border-collapse: separate;
  border-spacing: 0;
}

.poule-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface2);
}

.poule-table th.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  background: var(--surface2);
}

.poule-table th.name-head {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
}

.poule-table th.col-head {
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.poule-table th.col-head.poule-col-even,
.poule-table thead th.poule-col-even {
  background: #e8edf3;
}

.poule-table th.name-head.poule-row-even {
  background: #eef2f7;
}

.poule-table td.poule-cell-data.poule-row-even {
  background: #f1f5f9;
}

.poule-table td.poule-cell-data.poule-row-odd {
  background: #ffffff;
}

.poule-table td.poule-cell-data.poule-col-even.poule-row-even {
  background: #e8edf3;
}

.poule-table td.poule-cell-data.poule-col-even.poule-row-odd {
  background: #f1f5f9;
}

.poule-table td.poule-hl-row {
  box-shadow: inset 0 0 0 9999px rgba(31, 78, 234, 0.07);
}

.poule-table th.poule-hl-row,
.poule-table td.poule-hl-col {
  box-shadow: inset 0 0 0 9999px rgba(31, 78, 234, 0.09);
}

.poule-table td.poule-hl-active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.poule-table td.poule-cell-next {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 9999px rgba(232, 197, 71, 0.14);
  z-index: 1;
}

.poule-table td.poule-hl-active.poule-cell-next {
  outline: 2px solid var(--accent);
  box-shadow:
    inset 0 0 0 9999px rgba(232, 197, 71, 0.14),
    0 0 0 2px var(--gold);
}

.matrix-bout-queue {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  background: linear-gradient(90deg, rgba(232, 197, 71, 0.12) 0%, var(--bg-elevated) 100%);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
}

.matrix-bout-queue__line + .matrix-bout-queue__line {
  margin-top: 0.35rem;
}

.matrix-bout-queue__line--upcoming {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.84rem;
}

.matrix-bout-queue.hidden {
  display: none;
}

.matrix-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.matrix-view-tab {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.matrix-view-tab--active,
.matrix-view-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: rgba(31, 78, 234, 0.1);
  color: var(--accent);
}

.matrix-bout-list {
  margin: 0 0 1rem;
}

.matrix-bout-list.hidden {
  display: none;
}

.matrix-bout-list__rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.matrix-bout-list__row {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem 0.7rem;
  width: 100%;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.matrix-bout-list__row:hover,
.matrix-bout-list__row:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.matrix-bout-list__row--next {
  border-color: var(--border-gold);
  background: linear-gradient(90deg, rgba(232, 197, 71, 0.14) 0%, var(--surface) 100%);
}

.matrix-bout-list__row--done {
  opacity: 0.92;
}

.matrix-bout-list__num {
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.matrix-bout-list__names {
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.matrix-bout-list__score {
  justify-self: end;
  min-width: 3.6rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.matrix-bout-list__row--done .matrix-bout-list__score {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.name-head__seed {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text, #0f172a);
}
.name-head__name {
  font-weight: 600;
}

.poule-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.poule-table input.cell {
  background: transparent;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.poule-table input.cell--picker {
  cursor: pointer;
  caret-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.poule-table input.cell--invalid {
  outline: 2px solid var(--warn);
  background: rgba(217, 119, 6, 0.12);
}

/* Незаполненные клетки — без placeholder «5», зато заметная рамка */
.poule-table td.poule-cell-empty {
  box-shadow: inset 0 0 0 2px dashed rgba(217, 119, 6, 0.55);
}

.poule-table td.poule-cell-empty.poule-row-even,
.poule-table td.poule-cell-empty.poule-row-odd {
  background-color: rgba(217, 119, 6, 0.09);
}

.poule-table td.poule-cell-empty.poule-col-even.poule-row-even,
.poule-table td.poule-cell-empty.poule-col-even.poule-row-odd {
  background-color: rgba(217, 119, 6, 0.11);
}

.poule-table input.cell.cell--empty {
  color: var(--text);
}

.poule-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2200;
  touch-action: none;
  background: rgba(15, 23, 42, 0.45);
  isolation: isolate;
}

.poule-picker-backdrop:not(.hidden) {
  display: block;
}

.poule-picker-backdrop.hidden {
  display: none;
}

.poule-picker {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  width: auto;
  max-width: 24rem;
  margin: 0 auto;
  max-height: min(85vh, 36rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.28);
  padding: 1rem 1rem max(1.25rem, env(safe-area-inset-bottom));
}

.poule-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.poule-picker-titles {
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text);
}

.poule-picker-vs {
  margin: 0 0.35rem;
  color: var(--muted2);
  font-weight: 600;
}

.poule-picker-close {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.poule-picker-sub {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
}

.poule-picker-section + .poule-picker-section {
  margin-top: 0.85rem;
}

.poule-picker-section-label {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.poule-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.poule-picker-grid--5 {
  grid-template-columns: repeat(5, 1fr);
}

.poule-picker-grid--winners {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.poule-picker-btn--winner {
  min-height: 52px;
  font-size: 0.95rem;
  text-align: center;
  padding: 0.65rem 0.5rem;
  line-height: 1.25;
}

.poule-picker-btn--winner.is-selected {
  border-color: var(--accent);
  background: rgba(31, 78, 234, 0.16);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.poule-picker-sub.hidden {
  display: none;
}

.bracket-picker-sections {
  max-height: min(42vh, 20rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.15rem;
}

.poule-picker--bracket {
  max-height: min(88vh, 40rem);
}

.poule-picker-custom-digits--de {
  grid-template-columns: repeat(4, 1fr);
  max-height: 10.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.match-score--picker {
  cursor: pointer;
  caret-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.match-score-wrap[role="button"] {
  touch-action: manipulation;
}

.poule-picker-btn {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.poule-picker-btn:active {
  border-color: var(--accent);
  background: rgba(31, 78, 234, 0.14);
}

.poule-picker-btn:hover,
.poule-picker-btn:focus-visible {
  border-color: var(--accent);
  background: rgba(31, 78, 234, 0.08);
  outline: none;
}

.poule-picker-custom-entry {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}

.poule-picker-btn--custom {
  width: 100%;
  letter-spacing: 0.06em;
}

.poule-picker-referee-entry {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.poule-picker-referee-hint {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.35;
}

.poule-picker-btn--referee {
  width: 100%;
  font-weight: 800;
  color: #fff;
  border-color: #15803d;
  background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
}

.poule-picker-btn--referee:hover,
.poule-picker-btn--referee:focus-visible {
  border-color: #166534;
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
}

.poule-picker-custom {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.poule-picker-custom.hidden {
  display: none;
}

.poule-picker-custom-back {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
}

.poule-picker-custom-cols {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: start;
}

.poule-picker-custom-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.poule-picker-custom-head {
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
  padding: 0.35rem 0.25rem;
  border-radius: 8px;
  background: rgba(31, 78, 234, 0.08);
  border: 1px solid var(--border);
}

.poule-picker-custom-sep {
  align-self: center;
  padding-top: 2.5rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--muted);
}

.poule-picker-custom-digits {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}

.poule-picker-digit {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.poule-picker-digit.is-selected {
  border-color: var(--accent);
  background: rgba(31, 78, 234, 0.18);
  box-shadow: 0 0 0 1px rgba(31, 78, 234, 0.35);
}

.poule-picker-custom-preview {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.poule-picker-custom-apply {
  min-height: 48px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.poule-picker-custom-apply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.poule-touch-shield {
  position: fixed;
  inset: 0;
  z-index: 2250;
  background: transparent;
  touch-action: none;
}

.poule-touch-shield.hidden {
  display: none;
}

@media (min-width: 641px) {
  .poule-picker {
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(24rem, calc(100vw - 2rem));
    max-height: min(80vh, 36rem);
    padding-bottom: 1.25rem;
  }
}

/* SVG-логотип в шапке инструмента вместо PNG. */
.brand-logo--svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
}

.brand-logo--svg svg { width: 24px; height: 24px; }

/* В RTL (арабский) стрелка «назад» зеркалится автоматически по контенту. */
[dir="rtl"] .site-nav__back { direction: rtl; }

/* WD (снялся) в таблице итогов */
.btn-wd {
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  min-height: 32px;
  border-color: var(--border);
  background: var(--surface2);
  color: var(--muted);
}
.btn-wd--active {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(217, 119, 6, 0.1);
}
.status-badge {
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  text-transform: lowercase;
  cursor: pointer;
}
.status-badge--continue {
  border-color: var(--ok, #16a34a);
  color: var(--ok, #16a34a);
  background: rgba(22, 163, 74, 0.08);
}
.status-badge--withdrawn {
  border-color: var(--warn);
  color: var(--warn);
  background: rgba(217, 119, 6, 0.1);
}
.standings-table .status-badge {
  white-space: nowrap;
}
.event-name-field {
  display: block;
  margin: 0.75rem 0 0.5rem;
}
.event-name-field__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.event-name-field__input {
  width: 100%;
  max-width: 28rem;
}
.custom-poule-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
}
.custom-poule-option {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.custom-poule-option--check {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
}
.custom-poule-option__input {
  width: 5rem;
}
.standings-row-wd .wd-name {
  text-decoration: line-through;
  opacity: 0.65;
}
.wd-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(217, 119, 6, 0.15);
  color: var(--warn);
}
.standings-table .btn-wd {
  white-space: nowrap;
}

/* Mid-poule exclude / add */
.poule-table .name-head {
  position: relative;
  padding-right: 1.85rem;
}
.name-head__label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-poule-exclude {
  position: absolute;
  top: 50%;
  right: 0.2rem;
  transform: translateY(-50%);
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.btn-poule-exclude:hover {
  border-color: var(--danger, #dc2626);
  color: var(--danger, #dc2626);
  background: rgba(220, 38, 38, 0.08);
}
.poule-roster-tools {
  margin: 0.85rem 0 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.poule-add-row {
  align-items: center;
}
.poule-add-input {
  flex: 1 1 12rem;
  min-width: 10rem;
  max-width: 22rem;
}
.exclude-fencer-dialog {
  max-width: 26rem;
}
.exclude-fencer-hint {
  margin: 0 0 0.85rem;
}
.exclude-fencer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.exclude-fencer-actions .btn {
  width: 100%;
}

/* Кнопка «Начать заново» — визуально опасное действие */
.btn-danger {
  border-color: #fca5a5 !important;
  color: #b91c1c !important;
  background: #fef2f2 !important;
}
.btn-danger:hover {
  border-color: #f87171 !important;
  background: #fee2e2 !important;
}

/* Подтверждение сброса турнира */
.reset-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(127, 29, 29, 0.55);
}

.reset-confirm-overlay:not(.hidden) {
  display: flex;
}

.reset-confirm-dialog {
  width: min(100%, 22rem);
  padding: 1.25rem 1.25rem 1rem;
  border-radius: 14px;
  border: 2px solid #fecaca;
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  box-shadow: 0 16px 40px rgba(127, 29, 29, 0.45);
  text-align: center;
}

.reset-confirm-title {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.25;
}

.reset-confirm-text {
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: #fee2e2;
}

.reset-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.reset-confirm-cancel {
  min-height: 44px;
  border-color: rgba(255, 255, 255, 0.55) !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
}

.reset-confirm-cancel:hover {
  background: rgba(255, 255, 255, 0.22) !important;
}

.reset-confirm-yes {
  min-height: 44px;
  border-color: #7f1d1d !important;
  background: #fff !important;
  color: #b91c1c !important;
  font-weight: 700;
}

.reset-confirm-yes:hover {
  background: #fef2f2 !important;
}

/* ====================== Fencing hub (/fencing/) ====================== */
.hub-main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

.hub-intro {
  text-align: center;
  margin-bottom: 1.75rem;
}

.hub-intro h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.hub-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.hub-lang-row {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* Fencing hub: 1 column mobile → strict 2×N pairs from 768px (B2B coach grid) */
.hub-menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: stretch;
  width: 100%;
}

@media (min-width: 768px) {
  .hub-menu-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.1rem 1.15rem;
  }
}

@media (max-width: 767.98px) {
  .hub-menu-grid {
    grid-template-columns: 1fr;
  }
}

.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 1.35rem 1.25rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}

a.hub-card:hover,
a.hub-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(31, 78, 234, 0.1);
  outline: none;
}

.hub-card__icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.hub-card__title {
  margin: 0 0 0.45rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
}

.hub-card__desc {
  margin: 0;
  margin-top: auto;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.hub-card--soon {
  opacity: 0.72;
  cursor: not-allowed;
  background: #f8fafc;
}

.hub-card--soon:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.hub-card__badge {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #e2e8f0;
  color: #64748b;
}

.site-nav__brand-suffix {
  font-weight: 700;
  color: var(--accent);
}

.hub-footer-note {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted2);
}

/* —— Multi-poule tournament —— */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tournament-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tournament-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tournament-tab:hover {
  border-color: var(--accent);
}

.tournament-tab--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tournament-tab-panel {
  min-height: 2rem;
}

.tournament-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.tournament-split-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.85rem 0 0.65rem;
}

.tournament-batch-import {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.tournament-batch-club {
  width: 100%;
  max-width: 20rem;
}

.tournament-setup-roster {
  margin-bottom: 0.85rem;
}

.tournament-setup-roster__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.5rem;
}

.tournament-setup-roster__summary {
  margin: 0;
}

.tournament-setup-roster-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  max-height: 16rem;
  overflow-y: auto;
}

.tournament-setup-roster-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) minmax(5rem, 8rem) 2rem;
  gap: 0.45rem;
  align-items: center;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.tournament-setup-roster-row:last-child {
  border-bottom: none;
}

.tournament-setup-roster-row--head {
  background: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.tournament-setup-roster-row--dup {
  background: #fef2f2;
}

.tournament-setup-roster-seed {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tournament-setup-roster-club {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tournament-setup-roster-remove {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
}

.tournament-setup-roster-remove:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.tournament-setup-roster-empty {
  padding: 0.75rem 0.55rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.tournament-split-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.tournament-poule-count-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.tournament-poule-count-row.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.tournament-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.tournament-assign-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.tournament-assign-row {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) minmax(4.5rem, 6rem) minmax(7.5rem, 9.5rem);
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.tournament-assign-row:last-child {
  border-bottom: none;
}

.tournament-assign-row--head {
  background: #f1f5f9;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.tournament-assign-row--open {
  background: #fff7ed;
}

.tournament-assign-seed {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tournament-assign-name {
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tournament-assign-club {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tournament-assign-select {
  width: 100%;
  min-width: 0;
  font-size: 0.85rem;
}

@media (max-width: 520px) {
  .tournament-assign-row {
    grid-template-columns: 1.75rem minmax(0, 1fr);
  }

  .tournament-assign-row--head span:nth-child(3),
  .tournament-assign-row--head span:last-child {
    display: none;
  }

  .tournament-assign-club {
    grid-column: 2;
    font-size: 0.75rem;
  }

  .tournament-assign-select {
    grid-column: 1 / -1;
  }

  .tournament-setup-roster-row {
    grid-template-columns: 1.75rem minmax(0, 1fr) 2rem;
  }

  .tournament-setup-roster-row .tournament-setup-roster-club {
    display: none;
  }
}

.tournament-preview-card--empty {
  opacity: 0.65;
}

.tournament-preview-card--bad {
  border-color: #f59e0b;
  background: #fffbeb;
}

.tournament-preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: #fafbfc;
}

.tournament-preview-card h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}

.tournament-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tournament-preview-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.tournament-preview-item:last-child {
  border-bottom: none;
}

.tournament-preview-seed {
  flex: 0 0 1.5rem;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.8rem;
}

.tournament-preview-name {
  flex: 1 1 auto;
  font-size: 0.9rem;
}

.tournament-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.btn-sm {
  padding: 0.15rem 0.4rem;
  font-size: 0.72rem;
  min-height: 0;
}

.tournament-standings-block {
  margin-top: 1.25rem;
}

.tournament-referee-block {
  margin: 1rem 0;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.live-tournament-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0 0.25rem;
}

.live-tournament-tab {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.live-body--light .live-tournament-tab {
  background: #fff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.live-tournament-tab--active {
  background: #1f4eea;
  border-color: #1f4eea;
  color: #fff;
}

/* Tournament DE champion card (same art as live board) */
.tournament-champion {
  margin: 1.25rem 0 0;
}

.tournament-champion__card {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 1024 / 682;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(251, 191, 36, 0.45);
}

.tournament-champion__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tournament-champion__name {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 42.5%;
  height: 12%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 800;
  font-size: clamp(0.95rem, 4.2vw, 1.65rem);
  letter-spacing: 0.01em;
  line-height: 1.12;
  color: #0f172a;
  text-wrap: balance;
  overflow: hidden;
  padding: 0 0.35rem;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.tournament-champion__when {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 80.5%;
  height: 5.5%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(0.78rem, 2.8vw, 1.05rem);
  letter-spacing: 0.04em;
  color: #fef9c3;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.55);
  white-space: nowrap;
}

.tournament-champion__brand {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 89%;
  height: 5%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(0.72rem, 2.4vw, 0.95rem);
  letter-spacing: 0.08em;
  color: #fde68a;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.55);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .tournament-champion__name {
    left: 14%;
    right: 14%;
    font-size: clamp(0.85rem, 5vw, 1.2rem);
  }
  .tournament-champion__when {
    font-size: 0.72rem;
  }
  .tournament-champion__brand {
    font-size: 0.68rem;
  }
}

/* Direct elimination only (poule.html?mode=de) */
body[data-poule-mode="de"] #matrix-section,
body[data-poule-mode="de"] #to-tournament,
body[data-poule-mode="de"] #compute,
body[data-poule-mode="de"] #build-bracket,
body[data-poule-mode="de"] #share-results,
body[data-poule-mode="de"] #share-results-full,
body[data-poule-mode="de"] #export-pdf,
body[data-poule-mode="de"] #standings,
body[data-poule-mode="de"] .poule-roster-tools,
body[data-poule-mode="de"] .matrix-view-tabs {
  display: none !important;
}
