/* ==========================================================================
   Compteur Flip 7 — univers pastel « autocollant »
   Mobile-first · aplats pastel, contours encre, ombres franches.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #fff6ec;
  --surface: #ffffff;
  --surface-2: #fbf4ff;
  --ink: #2a2340;
  --ink-soft: #5e5677;
  --outline: #2a2340;
  --line: #e6dcef;
  --on-pastel: #2a2340;

  --peach: #ffb3a1;
  --mint: #a8e8cf;
  --lavender: #d9caff;
  --butter: #ffe08a;
  --sky: #b5dcff;
  --pink: #ffc2dd;

  --primary: #ff9f87;
  --primary-press: #ff8a6e;
  --danger: #b4232f;
  --danger-soft: #ffd9dc;
  --focus: #5b3fff;
  --pop: 0 3px 0 var(--outline);
  --pop-sm: 0 2px 0 var(--outline);
  --radius: 20px;
  --radius-sm: 14px;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --speed: 140ms;

  --blob-1: #c6f1df;
  --blob-2: #e5d9ff;
  --blob-3: #ffd8c9;
  --blob-4: #fff0b8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1930;
    --surface: #282340;
    --surface-2: #2f2a4a;
    --ink: #f7f3ff;
    --ink-soft: #c4bbdc;
    --outline: #0d0a19;
    --line: #3b3558;
    --danger: #ff8f97;
    --danger-soft: #4a2230;
    --focus: #b8a8ff;
    --blob-1: #1f3b3a;
    --blob-2: #2f2757;
    --blob-3: #43293a;
    --blob-4: #3a3424;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root { --speed: 0ms; }
  *, *::before, *::after { animation-duration: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important; }
  .confetti { display: none; }
}

/* --- Base ---------------------------------------------------------------- */

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

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(34rem 26rem at -8% -6%, var(--blob-1), transparent 62%),
    radial-gradient(30rem 24rem at 108% 8%, var(--blob-2), transparent 62%),
    radial-gradient(34rem 26rem at 105% 75%, var(--blob-4), transparent 60%),
    radial-gradient(36rem 28rem at -10% 100%, var(--blob-3), transparent 62%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 700 0.85em var(--font-body); padding: 1px 6px; border-radius: 6px; border: 1.5px solid var(--outline); background: var(--surface); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1:focus, h1:focus-visible { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.icon { width: 22px; height: 22px; flex: none; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(130px + env(safe-area-inset-bottom));
}

.screen { display: flex; flex-direction: column; gap: 16px; animation: screen-in 200ms ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack--tight { gap: 10px; }

/* --- Boutons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px;
  border: 2px solid var(--outline); border-radius: 16px;
  background: var(--surface); color: var(--ink);
  font: 800 1rem/1.1 var(--font-display); text-decoration: none; text-align: center;
  box-shadow: var(--pop);
  transition: transform var(--speed) ease, box-shadow var(--speed), background-color var(--speed);
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn--primary { background: var(--primary); color: var(--on-pastel); }
.btn--primary:active:not(:disabled) { background: var(--primary-press); }
.btn--secondary { background: var(--mint); color: var(--on-pastel); }
.btn--ghost { background: var(--surface); }
.btn--danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--danger { color: #2a0b10; } }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: currentColor; box-shadow: none; }
.btn--xl { min-height: 62px; font-size: 1.15rem; border-radius: 20px; width: 100%; }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 0.92rem; box-shadow: var(--pop-sm); }
.btn--square { width: 54px; padding: 0; flex: none; }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink);
  text-decoration: none; transition: background-color var(--speed);
}
.iconbtn:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.iconbtn:disabled { opacity: 0.25; cursor: not-allowed; }
.iconbtn--danger { color: var(--danger); }

.link-quiet {
  align-self: center; padding: 10px; min-height: 44px; border: 0; background: none;
  color: var(--ink-soft); font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.link-quiet--small { font-size: 0.85rem; padding: 4px 8px; min-height: 36px; }

/* --- Barre du haut ------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  margin: 0 -16px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  margin-top: calc(-1 * env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar__title { flex: 1; text-align: center; font-size: 1.3rem; font-weight: 900; }
.topbar__center { flex: 1; text-align: center; }
.topbar__center .topbar__title { flex: none; }
.topbar__sub { color: var(--ink-soft); font-size: 0.85rem; font-weight: 700; }
.topbar__spacer { width: 44px; flex: none; }

/* --- Panneaux, bannières, textes ---------------------------------------- */

.panel {
  background: var(--surface);
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--pop);
  display: flex; flex-direction: column; gap: 12px;
}
.panel__head { display: flex; align-items: center; gap: 8px; }
.panel__title { font-size: 1.15rem; font-weight: 900; }
.section-title {
  font: 900 0.8rem var(--font-body); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft); margin: 2px 2px 8px;
}
.eyebrow { font-size: 0.78rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.hint { color: var(--ink-soft); font-size: 0.9rem; }
.hint--center { text-align: center; font-size: 0.82rem; }
.hint--box { padding: 10px 12px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1.5px dashed var(--line); }
.badge {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px;
  display: inline-grid; place-items: center;
  background: var(--lavender); color: var(--on-pastel); border: 2px solid var(--outline);
  font: 900 0.85rem var(--font-display);
}
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--sky); color: var(--on-pastel); font-size: 0.92rem;
  border: 2px solid var(--outline); box-shadow: var(--pop-sm);
}
.banner--tie { background: var(--butter); }
.banner--win { background: var(--mint); }
.banner .icon { flex: none; }
.notice--warn {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.9rem;
  background: #fff1c2; color: #3b2f00; border: 2px dashed #b88a00;
}
.fineprint { text-align: center; color: var(--ink-soft); font-size: 0.8rem; margin-top: 8px; }
.tag-provisoire {
  display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 99px;
  background: #fff1c2; color: #5c4600; border: 1.5px dashed #b88a00;
  font-size: 0.75rem; font-weight: 800; white-space: nowrap;
}
.pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink-soft);
  font-size: 0.8rem; font-weight: 800;
}
.pill--bust { background: var(--danger); border-color: var(--outline); color: #fff; }
.pill--flip7 { background: var(--butter); border-color: var(--outline); color: var(--on-pastel); }

/* --- Champs -------------------------------------------------------------- */

.input {
  width: 100%; min-height: 54px; padding: 0 14px;
  border: 2px solid var(--outline); border-radius: 16px;
  background: var(--surface); font-size: 1.05rem; color: var(--ink);
  transition: box-shadow var(--speed);
}
.input:focus { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 35%, transparent); }
.input::placeholder { color: color-mix(in srgb, var(--ink-soft) 85%, transparent); }
.input--short { width: 120px; text-align: center; font-weight: 800; }
.input--score { font: 900 1.6rem var(--font-display); text-align: center; }
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }

