:root {
  --accent: #2447f5;
  --accent-ink: #ffffff;
  --accent-soft: #e6ebff;
  --top: #0f9f5c;
  --top-bright: #2ee07a;
  --top-soft: #dcf7e9;
  --top-bg: #0f9f5c;
  --flop: #e5392c;
  --flop-bright: #ff5a4e;
  --flop-soft: #ffe4e1;
  --flop-bg: #e5392c;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0e1530;
  --muted: #5b6480;
  --line: #e3e7f0;
  --shadow: 0 1px 2px rgba(14, 21, 48, .06), 0 6px 20px rgba(14, 21, 48, .06);
  --radius: 18px;
  --font-title: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5b78ff;
    --accent-soft: #1d2650;
    --top: #32d583;
    --top-soft: #0f3324;
    --flop: #ff6b5e;
    --flop-soft: #3d1715;
    --bg: #0b1020;
    --card: #151b2e;
    --text: #eef1fa;
    --muted: #9aa3bd;
    --line: #26304a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3, .title {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.05;
  margin: 0;
}
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Barre du haut ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: var(--accent-ink);
  padding: calc(var(--safe-top) + 6px) max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--safe-top) + 58px);
}
.bar .title { font-size: 24px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.bar .title.with-back { padding-left: 0; }
.icon-btn {
  width: 48px; height: 48px;
  display: inline-grid; place-items: center;
  border: 0; background: transparent; color: inherit;
  border-radius: 14px;
  text-decoration: none;
  flex: none;
}
.icon-btn:active { background: rgba(255, 255, 255, .16); }
.icon-btn svg { width: 24px; height: 24px; }
.bar .sport-ico { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; flex: none; margin-left: 2px; }
.bar .sport-ico svg { width: 22px; height: 22px; }

.page {
  padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Cartes & listes ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:active { transform: scale(.985); }
.section-title { font-family: var(--font-title); font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 4px 10px; }
.list { display: grid; gap: 10px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px;
  border-radius: 16px; border: 0;
  font-weight: 700; font-size: 16px;
  background: var(--accent); color: var(--accent-ink);
  text-decoration: none;
  transition: transform .08s ease, opacity .15s;
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--line); }
.btn.danger { background: var(--flop-soft); color: var(--flop); }
.btn.top { background: var(--top-bg); color: #fff; }
.btn.flop { background: var(--flop-bg); color: #fff; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 14px; width: auto; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
@media (prefers-color-scheme: dark) { .btn.secondary { color: #c9d3ff; } }

/* ---------- Formulaires ---------- */
.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: 14px; margin: 0 2px 6px; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border-radius: 14px; border: 2px solid var(--line);
  background: var(--card);
  font-size: 17px; /* ≥ 16px : pas de zoom auto sur iOS */
  outline: none;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.chip {
  min-height: 72px; border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 14px; font-weight: 600; padding: 8px 4px;
}
.chip svg { width: 26px; height: 26px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip[aria-pressed="true"] svg { color: var(--accent); }

.seg { display: flex; background: var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; min-height: 48px; border: 0; border-radius: 11px; background: transparent;
  font-weight: 700; font-size: 16px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg.big button { font-family: var(--font-title); font-size: 22px; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 48px; height: 48px; border-radius: 14px; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 24px; font-weight: 700; }
.stepper output { min-width: 56px; text-align: center; font-family: var(--font-title); font-size: 28px; font-weight: 800; }

/* ---------- Avatars ---------- */
.av {
  --size: 44px;
  width: var(--size); height: var(--size); border-radius: 50%;
  object-fit: cover; flex: none;
  display: inline-grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff;
  font-family: var(--font-title); font-weight: 700; font-size: calc(var(--size) * .42);
  letter-spacing: .02em;
}
.av-xs { --size: 28px; }
.av-sm { --size: 36px; }
.av-lg { --size: 64px; }
.av-xl { --size: 96px; }
.av-xxl { --size: 128px; }

.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-pick .ph {
  width: 72px; height: 72px; border-radius: 50%; border: 2px dashed var(--line);
  display: grid; place-items: center; overflow: hidden; background: var(--card); flex: none; padding: 0;
}
.photo-pick .ph svg { width: 28px; height: 28px; color: var(--muted); }
.photo-pick .ph img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Accueil ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--accent); color: #fff;
  padding: calc(var(--safe-top) + 28px) 20px 34px;
  border-radius: 0 0 28px 28px;
}
.hero .pattern { position: absolute; inset: 0; pointer-events: none; opacity: .12; }
.hero .pattern svg { position: absolute; width: 44px; height: 44px; color: #fff; }
.logo { font-family: var(--font-title); font-weight: 800; font-size: 52px; line-height: .9; letter-spacing: .01em; display: flex; align-items: center; gap: 10px; position: relative; }
.logo .t { color: var(--top-bright); }
.logo .f { color: var(--flop-bright); }
.logo img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.hero p { margin: 10px 0 0; opacity: .88; position: relative; font-weight: 500; }

.group-card { display: flex; align-items: center; gap: 14px; }
.sport-badge { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.sport-badge svg { width: 30px; height: 30px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.vote { background: var(--accent); color: #fff; }
.badge.top { background: var(--top-soft); color: var(--top); }
.badge.flop { background: var(--flop-soft); color: var(--flop); }
.badge.grey { background: var(--line); color: var(--muted); }
.chev { color: var(--muted); width: 20px; height: 20px; flex: none; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .icons { display: flex; justify-content: center; gap: 14px; margin-bottom: 14px; color: var(--accent); opacity: .6; }
.empty .icons svg { width: 30px; height: 30px; }

/* ---------- Groupe ---------- */
.tabs { display: flex; gap: 4px; background: var(--card); box-shadow: var(--shadow); border-radius: 16px; padding: 4px; margin-bottom: 16px; }
.tabs a {
  flex: 1; min-height: 48px; display: grid; place-items: center; border-radius: 12px;
  text-decoration: none; color: var(--muted); font-family: var(--font-title); font-size: 20px; font-weight: 700;
}
.tabs a[aria-current="page"] { background: var(--accent); color: #fff; }
.banner { border-radius: 14px; padding: 12px 14px; background: var(--accent-soft); color: var(--text); font-size: 14px; font-weight: 500; }
.banner.warn { background: #fff4d6; color: #6b4e00; }
@media (prefers-color-scheme: dark) { .banner.warn { background: #3a2f10; color: #ffd978; } }

.match-card .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.match-card .res { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.match-card.todo { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

.countdown { font-family: var(--font-title); font-weight: 800; font-variant-numeric: tabular-nums; }
.countdown.title { display: block; font-size: 30px; line-height: 1; }
.clock { display: inline-flex; align-items: center; gap: 4px; }
.clock svg { width: 14px; height: 14px; }

/* ---------- Sélection des participants ---------- */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.ptile {
  position: relative; border: 2px solid transparent; background: var(--card); box-shadow: var(--shadow);
  border-radius: 18px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; min-height: 116px; text-align: center; line-height: 1.15;
  transition: transform .1s ease, border-color .15s, background .15s;
}
.ptile:active { transform: scale(.96); }
.ptile .name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.ptile .check {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--line); display: grid; place-items: center; color: #fff;
}
.ptile .check svg { width: 16px; height: 16px; opacity: 0; }
.ptile[aria-pressed="true"] { border-color: var(--accent); }
.ptile[aria-pressed="true"] .check { background: var(--accent); }
.ptile[aria-pressed="true"] .check svg { opacity: 1; }
.ptile.off { opacity: .45; }
.ptile.off .av { filter: grayscale(1); }

/* ---------- Vote ---------- */
.vote-head { border-radius: 20px; padding: 16px; color: #fff; display: flex; align-items: center; gap: 12px; }
.vote-head.top { background: var(--top-bg); }
.vote-head.flop { background: var(--flop-bg); }
.vote-head .step { font-family: var(--font-title); font-size: 15px; font-weight: 700; opacity: .85; letter-spacing: .06em; text-transform: uppercase; }
.vote-head h2 { font-size: 30px; }
.vote-head svg { width: 40px; height: 40px; flex: none; }
.vote-grid .ptile { min-height: 124px; }
.vote-grid .ptile[data-pick="top"] { border-color: var(--top); background: var(--top-soft); }
.vote-grid .ptile[data-pick="flop"] { border-color: var(--flop); background: var(--flop-soft); }
.vote-grid .ptile:disabled { opacity: .35; }
.vote-grid .ptile .tag { position: absolute; top: 6px; left: 6px; }
.pick-card { display: flex; align-items: center; gap: 14px; border-radius: 20px; padding: 14px; }
.pick-card.top { background: var(--top-soft); }
.pick-card.flop { background: var(--flop-soft); }
.pick-card .lbl { font-family: var(--font-title); font-weight: 800; font-size: 18px; letter-spacing: .06em; }
.pick-card.top .lbl { color: var(--top); }
.pick-card.flop .lbl { color: var(--flop); }
.pick-card .nm { font-family: var(--font-title); font-weight: 700; font-size: 28px; line-height: 1; }

.status-hero { text-align: center; padding: 24px 16px; }
.status-hero .big { font-size: 56px; line-height: 1; margin-top: 4px; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }

/* ---------- Tableau de bord ---------- */
.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tally .col h3 { font-size: 18px; margin-bottom: 8px; }
.tally .top h3 { color: var(--top); }
.tally .flop h3 { color: var(--flop); }
.tally-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 6px; }
.tally-row .n { font-family: var(--font-title); font-size: 20px; font-weight: 800; min-width: 18px; text-align: right; }
.bar-mini { height: 6px; border-radius: 9px; margin-top: 3px; }
.top .bar-mini { background: var(--top); }
.flop .bar-mini { background: var(--flop); }
.vote-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.vote-line:first-child { border-top: 0; }
.vote-line .picks { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; font-size: 13px; }

/* ---------- Résultats ---------- */
.reveal { text-align: center; }
.reveal .slot { border-radius: 24px; padding: 22px 16px; margin-top: 14px; position: relative; overflow: hidden; }
.reveal .slot.top { background: var(--top-soft); }
.reveal .slot.flop { background: var(--flop-soft); }
.reveal .kicker { font-family: var(--font-title); font-weight: 800; font-size: 20px; letter-spacing: .1em; }
.reveal .top .kicker { color: var(--top); }
.reveal .flop .kicker { color: var(--flop); }
.reveal .who { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 12px; }
.reveal .who > div { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.reveal .nm { font-family: var(--font-title); font-weight: 800; font-size: 34px; line-height: 1; }
.reveal .top .av { box-shadow: 0 0 0 4px var(--top); }
.reveal .flop .av { box-shadow: 0 0 0 4px var(--flop); }
.reveal .suspense { font-family: var(--font-title); font-size: 26px; font-weight: 700; color: var(--muted); padding: 40px 0; }

@media (prefers-reduced-motion: no-preference) {
  .anim-pop { animation: pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
  .anim-drop { animation: drop .6s cubic-bezier(.3, 1.3, .5, 1) both; }
  .anim-pulse { animation: pulse 1s ease-in-out infinite; }
  .confetti i { position: absolute; top: -10px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
  @keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
  @keyframes drop { 0% { transform: translateY(-40px) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
  @keyframes pulse { 50% { opacity: .45; } }
  @keyframes fall { to { transform: translateY(260px) rotate(540deg); opacity: 0; } }
}

/* ---------- Classement ---------- */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 8px; margin: 8px 0 18px; }
.podium .spot { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.podium .nm { font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .block {
  width: 100%; border-radius: 14px 14px 6px 6px; display: grid; place-items: center;
  font-family: var(--font-title); font-weight: 800; color: #fff; font-size: 30px; line-height: 1; padding-top: 8px;
}
.podium .block small { display: block; font-size: 14px; font-weight: 700; opacity: .9; }
.podium .p1 .block { height: 118px; background: linear-gradient(#f7c948, #e0a800); }
.podium .p2 .block { height: 90px; background: linear-gradient(#b8c2d6, #8e9ab3); }
.podium .p3 .block { height: 70px; background: linear-gradient(#e0a47a, #c07847); }
.podium .p1 .av { box-shadow: 0 0 0 3px #f7c948; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rank-row:first-child { border-top: 0; }
.rank-row .r { font-family: var(--font-title); font-weight: 800; font-size: 22px; width: 28px; text-align: center; color: var(--muted); }
.rank-row .pts { font-family: var(--font-title); font-weight: 800; font-size: 26px; min-width: 44px; text-align: right; }
.rank-row .tf { display: flex; gap: 8px; font-size: 13px; font-weight: 600; margin-top: 2px; }
.rank-row .tf .t { color: var(--top); }
.rank-row .tf .f { color: var(--flop); }
.rank-row.me { background: var(--accent-soft); border-radius: 14px; margin: 0 -8px; padding: 10px 8px; border-top-color: transparent; }

/* ---------- Réglages ---------- */
.member-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.member-row:first-child { border-top: 0; }
.link-box { font-size: 14px; word-break: break-all; background: var(--bg); border-radius: 12px; padding: 10px 12px; color: var(--muted); }

/* ---------- Crédit (dans le flux, sous le contenu : ne masque jamais un bouton) ---------- */
.credit {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 16px calc(16px + var(--safe-bottom));
}
.credit a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.credit a:hover { color: var(--accent); }

/* ---------- Toast & feuille modale ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translate(-50%, 30px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 28, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 520px; border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(16px + var(--safe-bottom));
}
@media (min-width: 560px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 24px; } }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: up .22s ease-out; } @keyframes up { from { transform: translateY(40px); opacity: 0; } } }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); margin: 48px auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
