:root {
    --bg: #faf6f1;
    --card: #ffffff;
    --ink: #2a2430;
    --muted: #4a4352;
    --line: #ece4dc;
    --accent: #b8466f;
    --accent-ink: #ffffff;
    --accent-soft: #f7e6ed;
    --good: #17794d;
    --good-soft: #def3e8;
    --warn: #8a5300;
    --warn-soft: #fdecd0;
    --info: #1f5f8b;
    --info-soft: #dcebf6;
    --bad: #a8231a;
    --bad-soft: #fde2df;
    --shadow: 0 1px 2px rgba(40, 20, 40, .06), 0 8px 24px rgba(40, 20, 40, .06);
    --radius: 18px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16131a;
        --card: #211d27;
        --ink: #f3eef6;
        --muted: #dcd6e3;
        --line: #342d3c;
        --accent: #e8789f;
        --accent-ink: #20101a;
        --accent-soft: #3a2230;
        --good: #6fd6a2;
        --good-soft: #17352a;
        --warn: #f0b960;
        --warn-soft: #3b2c12;
        --info: #8cc4ee;
        --info-soft: #172c3d;
        --bad: #ff9a90;
        --bad-soft: #45201d;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding-bottom: 96px;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }

/* Pleine largeur, petite marge sur les côtés */
.wrap { width: 100%; max-width: 1320px; padding-inline: clamp(12px, 2vw, 24px); margin-inline: auto; }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, #8c2f55 0%, #b8466f 55%, #c79a3b 120%);
    color: #fff;
    padding: 20px 0 56px;
    margin-bottom: -30px;
    overflow: hidden;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-items: end; gap: 12px; }
.hero-title { display: grid; justify-items: center; text-align: center; gap: 6px; padding-bottom: 8px; }
.eyebrow { margin: 0; font-size: clamp(.85rem, 2vw, 1.05rem); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr) minmax(0, 1fr); }
.hero h1 { font-size: clamp(1.7rem, 4.2vw, 2.8rem); font-weight: 900; text-wrap: balance; text-shadow: 0 2px 14px rgba(60, 10, 30, .45); }
.countdown { margin: 4px 0 0; display: grid; justify-items: center; line-height: 1; }
.countdown b {
    font-size: clamp(5.5rem, 17vw, 10rem); font-weight: 900; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
    text-shadow: 0 5px 0 rgba(60, 10, 30, .25), 0 10px 34px rgba(60, 10, 30, .4);
}
.countdown span {
    margin-top: 6px; padding: 6px 20px; border-radius: 999px; background: rgba(255, 255, 255, .22);
    font-size: clamp(1rem, 2.6vw, 1.5rem); font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}
.fig {
    width: 100%; max-height: 300px; object-fit: contain; align-self: end;
    background: radial-gradient(ellipse at 50% 62%, rgba(255, 255, 255, .3), transparent 68%);
    filter: drop-shadow(0 6px 10px rgba(60, 10, 30, .28));
}
.fig-runner { object-position: right bottom; }   /* à gauche du titre, regarde vers la droite */
.fig-pushup { object-position: left bottom; transform: scale(1.25); transform-origin: left bottom; }    /* à droite du titre, regarde vers la gauche */
@media (max-width: 700px) {
    .hero-grid { grid-template-columns: 1fr 1fr; grid-template-areas: "title title" "runner pushup"; }
    .fig-runner { grid-area: runner; max-height: 150px; }
    .fig-pushup { grid-area: pushup; max-height: 150px; transform: none; }
    .hero-title { grid-area: title; padding-bottom: 0; }
    .hero-grid { row-gap: 0; }
}

/* ---------- Layout ---------- */
main { display: grid; gap: 16px; position: relative; }

