/* ==========================================================================
   Qui a dit ça ? — direction artistique
   Plateau violet, couleurs pleines, ombres dures : tout ce qui se touche a
   l'air d'un gros bouton de jeu. Chaque joueur = une forme + une couleur.
   Le blanc est réservé à ce qu'on lit (anecdotes, champs, classements).
   ========================================================================== */

@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/baloo-2-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --plateau: #43179a;
  --plateau-deep: #2b0c66;
  --plateau-light: #5a2bb8;
  --ink: #22103f;
  --ink-soft: #6b5a8e;
  --paper: #fff;
  --mist: #efe9fb;
  --mist-strong: #d9cef5;
  --ok: #179457;
  --ok-dark: #0f6b3e;
  --ko: #e8354f;
  --ko-dark: #b01f37;
  --go: #ffc21a;
  --go-dark: #c98f00;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 28px;
  --drop: 0 6px 0 rgb(20 4 60 / 0.35); /* ombre dure des surfaces blanches */

  --font: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: dark;
}

/* Couleurs des joueurs (--tile), leur bord 3D (--tile-dark) et le texte posé dessus (--on) */
.c0 { --tile: #e8354f; --tile-dark: #b01f37; --on: #fff; }
.c1 { --tile: #1c6fe0; --tile-dark: #1250a6; --on: #fff; }
.c2 { --tile: #ffc21a; --tile-dark: #c98f00; --on: #22103f; }
.c3 { --tile: #179457; --tile-dark: #0f6b3e; --on: #fff; }
.c4 { --tile: #d6339f; --tile-dark: #a01f76; --on: #fff; }
.c5 { --tile: #0e8c9a; --tile-dark: #086570; --on: #fff; }
.c6 { --tile: #f26b1d; --tile-dark: #bf4e0c; --on: #fff; }
.c7 { --tile: #7b55e0; --tile-dark: #5836b3; --on: #fff; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: #fff;
  background-color: var(--plateau);
  /* Grandes formes en filigrane : le plateau de jeu */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.06' stroke-width='12' stroke-linejoin='round'%3E%3Cpath d='M70 40 125 135H15Z'/%3E%3Crect x='265' y='55' width='90' height='90' rx='10' transform='rotate(14 310 100)'/%3E%3Ccircle cx='105' cy='300' r='52'/%3E%3Cpath d='M315 235 370 290 315 345 260 290Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 420px;
  background-attachment: fixed;
}

h1, h2, h3 { margin: 0 0 0.4rem; line-height: 1.15; font-weight: 800; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.5rem; }
small { font-size: 0.85rem; }

.hint { color: var(--ink-soft); }
.soft { color: var(--mist-strong); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 0.75rem; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 0.75rem; }

:focus-visible { outline: 3px solid var(--go); outline-offset: 3px; }

/* ------------------------------------------------------------ Mise en page */

#layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

#screen { display: grid; gap: 1.1rem; max-width: 640px; margin: 0 auto; width: 100%; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--plateau-deep);
}
#topbar[hidden] { display: none; }

.code-pill {
  padding: 0.15rem 0.8rem;
  border-radius: 99px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.code-pill b { color: var(--plateau); font-size: 1.05rem; font-weight: 800; letter-spacing: 0.08em; }
.topbar-round {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--mist-strong);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { display: flex; gap: 0.4rem; }
/* Sur petit écran, l'en-tête de chaque phase suffit à se repérer */
@media (max-width: 480px) { .topbar-round { visibility: hidden; } }

/* Scores : panneau qui glisse depuis le bas sur mobile */
#scoreboard {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-height: 70dvh;
  overflow-y: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  box-shadow: 0 -10px 30px rgb(20 4 60 / 0.45);
  transform: translateY(105%);
  transition: transform 0.25s ease;
}
body.show-scores #scoreboard { transform: none; }
#scoreboard[hidden] { display: none; }
#scoreboard h3 { color: var(--plateau); }

/* Grand écran : les scores deviennent une sidebar toujours visible */
@media (min-width: 900px) {
  body.in-room #layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
  #scoreboard {
    position: sticky; top: 4.2rem; transform: none;
    max-height: none; border-radius: var(--radius-m); box-shadow: var(--drop);
  }
  #toggle-scores { display: none; }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
  padding: 0.7rem 1.4rem;
  border: 0;
  border-radius: var(--radius-s);
  font: 800 1.15rem/1 var(--font);
  color: var(--btn-on, #fff);
  background: var(--btn, var(--plateau-light));
  box-shadow: 0 5px 0 var(--btn-dark, var(--plateau-deep));
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--btn-dark, var(--plateau-deep)); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-go { --btn: var(--go); --btn-dark: var(--go-dark); --btn-on: var(--ink); }
.btn-ink { --btn: var(--plateau); --btn-dark: var(--plateau-deep); }
.btn-flat {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
  background: rgb(255 255 255 / 0.14);
  box-shadow: none;
}
.btn-flat:active:not(:disabled) { transform: none; box-shadow: none; background: rgb(255 255 255 / 0.24); }
.btn.block { width: 100%; }
.btn.big { min-height: 62px; font-size: 1.3rem; }

/* --------------------------------------------------- Jetons des joueurs */
/* Carré arrondi de la couleur du joueur, avec sa forme en blanc dessus */

.token {
  --t: 2rem;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--t);
  height: var(--t);
  border-radius: 24%;
  background: var(--tile, var(--mist-strong));
}
.token i { display: block; width: 58%; height: 58%; background: var(--on, #fff); }
.s0 i { clip-path: polygon(50% 8%, 96% 90%, 4% 90%); }
.s1 i { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.s2 i { border-radius: 50%; }
.s3 i { width: 48%; height: 48%; border-radius: 10%; }
.token.ghost i { opacity: 0; }
.token.mystery { background: var(--plateau-deep); box-shadow: inset 0 0 0 3px rgb(255 255 255 / 0.35); }
.token.mystery i {
  width: auto; height: auto; background: none;
  font-style: normal; font-weight: 800; font-size: calc(var(--t) * 0.62); line-height: 1; color: #fff;
}

/* ------------------------------------------------------- Surfaces */

.panel {
  padding: 1.2rem;
  border-radius: var(--radius-m);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--drop);
}
.panel h2, .panel h3 { color: var(--plateau); }

.screen-title { text-align: center; font-size: 2.2rem; }

/* Disques timer / compteur, façon plateau de quiz */
.phase-header { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 0.75rem; }
.phase-title { margin: 0; text-align: center; font-size: clamp(1.1rem, 4.6vw, 1.4rem); }
.disc {
  display: grid;
  place-items: center;
  align-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--plateau-deep);
  box-shadow: 0 4px 0 rgb(0 0 0 / 0.25);
}
.disc .timer { font-size: 1.7rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.disc.counter b { font-size: 1.25rem; line-height: 1; }
.disc.counter small { font-size: 0.7rem; color: var(--mist-strong); }
.disc[hidden] { display: none; }
.timer.urgent { color: var(--go); animation: pulse 1s infinite; }
.timer.inline { font-weight: 800; }

/* Bulle de l'anecdote : c'est la "question" du jeu */
.bubble {
  position: relative;
  margin: 0 0 0.4rem;
  padding: 1.3rem 1.5rem;
  border-radius: var(--radius-l);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--drop);
}
.bubble::after {
  content: "";
  position: absolute;
  left: 2.3rem;
  bottom: -24px;
  width: 38px;
  height: 28px;
  background: var(--paper);
  clip-path: polygon(0 0, 100% 0, 8% 100%);
}
.bubble blockquote {
  margin: 0;
  font-size: clamp(1.3rem, 4.6vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  quotes: "«\00a0" "\00a0»";
}
.bubble blockquote::before { content: open-quote; }
.bubble blockquote::after { content: close-quote; }
.bubble.big blockquote { font-size: clamp(1.6rem, 6.4vw, 2.4rem); }

/* L'"orateur" de la bulle : "?" jusqu'à la révélation */
.speaker {
  --t: 3rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}
.speaker .token { --t: 3rem; }
.speaker-name { font-size: 1.6rem; font-weight: 800; }
.flip { display: inline-block; animation: flip 0.8s 0.25s cubic-bezier(0.3, 1.5, 0.5, 1) both; }

/* Écran d'attente plein cadre */
.wait-screen { padding: 2rem 1rem; text-align: center; }
.wait-screen .token { --t: 5rem; margin-bottom: 1rem; animation: bob 1.6s ease-in-out infinite; }
.wait-screen h2 { font-size: 1.8rem; }

.continue-note { color: var(--mist-strong); text-align: center; font-size: 0.95rem; margin-top: 0.6rem; }
.badge {
  justify-self: center;
  padding: 0.3rem 0.9rem;
  border-radius: 99px;
  background: var(--go);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}

/* Progression de l'écriture quand chacun a plusieurs anecdotes à écrire */
#write-zone .row h2 { margin: 0; }
.dots { display: flex; flex: none; gap: 0.35rem; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--mist-strong); }
.dots i.on { background: var(--ok); }

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

.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; font-weight: 700; }

input, textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid transparent;
  border-radius: var(--radius-s);
  font: 600 17px/1.4 var(--font); /* 16px min : pas de zoom automatique sur iOS */
  color: var(--ink);
  background: var(--mist);
}
input::placeholder, textarea::placeholder { color: #9d90b8; }
input:focus, textarea:focus { outline: none; border-color: var(--plateau); }
textarea { resize: vertical; margin: 0.4rem 0 0.6rem; }
.code-input { text-align: center; text-transform: uppercase; letter-spacing: 0.3em; font-size: 1.5rem; font-weight: 800; }

.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.2rem 0; color: var(--ink-soft); font-weight: 600; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--mist-strong); }

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

.brand { padding: 1.5rem 0 0.8rem; text-align: center; }
.brand-tokens { display: flex; justify-content: center; gap: 0.45rem; margin-bottom: 1.2rem; }
.brand-tokens .token { --t: 1.9rem; }
.logo-bubble {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0.75rem 1.4rem 0.9rem;
  border-radius: var(--radius-l);
  background: var(--paper);
  color: var(--plateau);
  font-size: clamp(2.3rem, 11vw, 3.4rem);
  line-height: 1;
  transform: rotate(-3deg);
  box-shadow: 0 8px 0 var(--plateau-deep);
}
.logo-bubble::after {
  content: "";
  position: absolute;
  left: 1.8rem;
  bottom: -22px;
  width: 34px;
  height: 26px;
  background: var(--paper);
  clip-path: polygon(0 0, 100% 0, 8% 100%);
}
.tagline { max-width: 30rem; margin: 2rem auto 0; color: var(--mist-strong); font-size: 1.1rem; }
.join-panel { width: 100%; max-width: 440px; margin: 0 auto; }

/* ------------------------------------------------------------ Lobby */

.pin-panel {
  padding: 1.1rem 1.2rem 1.4rem;
  border-radius: var(--radius-m);
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--drop);
}
.pin-panel p { margin: 0; font-weight: 700; }
.room-code {
  margin: 0.1rem 0 0.9rem;
  color: var(--plateau);
  font-size: clamp(3.2rem, 17vw, 4.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
}

.stage-title { display: flex; align-items: center; gap: 0.6rem; }
.count { padding: 0.05rem 0.6rem; border-radius: 99px; background: var(--plateau-deep); font-size: 1rem; }

.player-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem 0.4rem 0.45rem;
  border-radius: var(--radius-s);
  background: var(--tile);
  color: var(--on);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--tile-dark);
}
.chip .token { --t: 1.9rem; background: transparent; }
.chip small { font-weight: 600; opacity: 0.85; }
.chip.me { outline: 3px solid #fff; outline-offset: 2px; }
.chip.new { animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both; }

.settings { display: grid; gap: 1.1rem; margin-top: 0.8rem; }
.setting { display: grid; gap: 0.35rem; }
.setting-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-weight: 700; }
.setting-head b { color: var(--plateau); white-space: nowrap; }
.setting small { line-height: 1.3; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  margin: 0.5rem 0;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: var(--mist-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--plateau);
  box-shadow: 0 2px 0 var(--plateau-deep), 0 0 0 1px var(--mist-strong);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--plateau);
  box-shadow: 0 2px 0 var(--plateau-deep);
  cursor: pointer;
}

