:root {
  /* Couleurs reprises de la maquette joueurs (thème clair) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2f7;   /* barre d'onglets */
  --surface-3: #f8fafc;   /* en-têtes de tableau et de carte, cases de score */
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4285f4;
  --primary-ink: #ffffff;
  --primary-soft: #e3eefd;
  --accent: #c8f031;
  --accent-ink: #1d2b05;
  --live: #3ba0e6;        /* en cours, différence négative (bleu clair) */
  --live-soft: #e4f2fc;
  --danger: #e05252;      /* erreurs et suppressions uniquement */
  --win: #48a868;
  --win-soft: #e6f5ec;
  --win-row: #f1f9f4;
  --warn: #b45309;
  --warn-soft: #fff1d6;
  --me: #fff6c2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1d;
    --surface: #121a2e;
    --surface-2: #19233d;
    --text: #e7ecf7;
    --muted: #93a0bd;
    --line: #263252;
    --primary: #5b8cff;
    --primary-ink: #06122e;
    --primary-soft: #1b2a52;
    --live: #ff5c7c;
    --live-soft: #3a1422;
    --win: #4ade80;
    --win-soft: #11301e;
    --warn: #fbbf24;
    --warn-soft: #33260a;
    --me: #3a3410;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0f1d;
  --surface: #121a2e;
  --surface-2: #19233d;
  --text: #e7ecf7;
  --muted: #93a0bd;
  --line: #263252;
  --primary: #5b8cff;
  --primary-ink: #06122e;
  --primary-soft: #1b2a52;
  --live: #ff5c7c;
  --live-soft: #3a1422;
  --win: #4ade80;
  --win-soft: #11301e;
  --warn: #fbbf24;
  --warn-soft: #33260a;
  --me: #3a3410;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
}
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: .4em 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 32px 0; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 16px 16px 80px; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.05rem; }
#topbar-extra { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .87rem; border-radius: 8px; }
.btn.lg { min-height: 50px; padding: 12px 20px; font-size: 1.05rem; border-radius: 12px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }

/* Cartes */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h2 + p, .card h3 + p { margin-top: 6px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 4px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea.input { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; border-color: var(--primary); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { font-size: .85rem; color: var(--muted); }
.error { color: var(--danger); font-weight: 600; font-size: .9rem; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); font-size: .92rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--win-soft); color: var(--win); }