/* --- Accueil ------------------------------------------------------------- */

.screen--home { padding-top: 12px; gap: 20px; }
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero__fan { display: flex; justify-content: center; height: 140px; margin-bottom: 8px; }
.hero__fan .card { width: 86px; flex: none; }
.hero__fan .card:nth-child(1) { transform: rotate(-14deg) translate(20px, 12px); }
.hero__fan .card:nth-child(2) { transform: translateY(-6px); z-index: 1; }
.hero__fan .card:nth-child(3) { transform: rotate(14deg) translate(-20px, 12px); }
.hero__title { font-size: clamp(2rem, 9vw, 2.6rem); font-weight: 900; letter-spacing: -0.01em; }
.hero__accent {
  display: inline-block; padding: 0 12px; border-radius: 14px;
  background: var(--pink); color: var(--on-pastel);
  border: 2.5px solid var(--outline); box-shadow: var(--pop);
  transform: rotate(-3deg);
}
.hero__lead { color: var(--ink-soft); max-width: 30ch; font-size: 1.05rem; }

.home-actions { display: flex; flex-direction: column; gap: 12px; }
.home-actions .btn--ghost { width: 100%; }

.resume {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--mint); color: var(--on-pastel);
  border: 2px solid var(--outline); border-radius: var(--radius);
  padding: 14px 14px 14px 16px; box-shadow: var(--pop);
}
.resume > div { min-width: 0; }
.resume__title { font-size: 1.1rem; font-weight: 900; }
.resume__meta { font-size: 0.88rem; font-weight: 700; }
.resume__names { font-size: 0.85rem; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume .btn { flex: none; }

.lastgame {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 2px dashed var(--line);
  color: var(--ink); text-decoration: none; font-size: 0.92rem;
}
.lastgame__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--butter); color: var(--on-pastel); border: 2px solid var(--outline); flex: none; }
.lastgame__icon .icon { width: 20px; height: 20px; }

