/* =========================================================================
   Pétanque Tournoi — Design system
   Style : Vibrant & block-based (violet + orange), Fira Sans / Fira Code.
   Thèmes clair + sombre. Responsive.
   ========================================================================= */

:root {
  /* Palette (clair) */
  --primary: #7C3AED;
  --primary-600: #6D28D9;
  --primary-300: #A78BFA;
  --primary-soft: #EDE4FF;
  --cta: #F97316;
  --cta-600: #EA580C;
  --cta-soft: #FFE7D3;

  --bg: #FAF5FF;
  --bg-grad-a: #F5EEFF;
  --bg-grad-b: #FFF3EA;
  --surface: #FFFFFF;
  --surface-2: #FAF7FF;
  --border: #E7E1F3;
  --border-strong: #D6CCEE;

  --text: #24123F;      /* titres / corps fort */
  --text-2: #5A4B72;    /* muted lisible (>=4.5:1) */
  --text-3: #7A6E90;

  --gold: #E0A100;
  --silver: #7C8598;
  --bronze: #B4703B;

  --win: #16A34A;
  --win-soft: #DCFCE7;
  --lose: #E11D48;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;

  --shadow-sm: 0 1px 2px rgba(76, 29, 149, .08);
  --shadow: 0 6px 20px rgba(76, 29, 149, .10);
  --shadow-lg: 0 18px 42px rgba(76, 29, 149, .18);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --nav-h: 72px;
  --maxw: 1120px;

  --mono: "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --primary: #A78BFA;
  --primary-600: #8B5CF6;
  --primary-300: #C4B5FD;
  --primary-soft: #2A2140;
  --cta: #FB923C;
  --cta-600: #F97316;
  --cta-soft: #3A2415;

  --bg: #140D22;
  --bg-grad-a: #17102A;
  --bg-grad-b: #211326;
  --surface: #1E1533;
  --surface-2: #241A3C;
  --border: #322550;
  --border-strong: #3F2F63;

  --text: #F3EEFF;
  --text-2: #C3B6DD;
  --text-3: #9B8CBC;

  --gold: #F5C542;
  --silver: #AEB6C6;
  --bronze: #D08A4E;

  --win: #34D399;
  --win-soft: #123324;
  --lose: #FB7185;
  --danger: #F87171;
  --danger-soft: #3A1620;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #A78BFA; --primary-600: #8B5CF6; --primary-300: #C4B5FD; --primary-soft: #2A2140;
    --cta: #FB923C; --cta-600: #F97316; --cta-soft: #3A2415;
    --bg: #140D22; --bg-grad-a: #17102A; --bg-grad-b: #211326;
    --surface: #1E1533; --surface-2: #241A3C; --border: #322550; --border-strong: #3F2F63;
    --text: #F3EEFF; --text-2: #C3B6DD; --text-3: #9B8CBC;
    --gold: #F5C542; --silver: #AEB6C6; --bronze: #D08A4E;
    --win: #34D399; --win-soft: #123324; --lose: #FB7185; --danger: #F87171; --danger-soft: #3A1620;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 8px 24px rgba(0,0,0,.45); --shadow-lg: 0 20px 48px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 12% -10%, var(--bg-grad-a), transparent 60%),
    radial-gradient(1000px 560px at 100% 0%, var(--bg-grad-b), transparent 55%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 16px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; color: var(--text); font-weight: 700; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.25rem, 2.2vw, 1.6rem); letter-spacing: -.01em; }
p { margin: 0 0 1rem; color: var(--text-2); }
a { color: var(--primary-600); }

/* -------- Layout -------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
main { padding: calc(var(--nav-h) + 28px) 0 72px; }
.section { margin-bottom: 34px; }
.grid { display: grid; gap: 18px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* -------- Navbar (flottante) -------- */
.nav {
  position: fixed; top: 14px; left: 14px; right: 14px; z-index: 50;
  height: calc(var(--nav-h) - 14px);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: var(--maxw); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand .logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--cta)); color: #fff; box-shadow: var(--shadow-sm); flex: 0 0 auto; }