/* Accueil */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.hero p { font-size: 1.05rem; color: var(--muted); max-width: 640px; }
.features { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); margin: 18px 0; }
.feature { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.feature b { display: block; margin-bottom: 2px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }

/* En-tête du tournoi */
.t-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.t-head h1 { font-size: clamp(1.35rem, 4vw, 1.9rem); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: .82rem; font-weight: 600; color: var(--muted); }
.chip.primary { background: var(--primary-soft); color: var(--primary); }
.chip.live { background: var(--live-soft); color: var(--live); }
.chip.ok { background: var(--win-soft); color: var(--win); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.live .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Onglets */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 4px; margin: 0 0 16px; border-radius: 12px; background: var(--surface-2);
  position: sticky; top: 57px; z-index: 10;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; border: 0; background: transparent; padding: 8px 14px; border-radius: 9px;
  font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab .count { margin-left: 4px; font-size: .78rem; color: var(--muted); }

/* Équipes */
.team { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.team .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: 0 0 auto; display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 6px; font-size: .72rem; font-weight: 800; background: var(--accent); color: var(--accent-ink); letter-spacing: .02em; }
.badge.tag { background: var(--surface-2); color: var(--muted); }
.badge.direct { background: var(--primary-soft); color: var(--primary); }
.tbd { color: var(--muted); font-style: italic; }
.me { background: var(--me); border-radius: 6px; }
.teams-list .list-item { gap: 8px; }
.teams-list .idx { width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }

/* Poules */
.poule h3 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
table.standings { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: center; padding: 4px 4px 6px; font-weight: 700; }
.standings th:nth-child(2) { text-align: left; }
.standings td { padding: 7px 4px; border-top: 1px solid var(--line); text-align: center; }
.standings td.tm { text-align: left; max-width: 0; width: 100%; padding-right: 8px; }
.standings td.tm .team { display: flex; max-width: 100%; }
.standings td.rk { width: 22px; color: var(--muted); font-weight: 700; }
.standings tr.q td.rk { color: var(--win); }
.standings tr.q td { background: color-mix(in srgb, var(--win-soft) 55%, transparent); }
.standings tr.me td { background: var(--me); }
.pmatches { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.pm {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; background: var(--surface-2); font-size: .88rem;
}
.pm .r { text-align: right; justify-content: flex-end; }
.pm .s { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: center; min-width: 60px; }
.pm .w { font-weight: 700; }
.pm.live { box-shadow: inset 3px 0 0 var(--live); }
.pm.clickable { cursor: pointer; }
.pm.clickable:hover { outline: 1px solid var(--primary); }
.pm .team { max-width: 100%; }

/* Tableau (bracket) */
.bracket-scroll { overflow-x: auto; padding: 4px 2px 12px; margin: 0 -2px; }
.bracket { display: flex; gap: 26px; align-items: stretch; min-width: min-content; }
.round { display: flex; flex-direction: column; width: 236px; flex: 0 0 auto; }
.round > h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; margin-bottom: 8px; height: 18px; }
.round-body { flex: 1; display: flex; flex-direction: column; }
.pair { flex: 1; display: flex; flex-direction: column; position: relative; }
.pair::after {
  content: ""; position: absolute; right: -14px; top: 25%; bottom: 25%; width: 14px;
  border: 2px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0;
}
.slot { flex: 1; display: flex; align-items: center; position: relative; padding: 5px 0; }
.round + .round .slot::before { content: ""; position: absolute; left: -14px; top: 50%; width: 14px; border-top: 2px solid var(--line); }
.mc {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; box-shadow: var(--shadow); font-size: .87rem;
}
.mc.clickable { cursor: pointer; }
.mc.clickable:hover { border-color: var(--primary); }
.mc.live { border-color: var(--live); }
.mc-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-height: 32px; }
.mc-row + .mc-row { border-top: 1px solid var(--line); }
.mc-row .team { flex: 1; }
.mc-row.win { font-weight: 700; }
.mc-row.win .sc { color: var(--text); }
.mc-row .sc { width: 18px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }
.mc-row.bye { color: var(--muted); }
.mc-foot { padding: 3px 8px; font-size: .74rem; color: var(--muted); background: var(--surface-2); display: flex; justify-content: space-between; gap: 6px; }
.mc.live .mc-foot { background: var(--live-soft); color: var(--live); font-weight: 700; }
.qualified { display: flex; flex-direction: column; justify-content: space-around; height: 100%; }

/* Podium */
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.pod { padding: 14px; border-radius: 12px; background: var(--surface-2); }
.pod.gold { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff)); color: var(--accent-ink); }
.pod .lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; opacity: .75; }
.pod .who { font-weight: 800; font-size: 1.05rem; margin-top: 4px; }

