/* Block Party
   Mise en page : un seul écran portrait. Score en haut, grille carrée au centre, pièces en bas ;
   les menus sont de gros boutons empilés. Un seul univers visuel, assumé : une soirée violet
   « jus de raisin », des blocs couleur bonbon et l'or de la patate chaude comme accent. */
:root {
  --night: #1d1038;
  --night-top: #2b1754;
  --night-low: #140a29;
  --well: #120922;
  --plum: #2f1b5c;
  --plum-hi: #3d2671;
  --plum-shadow: #170c30;
  --ink: #fff6e9;
  --mist: #b9a8dd;
  --tile-ink: #2a1240;
  --potato: #ffb22e;
  --potato-deep: #b76a00;
  --potato-ink: #3a1c00;
  --hot: #ff4d5e;
  --b1: #ff5d73;
  --b2: #ff9b3d;
  --b3: #ffd84d;
  --b4: #7ddc4b;
  --b5: #2fd4c5;
  --b6: #4d8dff;
  --b7: #b468ff;
  --spud-hi: #f6c77a;
  --spud: #c98a3e;
  --spud-lo: #8a5520;
  --empty: rgba(255, 255, 255, 0.055);
  --edge: rgba(255, 255, 255, 0.09);
  --scrim: rgba(12, 6, 26, 0.78);
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 75% at 50% 0%, var(--night-top) 0%, var(--night) 55%, var(--night-low) 100%) fixed, var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.35; }
:focus-visible { outline: 3px solid var(--potato); outline-offset: 3px; }

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(var(--safe-top) + 10px) calc(var(--safe-bottom) + 10px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 480px; margin-inline: auto; }

/* ---------- Boutons ---------- */
.btn {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  font-weight: 900;
  font-size: 17px;
  background: var(--plum-hi);
  box-shadow: 0 4px 0 var(--plum-shadow);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--plum-shadow); }