.brand .logo svg { width: 20px; height: 20px; }
.brand small { display: block; font-size: .72rem; font-weight: 500; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-pill);
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: .92rem;
  transition: color .2s, background-color .2s;
}
.nav-links a svg { width: 18px; height: 18px; }
.nav-links a:hover { color: var(--primary-600); background: var(--primary-soft); }
.nav-links a.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-600)); box-shadow: var(--shadow-sm); }
.nav-links a.active:hover { color: #fff; }

.theme-toggle {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; transition: color .2s, background-color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--primary-600); border-color: var(--primary-300); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

@media (max-width: 620px) {
  .nav-links a span { display: none; }
  .nav-links a { padding: 9px 11px; }
  .brand small { display: none; }
}

/* -------- Page header -------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head .eyebrow { color: var(--cta-600); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; margin-bottom: 6px; }
.page-head p { margin: 6px 0 0; }

/* -------- Cards -------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.card + .card { margin-top: 18px; }
.card h2 { display: flex; align-items: center; gap: 10px; }
.card h2 svg { width: 22px; height: 22px; color: var(--primary); }

/* -------- Buttons -------- */
.btn {
  --b: var(--primary); --bh: var(--primary-600);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 700; font-size: .95rem;
  padding: 12px 20px; min-height: 44px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: linear-gradient(135deg, var(--b), var(--bh)); color: #fff;
  box-shadow: var(--shadow-sm); transition: filter .2s, box-shadow .2s, background-color .2s, color .2s, border-color .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { filter: brightness(1.06); box-shadow: var(--shadow); }
.btn:active { filter: brightness(.97); }
.btn:focus-visible { outline: 3px solid var(--primary-300); outline-offset: 2px; }
.btn.cta { --b: var(--cta); --bh: var(--cta-600); }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); box-shadow: none; }
.btn.ghost:hover { border-color: var(--primary-300); color: var(--primary-600); filter: none; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); box-shadow: none; }
.btn.danger:hover { background: var(--danger-soft); filter: none; }
.btn.sm { padding: 8px 13px; min-height: 38px; font-size: .86rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }

/* -------- Forms -------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--text); }
.field .hint { font-weight: 400; color: var(--text-3); font-size: .82rem; }
.input, select {
  width: 100%; font-family: var(--sans); font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 46px; transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.input::placeholder { color: var(--text-3); }
.input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .input { flex: 1 1 200px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }

/* -------- Badges / chips -------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .74rem;
  padding: 4px 11px; border-radius: var(--radius-pill); text-transform: uppercase; letter-spacing: .04em;
  background: var(--primary-soft); color: var(--primary-600);
}
.badge.cta { background: var(--cta-soft); color: var(--cta-600); }
.badge.win { background: var(--win-soft); color: var(--win); }
.badge.warn { background: var(--cta-soft); color: var(--cta-600); }
.badge.muted { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge svg { width: 13px; height: 13px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.info-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.info-cell .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; margin-bottom: 4px; }
.info-cell .val { font-size: 1.15rem; font-weight: 700; color: var(--text); }

/* -------- Teams list -------- */
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.team-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px;
}
.team-item .num {
  min-width: 30px; height: 30px; padding: 0 7px; flex: 0 0 auto; border-radius: 9px; font-family: var(--mono); font-weight: 600; font-size: .85rem;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-600);
}
.team-item .tname { font-weight: 600; flex: 1 1 auto; word-break: break-word; }
/* Le 1er bouton est repoussé à droite ; les suivants se collent à lui.
   Sans la 2e règle, chaque bouton absorberait l'espace libre et ils seraient séparés. */
.team-item .btn { margin-left: auto; }
.team-item .btn ~ .btn { margin-left: 6px; }

/* -------- Rounds / match board (saisie par ligne) -------- */
.board { display: flex; flex-direction: column; gap: 28px; }
.round-block { display: flex; flex-direction: column; gap: 10px; }
.round-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 8px; border-bottom: 2px solid var(--border); }
.round-head .rtitle { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.1rem; }
.round-head .rtitle .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--cta)); }

.mrows { display: flex; flex-direction: column; gap: 8px; }

/* Une ligne = un match. Équipe A (droite) · scores (centre) · équipe B (gauche) · action. */
.mrow {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 9px 14px; transition: box-shadow .2s, border-color .2s;
}
.mrow:hover { box-shadow: var(--shadow); }
.mrow.done { border-color: var(--primary-300); background: var(--surface-2); }
.mrow.bye { border-style: dashed; }
.mrow-no { font-family: var(--mono); font-size: .78rem; color: var(--text-3); flex: 0 0 auto; width: 34px; }

