:root {
  --bg: #0e141b; --panel: #16202b; --panel2: #1e2c3b; --line: #2b3b4d;
  --txt: #e9eff6; --mut: #8ea3b9; --acc: #22c55e; --acc2: #16a34a;
  --red: #ef4444; --org: #f59e0b; --blue: #3b82f6; --yellow: #fde047;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--txt);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { height: 100%; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ---------- boutons & champs ---------- */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); font-weight: 600; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--acc2); border-color: var(--acc); color: #fff; }
.btn.red { background: #7f1d1d; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0b1118; color: var(--txt); font: inherit; }
textarea { min-height: 110px; }
label.fld { display: block; font-size: 13px; color: var(--mut); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.mut { color: var(--mut); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mut); display: inline-block; flex: none; }
.dot.ok { background: var(--acc); } .dot.pend { background: var(--org); } .dot.err { background: var(--red); }

/* ---------- écrans simples (liste, effectif, réglages) ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.page { flex: 1; overflow: auto; padding: 14px; max-width: 900px; width: 100%; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.mcard { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.mcard .sc { font-size: 24px; font-weight: 800; min-width: 74px; text-align: center; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--mut); }
.badge.live { background: #14532d; color: #86efac; } .badge.done { background: #1e293b; }
.prow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.prow .num { width: 72px; flex: none; text-align: center; font-weight: 700; }

/* ---------- écran match ---------- */
.mhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.mhead .ttl { min-width: 0; flex: 1 1 140px; }
.mhead .ttl b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhead .ttl small { color: var(--mut); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { display: flex; align-items: center; gap: 10px; }
.score .num { font-size: 40px; font-weight: 800; line-height: 1; min-width: 28px; text-align: center; }
.score .tm { font-size: 12px; color: var(--mut); text-align: center; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .sep { font-size: 28px; color: var(--mut); }
.goalbtns { display: flex; gap: 8px; }
.clock { text-align: center; min-width: 120px; }
.clock .t { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.clock .t.over { color: var(--org); }
.clock .s { font-size: 13px; color: var(--mut); margin-top: 2px; }
.ctrls { display: flex; gap: 8px; }

.mbody { flex: 1; min-height: 0; display: flex; gap: 10px; padding: 10px; }
.pitchwrap { flex: none; height: 100%; aspect-ratio: 68 / 105; position: relative; }
.panel { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.pitch { position: absolute; inset: 0; border-radius: 14px; overflow: hidden; container-type: inline-size;
  background: repeating-linear-gradient(0deg, #2e7d32 0 9.52%, #2a7230 9.52% 19.04%); border: 2px solid #1b4d1f; }
.pitch svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.formbtn { position: absolute; left: 2cqw; top: 2cqw; z-index: 3; background: #000a; border: 1px solid #fff5; color: #fff;
  border-radius: 10px; padding: 6px 12px; font-weight: 700; font-size: clamp(12px, 3.6cqw, 16px); }
.chip { position: absolute; transform: translate(-50%, -50%); width: 21cqw; display: flex; flex-direction: column; align-items: center; gap: .6cqw;
  background: none; border: 0; padding: 0; color: #fff; z-index: 2; }
.shirt { width: 11.5cqw; height: 11.5cqw; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  font-size: clamp(12px, 4.6cqw, 26px); background: var(--blue); border: .6cqw solid #fff; box-shadow: 0 2px 6px #0007; position: relative; }
.chip.gk .shirt { background: var(--org); }
.chip .nm { font-size: clamp(10px, 3.2cqw, 17px); font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; background: #0008; border-radius: 6px; padding: 0 1.2cqw; }
.chip .pos { font-size: clamp(9px, 2.6cqw, 13px); opacity: .85; font-weight: 600; text-shadow: 0 1px 2px #000; }
.chip.empty .shirt { background: #0003; border: .6cqw dashed #fffb; color: #fffd; font-size: clamp(10px, 3.4cqw, 15px); }
.chip.sel .shirt { outline: 1cqw solid var(--yellow); animation: pulse 1s infinite; }
.chip .goals { position: absolute; right: -2.2cqw; top: -2.2cqw; background: #fff; color: #000; font-size: clamp(9px, 2.8cqw, 14px);
  border-radius: 99px; padding: 0 .9cqw; font-weight: 800; }
@keyframes pulse { 50% { outline-offset: .8cqw; } }

.selbar { background: #3b3200; border: 1px solid var(--yellow); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.selbar .grow { font-weight: 600; }
.sect { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.sect h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--mut); }
.bench { display: flex; flex-wrap: wrap; gap: 8px; }
.bchip { min-height: 52px; padding: 6px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2);
  display: flex; align-items: center; gap: 8px; text-align: left; }
.bchip .n { font-weight: 800; font-size: 18px; min-width: 24px; text-align: center; }
.bchip small { display: block; color: var(--mut); font-size: 12px; }
.bchip.sel { border-color: var(--yellow); background: #3b3200; }
.bchip.low .n { color: var(--org); }

.tabs { display: flex; gap: 6px; }
.tab { flex: 1; min-height: 42px; border-radius: 10px 10px 0 0; border: 1px solid var(--line); border-bottom: 0; background: var(--bg); color: var(--mut); font-weight: 700; }
.tab.on { background: var(--panel); color: var(--txt); }
.tabbody { flex: 1; min-height: 0; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 14px 14px; padding: 10px; margin-top: -10px; }
.panel > .tabs { margin-bottom: 0; }

.ev { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.ev .min { width: 44px; flex: none; font-weight: 800; color: var(--acc); text-align: right; font-variant-numeric: tabular-nums; }
.ev .tx { flex: 1; min-width: 0; word-break: break-word; }
.ev.void .tx { text-decoration: line-through; opacity: .45; }
.ev.goal .tx { font-weight: 700; }
.ev.them .tx { color: #fca5a5; }
table.st { width: 100%; border-collapse: collapse; }
table.st th, table.st td { padding: 7px 4px; text-align: left; border-bottom: 1px solid var(--line); }
table.st th { font-size: 12px; color: var(--mut); text-transform: uppercase; }
.bar { height: 8px; border-radius: 4px; background: #0b1118; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--acc2); }

/* ---------- fenêtres & toasts ---------- */
.overlay { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: min(560px, 100%); max-height: 92dvh; overflow: auto; }
.modal h2 { margin: 0 0 12px; font-size: 19px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.pgrid .btn { text-align: left; display: flex; gap: 8px; align-items: center; min-height: 52px; }
.pgrid .btn b { min-width: 26px; text-align: center; font-size: 18px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); background: #0b1118; border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 12px; z-index: 60; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px #000a; max-width: 92vw; }
.toast button { background: none; border: 0; color: var(--yellow); font-weight: 800; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn.on { background: var(--acc2); border-color: var(--acc); }
.unav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.stbtn { border-width: 2px; }
.stbtn .stlab { font-weight: 700; margin-left: 4px; }
.st-blesse { border-color: var(--red); color: #fca5a5; }
.st-pret { border-color: var(--blue); color: #93c5fd; }
.st-suspendu { border-color: var(--org); color: #fcd34d; }
.st-absent { border-color: var(--mut); color: var(--mut); }
.warn { background: #451a03; border: 1px solid var(--org); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }

/* ---------- portrait (téléphone / tablette verticale) ---------- */
@media (orientation: portrait) {
  .mbody { flex-direction: column; overflow-y: auto; }
  .panel { display: contents; }
  .panel > .selbar { order: -2; }
  .panel > .benchsect { order: -1; }
  .pitchwrap { order: 0; height: auto; width: min(100%, calc((100dvh - 310px) * .6476)); min-height: 280px; align-self: center; }
  .mhead .ttl small { display: none; }
  .mhead .ttl b { font-size: 15px; }
  .mhead .btn { min-height: 42px; padding: 6px 11px; font-size: 15px; }
  .mhead .clock { min-width: 96px; }
  .goalbtns, .ctrls { gap: 6px; }
  .panel > .tabs { order: 1; margin-top: 4px; }
  .panel > .tabbody { order: 2; min-height: 260px; flex: none; margin-top: -10px; overflow: visible; }
  .bench { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .bchip { flex: none; }
  .mhead { gap: 6px 10px; }
  .score .num, .clock .t { font-size: 30px; }
  .mbody { padding: 8px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .score .num, .clock .t { font-size: 30px; }
  .mhead { padding: 4px 10px; }
  .btn { min-height: 40px; }
}