.btn.primary { background: var(--potato); color: var(--potato-ink); box-shadow: 0 5px 0 var(--potato-deep); }
.btn.primary:active { box-shadow: 0 2px 0 var(--potato-deep); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--edge); color: var(--ink); }
.btn.wide { width: min(100%, 340px); }
.btn.danger { background: #c8283a; color: var(--ink); box-shadow: 0 5px 0 #7d1220; }
.btn.danger:active { box-shadow: 0 2px 0 #7d1220; }
.btn.danger:disabled { opacity: 0.6; }
.link { border: 0; background: none; padding: 6px 4px; color: var(--mist); font-weight: 800; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn {
  width: 42px; height: 42px;
  border: 0; border-radius: 14px;
  background: var(--plum);
  font: 400 30px/1 var(--font-display);
  display: grid; place-items: center;
  padding-bottom: 3px;
}

/* ---------- Accueil ---------- */
.home { justify-content: center; align-items: center; gap: 22px; text-align: center; overflow-y: auto; }
/* Sans bande, l'accueil peut déborder (carte « Comment tu as connu le jeu ? ») : avec justify-content: center, le haut
   (le logo) sortait de l'écran sans pouvoir y revenir. Des marges automatiques centrent quand il y a la place et
   laissent défiler depuis le haut sinon (relecture du 22/11/2026). */
.home:not(.in-crew) { justify-content: flex-start; }
.home:not(.in-crew) > .logo { margin-top: auto; }
.home:not(.in-crew) > .home-foot { margin-bottom: auto; }
.logo { margin: 0; display: grid; justify-items: center; gap: 4px; }
.logo-tiles { display: flex; gap: 6px; }
.ltile {
  --c: var(--b1);
  width: clamp(46px, 13vw, 62px);
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 22%;
  font: 400 clamp(30px, 9vw, 42px)/1 var(--font-display);
  color: var(--tile-ink);
  background: linear-gradient(180deg, rgba(255,255,255,.4) 0%, rgba(255,255,255,0) 48%, rgba(0,0,0,.14) 100%), var(--c);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.2), inset 0 3px 0 rgba(255,255,255,.45), 0 6px 0 rgba(0,0,0,.25);
  transform: rotate(var(--rot, 0deg));
  animation: tile-in 520ms cubic-bezier(.2, 1.5, .4, 1) both;
  animation-delay: calc(var(--k) * 70ms);
}
.logo-word {
  font: 400 clamp(58px, 18vw, 88px)/0.92 var(--font-display);
  color: var(--potato);
  letter-spacing: 0.03em;
  text-shadow: 0 6px 0 var(--potato-deep), 0 12px 26px rgba(0,0,0,.35);
  transform: rotate(-3deg);
  animation: word-in 600ms 380ms cubic-bezier(.2, 1.4, .4, 1) both;
}
/* La patate couronnée de l'icône, glissée après SPUD (demande de Loïc du 21/11/2026) */
.logo-spud { height: 0.92em; width: auto; margin-left: 0.06em; vertical-align: -0.12em; filter: drop-shadow(0 0.06em 0 var(--potato-deep)) drop-shadow(0 0.12em 0.2em rgba(0,0,0,.35)); transform-origin: 50% 80%; animation: spud-in 700ms 620ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes spud-in { from { transform: translateY(-0.4em) rotate(-25deg) scale(.3); opacity: 0; } }
.tagline { margin: 0; color: var(--mist); font-size: 17px; font-weight: 800; text-wrap: balance; }
.menu { width: 100%; display: grid; justify-items: center; gap: 14px; }
.big-btn {
  width: min(100%, 360px);
  border: 0; border-radius: 22px;
  padding: 15px 20px 16px;
  display: grid; gap: 2px; text-align: left;
  background: var(--plum-hi);
  box-shadow: 0 6px 0 var(--plum-shadow), inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--plum-shadow); }
.big-btn.party { background: var(--potato); color: var(--potato-ink); box-shadow: 0 6px 0 var(--potato-deep), inset 0 1px 0 rgba(255,255,255,.4); }
.big-btn.party:active { box-shadow: 0 2px 0 var(--potato-deep); }
.big-btn-title { font: 400 28px/1.05 var(--font-display); letter-spacing: 0.01em; }
.big-btn-sub { font-size: 14px; font-weight: 800; opacity: 0.8; }
.card { width: min(100%, 360px); background: var(--plum); border-radius: 20px; padding: 14px; display: grid; gap: 10px; text-align: left; transition: opacity 250ms, transform 250ms; }
.card.done { opacity: 0; transform: scale(.96); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-q { margin: 0; font-weight: 900; font-size: 15px; }
.card-close { border: 0; background: none; color: var(--mist); font-size: 22px; line-height: 1; padding: 2px 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; border-radius: 999px; padding: 8px 12px; background: var(--plum-hi); font-weight: 800; font-size: 14px; }
.chip:active { background: var(--potato); color: var(--potato-ink); }
.home-foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; color: var(--mist); }
.home-foot .link { white-space: nowrap; } /* build 16 : avec « Design », les liens passent à la ligne entiers */

/* ---------- Jeu : en-tête, grille, pièces ---------- */
.hud { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; padding-bottom: 8px; }
.score-box { text-align: center; }
.score { font: 400 clamp(40px, 12vw, 56px)/1 var(--font-display); letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.score.bump { animation: bump 260ms ease-out; }
.best { color: var(--mist); font-size: 12px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.combo-slot { position: relative; height: 42px; }
.combo {
  position: absolute; right: 0; top: 50%;
  transform: translateY(-50%) rotate(6deg);
  white-space: nowrap;
  font: 400 17px/1 var(--font-display);
  color: var(--potato-ink);
  background: var(--potato);
  padding: 6px 9px; border-radius: 10px;
}
.combo.bump { animation: combo-in 320ms cubic-bezier(.2, 1.6, .4, 1); }

.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
.board {
  --gap: 4px;
  width: min(100%, 440px);
  width: min(100%, 440px, calc(100vh - 300px));
  width: min(100%, 440px, calc(100dvh - 300px));
  min-width: 220px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: var(--gap);
  padding: 8px;
  border-radius: 18px;
  background: var(--well);
  box-shadow: inset 0 3px 12px rgba(0,0,0,.5), 0 0 0 2px var(--edge);
  touch-action: none;
}
.party .board { width: min(100%, 440px, calc(100vh - 320px)); width: min(100%, 440px, calc(100dvh - 320px)); }
.cell { border-radius: 22%; background: var(--empty); }
.c1 { --c: var(--b1); } .c2 { --c: var(--b2); } .c3 { --c: var(--b3); } .c4 { --c: var(--b4); }
.c5 { --c: var(--b5); } .c6 { --c: var(--b6); } .c7 { --c: var(--b7); }
.cell.filled, .pcell {
  background: linear-gradient(180deg, rgba(255,255,255,.38) 0%, rgba(255,255,255,0) 46%, rgba(0,0,0,.16) 100%), var(--c);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.22), inset 0 2px 0 rgba(255,255,255,.38);
}
.pcell { border-radius: 22%; }
.cell.ghost { background: var(--c); opacity: 0.4; }
.cell.will-clear { filter: brightness(1.2) saturate(1.15); box-shadow: inset 0 0 0 2px var(--ink), 0 0 14px var(--c); }
.cell.land { animation: land 180ms ease-out; }
.board.dead .cell.filled { filter: grayscale(.85) brightness(.65); transition: filter 600ms ease; }
.pop { pointer-events: none; z-index: 46; animation: pop 440ms cubic-bezier(.3, .7, .4, 1) both; }

.tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; height: clamp(104px, 17vh, 150px); touch-action: none; }
.slot { min-width: 0; display: grid; place-items: center; touch-action: none; cursor: grab; border-radius: 16px; }
.slot.lifted .piece { opacity: 0; }
.slot.dead .piece { opacity: 0.3; filter: grayscale(.8); }
.slot.deal .piece { animation: deal 340ms cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--k, 0) * 70ms); }
.piece { display: grid; }
#drag-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.floating { position: absolute; left: 0; top: 0; will-change: transform; filter: drop-shadow(0 12px 14px rgba(0,0,0,.45)); }
#fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 48; }
#app:has(.overlay:not([hidden])) ~ #fx-canvas { z-index: 65; } /* confettis au-dessus d'une fenêtre ouverte */