/* --- Commutateur de langue -------------------------------------------- */

.home-top { display: flex; justify-content: flex-end; margin-bottom: -8px; }
.lang-switch {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 99px;
  background: var(--surface); border: 2px solid var(--outline); box-shadow: var(--pop-sm);
}
.lang-switch__btn {
  min-width: 44px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 99px;
  background: transparent; color: var(--ink-soft); font: 900 0.85rem var(--font-display); letter-spacing: 0.04em;
}
.lang-switch__btn[aria-pressed="true"] { background: var(--lavender); color: var(--on-pastel); }

/* --- Avatars ------------------------------------------------------------- */

.avatar {
  --pc: #ddd;
  display: inline-grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--pc); color: var(--on-pastel);
  border: 2px solid var(--outline); box-shadow: var(--pop-sm);
  font: 900 1.1rem var(--font-display);
  transform: rotate(-4deg);
}
.avatar--sm { width: 28px; height: 28px; font-size: 0.82rem; border-radius: 9px; box-shadow: none; border-width: 1.5px; }

/* --- Préparation --------------------------------------------------------- */

.add-player { display: flex; gap: 8px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px 6px 8px; border-radius: 16px;
  background: var(--surface-2); border: 1.5px solid var(--line);
}
.player-row.is-new { animation: row-in 180ms ease-out; }
@keyframes row-in { from { opacity: 0; transform: translateX(-6px); } }
.player-row__rank { width: 18px; text-align: center; color: var(--ink-soft); font: 900 0.85rem var(--font-display); flex: none; }
.player-row__field { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.player-row__name {
  width: 100%; min-height: 44px; padding: 0 8px; border: 2px solid transparent; border-radius: 12px;
  background: transparent; font: 800 1.05rem var(--font-display); text-overflow: ellipsis;
}
.player-row__name:hover { border-color: var(--line); }
.player-row__name:focus { outline: none; border-color: var(--outline); background: var(--surface); }
.player-row__warn { font-size: 0.75rem; color: var(--danger); font-weight: 800; padding-left: 10px; }
.player-row__tools { display: flex; flex: none; }
.player-row__tools .iconbtn { width: 40px; }
@media (max-width: 360px) {
  .player-row__rank { display: none; }
  .player-row__tools .iconbtn { width: 36px; }
}

.empty { list-style: none; text-align: center; padding: 18px 12px; border: 2px dashed var(--line); border-radius: 16px; }
.empty__title { font: 900 1.05rem var(--font-display); }
.empty__text { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; }
.empty--page { padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 16px; background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty--page .btn { margin-top: 12px; }
.empty__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--butter); color: var(--on-pastel); border: 2px solid var(--outline); box-shadow: var(--pop); }
.empty__icon .icon { width: 32px; height: 32px; }

.target { display: flex; align-items: flex-start; gap: 12px; }
.target__info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.target__value { font: 700 1.05rem var(--font-display); }
.target__value strong {
  display: inline-block; font-size: 2.2rem; font-weight: 900; letter-spacing: -0.02em;
  padding: 0 10px; margin-right: 4px; border-radius: 12px; background: var(--butter); color: var(--on-pastel);
  border: 2px solid var(--outline); transform: rotate(-2deg);
}
.target__editor { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; border-top: 2px dashed var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-width: 64px; min-height: 44px; padding: 0 14px; border-radius: 99px;
  border: 2px solid var(--outline); background: var(--surface);
  font: 900 1rem var(--font-display);
}
.chip[aria-pressed="true"] { background: var(--lavender); color: var(--on-pastel); box-shadow: var(--pop-sm); }

