:root {
  --bg: #f4f6f5; --card: #ffffff; --ink: #14201d; --muted: #63716d; --line: #e2e8e6;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #d9f0ec;
  --ok: #15803d; --no: #b91c1c; --warn: #b45309;
  --s-bureau: #2563eb; --s-depart: #d97706; --s-parti: #16a34a; --s-ailleurs: #7c3aed; --s-absent: #94a3b8;
  --radius: 16px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1413; --card: #16201e; --ink: #e8efed; --muted: #93a39f; --line: #24312e;
          --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123a35; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.top h1 { font-size: 22px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--brand); color: var(--brand-ink);
  font-weight: 600; cursor: pointer; min-height: 44px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: transparent; color: var(--no); border: 1.5px solid var(--no); }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.on { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
.err { color: var(--no); font-size: 14px; margin-top: 8px; min-height: 1em; }

/* Sondage du jour */
.poll h2 { font-size: 18px; margin-bottom: 4px; }
.poll .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.poll .yes.on { background: var(--ok); color: #fff; }
.poll .no.on { background: var(--no); color: #fff; }
.meter { display: flex; align-items: baseline; gap: 6px; }
.meter b { font-size: 34px; letter-spacing: -.02em; }
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--s-depart); transition: width .4s; }

/* Personnes */
.section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  display: flex; align-items: center; gap: 8px; margin: 18px 4px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.person { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px;
  text-align: center; cursor: pointer; position: relative; }
.person .name { font-size: 13px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .zone { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  font-weight: 700; color: #fff; background-size: cover; background-position: center; border: 3px solid var(--line); }
.meal { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.meal svg { width: 14px; height: 14px; }
.meal.yes { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.meal.no { background: var(--line); color: var(--muted); }
.person.nomeal { opacity: .55; }
.lane .meal { width: 28px; height: 28px; } .lane .meal svg { width: 18px; height: 18px; }
.empty { color: var(--muted); font-size: 14px; padding: 4px; }
.st-bureau .av { border-color: var(--s-bureau); } .st-depart .av { border-color: var(--s-depart); }
.st-parti .av { border-color: var(--s-parti); } .st-ailleurs .av { border-color: var(--s-ailleurs); }
.st-absent { opacity: .6; }

/* Navigation */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; z-index: 5; }
nav.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; position: relative; }
nav.tabs a.on { color: var(--brand); font-weight: 600; }
nav.tabs svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 8px; left: 55%; background: var(--no); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg .av { width: 32px; height: 32px; font-size: 12px; border-width: 2px; margin: 0; flex: none; }
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; max-width: 80%; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--brand); color: var(--brand-ink); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble .meta { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.msg.ping .bubble { border: 2px dashed var(--s-depart); }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg);
  padding: 10px 16px; border-top: 1px solid var(--line); }
.composer form { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; }

/* Panel horizontal (écran mural) */
.panel { min-height: 100vh; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.panel header { display: flex; align-items: center; justify-content: space-between; }
.panel header h1 { font-size: 34px; }
.panel .clock { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lanes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; flex: 1; }
.lane { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; }
.lane h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lane h2 .n { margin-left: auto; font-size: 28px; }
.lane .people { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.lane .av { width: 84px; height: 84px; font-size: 26px; border-width: 4px; }
.lane .name { font-size: 16px; }
.panel .summary { display: flex; gap: 28px; font-size: 22px; color: var(--muted); }
.panel .summary b { color: var(--ink); font-size: 30px; }
@media (max-width: 900px) { .lanes { grid-template-columns: 1fr 1fr; } }

/* Admin */
.seg { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.seg button { border: 1.5px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.code { font: 600 22px/1.2 ui-monospace, monospace; letter-spacing: .12em; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Feuille d'action */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet .av { width: 72px; height: 72px; font-size: 22px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 30; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hero { text-align: center; margin: 8vh 0 24px; }
.hero .logo { width: 72px; height: 72px; }
.hero h1 { font-size: 30px; margin-top: 10px; }

/* ───────── Ligne de départ façon piste d'athlétisme ───────── */
.race { position: relative; overflow: hidden; border-radius: 22px; margin: 6px 0 4px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); }
.race-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; }
.race-head b { font-size: 20px; letter-spacing: -.01em; }
.race-head .mood { color: var(--muted); font-size: 14px; }
.race-head .score { margin-left: auto; text-align: right; font-size: 15px; color: var(--muted); line-height: 1; }
.race-head .score b { font-size: 34px; color: var(--ink); }
.race-head .score small { display: block; font-size: 12px; margin-top: 2px; }
.flag { width: 30px; height: 30px; flex: none; border-radius: 6px; transform: rotate(-8deg);
  background: repeating-conic-gradient(#111 0 25%, #fff 0 50%) 0 0 / 10px 10px; box-shadow: 0 0 0 2px #111; }
.phase-go .flag { animation: wave 0.6s ease-in-out infinite alternate; }
.track { position: relative; padding: 18px 12px 0; min-height: 150px; display: flex; flex-direction: column;
  background: repeating-linear-gradient(180deg, #c8553d 0 38px, #f3e9e4 38px 41px); }
.runners { flex: 1; align-content: flex-end; display: flex; flex-wrap: wrap; gap: 14px 10px; align-items: flex-end; justify-content: center; padding-bottom: 12px; position: relative; z-index: 1; }
.runner { position: relative; width: 78px; text-align: center; cursor: pointer; }
.runner .av { width: 56px; height: 56px; border: 3px solid #fff; box-shadow: 0 3px 0 rgb(0 0 0 / .25);
  animation: hop 0.9s ease-in-out infinite; animation-delay: var(--d, 0s); }
.runner .bib { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); background: #fff; color: #111;
  font: 800 11px/1 ui-monospace, monospace; padding: 2px 5px; border-radius: 4px; border: 1.5px solid #111; }
.runner .rname { margin-top: 10px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runner .speech { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; white-space: nowrap;
  background: #fff; color: #111; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 10px; z-index: 2;
  animation: pop 2.4s ease-in-out infinite; }
.runner .speech::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: #fff; }
.runner.ghost .av { opacity: .55; filter: grayscale(1); border: 3px dashed #fff; box-shadow: none; animation: wobble 2.6s ease-in-out infinite; }
.runner.ghost .rname { opacity: .8; }
.runner .quip { font-size: 11px; color: #ffe8df; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-track { color: #ffe8df; font-weight: 600; padding: 30px 0 18px; }
.startline { height: 16px; margin: 0 -12px; background: repeating-conic-gradient(#111 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.gone-line { padding: 10px 16px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.phase-go .track { background: repeating-linear-gradient(180deg, #16a34a 0 38px, #dcfce7 38px 41px); }
.phase-go .runner .av { animation-duration: .45s; }
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; background: var(--c); border-radius: 2px;
  animation: fall 2.2s linear infinite; animation-delay: var(--t); }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes wave { from { transform: rotate(-14deg); } to { transform: rotate(10deg); } }
@keyframes pop { 0%, 70%, 100% { transform: translateX(-50%) scale(1); } 80% { transform: translateX(-50%) scale(1.12); } }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(260px) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .race * { animation: none !important; } .confetti { display: none; } }

/* Panel : piste en grand */
.race.big .race-head b { font-size: 30px; } .race.big .race-head .mood { font-size: 18px; }
.race.big .race-head .score b { font-size: 48px; } .race.big .flag { width: 44px; height: 44px; }
.race.big .track { min-height: 210px; padding-top: 26px; }
.race.big .runner { width: 120px; } .race.big .runner .av { width: 86px; height: 86px; font-size: 26px; }
.race.big .runner .bib { top: 56px; font-size: 14px; } .race.big .runner .rname { font-size: 16px; }
.lanes.three { grid-template-columns: repeat(3, 1fr); }

/* Admin : scanner de bornes */
.scan-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.scan-item:last-child { border-bottom: 0; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; }
.bars i { width: 4px; background: var(--line); border-radius: 1px; }
.bars i.on { background: var(--ok); }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tag.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
