:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6a6f76;
  --line: #d8d6d0;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --edge: #2b2b2b;
  --pawn: #1f2328;
  --cross: rgba(0, 0, 0, .55);
  --conflict: #d6336c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b;
    --surface: #22242a;
    --text: #e8e8ea;
    --muted: #9a9ea6;
    --line: #3a3d44;
    --accent: #7a95ff;
    --accent-text: #10121a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
  display: flex; align-items: center; gap: 16px;
  max-width: 760px; margin: 0 auto; padding: 16px;
}
h1 { font-size: 1.35rem; margin: 0; flex: 1; letter-spacing: -.01em; }
h2 { margin-top: 0; }

button, select, input {
  font: inherit; color: inherit;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 6px 12px; min-height: 36px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.link { border: none; background: none; color: var(--accent); padding: 6px 4px; }
button.chip { font-family: ui-monospace, Consolas, monospace; padding: 2px 8px; min-height: 0; }

.controls {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end;
  max-width: 760px; margin: 0 auto; padding: 0 16px 8px;
}
.controls label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; }
.controls label select { color: var(--text); }
#form-id { display: flex; gap: 6px; margin-left: auto; }
#in-id { width: 12ch; text-transform: uppercase; font-family: ui-monospace, Consolas, monospace; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 32px; }
.info {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  color: var(--muted); font-size: .92rem; margin-bottom: 10px;
}
.info b { color: var(--text); }
.info .done { color: #2f9e44; }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.board-wrap { display: flex; justify-content: center; }
.board {
  --n: 5;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  width: min(100%, 560px);
  aspect-ratio: 1;
  border: 3px solid var(--edge);
  border-radius: 4px;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  background: var(--edge);
}
.board:empty { display: none; }
.cell {
  position: relative;
  background: var(--c);
  border: 0 solid var(--edge);
  border-right-width: 1px; border-bottom-width: 1px;
  border-right-color: rgba(0, 0, 0, .18); border-bottom-color: rgba(0, 0, 0, .18);
  display: grid; place-items: center;
  cursor: pointer;
}
.cell.er { border-right: 3px solid var(--edge); }
.cell.eb { border-bottom: 3px solid var(--edge); }
.cell.last-c { border-right-width: 0; }
.cell.last-r { border-bottom-width: 0; }
.cell:hover { filter: brightness(.95); }
.cell.x::after {
  content: ""; width: 30%; height: 30%;
  background:
    linear-gradient(45deg, transparent 43%, var(--cross) 43% 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--cross) 43% 57%, transparent 57%);
}
.cell.p::after {
  content: ""; width: 56%; height: 56%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a5f69, var(--pawn) 60%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .35);
}
.cell.p.bad::after { background: radial-gradient(circle at 35% 30%, #f06595, var(--conflict) 60%); }
.board.won .cell.p::after { background: radial-gradient(circle at 35% 30%, #69db7c, #2b8a3e 60%); }

.message { text-align: center; color: var(--muted); margin: 0 0 12px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.actions { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 0 16px 16px; }
td.hinted { color: var(--conflict); font-weight: 600; }
.hint { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; }

dialog {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  padding: 20px 22px; max-width: min(92vw, 640px);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.table-wrap { max-height: 60vh; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
td.id { font-family: ui-monospace, Consolas, monospace; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(127, 127, 127, .1); }

@media (max-width: 560px) {
  header { padding: 12px 16px; gap: 8px; }
  #form-id { margin-left: 0; }
  .cell.er { border-right-width: 2px; }
  .cell.eb { border-bottom-width: 2px; }
}

/* ---------- joueur, classements, profil ---------- */
nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
button.player { font-family: inherit; font-weight: 600; padding: 4px 10px; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.stats .timer { margin-left: 0; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; margin: 0; }
.error { color: var(--conflict); margin: 0; font-size: .9rem; }
.points { font-size: 2rem; font-weight: 700; margin: 4px 0; color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.stack label { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; color: var(--muted); }
.stack input { color: var(--text); }
.stack button { align-self: flex-start; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.board-table tr.me td { font-weight: 700; color: var(--accent); }
.board-table td:first-child, .board-table th:first-child { width: 2.5em; }
.board-table td.date { white-space: nowrap; }
.table-wrap.short { max-height: 32vh; }
.board.big { width: min(100%, 720px); }
.board.big .cell.er { border-right-width: 2px; }
.board.big .cell.eb { border-bottom-width: 2px; }
#dlg-profile { width: min(92vw, 440px); }
#dlg-board, #dlg-history { width: min(92vw, 640px); }
@media (max-width: 560px) {
  header { flex-wrap: wrap; }
  h1 { flex-basis: 100%; }
  nav { justify-content: flex-start; }
}

/* ---------- indices ---------- */
.hint-box {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--accent); border-left-width: 4px; border-radius: 8px;
  background: var(--surface);
}
.hint-box p { margin: 0; flex: 1; }
.hint-box.error { border-color: var(--conflict); }
.cell.h-focus { box-shadow: inset 0 0 0 3px var(--accent); }
.cell.h-cross { box-shadow: inset 0 0 0 3px #f59f00; }
.cell.h-error { box-shadow: inset 0 0 0 3px var(--conflict); }
.cell.h-pawn { box-shadow: inset 0 0 0 4px #2b8a3e; }
.board-filters { display: flex; gap: 12px; margin-bottom: 8px; }
.board-filters label { display: flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--muted); }
.board-filters select { color: var(--text); min-height: 30px; padding: 2px 8px; }
.board-table tbody tr.click { cursor: pointer; }
.board-table td.id { font-family: ui-monospace, Consolas, monospace; }
#dlg-board, #dlg-history { width: min(96vw, 820px); max-width: 96vw; }

/* ---------- mise en page : barre du haut + menu ---------- */
body { overscroll-behavior: none; }
header, .controls { display: none; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  max-width: 760px; margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px 6px;
}
.topbar .back { font-size: 1.8rem; line-height: 1; color: var(--muted); text-decoration: none; padding: 0 4px; }
.topbar .back:hover { color: var(--text); }
.topbar h1 { flex: 1; font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.icon { font-size: 1.3rem; line-height: 1; width: 42px; min-height: 40px; padding: 0; }
main { padding: 4px 16px max(24px, env(safe-area-inset-bottom)); }
.info { flex-wrap: nowrap; gap: 10px; margin-bottom: 8px; white-space: nowrap; overflow: hidden; }
.info .done { overflow: hidden; text-overflow: ellipsis; }
.stats { gap: 10px; }
.stats b { margin-left: 2px; }

/* La grille tient dans la hauteur de l'écran : la dernière rangée n'est jamais collée en bas */
.board { width: min(100%, 560px, calc(100vh - 200px)); width: min(100%, 560px, calc(100dvh - 200px)); }
.board.big { width: min(100%, 720px, calc(100vh - 200px)); width: min(100%, 720px, calc(100dvh - 200px)); }
.actions { margin-top: 12px; }
.actions button { min-height: 44px; padding: 8px 14px; }

/* Menu : panneau latéral */
dialog.drawer {
  margin: 0 0 0 auto; height: 100%; max-height: 100%;
  width: min(86vw, 340px); max-width: 86vw;
  border-radius: 0; border: none; border-left: 1px solid var(--line);
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 4px;
}
dialog.drawer:not([open]) { display: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.drawer-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-section { padding: 12px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.drawer-section h3 { margin: 0; font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.filters { display: flex; gap: 10px; }
.filters label { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.filters select { color: var(--text); width: 100%; }
button.wide { width: 100%; min-height: 44px; }
#form-id { display: flex; gap: 6px; margin: 0; }
#in-id { flex: 1; width: auto; }
.menu-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); padding-top: 8px; }
.menu-list button {
  text-align: left; border: none; background: none; border-radius: 8px;
  min-height: 46px; padding: 8px 10px; font-size: 1rem;
}
.menu-list button:hover, .menu-list button:focus-visible { background: rgba(127, 127, 127, .12); }
.menu-list button:disabled { opacity: .45; }
.version { margin-top: auto; text-align: center; color: var(--muted); font-size: .75rem; }

@media (max-width: 560px) {
  main { padding-left: 10px; padding-right: 10px; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .info { font-size: .85rem; gap: 8px; }
  .board { width: min(100%, calc(100vh - 190px)); width: min(100%, calc(100dvh - 190px)); }
  .actions { gap: 6px; }
  .actions button { flex: 1; padding: 8px 6px; }
  dialog:not(.drawer) { padding: 16px; }
}
.menu-list button { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; }
#in-id { min-width: 0; }
#form-id button { flex: none; }

/* ---------- filtres en boutons ---------- */
.pick { display: flex; flex-direction: column; gap: 4px; }
.pick-label { font-size: .8rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
button.pick-chip {
  min-height: 34px; min-width: 40px; padding: 4px 8px; font-size: .85rem;
  border-radius: 999px; font-variant-numeric: tabular-nums;
}
button.pick-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
button.pick-chip.all { font-weight: 600; }

/* ---------- calcul des points ---------- */
#dlg-points { max-width: 640px; }
.formula { font-weight: 600; text-align: center; font-size: 1.05rem; }
.coef-table { width: 100%; border-collapse: collapse; }
.coef-table th { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; white-space: nowrap; }
.coef-table td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.coef-table code { font-size: .9rem; }
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.calc label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.calc input, .calc select { width: 100%; color: var(--text); }
.calc-result { width: 100%; border-collapse: collapse; margin-top: 8px; }
.calc-result td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.calc-result td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-result tr.total td { font-weight: 700; border-bottom: none; }
.calc-grid { border-collapse: collapse; margin: 6px 0; font-size: .85rem; font-variant-numeric: tabular-nums; }
.calc-grid th, .calc-grid td { padding: 3px 7px; border: 1px solid var(--line); text-align: center; white-space: nowrap; }
.coef-table td, .coef-table code { white-space: normal; overflow-wrap: anywhere; }
#dlg-points { width: min(640px, calc(100vw - 24px)); }

/* =================== plateau : rendu soigné =================== */
:root {
  --edge: #262a33;
  --pawn-a: #4a5161;
  --pawn-b: #14171d;
  --ink: #2a2f3a;
}
@media (prefers-color-scheme: dark) {
  :root { --edge: #0c0d10; }
}

.board {
  border: 3px solid var(--edge);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 30px -10px rgba(20, 24, 33, .45), 0 2px 6px rgba(20, 24, 33, .15);
}
.cell {
  /* reflet doux en haut de chaque case */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 60%),
    var(--c);
  border-right-color: rgba(30, 35, 45, .14); border-bottom-color: rgba(30, 35, 45, .14);
  transition: background-color .2s;
}
.cell.er { border-right-color: var(--edge); }
.cell.eb { border-bottom-color: var(--edge); }
.cell:hover { filter: none; }
.cell::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background .12s;
  pointer-events: none;
}
@media (hover: hover) {
  .cell:hover::before { background: rgba(255, 255, 255, .28); }
}

/* Croix : deux traits arrondis, couleur foncée de la zone */
.cell.x::after {
  content: ""; width: 40%; height: 40%;
  background: var(--ink);
  background: color-mix(in oklab, var(--c) 32%, var(--ink));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 2L8 8M8 2L2 8' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 2L8 8M8 2L2 8' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .9;
  animation: cross-in .14s ease-out;
}

/* Pion : bille brillante avec reflet, ombre portée et liseré clair */
.cell.p::after {
  content: ""; width: 60%; height: 60%; border-radius: 50%;
  position: relative; z-index: 1;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .9) 0 7%, rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 50% 60%, var(--pawn-a) 0 35%, var(--pawn-b) 78%);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, .55),
    0 3px 6px rgba(0, 0, 0, .35),
    inset 0 -3px 6px rgba(0, 0, 0, .4);
  animation: pawn-in .22s cubic-bezier(.3, 1.6, .5, 1);
}
.cell.p.bad::after {
  --pawn-a: #ff7a96; --pawn-b: #b3163f;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .9) 0 7%, rgba(255, 255, 255, 0) 24%),
    radial-gradient(circle at 50% 60%, var(--pawn-a) 0 35%, var(--pawn-b) 78%);
  animation: pawn-in .22s cubic-bezier(.3, 1.6, .5, 1), pawn-bad 1.1s ease-in-out .22s infinite;
}
.board.won .cell.p::after {
  --pawn-a: #ffe066; --pawn-b: #d98b00;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .95) 0 8%, rgba(255, 255, 255, 0) 26%),
    radial-gradient(circle at 50% 60%, var(--pawn-a) 0 35%, var(--pawn-b) 80%);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, .7),
    0 0 14px rgba(255, 196, 0, .65),
    inset 0 -3px 6px rgba(120, 60, 0, .35);
  animation: pawn-win .7s ease calc(var(--d) * 1ms) both;
}
.board.won .cell { animation: cell-wave .8s ease calc(var(--d) * 1ms) both; }
.board.won { box-shadow: 0 12px 34px -8px rgba(217, 139, 0, .55), 0 2px 6px rgba(20, 24, 33, .15); }

/* Indices : contour arrondi au-dessus du reflet */
.cell.h-focus, .cell.h-cross, .cell.h-error, .cell.h-pawn { z-index: 1; }

@keyframes cross-in { from { transform: scale(.4); opacity: 0; } }
@keyframes pawn-in { from { transform: scale(.3); opacity: .2; } }
@keyframes pawn-bad {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 3px 6px rgba(0, 0, 0, .35), inset 0 -3px 6px rgba(0, 0, 0, .4); }
  50% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 0 0 6px rgba(214, 51, 108, .35), inset 0 -3px 6px rgba(0, 0, 0, .4); }
}
@keyframes pawn-win {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) translateY(-8%); }
  70% { transform: scale(.95); }
  100% { transform: scale(1); }
}
@keyframes cell-wave {
  0%, 100% { filter: none; }
  45% { filter: brightness(1.12) saturate(1.25); }
}
@media (prefers-reduced-motion: reduce) {
  .cell.x::after, .cell.p::after, .cell.p.bad::after, .board.won .cell, .board.won .cell.p::after { animation: none; }
}

/* =================== pions : un emoji d'animal (tiré au hasard à chaque partie) =================== */
.cell { container-type: size; }
.cell.p::after,
.cell.p.bad::after,
.board.won .cell.p::after {
  content: var(--animal, "🦊");
  width: 86%; height: 86%;
  display: grid; place-items: center;
  font-size: 64cqmin; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .55) 0 46%, rgba(255, 255, 255, 0) 70%);
  box-shadow: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3));
  animation: pawn-in .25s cubic-bezier(.3, 1.6, .5, 1);
}
/* conflit : halo rouge et petit tremblement */
.cell.p.bad::after {
  background: radial-gradient(circle, rgba(232, 48, 96, .6) 0 48%, rgba(232, 48, 96, 0) 72%);
  animation: pawn-in .25s cubic-bezier(.3, 1.6, .5, 1), pawn-shake 1.4s ease-in-out .25s infinite;
}
/* victoire : halo doré et saut en vague */
.board.won .cell.p::after {
  background: radial-gradient(circle, rgba(255, 214, 64, .9) 0 46%, rgba(255, 190, 0, 0) 74%);
  filter: drop-shadow(0 0 6px rgba(255, 190, 0, .8)) drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
  animation: pawn-win .7s ease calc(var(--d) * 1ms) both;
}
@keyframes pawn-shake {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-12deg); }
  80% { transform: rotate(10deg); }
  90% { transform: rotate(-6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .cell.p::after, .cell.p.bad::after, .board.won .cell.p::after { animation: none; }
}

/* ---------- erreurs : la case reste rouge jusqu'à la fin ---------- */
.cell.err::before,
.cell.err:hover::before {
  background:
    repeating-linear-gradient(135deg, rgba(224, 49, 49, .28) 0 4px, rgba(224, 49, 49, .12) 4px 8px);
  box-shadow: inset 0 0 0 2px rgba(201, 42, 42, .85);
}
#errors-stat.has { color: var(--conflict); }
#errors-stat.has b { color: var(--conflict); }

/* ---------- indice par l'absurde : étapes numérotées et pions supposés en transparence ---------- */
.hint-steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 3px; }
.hint-steps li:first-child, .hint-steps li:last-child { font-weight: 600; }
.cell.h-ghost::after {
  content: var(--animal, "🦊");
  font-size: 56cqmin; line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  opacity: .45; filter: grayscale(.3);
}
.cell.h-ghost { box-shadow: inset 0 0 0 2px rgba(59, 91, 219, .55); z-index: 1; }

/* case d'erreur dont le pion a été enlevé : croix rouge, sans hachures */
.cell.err.x::before,
.cell.err.x:hover::before { background: rgba(224, 49, 49, .14); }
.cell.err.x::after { background: #e03131; }

/* ---------- réglages ---------- */
.stack label.check { flex-direction: row; align-items: center; gap: 8px; font-size: .95rem; color: var(--text); }
.stack label.check input { width: 18px; height: 18px; }
.board-filters { flex-wrap: wrap; }

/* ---------- visionneuse de partie ---------- */
.replay { margin: 14px auto 0; max-width: 560px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 10px 12px; }
.replay-head { font-size: .92rem; margin-bottom: 6px; }
.replay-head span { color: var(--muted); }
.replay-signals { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.signal { font-size: .8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.signal.w-fort { border-color: var(--conflict); color: var(--conflict); font-weight: 600; }
.signal.w-moyen { border-color: #e8a33d; color: #b7791f; }
.replay-controls { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 6px 0; }
.rp-pos { min-width: 70px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.replay-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rp-item { display: grid; grid-template-columns: 2.6em 3.6em 3.6em 1fr; gap: 6px; width: 100%; text-align: left;
  border: 0; border-radius: 0; background: none; padding: 4px 6px; font-size: .86rem; cursor: pointer; color: inherit; }
.rp-item:hover { background: rgba(127, 127, 127, .08); }
.rp-item.current { background: rgba(59, 91, 219, .14); }
.rp-item.flag .rp-l { color: var(--conflict); font-weight: 600; }
.rp-item.k-pause .rp-l, .rp-item.k-resume .rp-l { color: var(--muted); font-style: italic; }
.rp-n, .rp-t, .rp-w { font-variant-numeric: tabular-nums; color: var(--muted); }
.rp-w { font-size: .78rem; opacity: .8; }
.replay-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.replay-actions #review-actions { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.replay-actions input { flex: 1; min-width: 120px; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--conflict);
  color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4em; margin-left: 4px; }
#btn-menu { position: relative; }
#btn-menu .badge { position: absolute; top: -4px; right: -6px; margin: 0; }
.signals-cell { white-space: normal; min-width: 220px; font-size: .82rem; }

/* =================== rangée des couleurs : l'animal s'affiche quand la couleur a son pion =================== */
.color-bar { display: flex; justify-content: center; gap: 4px; margin: 0 auto 8px; max-width: 560px; }
.color-bar .swatch {
  flex: 0 1 30px; min-width: 0; aspect-ratio: 1; max-height: 30px; border-radius: 6px;
  background: var(--c); border: 2px solid rgba(30, 35, 45, .18);
  display: flex; align-items: center; justify-content: center; font-size: clamp(.7rem, 3.2vw, 1.05rem); line-height: 1;
}
.color-bar .swatch.on::after { content: var(--animal, "🦊"); }
.color-bar .swatch.bad { border-color: var(--conflict); box-shadow: 0 0 0 1px var(--conflict); }
.color-bar.won .swatch { border-color: #2b8a3e; }
.board { width: min(100%, 560px, calc(100vh - 240px)); width: min(100%, 560px, calc(100dvh - 240px)); }
.board.big { width: min(100%, 720px, calc(100vh - 240px)); width: min(100%, 720px, calc(100dvh - 240px)); }
@media (max-width: 560px) {
  .board { width: min(100%, calc(100vh - 226px)); width: min(100%, calc(100dvh - 226px)); }
  .color-bar { gap: 3px; margin-bottom: 6px; }
}

/* Bouton de fermeture toujours visible dans les fenêtres longues (règles…) */
dialog:not(.drawer) .dlg-actions {
  position: sticky; bottom: -20px; z-index: 1; margin: 16px -22px -20px; padding: 10px 22px;
  background: var(--surface); border-top: 1px solid var(--line);
}
@media (max-width: 560px) {
  dialog:not(.drawer) .dlg-actions { bottom: -16px; margin: 16px -16px -16px; padding: 10px 16px; }
}
.status-validated { color: #2b8a3e; font-weight: 600; }
.status-rejected { color: var(--conflict); font-weight: 600; }