/* --- Barre d'action en bas ---------------------------------------------- */

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 22px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 38%);
  pointer-events: none;
}
.bottombar__inner { max-width: 528px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.bottombar__summary { text-align: center; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }

/* ==========================================================================
   CARTES (visuels provisoires dessinés en CSS)
   --c : couleur du chiffre · --t : teinte pastel du fond
   ========================================================================== */

.card {
  --c: #333; --t: #eee;
  container-type: inline-size;
  position: relative; display: block;
  width: 100%; aspect-ratio: 5 / 7;
  padding: 0; border: 0; background: none;
  border-radius: 13% / 9.5%;
  transition: transform var(--speed) ease;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
button.card:active:not([aria-disabled="true"]) { transform: scale(0.94); }

.card__face {
  position: absolute; inset: 0; overflow: hidden;
  display: grid; place-items: center;
  border-radius: inherit;
  background:
    radial-gradient(circle at 18% 12%, rgb(255 255 255 / 0.55) 0 9%, transparent 10%),
    radial-gradient(circle at 85% 90%, rgb(255 255 255 / 0.45) 0 7%, transparent 8%),
    var(--t);
  border: 2px solid var(--outline);
  box-shadow: 0 3px 0 var(--outline);
  transition: background-color var(--speed), box-shadow var(--speed), transform var(--speed);
}
.card__face::before { /* cadre intérieur pointillé */
  content: ""; position: absolute; inset: 6.5%;
  border-radius: 10% / 7%;
  border: 1.5px dashed color-mix(in srgb, var(--c) 45%, transparent);
  pointer-events: none;
}
.card__medal {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 74%; aspect-ratio: 1; border-radius: 50%;
  background: rgb(255 255 255 / 0.78);
  border: 1.5px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.card__value {
  font: 900 50cqi/1 var(--font-display);
  color: var(--c);
  letter-spacing: -0.04em;
  text-shadow: 0 2.5cqi 0 color-mix(in srgb, var(--c) 22%, transparent);
}
.card__face[data-digits="2"] .card__value { font-size: 38cqi; }
.card__corner { position: absolute; font: 900 14cqi/1 var(--font-display); color: var(--c); }
.card__corner--tl { top: 10%; left: 12%; }
.card__corner--br { bottom: 10%; right: 12%; transform: rotate(180deg); }
.card__sub {
  font: 900 9.5cqi/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--c); margin-top: 2cqi;
}
.card--bonus .card__value, .card--multiplier .card__value, .card--second-chance .card__value { font-size: 34cqi; }
.card--bonus .card__corner, .card--multiplier .card__corner, .card--second-chance .card__corner { font-size: 11cqi; }

/* Coche de sélection */
.card__check {
  position: absolute; top: -8px; right: -8px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--mint); color: var(--on-pastel);
  border: 2px solid var(--outline);
  transform: scale(0); transition: transform var(--speed) cubic-bezier(.3,1.6,.6,1);
}
.card__check svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

/* Sélectionnée : remplie de sa couleur, soulevée, coche verte */
.card[data-state="selected"] .card__face {
  background: var(--c);
  transform: translateY(-5px);
  box-shadow: 0 6px 0 var(--outline), 0 0 0 3px var(--surface), 0 0 0 5px var(--outline);
}
.card[data-state="selected"] .card__face::before { border-color: rgb(255 255 255 / 0.6); }
.card[data-state="selected"] .card__medal { background: rgb(255 255 255 / 0.18); border-color: rgb(255 255 255 / 0.5); }
.card[data-state="selected"] .card__value,
.card[data-state="selected"] .card__corner,
.card[data-state="selected"] .card__sub { color: #fff; text-shadow: 0 2.5cqi 0 rgb(0 0 0 / 0.22); }
.card[data-state="selected"] .card__check { transform: translateY(-5px) scale(1); }

/* Désactivée : grisée et aplatie (limite de 7 cartes atteinte) */
.card[data-state="disabled"] { cursor: not-allowed; }
.card[data-state="disabled"] .card__face { filter: grayscale(1); opacity: 0.35; box-shadow: none; }

/* Incompatible : hachures rouges (bust) */
.card[data-state="incompatible"] { cursor: not-allowed; }
.card[data-state="incompatible"] .card__face { box-shadow: none; border-style: dashed; border-color: var(--danger); }
.card[data-state="incompatible"] .card__face::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(-45deg, transparent 0 7px, color-mix(in srgb, var(--danger) 26%, transparent) 7px 10px);
}
.card[data-state="incompatible"] .card__medal,
.card[data-state="incompatible"] .card__corner { opacity: 0.35; }

/* Visuel autorisé (image) */
.card__face--image { background: transparent; border: 0; box-shadow: none; }
.card__face--image::before { display: none; }
.card__img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }

