:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #0e1a2b;
  --muted: #5b6b82;
  --line: #d9dfe8;
  --court: #1f4fc4;
  --on-court: #ffffff;
  --ball: #f0641e;
  --on-ball: #0e1a2b;
  --good: #1a8a55;
  --bad: #c0392b;
  --tab-h: 62px;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a111e;
    --surface: #121c30;
    --ink: #e8edf6;
    --muted: #93a3bb;
    --line: #223250;
    --court: #2a5bd6;
    --good: #3fbf84;
    --bad: #ef7a6c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45; }
h1, h2, h3, .num { font-family: 'Barlow Condensed', 'Barlow', sans-serif; font-weight: 700; letter-spacing: 0.01em; margin: 0; }
h2 { font-size: 1.5rem; line-height: 1.1; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.6rem; }
.num { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ball); outline-offset: 2px; }

.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }
.loading { color: var(--muted); padding: 40px 0; }

/* En-tête */
#top { padding: calc(14px + env(safe-area-inset-top)) 0 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#top h1 { font-size: 1.7rem; }
.status { color: var(--muted); font-size: 0.9rem; text-align: right; }
.live { color: var(--ball); font-weight: 600; }
.live::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ball); margin-right: 6px; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Barre d'onglets */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { height: var(--tab-h); background: none; border: 0; cursor: pointer; font-weight: 600; color: var(--muted); position: relative; }
.tab.on { color: var(--ink); }
.tab.on::after { content: ''; position: absolute; left: 22%; right: 22%; top: 0; height: 4px; border-radius: 0 0 4px 4px; background: var(--ball); }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--ball); color: var(--on-ball); font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.alt { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; border-radius: 9px; font-size: 0.92rem; }
.btn.block { width: 100%; }
.field { width: 100%; min-height: 46px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.field:focus-visible { border-color: var(--court); outline-offset: 0; }
.row-form { display: flex; gap: 8px; }
.row-form .field { flex: 1; min-width: 0; }
label.lbl { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 0.92rem; }

/* Blocs */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.panel h2, .panel h3 { margin-bottom: 8px; }
.section-title { margin: 22px 0 10px; }
.empty { padding: 28px 4px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* Salle de draft : le seul moment fort de l'écran */
.clock { position: relative; overflow: hidden; background: var(--court); color: var(--on-court); border-radius: 22px 22px 22px 6px; padding: 18px 18px 14px; margin-bottom: 16px; }
.clock .court { position: absolute; right: -26px; bottom: -18px; width: 250px; fill: none; stroke: #fff; stroke-width: 2; opacity: 0.22; pointer-events: none; }
.clock-meta { display: flex; gap: 16px; font-size: 0.92rem; opacity: 0.85; }
.clock-who { font-size: 2.1rem; margin: 4px 0 14px; position: relative; }
.clock.mine { background: var(--ball); color: var(--on-ball); }
.clock.mine .court { stroke: var(--on-ball); opacity: 0.2; }
.clock.mine .clock-who { animation: nudge 1.8s ease-in-out 2; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateX(4px); } }
.track { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; position: relative; scrollbar-width: none; }
.track::-webkit-scrollbar { display: none; }
.slot { flex: none; width: 58px; text-align: center; font-size: 0.8rem; }
.slot b { display: grid; place-items: center; width: 40px; height: 40px; margin: 0 auto 3px; border-radius: 50%; border: 2px solid currentColor; font-family: 'Barlow Condensed', sans-serif; font-size: 1.05rem; opacity: 0.8; }
.slot.now b { background: #fff; color: var(--court); border-color: #fff; opacity: 1; }
.clock.mine .slot.now b { background: var(--on-ball); color: var(--ball); border-color: var(--on-ball); }
.slot.me b { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45); }
.slot span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn { flex: none; align-self: flex-start; width: 22px; height: 40px; display: grid; place-items: center; font-size: 1.1rem; opacity: 0.8; }

/* Recherche et liste de joueurs */
.finder { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 10px; }
.chips { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.plist, .plain { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.plist .who { flex: 1; min-width: 0; }
.plist .nm { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: 0.88rem; }
.picks li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.picks .n { width: 30px; flex: none; color: var(--muted); font-family: 'Barlow Condensed', sans-serif; font-size: 1.1rem; }
.picks .by { margin-left: auto; color: var(--muted); font-size: 0.9rem; }

/* Classement */
.sync-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 0.9rem; }
.board { list-style: none; margin: 0; padding: 0; }
.team-row { border-bottom: 1px solid var(--line); }
.team-head { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 12px 0; background: none; border: 0; text-align: left; cursor: pointer; }
.rank { font-size: 2.1rem; line-height: 1; color: var(--muted); }
.team-row:first-child .rank { color: var(--ball); }
.t-name { font-weight: 600; font-size: 1.08rem; }
.t-total { font-size: 2rem; line-height: 1; text-align: right; }
.t-today { display: block; text-align: right; font-size: 0.82rem; color: var(--good); font-family: 'Barlow', sans-serif; font-weight: 600; }
.me-tag { margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--court); color: var(--on-court); font-size: 0.78rem; font-weight: 600; vertical-align: 2px; }
.roster { padding: 0 0 12px 52px; }
.roster li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); }
.roster .pts { font-weight: 600; text-align: right; white-space: nowrap; }

/* Mon équipe */
.my-total { font-size: 3.4rem; line-height: 1; }
.game-chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.game-chips span { padding: 2px 8px; border-radius: 8px; background: var(--bg); font-size: 0.82rem; }
.pl-card { border-bottom: 1px solid var(--line); }
.pl-head { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; background: none; border: 0; text-align: left; cursor: pointer; }
.pl-who { display: grid; gap: 1px; min-width: 0; }
.pl-total { font-size: 1.7rem; line-height: 1; }
.games { padding: 0 0 10px; }
.game { border-top: 1px dashed var(--line); }
.game-head { width: 100%; display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 8px; padding: 10px 0; background: none; border: 0; text-align: left; cursor: pointer; }
.g-date { color: var(--muted); font-size: 0.9rem; }
.g-fp { font-size: 1.25rem; }
.g-detail { padding: 0 0 12px 70px; }
.calc li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 0.95rem; }
.calc .calc-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 7px; font-weight: 600; }

/* Barème */
.weights { display: grid; grid-template-columns: 1fr 92px; gap: 8px 12px; align-items: center; }
.weights input { min-height: 40px; text-align: right; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.members li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.members .slotn { width: 28px; color: var(--muted); font-family: 'Barlow Condensed', sans-serif; font-size: 1.1rem; }
.members .actions { margin-left: auto; display: flex; gap: 6px; }
.stack > * + * { margin-top: 10px; }
.err { color: var(--bad); font-size: 0.92rem; }

.facts { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
select.field { appearance: auto; }

/* Fenêtre de confirmation */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(8, 14, 26, 0.55); }
.modal-box { width: 100%; max-width: 420px; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.modal-msg { font-size: 1.05rem; margin-bottom: 14px; }
.modal-box .field { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* Message temporaire */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); z-index: 20; max-width: 528px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 500; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .live::before, .clock.mine .clock-who { animation: none; }
  #toast { transition: none; }
}
