:root {
  --fond: #2a3bd1;
  --fond-sombre: #1c2a9e;
  --encre: #101540;
  --papier: #ffffff;
  --papier-2: #eef0ff;
  --bombe: #ff4d3d;
  --soleil: #ffd23f;
  --menthe: #2fd18b;
  --gris: #6b7099;
  --rayon: 16px;
  --police: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--police);
  color: var(--encre);
  background: var(--fond);
  background-image: radial-gradient(var(--fond-sombre) 2px, transparent 2px);
  background-size: 28px 28px;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
main { width: 100%; flex: 1; max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
.pied { text-align: center; padding: 0 16px 20px; color: var(--papier); font-weight: 700; font-size: .9rem; }
.pied a { color: var(--soleil); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.pied a:focus-visible { outline: 3px solid var(--soleil); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); font-weight: 900; letter-spacing: -0.02em; color: var(--papier); text-shadow: 4px 4px 0 var(--encre); }
h2 { font-size: 1.35rem; font-weight: 800; }
p { margin: 0; }

/* Cartes "autocollant" */
.carte {
  background: var(--papier);
  border: 3px solid var(--encre);
  border-radius: var(--rayon);
  box-shadow: 6px 6px 0 var(--encre);
  padding: 18px;
}
.pile { display: grid; gap: 16px; }
.rang { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rang.espace { justify-content: space-between; }
.discret { color: var(--gris); font-size: 0.92rem; }

/* Champs et boutons */
label { display: block; font-weight: 800; margin-bottom: 6px; }
input[type=text], input[type=number], select {
  width: 100%; font: inherit; font-weight: 700; color: var(--encre);
  padding: 12px 14px; border: 3px solid var(--encre); border-radius: 12px; background: var(--papier);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 4px solid var(--soleil); outline-offset: 2px; }
.code-champ { text-transform: uppercase; letter-spacing: 0.35em; text-align: center; font-size: 1.6rem; }
button {
  font: inherit; font-weight: 900; cursor: pointer; color: var(--encre);
  background: var(--soleil); border: 3px solid var(--encre); border-radius: 12px;
  padding: 12px 18px; box-shadow: 4px 4px 0 var(--encre);
  transition: transform .08s, box-shadow .08s;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--encre); }
button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--encre); }
button.secondaire { background: var(--papier); }
button.danger { background: var(--bombe); color: #fff; }
button.grand { width: 100%; font-size: 1.15rem; padding: 15px 18px; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--encre); }
button.petit { padding: 4px 10px; font-size: .85rem; box-shadow: 2px 2px 0 var(--encre); }