/* Grilles */
.card-grid { display: grid; gap: 12px 8px; padding: 8px 2px 4px; }
.card-grid--numbers { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card-grid--mods { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 6px; }
@media (min-width: 440px) { .card-grid--numbers { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.screen--gallery .card-grid--mods { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.states { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; padding-top: 10px; }
.states figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.states figcaption { font-size: 0.72rem; text-align: center; line-height: 1.2; font-weight: 800; color: var(--ink-soft); }

.minicard {
  display: inline-grid; place-items: center;
  min-width: 30px; height: 40px; padding: 0 4px; border-radius: 8px;
  background: var(--t); color: var(--c);
  border: 2px solid var(--outline); box-shadow: 0 2px 0 var(--outline);
  font: 900 0.92rem var(--font-display);
}

/* ==========================================================================
   Partie
   ========================================================================== */

.ranking {
  list-style: none; margin: 0 -16px; padding: 2px 16px 8px;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ranking::-webkit-scrollbar { display: none; }
.ranking__item {
  flex: none; scroll-snap-align: start;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 8px; border-radius: 99px;
  background: var(--surface); border: 2px solid var(--outline); box-shadow: var(--pop-sm);
  font-weight: 800;
}
.ranking__rank { font: 900 0.85rem var(--font-display); color: var(--ink-soft); min-width: 14px; text-align: center; }
.ranking__name { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking__total { font: 900 1.05rem var(--font-display); }
.ranking__item.is-leader { background: var(--butter); color: var(--on-pastel); }
.ranking__item.is-leader .ranking__rank { color: var(--on-pastel); }
.ranking__item.is-leader .ranking__rank::before { content: "★ "; }

.pcards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pcard {
  --pc: #ddd;
  position: relative;
  background: var(--surface); border: 2px solid var(--outline); border-radius: var(--radius);
  padding: 10px 10px 10px 14px; box-shadow: var(--pop);
  display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.pcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--pc); border-right: 2px solid var(--outline); }
.pcard__head { display: flex; align-items: center; gap: 10px; }
.pcard__who { flex: 1; min-width: 0; }
.pcard__name { font-size: 1.1rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard__meta { font-size: 0.82rem; color: var(--ink-soft); font-weight: 700; }
.pcard__meta strong { color: var(--ink); font-weight: 900; }
.pcard__round {
  flex: none; min-width: 66px; min-height: 46px; padding: 2px 10px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--mint); color: var(--on-pastel); border: 2px solid var(--outline);
}
.pcard__round-value { font: 900 1.5rem/1 var(--font-display); }
.pcard__round.is-empty { background: var(--surface-2); color: var(--ink-soft); border-style: dashed; border-color: var(--line); }
.pcard__round.is-bust { background: var(--danger-soft); color: var(--danger); }
.pcard__round.is-flip7 { background: var(--butter); }
.pcard__detail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.pcard__minis { display: flex; flex-wrap: wrap; gap: 4px; }
.pcard__formula { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.pcard .link-quiet { align-self: flex-end; margin: -4px 0 -4px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 6px; border-radius: 14px;
  border: 2px solid var(--outline); background: var(--surface); box-shadow: var(--pop-sm);
  font: 800 0.92rem/1.1 var(--font-display); color: var(--ink); white-space: nowrap;
  transition: transform var(--speed);
}
.segmented__btn:active { transform: translateY(2px); box-shadow: none; }
.segmented__btn .icon { width: 19px; height: 19px; }
.segmented__btn--main { background: var(--lavender); color: var(--on-pastel); }
.segmented__btn[aria-expanded="true"] { background: var(--sky); color: var(--on-pastel); }
@media (max-width: 380px) { .segmented__btn .icon { display: none; } }

.direct { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 700; color: var(--ink-soft); }
.direct__row { display: flex; gap: 8px; }
.direct__row .btn { flex: none; }

/* --- Tableau des scores -------------------------------------------------- */

.board-wrap {
  overflow-x: auto; border-radius: var(--radius);
  border: 2px solid var(--outline); background: var(--surface); box-shadow: var(--pop);
  -webkit-overflow-scrolling: touch;
}
.board { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.board th, .board td { padding: 10px 10px; text-align: center; white-space: nowrap; border-bottom: 1.5px solid var(--line); }
.board thead th { font: 900 0.78rem var(--font-body); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); background: var(--surface-2); }
.board tbody tr:last-child > * { border-bottom: 0; }
.board__sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left !important; border-right: 1.5px solid var(--line); }
.board thead .board__sticky { background: var(--surface-2); }
.board__player { display: flex; align-items: center; gap: 6px; }
.board__rank { font: 900 0.8rem var(--font-display); color: var(--ink-soft); width: 14px; text-align: center; }
.board__name { font-weight: 800; max-width: 8.5ch; overflow: hidden; text-overflow: ellipsis; }
.board__total { font: 900 1.15rem var(--font-display); }
.board__cell { font-weight: 700; }
.board__cell.is-bust { color: var(--danger); font-weight: 900; }
.board__cell.is-flip7 { background: color-mix(in srgb, var(--butter) 55%, transparent); }
.board__star { color: #b07800; margin-left: 2px; font-size: 0.8em; }
.board__left { color: var(--ink-soft); font-weight: 700; }
.board tr.is-leader > * { background: color-mix(in srgb, var(--butter) 45%, var(--surface)); }
.board tr.is-leader .board__sticky { background: color-mix(in srgb, var(--butter) 70%, var(--surface)); }
.board__round-link {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px;
  border-radius: 10px; border: 1.5px solid var(--outline); background: var(--surface);
  color: var(--ink); text-decoration: none;
}
.board__round-link .icon { width: 14px; height: 14px; }

/* --- Fin de partie ------------------------------------------------------- */

.screen--end { position: relative; padding-top: 16px; }
.victory { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 12px; }
.victory__trophy {
  display: grid; place-items: center; width: 92px; height: 92px; border-radius: 28px;
  background: var(--butter); color: var(--on-pastel); border: 2.5px solid var(--outline); box-shadow: var(--pop);
  margin-bottom: 14px; transform: rotate(-6deg); animation: bounce 900ms cubic-bezier(.3,1.6,.6,1) both;
}
.victory__trophy .icon { width: 50px; height: 50px; stroke-width: 1.8; }
@keyframes bounce { from { transform: scale(0.4) rotate(-20deg); opacity: 0; } }
.victory__title { font-size: clamp(1.9rem, 8vw, 2.4rem); font-weight: 900; margin-top: 8px; }
.victory__score { font: 700 1.1rem var(--font-display); color: var(--ink-soft); }
.victory__score strong { color: var(--ink); font-size: 1.5rem; }

.podium { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.podium__row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px;
  border-radius: 16px; background: var(--surface-2); border: 1.5px solid var(--line);
}
.podium__row.is-winner { background: var(--butter); color: var(--on-pastel); border: 2px solid var(--outline); box-shadow: var(--pop-sm); }
.podium__rank { width: 22px; text-align: center; font: 900 1rem var(--font-display); }
.podium__name { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium__total { font: 900 1.25rem var(--font-display); }

.confetti { position: absolute; inset: 0 0 auto; height: 260px; pointer-events: none; overflow: hidden; z-index: -1; }
.confetti i {
  position: absolute; top: -20px; left: calc(var(--i) * 5.6%);
  width: 10px; height: 16px; border-radius: 3px;
  background: var(--peach);
  animation: fall 2.6s ease-in calc(var(--i) * -0.17s) 2 both;
}
.confetti i:nth-child(3n) { background: var(--mint); width: 12px; height: 12px; border-radius: 50%; }
.confetti i:nth-child(3n+1) { background: var(--lavender); }
.confetti i:nth-child(4n) { background: var(--butter); }
@keyframes fall { to { transform: translateY(280px) rotate(540deg); opacity: 0; } }

/* --- Historique ---------------------------------------------------------- */

.hlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hcard {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  border-radius: var(--radius); border: 2px solid var(--outline); background: var(--surface);
  box-shadow: var(--pop); color: var(--ink); text-decoration: none;
}
.hcard:active { transform: translateY(2px); box-shadow: none; }
.hcard__date { font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); }
.hcard__winner { display: flex; align-items: center; gap: 8px; }
.hcard__name { font: 900 1.1rem var(--font-display); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hcard__score { font: 900 1.3rem var(--font-display); }
.hcard__trophy { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--butter); color: var(--on-pastel); border: 1.5px solid var(--outline); }
.hcard__trophy .icon { width: 18px; height: 18px; }
.hcard__others { font-size: 0.85rem; color: var(--ink-soft); }

/* ==========================================================================
   Panneau de saisie des cartes et dialogues
   ========================================================================== */

.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh;
  margin: auto auto 0; padding: 0;
  border: 2px solid var(--outline); border-bottom: 0; border-radius: 26px 26px 0 0;
  background: var(--bg); color: var(--ink);
  box-shadow: 0 -10px 40px rgb(0 0 0 / 0.25);
  display: none; flex-direction: column;
}
.sheet[open] { display: flex; animation: sheet-up 220ms cubic-bezier(.2,.9,.3,1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop, .dialog::backdrop { background: rgb(30 22 50 / 0.45); }
.sheet__grip { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet__head { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 16px; flex: none; }
.sheet__heading { flex: 1; min-width: 0; }
.sheet__title { font-size: 1.2rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet__subtitle { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); }
.sheet__body { overflow-y: auto; padding: 0 16px 18px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.sheet__section-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.sheet__section { font: 900 0.78rem var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-top: 10px; }
.sheet__section-row .sheet__section { margin-top: 0; }
.counter {
  padding: 2px 10px; border-radius: 99px; border: 2px solid var(--outline);
  background: var(--surface); font: 900 0.9rem var(--font-display); font-variant-numeric: tabular-nums;
}
.counter.is-full { background: var(--butter); color: var(--on-pastel); }
.sheet__limit:empty { display: none; }
.sheet__limit { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); }
.sheet__foot {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--outline); background: var(--surface);
}
.sheet__result { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; }
.sheet__result-label { font-size: 0.78rem; font-weight: 800; color: var(--ink-soft); grid-column: 1 / -1; }
.sheet__result-value { font: 900 2.2rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.sheet__result-value.is-bust { color: var(--danger); }
.sheet__formula { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); line-height: 1.25; overflow-wrap: anywhere; }

.flip7 {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 16px; background: var(--butter); color: var(--on-pastel);
  border: 2px solid var(--outline); box-shadow: var(--pop-sm); cursor: pointer;
  animation: pop 200ms ease-out;
}
.flip7 input { width: 24px; height: 24px; accent-color: var(--outline); flex: none; }
.flip7__badge {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--outline); font: 900 1.2rem var(--font-display); color: var(--on-pastel);
}
.flip7__text { display: flex; flex-direction: column; font-size: 0.8rem; line-height: 1.3; }
.flip7__text strong { font: 900 1rem var(--font-display); }

.extras { display: flex; align-items: stretch; gap: 12px; padding-top: 6px; }
.extras__sc { margin: 0; width: 66px; flex: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.extras__sc figcaption { font-size: 0.72rem; font-weight: 800; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.bust-toggle {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  padding: 12px 16px; min-height: 56px;
  border-radius: 16px; border: 2px dashed var(--danger);
  background: var(--surface); color: var(--danger); text-align: left;
  transition: background-color var(--speed), color var(--speed);
}
.bust-toggle__title { font: 900 1.15rem var(--font-display); }
.bust-toggle__text { font-size: 0.85rem; font-weight: 700; }
.bust-toggle[aria-pressed="true"] { background: var(--danger); border: 2px solid var(--outline); color: #fff; box-shadow: var(--pop-sm); }

.dialog {
  width: min(92vw, 400px); padding: 0; border: 2px solid var(--outline); border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: 0 5px 0 var(--outline), 0 20px 40px rgb(0 0 0 / 0.25);
}
.dialog[open] { animation: pop 160ms ease-out; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.dialog__body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.dialog__title { font-size: 1.25rem; font-weight: 900; }
.dialog__text { color: var(--ink-soft); }
.dialog__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.dialog__actions .btn { padding: 0 10px; }

/* --- Toasts -------------------------------------------------------------- */

.toasts {
  position: fixed; left: 0; right: 0; z-index: 50;
  bottom: calc(118px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; padding: 0 16px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: 528px; padding: 10px 10px 10px 16px; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-weight: 700;
  border: 2px solid var(--outline); box-shadow: var(--pop);
  animation: toast-in 180ms ease-out;
}
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all 180ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast__action {
  min-height: 40px; padding: 0 14px; border: 2px solid var(--outline); border-radius: 12px;
  background: var(--butter); color: var(--on-pastel); font-weight: 900;
}

.noscript { padding: 24px; text-align: center; }
