/* Qui marche gagne · styles (lot 1) */

:root {
  --app: #F2F4F7; --surface: #FFFFFF; --surface-2: #F5F7FA;
  --ink: #121A24; --muted: #5A6573; --line: #D7DDE5;
  --c1: #2B59C3; --c1-soft: #E2E9FA; --c1-ink: #1D3F8F;
  --c2: #D5602A; --c2-soft: #FBE8DD; --c2-ink: #8E3A12;
  --on-c1: #FFFFFF; --on-c2: #FFFFFF;
  --carton: #F4C21B;
  --ok: #1C8456; --ok-soft: #DDF2E7;
  --warn: #9A5B00; --warn-soft: #FAEED6;
  --danger: #B42318; --danger-soft: #FDE8E6;
  --ombre: 0 10px 30px -18px rgba(16, 30, 54, .5);
  --f-titre: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-texte: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --app: #0B1117; --surface: #161F29; --surface-2: #1C2733;
    --ink: #E7ECF2; --muted: #98A4B3; --line: #2A3644;
    --c1: #7F9FF0; --c1-soft: #1D2B4C; --c1-ink: #BCCDF7;
    --c2: #F08B58; --c2-soft: #3B2317; --c2-ink: #F7C2A5;
    --on-c1: #0B1631; --on-c2: #2A1206;
    --ok: #4FC28C; --ok-soft: #143328;
    --warn: #F0B45A; --warn-soft: #382810;
    --danger: #FF8A80; --danger-soft: #3A1512;
    --ombre: 0 10px 30px -18px rgba(0, 0, 0, .9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--app); color: var(--ink);
  font-family: var(--f-texte); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
p { margin: 0; }
h1, h2 { margin: 0; }
:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.petit { font-size: 14px; }
.centre { text-align: center; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- Structure ---------- */
.shell { min-height: 100vh; }
.main {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 96px);
  display: flex; flex-direction: column; gap: 12px;
}
.plein {
  min-height: 100vh; display: grid; place-items: center; text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.plein > .carte { width: min(400px, 100%); display: grid; gap: 14px; padding: 24px; }
.actions { display: grid; gap: 10px; }

.tabbar {
  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: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
}
.tabbar button {
  background: none; border: 0; display: grid; justify-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0;
}
.tabbar .ic { width: 24px; height: 24px; opacity: .6; }
.tabbar button.on { color: var(--c1); }
.tabbar button.on .ic { opacity: 1; }
.side { display: none; }

.marque { font-family: var(--f-titre); font-weight: 700; font-size: 24px; line-height: 1; text-transform: uppercase; padding: 0 10px 16px; }
.qui-suis-je { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; font-weight: 600; }

/* ---------- Éléments communs ---------- */
.entete { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding-top: 4px; }
.entete h1 { font-family: var(--f-titre); font-weight: 700; font-size: 34px; line-height: 1; text-transform: uppercase; }
.surtitre { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.h-petit { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.h-petit.espace { margin-top: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.accueil-grid { display: flex; flex-direction: column; gap: 12px; }

.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; gap: 8px; }
.av {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-weight: 700; font-size: 13px; background: var(--c1); color: var(--on-c1);
}
.av.c2 { background: var(--c2); color: var(--on-c2); }
.av.petit { width: 26px; height: 26px; font-size: 11px; vertical-align: middle; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 700; font-size: 16px;
  background: var(--c1); color: var(--on-c1);
}
.btn.secondaire { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.lien { background: none; border: 0; padding: 0; color: var(--c1); font-weight: 600; }
.lien-texte { background: none; border: 0; padding: 0; color: var(--c1); font-weight: 600; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.alerte { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.bandeau { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.yc { display: inline-block; width: 13px; height: 18px; border-radius: 3px; background: var(--carton); transform: rotate(-8deg); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); flex: none; }
.pastille { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--c1); }
.pastille.c2 { background: var(--c2); }
.vide { padding: 8px 2px; }

/* ---------- Duel ---------- */
.duel { gap: 10px; padding: 16px; }
.cotes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cotes .droite { text-align: right; }
.cotes .droite .qui { justify-content: flex-end; }
.qui { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.gros { font-family: var(--f-titre); font-weight: 700; font-size: 42px; line-height: 1.02; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gros.c1 { color: var(--c1); }
.gros.c2 { color: var(--c2); }
.source { font-size: 12px; color: var(--muted); }
.split { display: flex; height: 9px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.split .c1 { background: var(--c1); }
.split .c2 { background: var(--c2); }
.ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }

/* ---------- Accueil ---------- */
.attente { gap: 4px; }
.ligne-lien, .activite {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 0 4px; text-align: left; font-size: 15px;
}
.attente .h-petit + .ligne-lien, .carte .h-petit + .activite { border-top: 0; padding-top: 4px; }
.activite { flex-direction: column; align-items: flex-start; gap: 1px; }
.activite small { color: var(--muted); font-size: 13px; }
.verdict { text-align: left; font-size: 16px; }
.verdict > b { font-size: 17px; }
.gage-ligne { display: flex; align-items: center; gap: 9px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.solde { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: none; border: 0; padding: 0; text-align: left; }
.solde .carte { gap: 2px; }
.solde small { font-size: 13px; font-weight: 600; color: var(--muted); }
.solde .n { font-family: var(--f-titre); font-weight: 700; font-size: 34px; line-height: 1; display: flex; align-items: center; gap: 9px; }
.solde .n .yc { width: 15px; height: 21px; }

/* ---------- Saisie ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; background: var(--app); overflow-y: auto; }
.feuille {
  width: 100%; max-width: 560px; margin: 0 auto; min-height: 100%; background: var(--app);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex; flex-direction: column; gap: 14px;
}
.barre-haut { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 32px; }
.barre-haut b { font-size: 17px; }
.puces { display: flex; gap: 8px; flex-wrap: wrap; }
.puce { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; font-size: 15px; }
.puce.on { background: var(--c1); border-color: var(--c1); color: var(--on-c1); font-weight: 600; }
.champ { display: grid; gap: 5px; font-size: 14px; font-weight: 600; color: var(--muted); text-align: left; }
.champ input {
  width: 100%; font-size: 17px; font-weight: 400; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
.saisie-jour { text-align: center; font-weight: 600; color: var(--muted); }
.entree { display: grid; justify-items: center; gap: 0; border-bottom: 2px solid var(--c1); padding-bottom: 6px; }
.entree input {
  width: 100%; text-align: center; border: 0; background: transparent; outline: none;
  font-family: var(--f-titre); font-weight: 700; font-size: 68px; line-height: 1.05; font-variant-numeric: tabular-nums;
}
.entree input::placeholder { color: var(--line); }
.entree span { color: var(--muted); font-size: 14px; }
.infos { display: grid; gap: 4px; font-size: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.note .ic { width: 16px; height: 16px; margin-top: 2px; }
.feuille .btn { margin-top: auto; }

/* ---------- Historique ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 7px 4px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.score { display: flex; justify-content: center; align-items: center; gap: 12px; }
.score .s { font-family: var(--f-titre); font-weight: 700; font-size: 38px; line-height: 1; }
.score .s.c1 { color: var(--c1); }
.score .s.c2 { color: var(--c2); }
.score small { font-size: 13px; font-weight: 600; color: var(--muted); }
.liste { gap: 0; padding: 4px 14px; }
.ligne-jour {
  display: grid; grid-template-columns: 58px 1fr 30px; gap: 10px; align-items: center; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 0; text-align: left;
}
.ligne-jour:last-child { border-bottom: 0; }
.jj { display: grid; font-size: 12px; color: var(--muted); line-height: 1.2; }
.jj b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.jj em { font-style: normal; font-size: 11px; color: var(--warn); }
.barres { display: grid; gap: 4px; }
.barre-pas { display: flex; align-items: center; gap: 6px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.barre-pas i { display: block; height: 7px; border-radius: 99px; background: var(--c1); }
.barre-pas.c2 i { background: var(--c2); }
.barre-pas.manque { font-style: italic; color: var(--warn); font-size: 12px; }
.badge { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--c1); color: var(--on-c1); }
.badge.c2 { background: var(--c2); color: var(--on-c2); }
.badge.neutre { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }

/* ---------- Détail ---------- */
.trace { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.trace li { display: grid; grid-template-columns: 10px 1fr; gap: 9px; font-size: 15px; }
.trace .pastille { margin-top: 6px; }
.trace small { display: block; color: var(--muted); font-size: 13px; }

/* ---------- Gages ---------- */
.liste-gages { display: grid; gap: 10px; }
.gage { display: grid; grid-template-columns: auto 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.carte .gage { border: 0; padding: 4px 0; background: none; }
.gage .yc { width: 20px; height: 27px; margin-top: 2px; }
.gage.passe { opacity: .72; }
.gage.passe .yc { background: var(--line); }
.gage-corps { display: grid; gap: 4px; min-width: 0; }
.gage-corps b { font-size: 16px; overflow-wrap: anywhere; }
.gage-corps small { color: var(--muted); font-size: 13px; }
.actions-ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.mini {
  display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 99px;
  padding: 7px 13px; font-size: 14px; font-weight: 700; background: var(--c1-soft); color: var(--c1-ink);
}
.mini .ic { width: 14px; height: 14px; }
.mini.ok { background: var(--ok-soft); color: var(--ok); }
.mini.plein-ok { background: var(--ok); color: var(--surface); }
.mini.neutre { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.etat { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.etat.du { background: var(--warn-soft); color: var(--warn); }
.etat.realise, .etat.compense, .etat.rembourse { background: var(--ok-soft); color: var(--ok); }
.compensation { grid-template-columns: 1fr auto; align-items: center; gap: 12px; background: var(--ok-soft); border-color: transparent; font-size: 14px; }
.note-edition { display: grid; gap: 8px; margin-top: 4px; }
.note-edition .champ input { font-size: 16px; padding: 9px 11px; }
.credit { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.credit .ic { margin-top: 2px; }

/* ---------- Connexion & réglages ---------- */
.connexion h1 { font-family: var(--f-titre); font-weight: 700; font-size: 38px; line-height: 1; text-transform: uppercase; }
.logo { justify-self: center; border-radius: 18px; }
.formulaire { display: grid; gap: 12px; }

/* ---------- Message ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  width: max-content; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--app); border-radius: 14px; padding: 11px 16px;
  font-size: 15px; font-weight: 600; box-shadow: var(--ombre);
}
.toast.erreur { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 28px; } }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: monte .2s ease-out; }
  @keyframes monte { from { transform: translate(-50%, 8px); opacity: 0; } }
}

/* ---------- Ajustements ---------- */
.barre-haut .lien { justify-self: start; }
.gage-corps .etat { justify-self: start; }
.compensation .mini.ok { background: var(--ok); color: var(--surface); }
.compensation .mini.plein-ok { background: var(--ink); color: var(--surface); }

.code-import { display: grid; gap: 8px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.code-import code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.carte a { color: var(--c1); font-weight: 600; }

.seg.periodes { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.seg.periodes button { font-size: 13px; padding: 7px 2px; line-height: 1.2; }

/* ---------- Ordinateur (en dernier : l'emporte sur les règles mobiles) ---------- */
@media (min-width: 900px) {
  .shell { display: flex; }
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px; width: 230px; flex: none;
    position: sticky; top: 0; height: 100vh; padding: 24px 14px;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .side button {
    display: flex; align-items: center; gap: 10px; background: none; border: 0;
    padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; text-align: left;
  }
  .side button.on { background: var(--c1-soft); color: var(--c1-ink); }
  .main { max-width: 980px; padding: 32px 36px 48px; }
  .accueil-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; align-items: start; }
  .overlay { background: rgba(8, 14, 22, .45); display: grid; place-items: center; padding: 24px; }
  .feuille { max-width: 460px; border-radius: 22px; box-shadow: var(--ombre); min-height: 0; }
}