.erreur { background: #ffe3df; border: 3px solid var(--bombe); border-radius: 12px; padding: 10px 14px; font-weight: 700; }

/* Accueil */
.accueil { padding-top: 6vh; gap: 22px; }
.titre-site .marque { display: block; font-size: .5em; letter-spacing: .02em; color: var(--soleil); text-shadow: 3px 3px 0 var(--encre); }
.accueil .bombe-logo { font-size: 3.4rem; display: inline-block; transform: rotate(-10deg); }
.sous-titre { color: var(--papier); font-weight: 700; font-size: 1.1rem; margin-top: 8px; }
.ou { text-align: center; font-weight: 900; color: var(--papier); }

/* Salon */
.code-salon {
  font-size: 2.6rem; font-weight: 900; letter-spacing: 0.25em; background: var(--soleil);
  border: 3px dashed var(--encre); border-radius: 12px; padding: 4px 16px 4px 26px; cursor: pointer; user-select: all;
}
.joueurs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.joueurs li {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 3px solid var(--encre);
  border-radius: 12px; background: var(--papier-2); font-weight: 800;
}
.joueurs li.moi { background: #fff3c4; }
.joueurs li.hors-ligne { opacity: .5; }
.joueurs .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pastille { font-size: .78rem; background: var(--encre); color: #fff; border-radius: 99px; padding: 2px 8px; }
.jeux { display: grid; gap: 10px; }
.jeu-choix { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; background: var(--papier-2); }
.jeu-choix[aria-pressed=true] { background: var(--menthe); }
.jeu-choix .emoji { font-size: 2rem; }
.jeu-choix small { display: block; font-weight: 600; }
.reglages { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* BombParty */
.table {
  position: relative; width: min(100%, 560px); aspect-ratio: 1; margin: 6px auto 0;
}
.siege {
  position: absolute; transform: translate(-50%, -50%); width: clamp(64px, 19%, 104px);
  text-align: center; font-weight: 800; font-size: clamp(.68rem, 2.4vw, .9rem);
  background: var(--papier); border: 3px solid var(--encre); border-radius: 12px; padding: 4px 3px;
  box-shadow: 3px 3px 0 var(--encre); transition: background .15s;
}
.siege .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.siege .vies { letter-spacing: -1px; font-size: .85em; min-height: 1.2em; }
.siege.actif { background: var(--soleil); z-index: 2; animation: pulse .6s ease-in-out infinite alternate; }
.siege.mort { opacity: .35; box-shadow: none; }
.siege.mort .nom { text-decoration: line-through; }
.siege.moi { border-color: var(--bombe); }
.siege .frappe { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; background: var(--encre); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: .95em; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
@keyframes pulse { to { transform: translate(-50%, -50%) scale(1.07); } }

.bombe { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 44%; text-align: center; }
.bombe .corps {
  aspect-ratio: 1; border-radius: 50%; background: var(--encre); color: #fff; border: 4px solid var(--encre);
  display: grid; place-items: center; box-shadow: 0 0 0 5px var(--papier), 6px 6px 0 5px var(--encre); position: relative;
}
.bombe .syllabe { font-size: clamp(1.6rem, 8vw, 3rem); font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.bombe .meche { position: absolute; top: -14px; right: 14%; width: 28px; height: 14px; border-top: 5px solid var(--soleil); border-right: 5px solid var(--soleil); border-radius: 0 14px 0 0; }
.bombe.urgent .corps { animation: tremble .12s linear infinite; background: var(--bombe); }
@keyframes tremble { 25% { transform: translate(2px, -1px); } 75% { transform: translate(-2px, 1px); } }
.minuteur { height: 12px; margin-top: 16px; background: var(--papier); border: 3px solid var(--encre); border-radius: 99px; overflow: hidden; }
.minuteur > i { display: block; height: 100%; width: 100%; background: var(--menthe); transform-origin: left; }
.bombe.urgent .minuteur > i { background: var(--bombe); }

.saisie { display: grid; gap: 10px; }
.saisie input { font-size: 1.4rem; text-align: center; text-transform: lowercase; }
.saisie input::placeholder { text-transform: none; font-size: 1.05rem; }
.saisie.attente input { background: #dfe2f5; }
.flash { text-align: center; font-weight: 900; min-height: 1.5em; white-space: pre-line; }
.flash.bon { color: #0b8a55; } .flash.mauvais { color: var(--bombe); }
.bonus { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.bonus span { width: 26px; height: 26px; display: grid; place-items: center; font-weight: 900; text-transform: uppercase; font-size: .8rem; border: 2px solid var(--encre); border-radius: 8px; background: var(--papier-2); color: var(--gris); }
.bonus span.ok { background: var(--menthe); color: var(--encre); }
.explosion { position: fixed; inset: 0; display: grid; place-items: center; font-size: 30vmin; pointer-events: none; animation: boum .6s ease-out forwards; z-index: 10; }
@keyframes boum { 0% { transform: scale(.2); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.podium { text-align: center; display: grid; gap: 12px; }
.podium .trophee { font-size: 4rem; }
.classement { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; text-align: left; }
.classement li { display: flex; justify-content: space-between; padding: 6px 12px; border: 3px solid var(--encre); border-radius: 10px; font-weight: 800; background: var(--papier-2); }

/* Page élargie pour les jeux qui en ont besoin (dessin) */
main.large { max-width: 1120px; }

/* Gribouille */
.grib { display: grid; gap: 16px; }
@media (min-width: 900px) { .grib { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.grib-scene { display: grid; gap: 10px; padding: 14px; }
.grib-entete { display: flex; align-items: center; gap: 10px; min-height: 2.6rem; }
.grib-indice { flex: 1; text-align: center; font-weight: 800; font-size: 1.15rem; }
.grib-indice strong { font-size: 1.35rem; text-transform: uppercase; letter-spacing: .06em; }
.grib-secondes { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.grib-lettres { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.grib-lettres span { width: 1.15em; font-size: 1.5rem; font-weight: 900; text-transform: uppercase; line-height: 1.2; }
.grib-lettres .vide, .grib-lettres .lettre { border-bottom: 4px solid var(--encre); }
.grib-lettres .espace { width: .7em; }
.minuteur.urgent > i { background: var(--bombe); }
.grib-cadre { position: relative; }
.grib-toile {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; background: #fff;
  border: 3px solid var(--encre); border-radius: 12px; touch-action: none; user-select: none;
}
.grib-toile.dessinable { cursor: crosshair; }
.grib-toile.dessinable.pot { cursor: cell; }
.grib-outil[aria-pressed=true] { background: var(--soleil); }
.grib-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 12px;
  background: rgba(16, 21, 64, .55); border-radius: 12px;
}
.grib-bulle {
  background: var(--papier); border: 3px solid var(--encre); border-radius: var(--rayon);
  box-shadow: 5px 5px 0 var(--encre); padding: 16px 20px; text-align: center; display: grid; gap: 10px;
  font-weight: 800; max-width: 100%; max-height: 100%; overflow: auto;
}
.grib-choix { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.grib-mot-final { font-size: clamp(1.5rem, 6vw, 2.4rem); font-weight: 900; text-transform: uppercase; color: var(--fond); }
.grib-gains { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-width: 200px; }
.grib-gains li { display: flex; justify-content: space-between; gap: 12px; }
.grib-gains strong { color: #0b8a55; }
.grib-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.grib-couleur { width: 34px; height: 34px; padding: 0; border-radius: 10px; box-shadow: 2px 2px 0 var(--encre); }
.grib-couleur[aria-pressed=true] { outline: 4px solid var(--soleil); outline-offset: 1px; transform: translate(-1px, -1px); }
.grib-taille { width: 42px; height: 38px; padding: 0; display: grid; place-items: center; box-shadow: 2px 2px 0 var(--encre); }
.grib-taille span { display: block; background: var(--encre); border-radius: 50%; }
.grib-taille[aria-pressed=true] { background: var(--soleil); }
.grib-cote { display: grid; gap: 10px; padding: 14px; }
.grib-cote h3 { font-size: 1.05rem; }
.grib-chat {
  list-style: none; margin: 0; padding: 8px; height: 240px; overflow-y: auto; display: grid; align-content: start; gap: 4px;
  background: var(--papier-2); border: 3px solid var(--encre); border-radius: 12px; overflow-wrap: anywhere;
}
@media (min-width: 900px) { .grib-chat { height: 340px; } }
.grib-chat li { padding: 2px 4px; border-radius: 6px; }
.grib-chat li.trouve { background: #c9f5df; font-weight: 800; }
.grib-chat li.prive { background: #e3f9ee; }
.grib-chat li.systeme { color: var(--gris); font-style: italic; }
.grib-chat li.systeme.bilan { color: var(--encre); font-weight: 800; font-style: normal; }
.grib-chat li.systeme.presque { background: #fff3c4; color: var(--encre); font-weight: 800; font-style: normal; }
.grib-saisie { display: flex; gap: 8px; }
.grib-saisie input { flex: 1; min-width: 0; }
.grib-saisie button { padding: 10px 14px; }
.grib-joueurs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.grib-joueurs li {
  display: flex; gap: 6px; align-items: center; padding: 6px 10px; border: 3px solid var(--encre);
  border-radius: 10px; background: var(--papier-2); font-weight: 800;
}
.grib-joueurs li.moi { background: #fff3c4; }
.grib-joueurs li.trouve { background: #c9f5df; }
.grib-joueurs li.parti { opacity: .45; }
.grib-joueurs .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grib-joueurs .score { font-variant-numeric: tabular-nums; }

/* Caméléon (cartes) */
:root { --c-rouge: #ff4d3d; --c-jaune: #ffd23f; --c-vert: #2fd18b; --c-bleu: #3a86ff; }
.cam { gap: 12px; }
.cam-joueurs { position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.cam-joueurs li {
  display: flex; align-items: center; gap: 6px; padding: 5px 9px; border: 3px solid var(--encre); border-radius: 10px;
  background: var(--papier-2); font-weight: 800; font-size: .9rem; min-width: 0;
}
.cam-joueurs .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-joueurs .cam-nb { font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.mini-carte { display: inline-block; width: 11px; height: 15px; border: 2px solid var(--encre); border-radius: 3px; background: var(--fond); }
.cam-joueurs li.actif { background: var(--soleil); box-shadow: 3px 3px 0 var(--encre); }
.cam-joueurs li.moi { border-color: var(--bombe); }
.cam-joueurs li.une .cam-nb { color: var(--bombe); }
.cam-joueurs li.parti { opacity: .4; }
.cam-table { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 8px 0; }
.cam-infos { display: grid; gap: 6px; justify-items: start; }
.cam-pastille { font-weight: 900; padding: 4px 12px; border: 3px solid var(--encre); border-radius: 99px; text-transform: capitalize; }
.cam-pastille.rouge { background: var(--c-rouge); } .cam-pastille.jaune { background: var(--c-jaune); }
.cam-pastille.vert { background: var(--c-vert); } .cam-pastille.bleu { background: var(--c-bleu); }
.cam-pastille.penalite { background: var(--encre); color: #fff; text-transform: none; }
.cam-consigne { text-align: center; font-weight: 800; min-height: 1.4em; }
.cam-consigne.a-toi { color: var(--fond); font-size: 1.1rem; }
.cam-boutons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.cam-boutons:empty { display: none; }
.cam-derniere { background: var(--menthe); font-size: 1.1rem; }
.cam-choix { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; padding: 10px; border: 3px dashed var(--encre); border-radius: 12px; }
.cam-choix p { width: 100%; text-align: center; font-weight: 900; }
.cam-couleur { min-width: 88px; }
.cam-couleur.rouge { background: var(--c-rouge); } .cam-couleur.jaune { background: var(--c-jaune); }
.cam-couleur.vert { background: var(--c-vert); } .cam-couleur.bleu { background: var(--c-bleu); }

.carte-jeu {
  --taille: 72px;
  position: relative; width: var(--taille); aspect-ratio: 5 / 7; flex: none; padding: 0;
  border: 3px solid var(--encre); border-radius: 12px; box-shadow: 4px 4px 0 var(--encre);
  display: grid; place-items: center; font-weight: 900; color: var(--encre); background: var(--papier);
  overflow: hidden;
}
.carte-jeu.rouge { background: var(--c-rouge); } .carte-jeu.jaune { background: var(--c-jaune); }
.carte-jeu.vert { background: var(--c-vert); } .carte-jeu.bleu { background: var(--c-bleu); }
.carte-jeu.joker { background: conic-gradient(var(--c-rouge) 0 25%, var(--c-jaune) 0 50%, var(--c-vert) 0 75%, var(--c-bleu) 0); }
.carte-jeu .centre {
  display: grid; place-items: center; width: 74%; aspect-ratio: 1; border-radius: 50%; background: var(--papier);
  border: 3px solid var(--encre); font-size: calc(var(--taille) * .36); line-height: 1; transform: rotate(-8deg);
}
.carte-jeu .centre small { font-size: .5em; }
.carte-jeu .coin { position: absolute; top: 3px; left: 6px; font-size: calc(var(--taille) * .2); line-height: 1; }
.carte-jeu.dos { background: var(--encre); color: #fff; cursor: pointer; }
.carte-jeu.dos .centre { background: var(--fond); color: #fff; border-color: var(--papier); }
.carte-jeu.dos:disabled { opacity: 1; cursor: default; }
.carte-jeu.dos.invite { outline: 4px solid var(--soleil); outline-offset: 3px; }
.cam-compte { position: absolute; bottom: 3px; right: 6px; font-size: .75rem; }
.cam-defausse .carte-jeu { --taille: 96px; transform: rotate(4deg); }
.cam-main { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 6px; }
.cam-main .carte-jeu { cursor: pointer; transition: transform .1s; }
.cam-main.mon-tour .carte-jeu.jouable { transform: translateY(-6px); box-shadow: 4px 8px 0 var(--encre); }
.cam-main .carte-jeu.jouable:hover { transform: translateY(-10px); }
.cam-main .carte-jeu.terne { filter: saturate(.35) brightness(.92); }
.cam-main .carte-jeu.piochee { outline: 4px solid var(--soleil); outline-offset: 2px; }
@media (max-width: 600px) {
  .carte-jeu { --taille: 58px; border-radius: 10px; box-shadow: 3px 3px 0 var(--encre); }
  .cam-defausse .carte-jeu { --taille: 82px; }
  .cam-main { gap: 6px; }
  .cam-joueurs { display: flex; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
  .cam-joueurs li { flex: none; max-width: 136px; }
  .cam-table { gap: 14px; padding: 2px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cam-main .carte-jeu { transition: none; }
}

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--encre); color: #fff; border-radius: 12px; padding: 12px 18px; font-weight: 800; transition: transform .25s; z-index: 20; max-width: 90vw; }
#toast.visible { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .siege.actif, .bombe.urgent .corps, .explosion { animation: none; }
  button { transition: none; }
}
@media (max-width: 899px) { .grib-saisie { order: -1; } }
@media (max-width: 600px) {
  .grib-entete { flex-wrap: wrap; justify-content: space-between; }
  .grib-indice { order: 3; flex-basis: 100%; }
  .grib-bulle { padding: 10px 12px; gap: 8px; }
  .grib-bulle h3 { font-size: 1rem; }
  .grib-choix { gap: 8px; }
  .grib-choix button { padding: 8px 12px; font-size: .95rem; box-shadow: 3px 3px 0 var(--encre); }
  .grib-chat { height: 180px; }
  .grib-scene, .grib-cote { padding: 10px; }
}