.mrow-body { display: flex; align-items: center; gap: 12px; flex: 1 1 440px; min-width: 0; }
.mrow-team { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.mrow-team.a { justify-content: flex-end; text-align: right; }
.mrow-team.b { justify-content: flex-start; text-align: left; }
.mrow-team.exempt { color: var(--text-3); font-style: italic; }
.mrow-team .seed { font-family: var(--mono); font-size: .74rem; color: var(--text-3); flex: 0 0 auto; }
/* Numéro d'équipe (étiquette). Badge plein, pour ne pas le confondre avec le
   rang `.seed` qui est juste à côté et déjà préfixé d'un #. */
.mrow-team .tno {
  min-width: 24px; height: 22px; padding: 0 6px; flex: 0 0 auto; border-radius: 7px;
  font-family: var(--mono); font-weight: 700; font-size: .76rem;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-600);
}
.mrow-team .name { font-weight: 600; word-break: break-word; }
.mrow-team .trophy { display: none; width: 15px; height: 15px; flex: 0 0 auto; color: var(--gold); }
.mrow-team.win .name { color: var(--win); }
.mrow-team.win .trophy { display: inline-flex; }

.mrow-mid { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.mrow-dash { font-family: var(--mono); color: var(--text-3); font-weight: 700; }
.mrow-score { font-family: var(--mono); font-weight: 700; font-size: 1.3rem; min-width: 30px; text-align: center; color: var(--text); }
.mrow-score.win { color: var(--win); }
.mrow-mid .score-input { width: 60px; flex: 0 0 auto; text-align: center; font-family: var(--mono); font-weight: 700; font-size: 1.1rem; padding: 7px; min-height: 40px; }

.mrow-actions { flex: 0 0 auto; margin-left: auto; }
.mrow .m-err { flex-basis: 100%; color: var(--danger); font-size: .82rem; margin: 0; display: none; }

@media (max-width: 620px) {
  .mrow-body { flex: 1 1 100%; }
  .mrow-actions { margin-left: 0; width: 100%; }
  .mrow-actions .btn { width: 100%; }
}

/* -------- Standings table -------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.standings { width: 100%; border-collapse: collapse; min-width: 640px; }
table.standings th, table.standings td { padding: 13px 14px; text-align: center; }
table.standings th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; }
table.standings th.left, table.standings td.left { text-align: left; }
table.standings td { border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.standings tr:last-child td { border-bottom: none; }
table.standings tbody tr { transition: background-color .15s; }
table.standings tbody tr:hover { background: var(--primary-soft); }
.rankcell { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; font-weight: 800; font-family: var(--mono); background: var(--surface-2); color: var(--text-2); }
tr.r1 .rankcell { background: color-mix(in srgb, var(--gold) 26%, transparent); color: var(--gold); }
tr.r2 .rankcell { background: color-mix(in srgb, var(--silver) 26%, transparent); color: var(--silver); }
tr.r3 .rankcell { background: color-mix(in srgb, var(--bronze) 26%, transparent); color: var(--bronze); }
.team-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.mono { font-family: var(--mono); }
.pos { color: var(--win); font-weight: 700; }
.neg { color: var(--lose); font-weight: 700; }
.col-strong { font-weight: 800; color: var(--text); }

/* -------- Champion / banners -------- */
.banner {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, var(--surface)), color-mix(in srgb, var(--cta) 14%, var(--surface)));
  border: 1px solid var(--primary-300); box-shadow: var(--shadow); margin-bottom: 24px;
}
.banner .cup { width: 54px; height: 54px; flex: 0 0 auto; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), var(--cta)); color: #fff; box-shadow: var(--shadow-sm); }
.banner .cup svg { width: 30px; height: 30px; }
.banner h2 { margin: 0; }
.banner p { margin: 2px 0 0; }
.banner .champ { color: var(--primary-600); font-weight: 800; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--cta-soft); border: 1px solid color-mix(in srgb, var(--cta) 35%, transparent); color: var(--cta-600); margin-bottom: 18px; font-size: .92rem; }
.notice svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.notice.err { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }

/* -------- Empty state -------- */
.empty { text-align: left; padding: 40px 28px; }
.empty .ill { width: 84px; height: 84px; margin: 0 0 18px; border-radius: 22px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); }
.empty .ill svg { width: 44px; height: 44px; }
.empty h2 { margin-bottom: 8px; }
.empty p { max-width: 520px; margin: 0 0 22px; }