.top { display: grid; gap: 16px; }
@media (min-width: 1000px) { .top { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.note { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }
.foot { text-align: center; color: var(--muted); font-size: .9rem; margin: 8px 0; }

/* ---------- Buttons ---------- */
.btn {
    font: inherit; font-weight: 600;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    border-radius: 999px; padding: 10px 18px; min-height: 44px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .65; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 14px; min-height: 40px; font-size: .92rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.fab {
    position: fixed; right: 16px; bottom: 16px; z-index: 20;
    box-shadow: 0 6px 20px rgba(184, 70, 111, .45); padding: 14px 22px; font-size: 1.05rem;
}

/* ---------- Avatar ---------- */
.av {
    --c: var(--accent);
    display: inline-grid; place-items: center; flex: none;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--c); color: #fff; font-weight: 700; font-size: 1.1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.av.lg { width: 52px; height: 52px; font-size: 1.4rem; }

/* ---------- Chart ---------- */
.chart-box { position: relative; height: 420px; }
@media (max-width: 600px) { .chart-box { height: 300px; } }

/* ---------- Podium ---------- */
.podium { display: flex; gap: 8px; align-items: flex-end; margin: 8px auto 0; }
.step { flex: 1 1 0; display: grid; justify-items: center; gap: 4px; text-align: center; min-width: 0; }
.step.s1 { flex-grow: 1.5; }
.who { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 6px; }
.pp { display: grid; justify-items: center; gap: 2px; width: 88px; }
.pp .nm { font-weight: 700; font-size: .8rem; max-width: 100%; overflow-wrap: anywhere; line-height: 1.15; }
.step .val { color: var(--muted); font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.step .block {
    width: 100%; margin-top: 6px; border-radius: 12px 12px 0 0; display: grid; place-items: start center;
    padding-top: 8px; font-size: 1.8rem;
}
.s1 .block { height: 120px; background: linear-gradient(#f5d565, #d9a92f); }
.s2 .block { height: 88px; background: linear-gradient(#e4e7ec, #aab1bb); }
.s3 .block { height: 64px; background: linear-gradient(#e9b98a, #b9763b); }

/* ---------- Person cards ---------- */
/* 4 cartes par ligne au maximum (3 gouttières de 16px), les autres passent dessous */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(260px, calc((100% - 48px) / 4)), 1fr)); gap: 16px; }
.person {
    --c: var(--accent);
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 18px; border-top: 5px solid var(--c); display: grid; gap: 10px; align-content: start;
}
.p-head { display: flex; align-items: center; gap: 12px; }
.p-id { display: grid; justify-items: start; gap: 4px; min-width: 0; }
.p-head h3 { font-size: 1.1rem; overflow-wrap: anywhere; }
.pill { font-size: .8rem; font-weight: 700; line-height: 1.25; padding: 5px 11px; border-radius: 14px; }
.pill.ahead, .pill.done { background: var(--good-soft); color: var(--good); }
.pill.ontrack { background: var(--info-soft); color: var(--info); }
.pill.behind, .pill.nostart { background: var(--warn-soft); color: var(--warn); }

.p-weight { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.p-weight b { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.p-weight small { color: var(--muted); }

.bar { position: relative; height: 12px; background: var(--bg); border-radius: 999px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--c); border-radius: 999px; transition: width .6s ease; }
.bar-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.effort { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 9px 12px; border-radius: 12px; font-size: .92rem; }
.effort b { font-size: 1rem; }
.effort.easy { background: var(--good-soft); color: var(--good); }
.effort.medium { background: var(--warn-soft); color: var(--warn); }
.effort.hard { background: var(--bad-soft); color: var(--bad); }

.p-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.p-actions .btn { flex: 1 1 auto; }

/* ---------- Dialogs ---------- */
dialog {
    border: 0; border-radius: 20px; padding: 22px; background: var(--card); color: var(--ink);
    width: min(500px, 100% - 24px); max-height: 92vh; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(20, 10, 25, .55); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 14px; }
dialog h3 { font-size: 1.3rem; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
input[type="text"] {
    font: inherit; font-weight: 400; width: 100%; min-height: 46px; padding: 8px 12px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
}
#wWeight { font-size: 1.4rem; font-weight: 700; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.hint { color: var(--muted); font-size: .9rem; margin: 0; min-height: 1.3em; }
.error { color: #b3261e; font-weight: 600; margin: 0; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } }

.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; padding: 0; }
.chips label { position: relative; display: block; }
.chips input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.chips input + span {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; min-height: 44px;
    border: 2px solid var(--line); border-radius: 999px; font-weight: 600;
}
.chips .av { width: 30px; height: 30px; font-size: .9rem; }
.chips input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.chips input:disabled { cursor: default; }
.chips input:disabled + span { opacity: .45; }
.chips input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Toast / confetti ---------- */
.toast {
    position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); z-index: 60;
    background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600;
    opacity: 0; pointer-events: none; transition: .3s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

@media (prefers-reduced-motion: reduce) {
    .bar > i, .toast { transition: none; }
}
