:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #6b7690;
  --line: #e4e8f0;
  --accent: #f26b21;
  --accent-soft: #fff1e8;
  --blue: #1d4ed8;
  --blue-soft: #e8efff;
  --ok: #138a4b;
  --ok-soft: #e4f6ec;
  --warn: #b45309;
  --warn-soft: #fff4dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 32px 0; }
.small { font-size: 13px; }

/* ---------- En-tête ---------- */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); }
.top-in { max-width: 960px; margin: 0 auto; padding: 10px 14px 0; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
.ball { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); position: relative; flex: none; box-shadow: inset -4px -4px 0 rgba(0,0,0,.18); }
.ball::before, .ball::after { content: ""; position: absolute; background: var(--ink); opacity: .85; }
.ball::before { left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%); }
.ball::after { top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); }
.brand-t { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-s { font-size: 12px; color: #aab4cc; }
.tabs { display: flex; gap: 2px; margin: 0 -6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; background: none; border: 0; color: #aab4cc; padding: 10px 14px 11px; font-weight: 600;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.on { color: #fff; border-bottom-color: var(--accent); }
@media (min-width: 720px) {
  .top-in { flex-direction: row; align-items: flex-end; justify-content: space-between; padding-top: 12px; }
  .tabs { margin: 0; }
}

.wrap { max-width: 960px; margin: 0 auto; padding: 14px 12px 60px; }

/* ---------- Pastilles / chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px;
  font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.sm { padding: 5px 11px; font-size: 13px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 13px 14px 9px; }
.card-h h2 { font-size: 17px; }
.card-h .sub { color: var(--muted); font-size: 13px; }
.card-b { padding: 4px 14px 14px; }
.section-t { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 18px 4px 8px; }
.empty { color: var(--muted); padding: 18px 14px; text-align: center; }
.note { color: var(--muted); font-size: 12.5px; padding: 8px 14px 12px; border-top: 1px solid var(--line); }

/* ---------- Tables ---------- */
table.t { width: 100%; border-collapse: collapse; }
.t th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); text-align: right; padding: 6px 6px; border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap; }
.t td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.t tr:last-child td { border-bottom: 0; }
.t th:first-child, .t td:first-child { padding-left: 14px; }
.t th:last-child, .t td:last-child { padding-right: 14px; }
.t .l { text-align: left; }
.t td.team { text-align: left; font-weight: 600; }
.t td.pts { font-weight: 800; font-size: 16px; }
.t th.pts { color: var(--ink); }
.t td.rk { width: 38px; text-align: center; color: var(--muted); font-weight: 700; }
.t tr.first td.rk span { background: var(--accent); color: #fff; }
.t td.rk span { display: inline-flex; min-width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; }
.t .eq { color: var(--accent); font-weight: 800; margin-left: 1px; cursor: help; }
.t .dim { color: var(--muted); }
.t tr.hl td { background: var(--accent-soft); }
.scroll-x { overflow-x: auto; }

/* ---------- Cartes de match ---------- */
.mlist { display: grid; gap: 10px; }
@media (min-width: 720px) { .mlist { grid-template-columns: 1fr 1fr; } }
.match { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 11px 13px 12px; text-align: left; border: 0; width: 100%; display: block; }
.match:hover { outline: 2px solid var(--blue-soft); }
.m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.m-time { font-weight: 800; font-size: 16px; }
.m-court { color: var(--muted); font-size: 13px; }
.m-head .sp { flex: 1; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.badge.div { background: #eef0f5; color: var(--ink); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.todo { background: #eef0f5; color: var(--muted); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.m-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.m-team { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-w { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; background: #eef0f5; font-variant-numeric: tabular-nums; }
.m-w.lead { background: var(--accent); color: #fff; }
.m-w.empty { background: transparent; color: var(--muted); font-weight: 500; }
.m-pts { width: 54px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.open-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 2px 12px; color: var(--muted); font-size: 13.5px; }

/* ---------- Modale ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 33, 61, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 720px) { .backdrop { align-items: center; } }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { .modal { border-radius: 18px; } }
.modal-h { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.modal-h .t1 { font-weight: 800; font-size: 17px; }
.modal-h .t2 { color: var(--muted); font-size: 13.5px; }
.x { border: 0; background: #eef0f5; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1; flex: none; }
.block { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.block h3 { font-size: 14px; margin-bottom: 2px; }
.block .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.qrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.qrow .nm { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: flex; gap: 4px; }
.seg button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: 16px; }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.sumline { margin-top: 6px; font-size: 13px; }
.dgrid { display: grid; grid-template-columns: 32px repeat(3, 1fr) 30px; gap: 6px; align-items: center; }
.dgrid .hd { font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dgrid .pl { font-weight: 800; color: var(--muted); font-size: 13px; }
.dgrid input { width: 100%; min-width: 0; text-align: center; padding: 9px 2px; border: 1px solid var(--line); border-radius: 9px; font-weight: 700; font-size: 16px; background: #fff; }
.dgrid input:focus, .field:focus { outline: 2px solid var(--blue); border-color: transparent; }
.dgrid input.win { background: var(--accent-soft); border-color: var(--accent); }
.dgrid .wn { text-align: center; font-size: 12px; color: var(--accent); font-weight: 800; }
.msg { border-radius: 10px; padding: 8px 10px; font-size: 13.5px; margin-top: 10px; }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.info { background: var(--blue-soft); color: var(--blue); }
.preview { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--card); padding: 10px 0 2px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f1c4c0; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Formulaires ---------- */
.field { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: #fff; }
textarea.field { min-height: 150px; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
label.lb { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }
.ocard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; margin-top: 8px; }
.checks label { display: flex; gap: 7px; align-items: center; font-size: 14px; }
details.dt { border-top: 1px solid var(--line); padding: 10px 14px; }
details.dt summary { cursor: pointer; font-weight: 700; }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
code { background: #eef0f5; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

/* ---------- Équipes ---------- */
details.team-d { padding: 0 14px; }
details.team-d summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 0; list-style: none; }
details.team-d summary::-webkit-details-marker { display: none; }
details.team-d summary::before { content: "▸"; color: var(--muted); width: 12px; transition: transform .15s; }
details.team-d[open] summary::before { transform: rotate(90deg); }

details.team-d > :not(summary) { padding-bottom: 12px; }

/* ---------- Divers ---------- */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .25s; z-index: 90; font-weight: 600; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }
.kpis { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.kpi { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 14px; min-width: 110px; }
.kpi b { display: block; font-size: 22px; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.pill-w { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: 1px; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }
.vs-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 10px; align-items: center; text-align: center; }
.vs-grid .big { font-size: 28px; font-weight: 800; }
.vs-grid .nm { font-weight: 700; }
.sel { display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 12px; }
@media (min-width: 560px) { .sel.two { grid-template-columns: 1fr 1fr; } }

/* ---------- Chasubles, logos, joueurs ---------- */
.bib { width: 19px; height: 19px; flex: none; }
.m-team, .qrow .nm { display: flex; align-items: center; gap: 7px; }
.m-team .tn, .qrow .nm .tn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dgrid .hd { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dgrid .hd .tn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tlogo { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; margin-right: 8px; border-radius: 4px; }
.tthumb { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; flex: none; }
.clogo { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; }
.club-h { display: flex; align-items: center; gap: 10px; }
.section-t.grp { margin-top: 20px; font-size: 14px; color: var(--ink); }
button.more { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); background: #fafbfd; padding: 11px; font-weight: 700; color: var(--blue); }
.plist { padding: 2px 0 6px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.pav { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: #eef0f5; }
.pav.ph { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); font-size: 15px; }
.pname { font-weight: 600; flex: 1; }
.pn { flex: 1; min-width: 120px; padding: 7px 10px; }
.btn.xs { padding: 5px 9px; font-size: 12.5px; border-radius: 8px; cursor: pointer; display: inline-block; }
.addp { margin: 8px 0 4px; }
.logo-ctl { margin: 8px 0 2px; }
.linkbtn { background: none; border: 0; color: var(--bad); text-decoration: underline; padding: 0; cursor: pointer; }
.addm { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.addm .qrow { margin-top: 6px; }
details.team-d summary .tname { font-weight: 700; }

/* ---------- Forfait ---------- */
.ff { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #fdecea; color: var(--bad); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; flex: none; }
.ffbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; flex: none; }
.ffbtn.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button:disabled { opacity: .35; }
.nmcol { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.qrow .nm { min-width: 0; }
.ffbtn { padding: 3px 8px; }
.nmcol .tn { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.2; }

/* Cartons (jaune / rouge) */
.kc { display: inline-flex; align-items: center; justify-content: center; min-width: 13px; height: 17px; padding: 0 3px; margin-left: 4px; border-radius: 3px; font-size: 11px; font-weight: 800; line-height: 1; flex: none; vertical-align: middle; }
.kc.y { background: #f5c518; color: #3d2f00; }
.kc.r { background: #d92d20; color: #fff; }
.kc.big { width: 13px; min-width: 13px; height: 18px; padding: 0; margin: 0 4px 0 0; }
.kstep { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; flex: none; }
.kstep b { min-width: 16px; text-align: center; }
.kstep .btn:disabled { opacity: .35; }
.t td.nowrap { white-space: nowrap; }
.small .linkbtn { color: var(--blue); }
.clubf { margin-top: 8px; }
.clubf label { flex: none; }