.float-text {
  position: fixed; z-index: 52;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  color: var(--ink);
  text-shadow: 0 3px 0 rgba(0,0,0,.45);
  white-space: nowrap;
  pointer-events: none;
  animation: rise 1050ms ease-out forwards;
}
.float-text.big { font-size: clamp(30px, 9vw, 40px); color: var(--potato); text-shadow: 0 4px 0 var(--potato-deep), 0 8px 20px rgba(0,0,0,.4); }
.float-text.small { font-size: 22px; }
.float-text.tiny { font-size: 16px; color: var(--mist); }
/* Gros coup : 3 lignes ou plus (BP.fx.bigHit) */
.float-text.huge { font-size: clamp(42px, 13vw, 60px); color: var(--potato); text-shadow: 0 5px 0 var(--potato-deep), 0 10px 26px rgba(0,0,0,.5); animation: rise-huge 1300ms ease-out forwards; }
.hit-flash { position: fixed; inset: 0; z-index: 49; pointer-events: none; background: radial-gradient(circle at 50% 45%, rgba(255,230,128,.45), rgba(255,178,46,.12) 45%, transparent 75%); animation: hit-flash 420ms ease-out forwards; }
.hit-flash.strong { background: radial-gradient(circle at 50% 45%, rgba(255,240,170,.7), rgba(255,178,46,.22) 50%, transparent 80%); }

/* ---------- Patate chaude ---------- */
.setup { align-items: center; gap: 14px; overflow-y: auto; padding-bottom: 8px; }
.setup-head { width: 100%; display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; }
.setup-head h2 { margin: 0; text-align: center; font: 400 30px/1.1 var(--font-display); }
.rules { margin: 0; max-width: 36ch; text-align: center; color: var(--mist); font-size: 15px; font-weight: 700; line-height: 1.45; text-wrap: pretty; }
.plist { width: min(100%, 360px); display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: 48px 1fr 42px; gap: 8px; align-items: center; }
.em-btn { height: 48px; border: 0; border-radius: 14px; background: var(--plum); font-size: 26px; line-height: 1; }
.prow input {
  height: 48px; min-width: 0;
  border: 2px solid transparent; border-radius: 14px;
  background: var(--plum); color: var(--ink);
  font: 800 17px var(--font-body);
  padding: 0 12px;
  -webkit-user-select: text; user-select: text;
}
.prow input:focus { outline: none; border-color: var(--potato); }
.del-btn { height: 42px; border: 0; border-radius: 12px; background: transparent; color: var(--mist); font-size: 24px; line-height: 1; }
.opts { width: min(100%, 360px); display: grid; gap: 10px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.opt-label { font-weight: 900; font-size: 15px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--plum); }
.seg button { border: 0; border-radius: 10px; background: transparent; color: var(--mist); font-weight: 900; font-size: 15px; padding: 8px 13px; }
.seg button[aria-pressed="true"] { background: var(--potato); color: var(--potato-ink); }