/* Interrupteurs */
.switch input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 54px; height: 30px;
  margin: 0; padding: 0;
  border-radius: 99px;
  background: var(--mist-strong);
  cursor: pointer;
  transition: background 0.2s;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.15);
  transition: transform 0.2s;
}
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(24px); }

/* --------------------------------------------------- Tuiles de vote */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 0.7rem; }
.tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 78px;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--tile);
  color: var(--on);
  font: 800 1.25rem/1.1 var(--font);
  text-align: left;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 0 var(--tile-dark);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.tile .token { --t: 2.5rem; background: transparent; }
.tile:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--tile-dark); }
.tile:disabled { cursor: default; }
.tiles.locked .tile:not(.selected) { opacity: 0.3; }
.tile.selected { outline: 4px solid #fff; outline-offset: 3px; }

/* ------------------------------------------------------- Révélation */

.result-banner {
  display: grid;
  gap: 0.1rem;
  margin: -1rem -1rem 0.2rem;
  padding: 1.1rem 1rem 1.2rem;
  text-align: center;
  background: var(--ok);
  box-shadow: 0 6px 0 var(--ok-dark);
  animation: drop 0.55s cubic-bezier(0.25, 1.5, 0.5, 1) both;
}
.result-banner.ko { background: var(--ko); box-shadow: 0 6px 0 var(--ko-dark); }
.result-banner.neutral { background: var(--plateau-deep); box-shadow: none; }
.result-banner b { font-size: 2.3rem; font-weight: 800; line-height: 1.05; }
.result-banner span { font-size: 1.1rem; font-weight: 700; }
@media (min-width: 700px) { .result-banner { margin: 0; border-radius: var(--radius-m); } }

.vote-list { display: grid; gap: 0.45rem; margin: 0.4rem 0 0; padding: 0; list-style: none; }
.vote-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-s);
  background: var(--mist);
}
.vote-list .token { --t: 1.5rem; }
.vote-list .verdict { margin-left: auto; font-weight: 800; }
.vote-list li.ok .verdict { color: var(--ok); }
.vote-list li.ko .verdict { color: var(--ko); }