/* Matchs */
.match-line {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.match-line + .match-line { margin-top: 8px; }
.match-line.live { border-color: var(--live); box-shadow: inset 4px 0 0 var(--live); }
.match-line .teams { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.match-line .teams .team { max-width: 100%; }
.match-line .meta { font-size: .78rem; color: var(--muted); font-weight: 600; }
.match-line .score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.match-line .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.court { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 4px 8px; border-radius: 8px; background: var(--live-soft); color: var(--live); font-weight: 800; font-size: .82rem; }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

/* Suivi d'équipe */
.follow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.follow select { max-width: 320px; }
.next-card { border-left: 4px solid var(--accent); }

/* Tirage */
.draw { display: grid; gap: 16px; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .draw { grid-template-columns: minmax(0, 1fr); } }
.wheel-card { text-align: center; position: sticky; top: 118px; }
@media (max-width: 820px) { .wheel-card { position: static; } }
.wheel-box { position: relative; width: min(100%, 340px); margin: 10px auto 12px; }
.wheel-box canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 50%; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); background: var(--surface-2); }
.pointer { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 26px solid var(--live); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); z-index: 2; }
.step-label { font-weight: 700; min-height: 1.4em; }
.drawn { margin-top: 8px; padding: 10px; border-radius: 10px; background: var(--win-soft); color: var(--win); font-weight: 700; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.drawn.idle { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.dslots { display: flex; flex-direction: column; gap: 4px; }
.dslot { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--surface-2); min-height: 36px; font-size: .9rem; }
.dslot.empty-slot { color: var(--muted); border: 1px dashed var(--line); background: transparent; }
.dslot.next { border: 2px solid var(--primary); background: var(--primary-soft); }
.dslot.fresh { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: var(--accent); } 100% { background: var(--surface-2); } }
.dslot .n { width: 22px; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.dpair { padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.dpair + .dpair { margin-top: 8px; }
.dpair .dslot + .dslot { margin-top: 4px; }
.dhalf { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }

/* Partage */
.share-link { display: flex; gap: 8px; align-items: center; }
.share-link input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.qr { display: inline-block; padding: 12px; background: #fff; border-radius: 12px; }
.qr img, .qr canvas { display: block; }
.code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); }

/* Fenêtre (modal) */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 10, 25, .55);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  animation: fade .15s;
}
@media (min-width: 640px) { .modal-back { align-items: center; padding: 16px; } }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px 16px;
  padding-bottom: max(18px, env(safe-area-inset-bottom)); box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
@media (min-width: 640px) { .modal { border-radius: 18px; padding: 20px; } }
.modal h2 { margin-bottom: 4px; }
.score-grid { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--n), 56px); gap: 8px; align-items: center; margin: 14px 0; }
.score-grid .hd { font-size: .74rem; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; }
.score-grid .tm { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-grid input { text-align: center; font-size: 1.25rem; font-weight: 800; padding: 6px 0; min-height: 48px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); gap: 2px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }
.courts { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin: 14px 0; }

/* Message flash */
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