.party-hud { display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: center; padding-bottom: 8px; }
.players { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-width: 0; }
.pchip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: var(--plum);
  font-size: 13px; font-weight: 900;
  max-width: 100%;
  transition: transform 200ms ease, background 200ms ease;
}
.pchip .em { font-size: 18px; line-height: 1; }
.pchip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; }
.pchip .hearts { color: var(--hot); letter-spacing: 1px; font-size: 12px; }
.pchip .hearts .lost { opacity: 0.25; }
.pchip.current { background: var(--potato); color: var(--potato-ink); transform: scale(1.07); }
.pchip.current .hearts { color: var(--potato-ink); }
.pchip.out { opacity: 0.35; }
.pchip.out .nm { text-decoration: line-through; }
.pchip.hit { animation: hit 520ms ease; }
.party-bottom { display: grid; gap: 8px; padding-top: 8px; }
.timer { height: 10px; border-radius: 999px; background: var(--empty); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; border-radius: inherit; background: var(--potato); transform-origin: left center; }
.timer-fill.urgent { background: var(--hot); }
.party-pieces { display: grid; grid-template-columns: 1fr 104px; gap: 10px; align-items: center; height: clamp(100px, 16vh, 140px); }
.slot.big { height: 100%; background: var(--empty); }
.big-wrap { position: relative; height: 100%; min-width: 0; }
/* Patate en réseau : à moi de jouer (pièce encadrée) ou tour d'un autre (sa pièce grisée et étiquetée). */
.slot-owner { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 12px); padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.screen.party.watch .slot.big { cursor: default; }
.screen.party.watch .slot.big .piece { opacity: 0.35; filter: grayscale(.7); }
.screen.party.my-turn .slot.big { box-shadow: inset 0 0 0 3px var(--potato); }
.slot.big.dead .piece { opacity: 0.45; filter: grayscale(.5); }
.next { display: grid; gap: 4px; justify-items: center; text-align: center; }
.next-label { display: grid; color: var(--mist); font-size: 11px; font-weight: 900; line-height: 1.25; text-transform: uppercase; letter-spacing: 0.06em; max-width: 104px; }
.next-label strong { color: var(--ink); font-size: 14px; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.small { width: 104px; height: 70px; cursor: default; background: var(--empty); }

.pass {
  position: fixed; inset: 0; z-index: 55;
  display: grid; place-content: center; justify-items: center; gap: 8px;
  padding: 24px max(16px, env(safe-area-inset-left, 0px));
  background: var(--scrim);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  text-align: center;
  cursor: pointer;
}
.pass-emoji { font-size: 92px; line-height: 1.1; animation: bob 1.1s ease-in-out infinite; }
.pass-title { font: 400 clamp(34px, 10vw, 46px)/1.05 var(--font-display); color: var(--potato); text-wrap: balance; }
.pass-sub { color: var(--mist); font-weight: 800; font-size: 16px; }

.banner {
  position: fixed; left: 50%; top: 40%; z-index: 56;
  transform: translate(-50%, -50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 14px 22px;
  border-radius: 20px;
  background: var(--hot);
  color: var(--ink);
  text-align: center;
  font: 400 clamp(26px, 8vw, 36px)/1.1 var(--font-display);
  box-shadow: 0 8px 0 rgba(0,0,0,.25);
  pointer-events: none;
}
.banner.show { animation: banner-in 360ms cubic-bezier(.2, 1.4, .4, 1); }
.banner small { display: block; margin-top: 4px; font: 900 16px/1.2 var(--font-body); }

.win { align-items: center; justify-content: center; gap: 16px; text-align: center; overflow-y: auto; }
.trophy { font-size: 88px; line-height: 1; animation: bob 1.4s ease-in-out infinite; }
.win-title { margin: 0; font: 400 clamp(36px, 11vw, 50px)/1.05 var(--font-display); color: var(--potato); text-wrap: balance; }
.stats { width: min(100%, 340px); border-collapse: collapse; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats th { color: var(--mist); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; padding: 6px 8px; }
.stats td { padding: 9px 8px; border-top: 1px solid var(--edge); }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats tr.winner td { color: var(--potato); }
.win-actions { width: 100%; display: grid; justify-items: center; gap: 10px; }

/* ---------- Fenêtres ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  overflow-y: auto; overscroll-behavior: contain; /* petit écran : la fenêtre défile jusqu'à son dernier bouton */
  display: grid; place-items: center;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  background: var(--scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.panel {
  width: min(100%, 360px);
  display: grid; justify-items: center; gap: 12px;
  padding: 24px 20px;
  border-radius: 26px;
  background: var(--plum);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  text-align: center;
  animation: panel-in 360ms cubic-bezier(.2, 1.3, .4, 1);
}
.panel p { margin: 0; }
.panel-title { font: 400 26px/1.1 var(--font-display); overflow-wrap: anywhere; }
.panel-kicker { font: 400 24px/1.1 var(--font-display); color: var(--potato); }
.over-score { font: 400 64px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.over-best { color: var(--mist); font-weight: 900; }
.over-stats { color: var(--mist); font-size: 14px; }
.panel .row { display: flex; gap: 10px; }
.about p:not(.panel-title) { color: var(--mist); font-size: 15px; line-height: 1.45; text-align: left; }
.about p.about-links { text-align: center; }
.erase { width: 100%; display: grid; justify-items: center; gap: 8px; }
.erase-open { color: var(--mist); font-size: 14px; }
.erase-box { width: 100%; display: grid; justify-items: center; gap: 10px; padding: 14px 12px; border-radius: 18px; background: var(--night); box-shadow: inset 0 0 0 2px rgba(255, 77, 94, 0.45); }
.about p.erase-warn { text-align: center; }
.about .erase p.form-error { width: 100%; color: var(--ink); text-align: center; }
.about-links a { color: var(--ink); font-weight: 800; text-underline-offset: 3px; padding: 6px 2px; }
/* Sauvegarde (src/backup.js) */
.backup { width: 100%; display: grid; justify-items: center; gap: 8px; padding: 14px 12px; border-radius: 18px; background: var(--night); }
.about .backup p.backup-title { color: var(--potato); font: 400 20px/1.1 var(--font-display); text-align: center; }
.about .backup p.backup-has { color: var(--ink); text-align: center; }
.backup-code { font: 400 24px/1.2 var(--font-display); letter-spacing: 0.06em; color: var(--ink); -webkit-user-select: text; user-select: text; }
.about .backup p.backup-hint { font-size: 13px; text-align: center; }
.backup-form { width: 100%; }
.backup-form .field input { background: var(--plum); text-transform: uppercase; letter-spacing: 0.12em; }
.about .backup p.form-error { width: 100%; color: var(--ink); text-align: left; }
/* Invitation de la bande à une partie de patate chaude */
.lobby-crews { width: min(100%, 360px); display: grid; gap: 8px; justify-items: center; }
.lobby-crew-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lobby-crew-btns .btn { min-height: 40px; padding: 0 14px; font-size: 15px; }
.lobby-crew-btns .btn[aria-pressed="true"] { opacity: .6; }
.crown-alert.party-invite { background: var(--plum-hi); border: 2px solid var(--potato); color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.crown-alert.party-invite p { color: var(--ink); }
.crown-alert.party-invite .link { color: var(--mist); }
.invite-float { position: fixed; z-index: 66; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); transform: translateX(-50%); width: min(calc(100% - 32px), 380px); animation: panel-in 300ms cubic-bezier(.2, 1.3, .4, 1); }
.party-invite .invite-actions { display: flex; gap: 12px; align-items: center; justify-content: center; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); z-index: 70;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink); color: var(--tile-ink);
  font-weight: 900; font-size: 15px; text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ---------- Animations ---------- */
@keyframes tile-in { from { transform: translateY(-40px) rotate(0deg) scale(.4); opacity: 0; } }
@keyframes word-in { from { transform: scale(.3) rotate(-12deg); opacity: 0; } }
@keyframes land { from { transform: scale(1.18); } to { transform: scale(1); } }
@keyframes pop {
  0% { transform: scale(1); opacity: 1; filter: brightness(1.7); }
  35% { transform: scale(1.22) rotate(5deg); opacity: 1; }
  100% { transform: scale(.15) rotate(-16deg); opacity: 0; }
}
@keyframes deal { from { transform: translateY(46px) scale(.5); opacity: 0; } }
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  28% { transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
@keyframes rise-huge {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.3) rotate(-8deg); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(3deg); }
  24% { transform: translate(-50%, -52%) scale(1) rotate(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}
@keyframes hit-flash { from { opacity: 1; } to { opacity: 0; } }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes combo-in { from { transform: translateY(-50%) rotate(-10deg) scale(.3); } }
@keyframes shake { 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, -1px); } }
@keyframes shake-big { 15% { transform: translate(-10px, 4px) rotate(-1deg); } 30% { transform: translate(9px, -4px) rotate(1deg); } 45% { transform: translate(-7px, 3px); } 60% { transform: translate(6px, -2px); } 80% { transform: translate(-3px, 1px); } }
.shake { animation: shake 350ms ease; }
.shake-big { animation: shake-big 520ms ease; }
@keyframes hit { 20% { transform: scale(1.25) rotate(-6deg); background: var(--hot); } 60% { transform: scale(.95) rotate(4deg); } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes banner-in { from { transform: translate(-50%, -50%) scale(.4) rotate(-6deg); opacity: 0; } }
@keyframes panel-in { from { transform: translateY(30px) scale(.9); opacity: 0; } }

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

/* ---------- La bande ---------- */
.home.in-crew { justify-content: flex-start; gap: 14px; }
.home.in-crew .logo-tiles { gap: 4px; }
.home.in-crew .ltile { width: 32px; font-size: 21px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2), inset 0 2px 0 rgba(255,255,255,.45), 0 4px 0 rgba(0,0,0,.25); }
.home.in-crew .logo-word { font-size: 38px; text-shadow: 0 4px 0 var(--potato-deep); }
.home.in-crew .tagline { display: none; }

.crown-alert {
  width: min(100%, 360px);
  display: grid; justify-items: center; gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: var(--hot); color: var(--ink);
  text-align: center;
  animation: panel-in 360ms cubic-bezier(.2, 1.3, .4, 1);
}
.crown-alert p { margin: 0; font-weight: 900; font-size: 16px; line-height: 1.3; text-wrap: balance; }
.btn.small { padding: 9px 14px; font-size: 15px; }

.crew-card { width: min(100%, 360px); display: grid; gap: 6px; padding: 16px; border-radius: 22px; background: var(--plum); text-align: left; }
.crew-top { display: flex; align-items: center; gap: 8px; }
.crew-tabs { display: flex; gap: 6px; overflow-x: auto; margin: -4px -4px 4px; padding: 2px 4px 4px; scrollbar-width: none; }
.crew-tabs::-webkit-scrollbar { display: none; }
.crew-tab { flex: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--edge); border-radius: 999px; padding: 6px 11px; background: var(--plum-hi); color: var(--mist); font: 800 13px/1.1 var(--font-body); cursor: pointer; }
.crew-tab[aria-pressed="true"] { background: var(--potato); border-color: var(--potato); color: var(--potato-ink); }
.eyebrow { color: var(--mist); font-size: 12px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.crew-code { margin-left: auto; padding: 5px 9px; border: 1px solid var(--edge); border-radius: 8px; background: var(--plum-hi); color: var(--ink); font: 900 12px/1 var(--font-body); letter-spacing: 0.12em; cursor: pointer; }
.crew-code:active { transform: translateY(1px); }
.demo-tag { padding: 2px 6px; border-radius: 6px; background: var(--mist); color: var(--tile-ink); font-size: 11px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.crew-name { margin: 0; font: 400 26px/1.1 var(--font-display); overflow-wrap: anywhere; }
.crew-crown { margin: 0; color: var(--potato); font-size: 15px; font-weight: 900; }
.crew-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; max-height: 236px; overflow-y: auto; }
.crew-list li { display: grid; grid-template-columns: 22px 26px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 7px 2px; border-top: 1px solid var(--edge); font-size: 15px; font-weight: 800; }
.crew-list li:first-child { border-top: 0; }
.crew-list .rk { color: var(--mist); text-align: right; font-variant-numeric: tabular-nums; }
.crew-list .av { font-size: 19px; line-height: 1; text-align: center; }
.crew-list .ps { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-list .ps small, .crew-list .sc small { margin-left: 5px; color: var(--mist); font-size: 11px; font-weight: 800; }
.crew-list .sc { font-variant-numeric: tabular-nums; }
.crew-list li.me .ps, .crew-list li.me .sc { color: var(--potato); }
.crew-list li.none .sc { color: var(--mist); }
.crew-foot { margin: 2px 0 0; color: var(--mist); font-size: 13px; font-weight: 800; }

.big-btn.crown { background: var(--potato); color: var(--potato-ink); box-shadow: 0 6px 0 var(--potato-deep), inset 0 1px 0 rgba(255,255,255,.4); }
.big-btn.crown:active { box-shadow: 0 2px 0 var(--potato-deep); }
.big-btn.party { background: var(--plum-hi); color: var(--ink); box-shadow: 0 6px 0 var(--plum-shadow), inset 0 1px 0 rgba(255,255,255,.12); }
.big-btn.party:active { box-shadow: 0 2px 0 var(--plum-shadow); }
.menu-row { width: min(100%, 360px); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.crew { align-items: center; gap: 14px; overflow-y: auto; padding-bottom: 8px; }
.form { width: min(100%, 360px); display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label { color: var(--mist); font-size: 14px; font-weight: 900; }
.field input {
  height: 48px; min-width: 0;
  border: 2px solid transparent; border-radius: 14px;
  background: var(--plum); color: var(--ink);
  font: 800 17px var(--font-body);
  padding: 0 12px;
  -webkit-user-select: text; user-select: text;
}
.field input:focus { outline: none; border-color: var(--potato); }
#crew-code-input { text-transform: uppercase; letter-spacing: 0.2em; }
.emoji-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-pick button { aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: 14px; background: var(--plum); font-size: 24px; line-height: 1; }
.emoji-pick button[aria-pressed="true"] { border-color: var(--potato); background: var(--plum-hi); }
.form-error { margin: 0; width: min(100%, 360px); padding: 10px 12px; border-radius: 12px; background: var(--hot); color: var(--ink); font-size: 14px; font-weight: 800; }
.demo-note { margin: 0; width: min(100%, 360px); color: var(--mist); font-size: 13px; font-weight: 700; line-height: 1.4; text-align: center; }

/* Les potes sur la barre de score */
.race { display: grid; gap: 2px; padding-bottom: 4px; }
.race-track { position: relative; height: 10px; margin: 26px 18px 24px; border-radius: 999px; background: var(--empty); }
.race-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--b5), var(--potato)); transition: width 380ms cubic-bezier(.2, .8, .3, 1); }
.race-av {
  position: absolute; bottom: 14px;
  transform: translateX(-50%);
  font-size: 22px; line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
  transition: left 380ms ease, opacity 300ms ease, transform 300ms ease;
}
.race-av .crown { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); font-size: 14px; }
.race-av.passed { opacity: 0.4; transform: translateX(-50%) scale(.8); }
.race-av.me { bottom: auto; top: 14px; font-size: 18px; }
.race-target { margin: 0; min-height: 1.3em; text-align: center; color: var(--mist); font-size: 13px; font-weight: 900; }
.race-target strong { color: var(--ink); }
.game.with-race .board { width: min(100%, 440px, calc(100vh - 370px)); width: min(100%, 440px, calc(100dvh - 370px)); }

/* La patate */
.cell.potato {
  position: relative;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--spud-hi) 0%, var(--spud) 55%, var(--spud-lo) 100%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.35);
}
.cell.potato::before { content: '🥔'; font-size: clamp(14px, 4.6vw, 26px); line-height: 1; }
.cell.potato[data-count]::after {
  content: attr(data-count);
  position: absolute; right: -5px; top: -6px;
  min-width: 19px; height: 19px; padding: 0 4px;
  border-radius: 999px;
  background: var(--ink); color: var(--tile-ink);
  font: 900 12px/19px var(--font-body);
  text-align: center;
  box-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.cell.potato.hot { animation: potato-hot 600ms ease-in-out infinite; }
.cell.potato.hot[data-count]::after { background: var(--hot); color: var(--ink); }
.cell.potato.will-clear { box-shadow: inset 0 0 0 2px var(--ink), 0 0 16px var(--potato); }
.party-hint { margin: 0; min-height: 1.3em; text-align: center; color: var(--mist); font-size: 14px; font-weight: 900; }
.party-hint.hot { color: var(--hot); }
.screen.party.watch .party-hint { color: var(--ink); font-size: 17px; }
.screen.party.my-turn .party-hint { color: var(--potato); font-size: 17px; }
.screen.party .party-hint.hot { color: var(--hot); }
.panel-text { color: var(--mist); font-size: 15px; line-height: 1.4; }
.over-crew { color: var(--potato); font-weight: 900; text-wrap: balance; }
.results-dates { margin-top: -8px !important; color: var(--mist); font-size: 14px; font-weight: 800; }
.results-crown { color: var(--potato); font-size: 18px; font-weight: 900; }
.results-list { width: 100%; max-height: 220px; text-align: left; }
.results-me { font-weight: 900; text-wrap: balance; }
.results-season { margin-top: -6px !important; color: var(--mist); font-size: 14px; font-weight: 800; text-wrap: balance; }
.crew-view { justify-self: start; margin-top: 2px; background: var(--plum-hi); }
.crew-view button { font-size: 13px; padding: 6px 11px; white-space: nowrap; }
@media (max-width: 380px) { .crew-view button { padding: 6px 8px; font-size: 12px; } } /* trois onglets (build 16) */
@keyframes potato-hot { 50% { transform: scale(1.12) rotate(-6deg); } }

/* ---------- Patate chaude en réseau ---------- */
.potato-me { width: min(100%, 340px); display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; }
.potato-me input, .join-row input {
  min-width: 0; height: 48px; padding: 0 14px; border-radius: 14px; border: 2px solid var(--edge);
  background: var(--plum); color: var(--ink); font: 800 17px var(--font-body);
}
.potato-me input:focus, .join-row input:focus { outline: none; border-color: var(--potato); }
.join-row { width: min(100%, 340px); display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 2px; }
.lobby-code {
  border: 0; border-radius: 18px; padding: 10px 22px; background: var(--plum); color: var(--potato);
  font: 400 44px/1.1 var(--font-display); letter-spacing: 4px; cursor: pointer;
}
.lobby-list { width: min(100%, 360px); max-height: none; }
.lobby-list .rk.here { color: #5fd38a; }
.lobby-list .rk.away { color: var(--mist); }
.lobby-list .sc { color: var(--mist); font-size: 13px; }
.pchip.me { box-shadow: inset 0 0 0 2px var(--potato); }

/* Modération : lignes d'autres joueurs et nom de la bande qu'on peut toucher pour signaler ou bloquer. */
.crew-list li.tap, .crew-list li.tap .ps[role="button"], #crew-name { cursor: pointer; }
.crew-list li.tap:active { filter: brightness(1.15); }
#mod-sheet .panel { gap: 10px; }

/* ---------- Astuces de prise en main (src/tuto.js) ----------
   Voile percé sur l'élément expliqué (61), zone qui reçoit les touchers (62), bulle (63) : au-dessus des écrans, du
   glisser (50), de l'écran « passe le téléphone » (55), des bandeaux (56) et des fenêtres (60) ; sous les confettis
   d'une fenêtre (65), l'invitation flottante (66) et les messages (70). Pas de classe .overlay : elle relèverait les
   confettis et bloquerait la carte des résultats et le retour dans le jeu (src/app.js). */
.tuto { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tuto-catch { position: fixed; inset: 0; z-index: 62; -webkit-tap-highlight-color: transparent; }
.tuto-hole {
  position: fixed; z-index: 61; pointer-events: none; border-radius: 22px;
  box-shadow: 0 0 0 3px var(--potato), 0 0 0 200vmax var(--scrim);
  transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease;
}
.tuto-hole.none { box-shadow: 0 0 0 200vmax var(--scrim); }
.tuto-bubble {
  position: fixed; z-index: 63; display: grid; gap: 10px; padding: 14px 16px; border-radius: 20px;
  background: var(--plum-hi); border: 2px solid var(--potato); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  text-align: left;
}
.tuto-bubble.in { animation: tuto-in .26s cubic-bezier(.2, 1.3, .4, 1) both; }
.tuto-text { margin: 0; font-size: 16px; font-weight: 900; line-height: 1.3; text-wrap: pretty; overflow-wrap: anywhere; }
.tuto-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } /* texte agrandi : les boutons passent à la ligne */
.tuto-step { margin-right: auto; color: var(--mist); font-size: 13px; font-weight: 800; white-space: nowrap; }
.tuto-foot .btn { min-width: 0; min-height: 40px; padding: 8px 14px; font-size: 15px; }
.tuto-arrow { position: absolute; left: var(--ax, 50%); width: 14px; height: 14px; margin-left: -8px; background: var(--plum-hi); transform: rotate(45deg); }
.tuto-bubble[data-arrow="top"] .tuto-arrow { top: -9px; border-top: 2px solid var(--potato); border-left: 2px solid var(--potato); }
.tuto-bubble[data-arrow="bottom"] .tuto-arrow { bottom: -9px; border-bottom: 2px solid var(--potato); border-right: 2px solid var(--potato); }
.tuto-bubble[data-arrow="none"] .tuto-arrow { display: none; }
/* Indication pendant le jeu : elle ne prend aucun toucher, le glisser passe dessous. */
.tuto.hint .tuto-bubble { pointer-events: none; padding: 10px 14px; }
.tuto.hint .tuto-text { font-size: 15px; }
.tuto-probe {
  position: fixed; top: 0; left: 0; visibility: hidden; pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.about-tuto { margin: 0; }
/* Réactions au score d'un pote : dans la fenêtre « Signaler / Bloquer », et leur compte sur la carte de la bande. */
.crew-salon {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 2px; padding: 8px 10px 8px 12px;
  border-radius: 14px; background: var(--plum-hi); border: 2px solid var(--potato); font-size: 14px; font-weight: 900; text-align: left;
}
.mod-react { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.mod-react button {
  width: 52px; height: 52px; border: 0; border-radius: 16px; background: var(--plum-hi); font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 0 var(--plum-shadow);
}
.mod-react button[aria-pressed="true"] { background: var(--potato); box-shadow: 0 4px 0 var(--potato-deep); }
.mod-react button:active { transform: translateY(3px); box-shadow: none; }
.crew-list .rx { margin-left: 6px; font-size: 13px; font-weight: 800; color: var(--mist); white-space: nowrap; }
/* Défi de la semaine : entrée sur la carte de la bande, bandeau de la partie. */
.crew-defi {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%; margin: 4px 0 2px; padding: 9px 12px;
  border: 0; border-radius: 14px; background: var(--plum-hi); color: var(--ink); text-align: left; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 178, 46, .45);
}
.crew-defi:active { transform: translateY(2px); }
.crew-defi-t { font: 400 17px/1.2 var(--font-display); color: var(--potato); }
.crew-defi-s { font-size: 13px; font-weight: 800; color: var(--mist); }
.defi-tag { margin: 2px 0 0; text-align: center; font: 400 17px/1.2 var(--font-display); color: var(--potato); }
/* Règles d'utilisation à accepter avant le premier pseudo (écran de la bande, entrée de la patate). */
.rules-ok { width: min(100%, 340px); display: flex; gap: 10px; align-items: center; text-align: left; color: var(--mist); font-size: 15px; line-height: 1.35; cursor: pointer; }
.rules-ok input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--potato); }
.rules-ok a { color: var(--potato); }
/* Zone lue par les lecteurs d'écran pour les indications : hors de la vue, jamais masquée. */
.tuto-live { position: fixed; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@keyframes tuto-in { from { opacity: 0; transform: translateY(8px) scale(.96); } }
/* Résultats du lundi en notification (build 16), sous le partage. */
.results-notif { display: block; margin: 4px auto 0; font-size: 14px; }

/* ---------- Tablettes (build 16) ----------
   Le jeu reste en portrait (iPad : plein écran, portrait ; Android : jeu, portrait gardé même au-delà de 600 dp).
   En portrait, une tablette donne 744 à 1032 px de large : la grille et les pièces grandissent (src/board.js mesure
   la grille pour dessiner les pièces), les menus gardent une largeur de lecture. */
@media (min-width: 700px) and (min-height: 900px) {
  .screen { max-width: 680px; }
  .board { --gap: 6px; padding: 10px; border-radius: 24px; }
  .board { width: min(100%, 640px, calc(100vh - 400px)); width: min(100%, 640px, calc(100dvh - 400px)); }
  .party .board { width: min(100%, 640px, calc(100vh - 420px)); width: min(100%, 640px, calc(100dvh - 420px)); }
  .game.with-race .board { width: min(100%, 640px, calc(100vh - 470px)); width: min(100%, 640px, calc(100dvh - 470px)); }
  .tray { height: clamp(150px, 15vh, 210px); gap: 12px; }
  /* Accueil avec une bande : centré dans la hauteur (sur téléphone, il remplit l'écran), un peu plus large. */
  .home.in-crew > .logo { margin-top: auto; }
  .home.in-crew > .home-foot { margin-bottom: auto; }
  .home.in-crew .ltile { width: 40px; font-size: 26px; }
  .home.in-crew .logo-word { font-size: 48px; }
  .home .crew-card, .home .big-btn, .home .menu-row { width: min(100%, 440px); }
}

/* QR code d'une bande ou d'une partie (build 16). Fond blanc et marge de 4 modules : les appareils photo le lisent
   mieux sur un fond clair, quel que soit le thème. */
.invite-qr { font-size: 14px; }
.qr-panel { justify-items: center; text-align: center; }
.qr-box { width: min(232px, 70vw); aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: #fff; box-shadow: 0 0 0 4px var(--potato); }
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-code { margin: 0; font: 400 34px/1 var(--font-display); letter-spacing: 0.08em; color: var(--potato); }

/* Design des blocs (build 16, src/themes.js) : un échantillon des sept couleurs, habillé par le design choisi. */
.board.design-sample {
  width: auto; min-width: 0; aspect-ratio: auto; touch-action: auto;
  grid-template-columns: repeat(7, 30px); grid-template-rows: repeat(2, 30px);
  --gap: 5px; padding: 10px; border-radius: 16px;
}
.design-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.design-chip { color: var(--ink); cursor: pointer; }
.design-chip[aria-checked="true"] { background: var(--potato); color: var(--potato-ink); }
.design-hint { min-height: 2.8em; color: var(--mist); font-size: 14px; font-weight: 700; line-height: 1.4; text-wrap: balance; }
.design-light { justify-content: center; }

/* Salon : « Envoyer le lien » et le QR code sur une même ligne, pour laisser la place à la liste des joueurs. */
.lobby-share-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