/* --------------------------------------------------------- Classements */

.ranking, .score-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.ranking li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 4px 0 rgb(20 4 60 / 0.3);
}
.ranking .rank { width: 1.4rem; color: var(--plateau); font-weight: 800; }
.ranking .name, .score-list .name { flex: 1; overflow-wrap: anywhere; }
.ranking .pts { font-weight: 800; }
.ranking li.me { outline: 3px solid var(--go); outline-offset: 2px; }

.score-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-s);
  background: var(--mist);
  font-weight: 700;
}
.score-list .token { --t: 1.6rem; }
.score-list small { color: var(--ink-soft); font-weight: 600; }
.score-list li.me { outline: 2px solid var(--plateau); }
.score-list .done { color: var(--ink-soft); }
.score-list .done.yes { color: var(--ok); font-weight: 800; }
.score-list .score { min-width: 1.5rem; text-align: right; font-weight: 800; }

/* Podium : les marches prennent la couleur du joueur */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 0.6rem; padding-top: 0.5rem; }
.podium-step { flex: 1; max-width: 160px; text-align: center; animation: rise 0.7s cubic-bezier(0.25, 1.3, 0.5, 1) both; }
.podium-step .token { --t: 3.2rem; margin-bottom: 0.35rem; box-shadow: 0 4px 0 var(--tile-dark); }
.podium-name { font-size: 1.15rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.podium-score { margin-bottom: 0.4rem; color: var(--mist-strong); font-weight: 600; }
.podium-block {
  display: grid;
  place-items: center;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  background: var(--tile);
  color: var(--on);
  font-size: 2.8rem;
  font-weight: 800;
  box-shadow: inset 0 -10px 0 var(--tile-dark);
}
.step-1 .podium-block { height: 160px; }
.step-2 .podium-block { height: 115px; }
.step-3 .podium-block { height: 80px; }
.step-3 { animation-delay: 0.2s; }
.step-2 { animation-delay: 0.5s; }
.step-1 { animation-delay: 0.9s; }
.podium-step.me .podium-name { color: var(--go); }

/* ------------------------------------------------------- Manche bonus */

.options { display: grid; gap: 0.9rem; }
.option {
  display: grid;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  box-shadow: var(--drop);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.option:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgb(20 4 60 / 0.35); }
.option:disabled { cursor: default; }
.option blockquote { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.3; quotes: "«\00a0" "\00a0»"; }
.option blockquote::before { content: open-quote; }
.option blockquote::after { content: close-quote; }
.by { display: flex; align-items: center; gap: 0.45rem; color: var(--ink-soft); font-weight: 700; }
.by .token { --t: 1.5rem; }
.option.mine, .options.locked .option:not(.selected) { opacity: 0.45; }
.option.selected { outline: 4px solid var(--go); outline-offset: 3px; }

.tally { display: grid; gap: 0.7rem; }
.tally-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.8rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 rgb(20 4 60 / 0.3);
  transition: opacity 0.4s;
}
.tally-text { grid-column: 1 / -1; font-weight: 700; line-height: 1.3; }
.tally-text .by { margin-top: 0.3rem; font-size: 0.9rem; }
.tally-bar { height: 16px; overflow: hidden; border-radius: 99px; background: var(--mist); }
.tally-bar span { display: block; width: 0; height: 100%; background: var(--tile, var(--plateau)); transition: width 0.45s cubic-bezier(0.25, 1.3, 0.5, 1); }
.tally-count { min-width: 1.6rem; text-align: right; font-size: 1.4rem; font-weight: 800; }
.tally-row.bump .tally-count { animation: pop 0.4s ease; }
.tally-row.won { outline: 4px solid var(--go); outline-offset: 2px; }
.tally-row.lost { opacity: 0.6; }
#winner { display: grid; gap: 0.8rem; }

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

#toasts {
  position: fixed;
  top: 4rem; left: 50%;
  z-index: 50;
  display: grid;
  gap: 0.5rem;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 5px 0 var(--plateau-deep);
  animation: drop 0.3s ease both;
  transition: opacity 0.4s;
}
.toast.error { background: var(--ko); color: #fff; box-shadow: 0 5px 0 var(--ko-dark); }
.toast.hide { opacity: 0; }

/* --------------------------------------------------------- Animations */

@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
@keyframes flip { from { transform: rotateY(90deg) scale(0.6); } to { transform: none; } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes pulse { 50% { opacity: 0.45; } }

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