.refresh { font-size: .78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.refresh .dot { background: var(--win); }
.refresh.off .dot { background: var(--danger); }

@media (max-width: 560px) {
  h1 { font-size: 1.4rem; }
  .card { padding: 14px; }
  .match-line { flex-wrap: wrap; }
  .match-line .acts { width: 100%; justify-content: stretch; }
  .match-line .acts .btn { flex: 1; }
  .round { width: 210px; }
  .tabs { top: 53px; }
}

@media print {
  .topbar, .tabs, .btn, #toast { display: none !important; }
  body { background: #fff; }
}

/* Tableau : matchs contre un exempt masqués (l'équipe apparaît au tour où elle joue) */
.mc.ghost { visibility: hidden; min-height: 0; height: 0; border: 0; box-shadow: none; }
.slot.ghost::before, .slot.entry::before { display: none; }
.pair.ghost::after { display: none; }
.pair.gt::after { top: 50%; border-top: 0; border-radius: 0 0 8px 0; }
.pair.gb::after { bottom: 50%; border-bottom: 0; border-radius: 0 8px 0 0; }

/* Tableau composé à la main */
.box-add {
  width: 100%; min-height: 28px; border: 1px dashed color-mix(in srgb, var(--primary) 55%, var(--line)); border-radius: 7px;
  background: transparent; color: var(--primary); font-weight: 600; font-size: .82rem; cursor: pointer;
}
.box-add:hover { background: var(--primary-soft); }
.mc-row.next { background: var(--primary-soft); }
.mc-row.covered { background: var(--surface-2); min-height: 26px; }
.mc-row.fresh { animation: flash 1.6s ease-out; }
.mc-row .box-x { min-height: 24px; padding: 0 6px; margin-left: auto; }
button.dslot.pick { width: 100%; text-align: left; border: 1px solid var(--line); cursor: pointer; }
button.dslot.pick:hover { border-color: var(--primary); }

/* Affiche QR */
.poster .qr { display: block; width: max-content; }
@media print {
  body * { visibility: hidden; }
  .poster, .poster * { visibility: visible; }
  .modal-back { position: absolute; inset: 0; background: #fff; }
  .modal { box-shadow: none; max-height: none; }
  .poster { position: absolute; left: 0; right: 0; top: 40px; color: #000; }
  .no-print { display: none !important; }
}

/* Live */
.live-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: 0 0 14px; border-radius: 12px; border: 1px dashed var(--line); background: var(--surface); }
.live-bar.on { border-style: solid; border-color: color-mix(in srgb, var(--live) 45%, var(--line)); background: color-mix(in srgb, var(--live-soft) 50%, var(--surface)); }
.waiting { max-width: 560px; margin: 32px auto; padding: 32px 20px; }
.waiting h1 { margin-top: 8px; }
.waiting-icon { font-size: 2.6rem; animation: bounce 1.8s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .waiting-icon { animation: none; } }

/* ---------- Accueil joueurs ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); }
.eyebrow .dot { background: var(--live); animation: pulse 1.4s infinite; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 560px; margin-top: 10px; }
.home-hero {
  position: relative; overflow: hidden; margin: 8px 0 8px; padding: 36px 20px 28px; border-radius: 24px;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent) 28%, transparent) 0%, transparent 55%),
    linear-gradient(160deg, #4285f4 0%, #2f6ad8 55%, #1d4296 100%);
  color: #fff; box-shadow: 0 18px 48px rgba(29, 78, 216, .28);
}
.home-hero .eyebrow { color: var(--accent); }
.home-hero h1 { font-size: clamp(2.1rem, 8vw, 3.4rem); line-height: 1.02; letter-spacing: -.03em; margin-top: 12px; }
.home-hero .hl { color: var(--accent); }
.home-hero .lead { color: rgba(255, 255, 255, .82); }
.home-hero-inner { position: relative; z-index: 1; max-width: 560px; }
.court-art { position: absolute; right: -40px; top: -30px; width: 300px; height: 600px; color: rgba(255, 255, 255, .13); transform: rotate(18deg); pointer-events: none; }
@media (min-width: 820px) { .home-hero { padding: 56px 48px 44px; } .court-art { right: 40px; width: 340px; } }
.join-card { margin-top: 22px; padding: 16px; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.join-form { display: flex; gap: 8px; }
.code-input {
  flex: 1; min-width: 0; min-height: 54px; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--text); font: 800 1.25rem/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: lowercase;
}
.code-input::placeholder { font: 600 1rem system-ui, sans-serif; letter-spacing: 0; text-transform: none; color: var(--muted); }
.code-input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.join-form .btn { min-height: 54px; }
.or { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.scan-btn { min-height: 54px; background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.home-section { margin-top: 28px; }
.home-section h2 { margin-bottom: 12px; }
.recent { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.recent-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.recent-card:hover { border-color: var(--primary); }
.recent-card .badge { align-self: flex-start; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.steps li div { display: flex; flex-direction: column; gap: 2px; }
.steps .num { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.feature-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.feature-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.ficon { font-size: 1.5rem; }
.home-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin: 36px 0 8px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }

/* ---------- Guide JA ---------- */
.info-head { padding: 18px 0 16px; }
.info-head h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin-top: 8px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.toc a { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .88rem; font-weight: 600; }
.toc a:hover { background: var(--primary-soft); color: var(--primary); }
.info-sec { scroll-margin-top: 70px; }
.info-sec h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.info-sec ul { margin: 6px 0 0; padding-left: 20px; }
.info-sec li { margin: 6px 0; }
.info-sec code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: .9em; }

/* ---------- Connexion, admin ---------- */
.auth-card { max-width: 440px; margin: 28px auto; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 4px; }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.stat { padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat .v { font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .82rem; color: var(--muted); font-weight: 600; }
.list-item.revoked b { text-decoration: line-through; color: var(--muted); }
.cred input { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--text); }
.btn.on { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 560px) { .hide-sm { display: none !important; } }

/* ---------- Scanner QR ---------- */
.scan-box { position: relative; margin: 12px 0; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 1; max-height: 60vh; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid var(--accent); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
@media (max-width: 819px) { .court-art circle { display: none; } }
.section-title { flex-wrap: wrap; }
@media (max-width: 560px) {
  .brand span { display: none; }
  #topbar-extra { gap: 4px; }
  #topbar-extra .btn.sm { padding: 4px 8px; }
}

/* Terrains d'une poule */
.poule-courts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: -2px 0 10px; }
.poule-courts .input.sm { width: auto; min-height: 32px; padding: 4px 8px; font-size: .86rem; border-radius: 8px; }

/* Choix des terrains (1 à 21) */
.court-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 2px; }
.court-pick label { cursor: pointer; }
.court-pick input { position: absolute; opacity: 0; pointer-events: none; }
.court-pick span {
  display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
}
.court-pick input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.court-pick input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- Vue mobile ---------- */
/* Noms d'équipe : retour à la ligne plutôt que coupés (sauf dans les cartes du tableau sur grand écran) */
.team { display: inline; min-width: 0; }
.team .badge { margin-right: 5px; vertical-align: 1px; }
.team .badge.tag { margin: 0 0 0 5px; }
.team .nm { white-space: normal; overflow-wrap: anywhere; }
.mc-row .team, .pm-row .team { flex: 1; }
.bracket .mc .team .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bracket .mc .team { display: flex; align-items: center; overflow: hidden; }

/* En-tête du tournoi */
.t-format { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 8px; font-size: .84rem; color: var(--muted); }

/* Onglets */
.tab .count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--surface); font-size: .72rem; font-weight: 800; }
.tab .count.live { background: var(--live); color: #fff; }

/* Matchs de poule : une ligne par équipe */
.pm { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
.pm-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pm-row { display: flex; align-items: center; gap: 6px; }
.pm-row.w { font-weight: 700; }
.pm-row .sc { width: 18px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.pm-row.w .sc { color: var(--text); }
.pm.done { opacity: .92; }
.pm-tag { flex: 0 0 auto; }

/* Suivi d'équipe */
.follow select { flex: 1; min-width: 0; max-width: 420px; }

/* Tableau par tour (téléphone) */
.bracket-mobile { display: none; }
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 10px; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 7px 14px; border-radius: 999px; font-weight: 700; cursor: pointer; }
.pill.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.round-list { display: flex; flex-direction: column; gap: 10px; }
.round-list:empty::before { content: "Aucun match à ce tour."; color: var(--muted); }

@media (max-width: 700px) {
  .bracket-mobile { display: block; }
  .bracket-scroll, .desk-only { display: none; }
}

@media (max-width: 560px) {
  .wrap { padding: 12px 12px 72px; }
  .t-head { margin: 2px 0 10px; }
  .t-head h1 { font-size: 1.35rem; }
  .chips { margin-top: 6px; }
  .tabs.fit .tab { flex: 1 1 0; padding: 8px 4px; text-align: center; }
  .tabs { margin-bottom: 12px; }
  .card { padding: 12px; border-radius: 12px; }
  .follow { flex-direction: column; align-items: stretch; gap: 6px; }
  .follow select { max-width: none; width: 100%; }
  .next-card { margin-bottom: 12px !important; }
  .match-line { padding: 10px; gap: 10px; }
  .match-line .teams { font-size: .92rem; }
  .standings td { padding: 7px 3px; }
  .standings th { padding: 4px 3px 6px; }
  .grid { gap: 10px; }
  .section-title { margin: 18px 0 8px; }
  .podium { grid-template-columns: 1fr; }
}

/* ---------- Poules (vue type « fiche ») ---------- */
.poule-pills { display: none; }
.pill.big { padding: 10px 18px; border-radius: 12px; font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; }
.poule-terrain { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; color: var(--muted); }
.piste { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .86rem; text-transform: uppercase; letter-spacing: .03em; }
.table-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.standings.v2 th { text-align: center; padding: 10px 6px; background: var(--surface-2); }
.standings.v2 th:first-child { text-align: left; padding-left: 12px; }
.standings.v2 td { padding: 10px 6px; }
.standings.v2 td.tm { padding-left: 12px; }
.standings.v2 tr:first-child td { border-top: 1px solid var(--line); }
.standings.v2 td.diff { font-weight: 800; }
.standings.v2 td.diff.pos { color: var(--win); }
.standings.v2 td.diff.neg { color: var(--live); }
.standings.v2 .badge:not(.tag) { background: var(--primary-soft); color: var(--primary); }
.standings.v2 .team .nm { font-weight: 600; }

/* Cartes de match de poule */
.mcards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.mcard { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.mcard.clickable { cursor: pointer; }
.mcard.clickable:hover { border-color: var(--primary); }
.mcard.live { border-color: var(--live); }
.mcard-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mcard-head .ok { color: var(--win); font-size: .9rem; }
.mcard-head .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
.mcard-head .court-txt { color: var(--live); }
.mcard-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; min-height: 48px; }
.mcard-row + .mcard-row { border-top: 1px solid var(--line); }
.mcard-row .team { flex: 1; }
.mcard-row .team .nm { font-weight: 500; }
.mcard-row.win .team .nm { color: var(--win); font-weight: 800; }
.mcard-row .boxes { display: flex; gap: 4px; }
.mcard-row .box { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 8px; background: var(--surface-2); font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.mcard-row.win .box { background: var(--win-soft); color: var(--win); }

/* Classement final */
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); }
.rank-row:first-child { border-top: 0; }
.rank-row .rk { width: 36px; text-align: center; font-weight: 800; font-size: 1.05rem; color: var(--muted); }
.rank-row .rk-stage { display: block; margin-top: 2px; }
.rank-row.me { background: var(--me); border-radius: 8px; }

@media (max-width: 700px) {
  .poule-pills { display: flex; }
  .poules-grid .poule:not(.sel) { display: none; }
  .poules-grid .poule { border: 0; box-shadow: none; background: transparent; padding: 0; }
  .poules-grid .poule > h3 { display: none; }
  /* Onglets sur plusieurs lignes, comme des boutons */
  .tabs { flex-wrap: wrap; overflow: visible; position: static; padding: 6px; gap: 4px; }
  .tabs .tab { flex: 0 0 auto; padding: 9px 12px; font-size: .95rem; }
  .tabs.fit .tab { flex: 0 0 auto; }
}
.mcard .badge:not(.tag), .rank-row .badge:not(.tag) { background: var(--primary-soft); color: var(--primary); }
/* Phase finale sur téléphone : même style que les cartes de poule */
.round-list .mc { border-radius: 12px; box-shadow: none; }
.round-list .mc .badge:not(.tag) { background: var(--primary-soft); color: var(--primary); }
.round-list .mc-row { min-height: 48px; padding: 8px 8px 8px 12px; gap: 10px; }
.round-list .mc-row.win .team .nm { color: var(--win); font-weight: 800; }
.round-list .mc-row .sc { display: grid; place-items: center; width: auto; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 1.05rem; }
.round-list .mc-row.win .sc { background: var(--win-soft); color: var(--win); }

/* ---------- Couleurs de la maquette ---------- */
.badge { background: var(--primary-soft); color: var(--primary); }
.badge.tag { background: var(--surface-3); color: var(--muted); border: 1px solid var(--line); }
.badge.direct { background: var(--primary-soft); color: var(--primary); }
.tabs { background: var(--surface-2); }
.tab { color: var(--muted); font-weight: 500; }
.tab.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .08); }
.pill { background: var(--surface); color: var(--text); border-color: var(--line); }
.pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill.big { font-weight: 800; }
.piste { background: var(--primary-soft); color: var(--primary); }
.table-card, .mcard { border-color: var(--line); }
.standings.v2 th, .mcard-head { background: var(--surface-3); color: var(--muted); }
.standings tr.q td, .standings.v2 tr.q td { background: var(--win-row); }
.standings tr.q td.rk { color: var(--win); }
.standings.v2 td.diff.pos { color: var(--win); }
.standings.v2 td.diff.neg { color: var(--live); }
.mcard-head .ok { color: var(--win); }
.mcard-row .box, .round-list .mc-row .sc { background: var(--surface-3); color: var(--text); }
.mcard-row.win .box, .round-list .mc-row.win .sc { background: var(--win-soft); color: var(--win); }
.mcard-row.win .team .nm, .round-list .mc-row.win .team .nm { color: var(--win); }
.card { border-color: var(--line); }
.notice { background: var(--primary-soft); }