/* -------- Progress / round stepper -------- */
.progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.steps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: .82rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.step .idx { font-family: var(--mono); }
.step.done { background: var(--win-soft); border-color: transparent; color: var(--win); }
.step.current { background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 6px 0 22px; }
.toolbar .spacer { flex: 1; }

.footer { text-align: center; color: var(--text-3); font-size: .84rem; padding: 30px 0 8px; }

/* -------- Toast -------- */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--surface); padding: 11px 18px; border-radius: var(--radius-pill); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); color: #fff; }

.hidden { display: none !important; }

/* =========================================================================
   Impression (feuilles A4 portrait) — aperçu écran + règles @media print
   ========================================================================= */
.print-controls { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 24px; }
.print-controls h1 { margin: 0 0 4px; }
.print-controls p { margin: 0; }

/* Une "feuille" ressemble à une page A4 (blanche, texte noir) même en thème sombre. */
.sheet {
  background: #ffffff; color: #14110f;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  width: 100%; max-width: 794px; margin: 0 auto 26px; padding: 26px 30px;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}

/* En-tête centré : nom du tournoi, titre (nom du tour / classement / équipes), méta. */
.pr-head { text-align: center; border-bottom: 2px solid #14110f; padding-bottom: 12px; margin-bottom: 16px; }
.pr-head-tournament { font-size: .95rem; font-weight: 700; color: #4a4a4a; text-transform: uppercase; letter-spacing: .06em; }
.pr-head-title { font-size: 1.7rem; font-weight: 800; color: #14110f; line-height: 1.15; margin-top: 2px; }
.pr-head-meta { font-size: .88rem; color: #4a4a4a; margin-top: 4px; }
.pr-head-extra { font-size: .85rem; color: #777; margin-top: 2px; }

/* Feuille des équipes inscrites (deux colonnes) */
.pr-teams-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; }
.pr-team-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid #e5e5e5; }
.pr-team-name { font-weight: 700; color: #14110f; }

/* Récapitulatif d'un tour (lignes serrées) */
.pr-matches { display: flex; flex-direction: column; }
.pr-match { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 4px; border-bottom: 1px solid #dddddd; }
.pr-match:last-child { border-bottom: none; }
.pr-match.bye { background: #f5f5f5; }
.pr-teams { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: #14110f; flex-wrap: wrap; }
.pr-n { font-family: var(--mono); font-weight: 700; color: #777; min-width: 22px; flex: 0 0 auto; }
/* Numéro d'équipe sur la feuille d'un tour. Encadré (et non gris comme `.pr-n`)
   pour rester lisible à l'impression noir et blanc. */
.pr-tno {
  font-family: var(--mono); font-weight: 700; font-size: .8rem; color: #14110f;
  border: 1px solid #999999; border-radius: 5px; padding: 1px 5px; flex: 0 0 auto;
  margin-right: -4px; /* rapproche le badge du nom qu'il désigne (gap .pr-teams = 10px) */
}
.pr-team { font-weight: 700; }
.pr-vs { color: #777; font-weight: 500; font-size: .88rem; }
.pr-score { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.pr-box { display: inline-block; width: 46px; height: 30px; border: 1.5px solid #14110f; border-radius: 6px; }
.pr-slash { color: #777; font-weight: 700; }
.pr-exempt { color: #4a4a4a; font-style: italic; font-size: .88rem; margin-left: 4px; }
.pr-team.win { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.pr-num { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; min-width: 28px; text-align: center; color: #14110f; }
.pr-num.win { color: #127a33; }

/* Classement imprimable (lignes moins hautes) */
.pr-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
table.pr-standings { width: 100%; border-collapse: collapse; min-width: 0; }
table.pr-standings th, table.pr-standings td { border: 1px solid #bbbbbb; padding: 6px 9px; text-align: center; color: #14110f; font-variant-numeric: tabular-nums; }
table.pr-standings th { background: #efeaf9; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
table.pr-standings .left { text-align: left; }
table.pr-standings tbody tr:nth-child(1) td { font-weight: 800; }
.sheet-foot { margin-top: 14px; color: #777; font-size: .78rem; border-top: 1px solid #dddddd; padding-top: 8px; }
.sheet-empty { color: #777; padding: 26px; text-align: center; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body { background: #ffffff !important; }
  .pr-table-wrap { overflow: visible !important; }
  .nav, .print-controls, .footer, .toast-wrap, noscript { display: none !important; }
  main { padding: 0 !important; }
  .container { max-width: none; padding: 0; }
  /* Chaque feuille sur sa propre page ; saut avant chaque feuille (le tout
     premier saut est ignoré par le navigateur, donc pas de page blanche). */
  .sheet { box-shadow: none; border: none; border-radius: 0; max-width: none; margin: 0; padding: 0; break-before: page; page-break-before: always; }
  .sheet:first-child { break-before: avoid; page-break-before: avoid; }
  body.only-teams .sheet:not(.sheet-teams) { display: none !important; }
  body.only-matches .sheet:not(.sheet-round) { display: none !important; }
  body.only-standings .sheet:not(.sheet-standings) { display: none !important; }
  .modal-overlay { display: none !important; }
}

/* =========================================================================
   Multi-tournois : cartes de liste, bouton danger plein, modal de confirmation
   ========================================================================= */
.tcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tcard-name { margin: 0; font-size: 1.2rem; line-height: 1.25; word-break: break-word; }
.tcard .toolbar { gap: 8px; }
.tcard .toolbar .btn { flex: 1 1 auto; }

.btn.danger-solid { background: var(--danger); color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.btn.danger-solid:hover { filter: brightness(1.06); box-shadow: var(--shadow); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: rgba(20, 13, 34, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: modal-fade .18s ease;
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 26px 26px 22px; text-align: center;
  animation: modal-pop .2s ease;
}
.modal-icon { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon svg { width: 28px; height: 28px; }
.modal h3 { margin: 0 0 8px; font-size: 1.25rem; }
.modal-body { color: var(--text-2); margin-bottom: 22px; }
.modal-body p { margin: 0; }
.modal-body strong { color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { flex: 1; max-width: 190px; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Indicateur hors ligne */
.offline-badge {
  position: fixed; left: 16px; bottom: 16px; z-index: 55;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--cta), var(--cta-600)); color: #fff;
  padding: 10px 15px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: .85rem; max-width: calc(100vw - 32px);
  animation: modal-pop .2s ease;
}
.offline-badge svg { width: 18px; height: 18px; flex: 0 0 auto; }
@media (max-width: 480px) { .offline-badge span { display: none; } }
@media print { .offline-badge { display: none !important; } }

/* =========================================================================
   Mobile UI/UX — en-têtes empilés, barres d'actions pleine largeur, nav compacte
   ========================================================================= */
@media (max-width: 560px) {
  main { padding-top: calc(var(--nav-h) + 14px); }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head .toolbar { width: 100%; }
  .page-head .toolbar > .btn, .page-head .toolbar > label.btn { flex: 1 1 auto; justify-content: center; }
  .toolbar .btn { justify-content: center; }
  .tcard .toolbar .btn { flex: 1 1 auto; }
  .print-controls { flex-direction: column; align-items: stretch; }
  .print-controls .toolbar { width: 100%; }
  .print-controls .toolbar .btn { flex: 1 1 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { max-width: none; flex: 1 1 auto; }
  .card { padding: 20px; }
  .empty { padding: 32px 22px; }
  h1 { font-size: 1.55rem; }
  .toolbar { gap: 10px; }
}

@media (max-width: 430px) {
  .nav { gap: 8px; padding: 0 12px; }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 9px 9px; }
  .brand > span:last-child { display: none; }   /* garde le logo seul */
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Équipe déclarée forfait : visible mais neutralisée. Elle garde son numéro à
   l'écran pour que celui-ci ne paraisse pas libre, et n'a plus de boutons. */
.team-item.is-forfait { opacity: .55; }
.team-item.is-forfait .tname { text-decoration: line-through; font-weight: 500; }
.team-item.is-forfait .num { background: var(--surface-2); color: var(--text-3); }
.tag-forfait {
  margin-left: auto; flex: 0 0 auto; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border);
}

/* Forfaits au classement : relégués en bas, grisés, sans rang. */
table.standings tr.is-forfait { opacity: .5; }
table.standings tr.is-forfait .team-cell { text-decoration: line-through; }
table.standings tr.is-forfait .rankcell { background: none; color: var(--text-3); font-weight: 500; }
/* Feuille imprimable (noir et blanc) : le gris seul ne suffit pas à l'impression. */
table.pr-standings tr.pr-forfait td { color: #777; font-style: italic; }
