/* Palette inspirée du Bonzini B90 : rouge franc, bleu soutenu, vert billard, liseré chrome. */
:root {
  --bg: #F7F5EF;
  --card: #FFFFFF;
  --ink: #16181A;
  --ink-2: #57534A;
  --muted: #8A8578;
  --faint: #A9A296;
  --line: #E7E2D2;
  --line-2: #EFEBDD;
  --chip: #EAE6D9;
  --red: #D42027;
  --red-ink: #8A1418;
  --red-soft: #FBE4E5;
  --red-line: #F0BBBD;
  --blue: #0057A0;
  --blue-ink: #003F73;
  --blue-soft: #E1EBF5;
  --blue-line: #B9D0E6;
  --felt: #1E7A4C;
  --gold: #B8902F;
  --silver: #8F897C;
  --bronze: #A86B35;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 24, 26, 0.04);
  --nav-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--red); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: calc(env(safe-area-inset-top) + 16px) 20px 24px; }
.page--nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.page--flush { padding-left: 0; padding-right: 0; }
.page--flush > .pad { padding: 0 20px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------------------------------------ en-têtes */
.topbar { display: flex; align-items: center; gap: 12px; min-height: 36px; }
.topbar h1 { font-size: 20px; font-weight: 800; flex: 1; }
.icon-btn {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  border: 1.5px solid #D8D2C4; background: transparent; color: #6B6555;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 16px; height: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 15px; font-weight: 800; }
.section-head a, .link { font-size: 13px; font-weight: 700; color: var(--red); background: none; border: none; padding: 0; }
.eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* ------------------------------------------------------------ boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 14px 16px; border-radius: var(--radius);
  border: none; font-size: 16px; font-weight: 700; text-align: center;
}
.btn svg { width: 17px; height: 17px; }
.btn--red { background: var(--red); color: #fff; box-shadow: 0 6px 14px rgba(212, 32, 39, 0.26); }
.btn--blue { background: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(0, 87, 160, 0.26); }
.btn--dark { background: var(--ink); color: #fff; }
.btn--ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn--small { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 12px; }
.btn--pill { width: auto; min-height: 38px; padding: 8px 14px; border-radius: 100px; font-size: 13px; }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.btn--danger { background: var(--card); color: var(--red); border: 1.5px solid var(--red-line); }
.btn--danger.is-armed { background: var(--red); color: #fff; }
.text-btn { background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 16px; min-height: 44px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-width: 44px; min-height: 36px; padding: 6px 12px; border-radius: 10px; border: none;
  background: var(--chip); color: var(--ink-2); font-size: 13px; font-weight: 700;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }

.segmented { display: flex; gap: 6px; }
.segmented > * {
  flex: 1; text-align: center; padding: 9px 0; min-height: 38px; border-radius: 10px; border: none;
  background: var(--chip); color: var(--ink-2); font-size: 12.5px; font-weight: 700;
}
.segmented > [aria-current="true"], .segmented > [aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ------------------------------------------------------------ cartes & listes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card--pad { padding: 14px 16px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line-2); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; width: 100%; background: none; border-left: none; border-right: none; border-bottom: none; text-align: left; }
.list > .list-row:first-child { border-top: none; }
button.list-row:active { background: #FBF8F0; }
.list-row .rank { width: 20px; font-size: 14px; font-weight: 800; color: var(--faint); flex-shrink: 0; }
.rank--1 { color: var(--gold) !important; }
.rank--2 { color: var(--silver) !important; }
.rank--3 { color: var(--bronze) !important; }
.list-row .name { font-size: 14.5px; font-weight: 700; }
.list-row .sub { font-size: 11.5px; color: var(--muted); }
.list-row .value { font-size: 14.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.list-row.is-me { background: #FBF8F0; }
.empty { padding: 20px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; background: var(--red-soft); color: #A61A20;
}
.avatar--blue { background: var(--blue-soft); color: var(--blue); }
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }
.avatar--lg { width: 56px; height: 56px; font-size: 19px; }

.delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.delta--up { color: var(--felt); }
.delta--down { color: var(--red); }
.trophy { width: 15px; height: 15px; color: var(--gold); vertical-align: -2px; }

/* ------------------------------------------------------------ accueil */
.site-card { display: flex; align-items: center; gap: 10px; padding: 11px 14px; width: 100%; text-align: left; }
.site-card svg { width: 16px; height: 16px; flex-shrink: 0; }
.site-card .title { font-size: 13.5px; font-weight: 700; }
.site-card .sub { font-size: 11px; color: var(--muted); }
.hero { margin: 0 -20px; aspect-ratio: 390 / 215; max-height: 280px; overflow: hidden; background: #07281A; border-top: 2px solid #C9CDD0; }
.hero img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 55%; }
.cta-card { margin: -42px -20px 0; position: relative; background: var(--card); border-radius: 26px 26px 0 0; padding: 22px 24px 20px; box-shadow: 0 -6px 16px rgba(22, 24, 26, 0.06); display: flex; flex-direction: column; gap: 10px; }
.cta-card h1 { font-size: 22px; font-weight: 800; }
.me-card { display: flex; align-items: center; gap: 12px; }
.me-card .big { font-size: 20px; font-weight: 800; }
.feed-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13px; }
.feed-item .score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-item .red { color: #A61A20; }
.feed-item .blue { color: var(--blue); }
.feed-item .when { font-size: 11px; color: var(--faint); white-space: nowrap; }

/* ------------------------------------------------------------ navigation */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { display: flex; width: 100%; max-width: 480px; }
.nav a { flex: 1; min-height: var(--nav-h); padding: 10px 0 8px; text-align: center; color: #ADA89A; font-size: 11px; font-weight: 700; }
.nav a svg { display: block; width: 22px; height: 22px; margin: 0 auto 3px; }
.nav a[aria-current="page"] { color: var(--red); }

/* ------------------------------------------------------------ composition des équipes */
.team { border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.team--red { background: var(--red-soft); border: 1px solid var(--red-line); }
.team--blue { background: var(--blue-soft); border: 1px solid var(--blue-line); }
.team-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.team--red .team-title { color: var(--red-ink); }
.team--blue .team-title { color: var(--blue-ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot--red { background: var(--red); }
.dot--blue { background: var(--blue); }
.slot-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.team--red .slot-label { color: #A15458; }
.team--blue .slot-label { color: #4E7CA6; }
.slot { display: flex; flex-direction: column; gap: 6px; position: relative; }
.picker-input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px; font-size: 16px;
  background: var(--card); border: 1px solid #E4B9B0; outline: none;
}
.team--blue .picker-input { border-color: #B7CFE4; }
.picker-input:focus { border: 1.5px solid var(--red); }
.team--blue .picker-input:focus { border-color: var(--blue); }
.picker-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 8px 20px rgba(22, 24, 26, 0.08); }
.picker-list[hidden] { display: none; }
.picker-list li + li { border-top: 1px solid var(--line-2); }
.picker-list button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px; border: none; background: none; text-align: left; font-size: 14px; font-weight: 600; }
.picker-list button[aria-selected="true"] { background: #FBF8F0; }
.picker-list .meta { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 500; }
.picker-list .create { color: var(--red); }
.picked { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--red); }
.team--blue .picked { border-color: var(--blue); }
.picked .name { flex: 1; font-size: 15px; font-weight: 700; }
.picked .clear { width: 36px; height: 36px; border: none; background: none; color: var(--faint); border-radius: 8px; }
.sticky-foot { position: sticky; bottom: 0; padding: 12px 0 calc(env(safe-area-inset-bottom) + 8px); background: linear-gradient(to top, var(--bg) 70%, rgba(247, 245, 239, 0)); display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------ partie en cours */
.match-head { text-align: center; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.versus { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.versus .side { width: 44%; display: flex; flex-direction: column; gap: 2px; }
.versus .side--blue { align-items: flex-end; text-align: right; }
.versus .team-tag { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.versus .side--red .team-tag { color: #A61A20; }
.versus .side--blue .team-tag { color: var(--blue); }
.versus .pl { font-size: 16px; font-weight: 800; margin-top: 4px; }
.versus .pos { font-size: 12px; color: var(--muted); }
.versus .vs { font-size: 14px; font-weight: 800; color: #C8C2B2; padding-top: 34px; }
.points { display: flex; justify-content: center; }
.points-inner { display: flex; align-items: center; gap: 5px; padding: 7px 16px; min-height: 22px; background: var(--chip); border-radius: 100px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.points-inner .dot { width: 8px; height: 8px; }
.scoreboard { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 180px; }
.scoreboard-inner { display: flex; align-items: center; gap: 28px; padding: 28px 32px; background: var(--card); border-radius: 28px; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(22, 24, 26, 0.06); position: relative; }
.scoreboard-inner::before { content: ""; position: absolute; inset: 6px; border-radius: 22px; border: 1px solid #DADDE0; pointer-events: none; }
.big-score { font-size: 84px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1ch; text-align: center; }
.big-score--red { color: var(--red); }
.big-score--blue { color: var(--blue); }
.score-sep { font-size: 34px; font-weight: 300; color: #D8D2C4; }
.goal-buttons { display: flex; gap: 12px; }
.goal-buttons .btn { min-height: 76px; font-size: 18px; border-radius: 20px; }
.goal-buttons .btn:active { transform: scale(0.98); }

/* ------------------------------------------------------------ récapitulatif */
.recap-title { text-align: center; }
.recap-title h1 { font-size: 22px; font-weight: 800; }
.score-edit { display: flex; align-items: center; justify-content: center; gap: 20px; }
.score-edit .side { display: flex; align-items: center; gap: 8px; }
.score-edit .n { font-size: 40px; font-weight: 800; width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.step { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; font-weight: 700; }
.step--red { border: 1px solid var(--red-line); background: var(--red-soft); color: var(--red-ink); }
.step--blue { border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--blue-ink); }
.player-line { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.player-line .name { font-size: 14px; font-weight: 700; }
.player-line .sub { font-size: 12px; color: var(--muted); }
.congrats { padding: 14px 16px; border-radius: var(--radius); background: #E4F3EA; color: #14583A; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.congrats svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: var(--felt); color: #E4F3EA; border-radius: 100px; font-size: 11.5px; font-weight: 700; }

/* ------------------------------------------------------------ saisie rapide */
.round { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.round .num { width: 20px; font-size: 12px; font-weight: 800; color: var(--faint); }
.round .side { flex: 1; display: flex; align-items: center; justify-content: space-between; border-radius: 10px; padding: 2px; }
.round .side--red { background: var(--red-soft); color: #A61A20; }
.round .side--blue { background: var(--blue-soft); color: var(--blue-ink); }
.round .side button { width: 38px; height: 40px; border: none; background: none; font-size: 18px; color: inherit; border-radius: 8px; }
.round .side .n { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.round .sep { color: #C8C2B2; font-weight: 700; font-size: 12px; }
.round .remove { width: 36px; height: 40px; border: none; background: none; color: #B9B4A6; }
.round.is-invalid { border-color: var(--red); }
.add-round { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1.5px dashed #D8D2C4; border-radius: 14px; background: transparent; color: var(--ink-2); font-size: 13.5px; font-weight: 700; }
.lineup-summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.lineup-summary .side { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.lineup-summary .side--blue { justify-content: flex-end; text-align: right; }
.lineup-summary .vs { font-size: 12px; font-weight: 800; color: #C8C2B2; }

/* ------------------------------------------------------------ stats */
.tiles { display: flex; gap: 10px; }
.tile { flex: 1; padding: 12px 14px; }
.tile .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 11px; color: var(--muted); font-weight: 600; }
.level-bar { height: 8px; border-radius: 8px; background: var(--chip); overflow: hidden; }
.level-bar > span { display: block; height: 100%; background: var(--felt); border-radius: 8px; }
.spark { width: 100%; height: 70px; display: block; }
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-2); border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.badge svg { width: 26px; height: 26px; }
.badge.is-locked { color: var(--faint); background: transparent; border-style: dashed; }
.badge .prog { font-weight: 500; color: var(--faint); }
.match-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13px; }
.match-row .names { flex: 1; min-width: 0; }
.match-row .names div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-row .names .win { font-weight: 800; }
.match-row .score { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; min-width: 56px; }
.match-row .meta { font-size: 11px; color: var(--faint); text-align: right; min-width: 64px; }

/* ------------------------------------------------------------ formulaires */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.input, .select {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: 12px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); outline: none;
}
.input:focus, .select:focus { border-color: var(--ink); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; min-height: 56px; }
.toggle { appearance: none; width: 46px; height: 28px; border-radius: 28px; background: #D8D2C4; position: relative; transition: background 0.2s; flex-shrink: 0; margin: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.toggle:checked { background: var(--felt); }
.toggle:checked::after { transform: translateX(18px); }
.admin-inline { display: flex; gap: 6px; align-items: center; }
.admin-inline .input { min-height: 40px; padding: 6px 8px; width: 56px; text-align: center; }

/* ------------------------------------------------------------ règles */
.prose { font-size: 14.5px; line-height: 1.6; color: #2B2D2F; }
.prose h2 { font-size: 17px; font-weight: 800; margin: 8px 0 6px; color: var(--ink); }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin-bottom: 4px; }

/* ------------------------------------------------------------ toasts & célébration */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 50;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); animation: toast-in 0.2s ease-out;
}
.toast--error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.celebrate {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  background: radial-gradient(circle at 50% 35%, #2E9457 0%, #0F4B2C 60%, #062316 100%); color: #fff; overflow: hidden;
  animation: fade-in 0.25s ease-out;
}
.celebrate .title { font-size: 34px; font-weight: 800; text-align: center; padding: 0 24px; animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.celebrate .score { font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; }
.celebrate .names { font-size: 16px; opacity: 0.85; }
.confetti { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

.loading { flex: 1; display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--chip); border-top-color: var(--red); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

a.list-row, a.card { color: inherit; }