/* « Mon équipe » : bouton à l'allure d'un sélecteur, et liste des équipes en grand */
.follow-btn { flex: 1; min-width: 0; max-width: 420px; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer; }
.follow-btn .follow-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-btn svg { flex: 0 0 auto; color: var(--muted); }
.follow-search { font-size: 16px; }
.follow-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 58vh; overflow-y: auto; }
.follow-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  font-size: 1.12rem; font-weight: 600; line-height: 1.3;
}
.follow-item:hover { border-color: var(--primary); }
.follow-item.on { border-color: var(--primary); background: var(--primary-soft); }
.follow-item .badge { font-size: .8rem; }
@media (max-width: 560px) { .follow-btn { max-width: none; width: 100%; } }

/* ---------- Administration : juges-arbitres ---------- */
.admin-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.admin-bar .input { min-width: 200px; }
.ja-grid { align-items: stretch; }
.ja-card { display: flex; flex-direction: column; gap: 10px; margin: 0 !important; }
.ja-card.revoked { opacity: .7; }
.ja-card.revoked .ja-name b { text-decoration: line-through; }
.ja-top { display: flex; align-items: center; gap: 12px; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .95rem; }
.ja-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ja-mail { overflow-wrap: anywhere; }
.ja-tours { display: flex; flex-wrap: wrap; gap: 6px; }
.ja-tours a.chip { text-decoration: none; }
.ja-tours a.chip:hover { outline: 1px solid var(--primary); }
.ja-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.chip.warn-chip { background: var(--warn-soft); color: var(--warn); }
.cred-box { display: grid; gap: 10px; margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line); }
.cred-box .code { display: inline-block; margin-top: 2px; font-size: 1.05rem; background: var(--surface); }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.check-item > span { display: flex; flex-direction: column; gap: 2px; }
.check-item.disabled { opacity: .7; cursor: default; background: var(--surface-3); }
@media (max-width: 560px) {
  .ja-actions .btn { flex: 1 1 auto; }
  .admin-bar .btn { width: 100%; }
}

/* Cartes côte à côte (poules, JA…) : pas de décalage vertical */
.grid > .card + .card { margin-top: 0; }
.grid { align-items: start; }
.ja-grid { align-items: stretch; }

/* Classement final : position modifiable et points FFT */
.rank-row .rank-input { width: 62px; min-height: 38px; padding: 4px 6px; text-align: center; font-weight: 800; font-size: 1rem; }
.rank-row .rk:has(.rank-input) { width: 62px; }
.rank-row .pts { flex: 0 0 auto; display: flex; align-items: baseline; gap: 3px; min-width: 58px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.rank-row .pts b { font-size: 1.1rem; color: var(--primary); }
.pod-pts { font-size: .8rem; font-weight: 700; opacity: .75; white-space: nowrap; }

/* Page de création : importer un export */
.import-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; border-style: dashed; }
.import-card h3 { margin-bottom: 2px; }
.import-card + .card { margin-top: 0; }

/* Application installable */
.brand img { border-radius: 8px; display: block; }
.install-bar {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 40;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(15, 30, 60, .18);
}
.install-bar[hidden] { display: none; }
.install-bar img { border-radius: 10px; flex: 0 0 auto; }
.install-bar .grow { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.install-bar b { font-size: .92rem; }
body.has-install-bar { padding-bottom: 86px; }
.install-btn { margin-top: 10px; }
.install-steps { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 10px; line-height: 1.45; }
.kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); font-weight: 700; }
[hidden] { display: none !important; }
.hero-logo { display: block; border-radius: 16px; margin-bottom: 14px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), 0 10px 26px rgba(0, 0, 0, .28); }
.auth-logo { display: block; border-radius: 14px; margin-bottom: 12px; }
.admin-chip { background: #1e293b; color: #fff; border-color: #1e293b; }
