/* ===== Jetons ===== */
:root {
  --bg: #edf0fa;
  --surface: #ffffff;
  --surface-2: #f5f6fc;
  --ink: #1d1a3f;
  --muted: #5d5a7e;
  --line: #d8dbec;
  --royal: #2f4bd8;
  --royal-deep: #1f35a8;
  --royal-ink: #ffffff;
  --sun: #ffc53d;
  --sun-deep: #d99a00;
  --berry: #e0446a;
  --mint: #16a673;
  --shadow: 0 1px 0 rgba(29, 26, 63, .06), 0 8px 24px -12px rgba(29, 26, 63, .28);
  --font-display: "Bricolage Grotesque", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141230; --surface: #1e1b3e; --surface-2: #26234a; --ink: #eeebff; --muted: #aaa6d2; --line: #37335f;
    --royal: #7086ff; --royal-deep: #4b5fd6; --royal-ink: #0f0d26; --sun: #ffd45e; --sun-deep: #c99a1c;
    --berry: #ff6f8e; --mint: #3dd49b; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141230; --surface: #1e1b3e; --surface-2: #26234a; --ink: #eeebff; --muted: #aaa6d2; --line: #37335f;
  --royal: #7086ff; --royal-deep: #4b5fd6; --royal-ink: #0f0d26; --sun: #ffd45e; --sun-deep: #c99a1c;
  --berry: #ff6f8e; --mint: #3dd49b; --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ===== Base ===== */
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.45;
  background-image:
    linear-gradient(45deg, rgba(47, 75, 216, .035) 25%, transparent 25%, transparent 75%, rgba(47, 75, 216, .035) 75%),
    linear-gradient(45deg, rgba(47, 75, 216, .035) 25%, transparent 25%, transparent 75%, rgba(47, 75, 216, .035) 75%);
  background-size: 64px 64px; background-position: 0 0, 32px 32px;
}
button { font: inherit; color: inherit; }
img, svg, canvas { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

.app { max-width: 1180px; margin: 0 auto; padding: 14px clamp(12px, 3vw, 28px) 28px; }
.screen { display: none; }
.screen.active { display: block; animation: screen-in .28s ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Boutons « à socle » ===== */
.btn {
  --b: var(--surface); --bd: var(--line); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: .55em 1.1em; border-radius: 999px;
  background: var(--b); color: var(--fg); border: 2px solid var(--bd);
  box-shadow: 0 3px 0 var(--bd); font-weight: 700; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s;
  -webkit-tap-highlight-color: transparent; user-select: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--bd); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 0 3px 0 var(--bd); }
.btn-primary { --b: var(--royal); --bd: var(--royal-deep); --fg: var(--royal-ink); }
.btn-sun { --b: var(--sun); --bd: var(--sun-deep); --fg: #2a1f00; }
.btn-danger { --b: var(--surface); --bd: var(--berry); --fg: var(--berry); }
.btn-small { min-height: 38px; padding: .35em .9em; font-size: .92rem; }
.btn-wide { width: 100%; }
.btn .ico { width: 1.25em; height: 1.25em; flex: none; }
.link { background: none; border: 0; padding: .3em .2em; color: var(--royal); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 5px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: .5em .9em; border-radius: 11px; font-weight: 700; cursor: pointer; color: var(--muted); min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--line), 0 0 0 2px var(--royal) inset; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; cursor: pointer; }
.toggle input { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.toggle input:checked { background: var(--mint); }
.toggle input:checked::after { transform: translateX(20px); }

/* ===== Barre du haut ===== */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 48px; }
.topbar h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; box-shadow: 0 3px 0 var(--line); flex: none; }
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn svg { width: 22px; height: 22px; }

/* ===== Accueil ===== */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(18px, 4vw, 48px); align-items: center; padding: clamp(8px, 3vw, 28px) 0 clamp(18px, 3vw, 30px); }
.wordmark { padding-top: .2em; font-family: var(--font-display); font-weight: 800; font-size: clamp(3.2rem, 11vw, 7.4rem); line-height: .86; letter-spacing: -0.045em; margin: 0; color: var(--ink); }
.wordmark .acc { display: inline-block; color: var(--royal); transform: translateY(-.04em) rotate(-6deg); }
.tagline { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.1rem, 2.6vw, 1.5rem); color: var(--muted); margin-top: 14px; max-width: 30ch; }
.hero-strip { display: grid; grid-template-columns: repeat(6, 1fr); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); max-width: 460px; justify-self: end; width: 100%; }
.hero-strip .sq { aspect-ratio: 1; display: grid; place-items: center; }
.hero-strip .piece { position: static; width: 92%; height: 92%; transform: none; animation: wave .7s cubic-bezier(.3,1.6,.5,1) both; }
.hero-strip .sq:nth-child(2) .piece { animation-delay: .08s; } .hero-strip .sq:nth-child(3) .piece { animation-delay: .16s; }
.hero-strip .sq:nth-child(4) .piece { animation-delay: .24s; } .hero-strip .sq:nth-child(5) .piece { animation-delay: .32s; }
.hero-strip .sq:nth-child(6) .piece { animation-delay: .4s; }
@keyframes wave { 0% { transform: translateY(40%) scale(.6); opacity: 0; } 60% { transform: translateY(-14%) scale(1.05); opacity: 1; } 100% { transform: none; } }

.home-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mode {
  position: relative; display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 14px;
  text-align: left; padding: 16px 18px; border-radius: 20px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line);
  transition: transform .1s ease, box-shadow .1s ease, border-color .15s;
}
.mode:hover { border-color: var(--royal); }
.mode:active { transform: translateY(4px); box-shadow: none; }
.mode .m-ico { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); }
.mode .m-ico .piece { position: static; width: 54px; height: 54px; transform: none; }
.mode h3 { font-size: 1.22rem; }
.mode p { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.mode.primary { grid-column: 1 / -1; padding: 20px 22px; background: var(--royal); border-color: var(--royal-deep); box-shadow: 0 5px 0 var(--royal-deep); color: var(--royal-ink); grid-template-columns: 76px 1fr auto; }
.mode.primary p { color: inherit; opacity: .85; }
.mode.primary .m-ico { width: 76px; height: 76px; background: rgba(255,255,255,.16); }
.mode.primary .m-ico .piece { width: 64px; height: 64px; }
.mode.primary h3 { font-size: 1.5rem; }
.opp-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 14px; background: rgba(255,255,255,.16); font-weight: 700; font-size: .92rem; }
.opp-chip .emo { font-size: 1.5rem; line-height: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.player-card h3 { font-size: 1.35rem; }
.player-card .rank-sub { color: var(--muted); font-size: .92rem; }
.xpbar { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: 12px 0 6px; }
.xpbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), #ff9f43); border-radius: 999px; transition: width .6s ease; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px; text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.35rem; }
.stat span { font-size: .8rem; color: var(--muted); }
.home-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.stars { color: var(--sun-deep); letter-spacing: 1px; white-space: nowrap; }
:root[data-theme="dark"] .stars { color: var(--sun); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stars { color: var(--sun); } }
.stars .off { opacity: .25; }

/* ===== Réglages de partie ===== */
.setup { display: grid; gap: 16px; max-width: 760px; }
.field h3 { font-size: 1.08rem; margin-bottom: 8px; font-family: var(--font-ui); font-weight: 700; }
.field .hint { color: var(--muted); font-size: .9rem; margin-top: 6px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice { text-align: left; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.choice[aria-pressed="true"] { border-color: var(--royal); box-shadow: 0 3px 0 var(--royal-deep); }
.choice b { display: block; font-size: 1rem; }
.choice span { display: block; color: var(--muted); font-size: .86rem; margin-top: 2px; line-height: 1.35; }
.choice .emo { font-size: 1.6rem; display: block; margin-bottom: 4px; }

/* ===== Écran de partie ===== */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.board-col { width: min(100%, calc(100vh - 190px)); min-width: 280px; justify-self: center; }
@supports (height: 100dvh) { .board-col { width: min(100%, calc(100dvh - 190px)); } }
.pbar { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 2px; }
.pbar .av { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); font-size: 1.4rem; flex: none; }
.pbar .who { flex: 1; min-width: 0; }
.pbar .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar .who small { color: var(--muted); display: flex; align-items: center; gap: 6px; min-height: 1.2em; }
.pbar.turn .av { border-color: var(--royal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--royal) 30%, transparent); }
.captured { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0; }
.captured .piece { position: static; width: 18px; height: 18px; transform: none; margin-right: -5px; }
.captured .adv { margin-left: 8px; font-weight: 700; color: var(--muted); font-size: .85rem; }
.clock { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; padding: 4px 12px; border-radius: 12px; background: var(--surface); border: 2px solid var(--line); min-width: 84px; text-align: center; font-variant-numeric: tabular-nums; }
.clock.run { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.clock.low { background: var(--berry); color: #fff; border-color: var(--berry); }

.side { display: grid; gap: 14px; }
.coach { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.owl { width: 64px; height: 64px; }
.owl .lid { transform-box: fill-box; transform-origin: center; transform: scaleY(0); }
.owl.blink .lid { animation: blink .18s ease 2; }
@keyframes blink { 50% { transform: scaleY(1); } }
.owl.happy .pupil { transform: translateY(-1px); }
.owl.worried .brow { opacity: 1; }
.owl .brow { opacity: 0; transition: opacity .2s; }
.bubble { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 10px 14px; min-height: 64px; display: flex; align-items: center; font-size: .98rem; }
.bubble::before { content: ""; position: absolute; left: -9px; top: 20px; width: 14px; height: 14px; background: var(--surface); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(45deg); }
.bubble.warn { border-color: var(--berry); }
.bubble.warn::before { border-color: var(--berry); }
.bubble.good { border-color: var(--mint); }
.bubble.good::before { border-color: var(--mint); }
.bubble.pop { animation: bubble-pop .3s ease; }
/* Bulle d'un événement passé (version web : effacée au coup suivant) : rien à dire, rien d'affiché. */
.bubble:empty { visibility: hidden; }
.pseudo-requis { margin: 0; font-weight: 700; color: var(--ink); }
@keyframes bubble-pop { 0% { transform: scale(.96); } 60% { transform: scale(1.02); } 100% { transform: none; } }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions .btn { min-width: 0; }
.status-line { font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 28px; }
.dot-turn { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.dot-turn.w { background: #fff; } .dot-turn.b { background: #111; }
.vbox { padding: 12px 14px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--line); font-size: .92rem; }
.vbox b { font-family: var(--font-display); }
.checks-row { display: flex; gap: 14px; margin-top: 6px; }
.checks-row span { display: inline-flex; gap: 3px; align-items: center; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--berry); display: inline-block; }
.pip.on { background: var(--berry); }
.moves { max-height: 260px; overflow-y: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 6px; font-variant-numeric: tabular-nums; }
.moves ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 2.4em 1fr 1fr; gap: 2px 4px; }
.moves li { display: contents; }
.moves .num { color: var(--muted); padding: 4px 2px; text-align: right; font-size: .9rem; }
.moves button { text-align: left; border: 0; background: transparent; padding: 4px 8px; border-radius: 8px; cursor: pointer; font-variant-emoji: text; display: flex; align-items: center; gap: 6px; }
.moves button:hover { background: var(--surface-2); }
.moves button.cur { background: var(--royal); color: var(--royal-ink); }
.q { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.q.best { background: var(--mint); } .q.ok { background: #8bc34a; } .q.inacc { background: var(--sun); } .q.blunder { background: var(--berry); }
.moves .empty { color: var(--muted); padding: 8px; font-size: .92rem; }
.review-bar { display: none; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 14px; background: var(--sun); color: #2a1f00; font-weight: 700; margin-top: 8px; }
.review-bar.show { display: flex; }
/* Navigation dans les coups, sous l'échiquier, pendant toute la partie */
.nav-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.nav-bar .icon-btn { width: 100%; height: 40px; border-radius: 12px; box-shadow: 0 2px 0 var(--line); color: inherit; }
.nav-bar .icon-btn[disabled] { opacity: .38; cursor: default; box-shadow: none; transform: none; }
#s-game .board-col { width: min(100%, calc(100vh - 240px)); }
@supports (height: 100dvh) { #s-game .board-col { width: min(100%, calc(100dvh - 240px)); } }

/* ===== Plateau ===== */
.board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: var(--shadow); container-type: inline-size; }
.board .squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.board .sq { position: relative; background: var(--sq-l); }
.board .sq.d { background: var(--sq-d); }
.board .coord { position: absolute; font-size: clamp(8px, 2.3cqi, 13px); font-weight: 700; line-height: 1; pointer-events: none; opacity: .85; }
.board .coord.f { right: 4%; bottom: 4%; }
.board .coord.r { left: 4%; top: 4%; }
.board .sq.l .coord { color: var(--sq-d-text, var(--sq-d)); }
.board .sq.d .coord { color: var(--sq-l-text, var(--sq-l)); }
.board .layer { position: absolute; inset: 0; pointer-events: none; }
.board .mark { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; }
.mark.last { background: var(--hl-last); }
.mark.sel { background: var(--hl-sel); }
.mark.check { background: radial-gradient(circle, rgba(255, 40, 70, .85) 0%, rgba(255, 40, 70, .45) 40%, transparent 72%); animation: pulse 1.1s ease-in-out infinite; }
.mark.hint { box-shadow: inset 0 0 0 4px var(--sun); animation: pulse 1s ease-in-out infinite; border-radius: 6px; }
.mark.threat { box-shadow: inset 0 0 0 4px var(--berry); animation: pulse .9s ease-in-out 3; border-radius: 6px; }
.mark.hill { background: repeating-linear-gradient(45deg, rgba(255, 197, 61, .32) 0 6px, rgba(255, 197, 61, .12) 6px 12px); }
.mark.dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--dot); }
.mark.ring::after { content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 5px solid var(--dot); }
.mark.wrong { background: rgba(224, 68, 106, .5); animation: fade-out .8s ease forwards; }
.mark.right { background: rgba(22, 166, 115, .5); animation: fade-out .9s ease forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.board .pieces { position: absolute; inset: 0; }
.piece { position: absolute; top: 0; left: 0; width: 12.5%; height: 12.5%; will-change: transform; pointer-events: none; }
.piece svg { width: 100%; height: 100%; display: block; overflow: visible; }
.piece .o { fill: var(--po); stroke: var(--po); stroke-width: 7px; stroke-linejoin: round; }
.piece .f { fill: var(--pf); }
.piece .d { fill: none; stroke: var(--pd); stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; }
.piece .dd { fill: var(--pd); }
.piece .face { display: var(--face, none); }
.piece.w { --po: var(--w-o); --pf: var(--w-f); --pd: var(--w-d); filter: var(--w-filter, none); }
.piece.b { --po: var(--b-o); --pf: var(--b-f); --pd: var(--b-d); filter: var(--b-filter, none); }
.piece.dragging { z-index: 10; transition: none !important; }
.piece.dragging svg { transform: scale(1.14) translateY(-6%); filter: drop-shadow(0 8px 6px rgba(0,0,0,.28)); }
.piece.land svg { animation: land .22s ease-out; }
@keyframes land { 0% { transform: scale(1.1, .9); } 60% { transform: scale(.97, 1.04); } 100% { transform: none; } }
.piece.promote svg { animation: promote .45s cubic-bezier(.3,1.7,.5,1); }
@keyframes promote { 0% { transform: scale(.3) rotate(-30deg); } 100% { transform: none; } }
.board .arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board canvas.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board.shake { animation: shake .35s ease; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }
.board.locked { cursor: default; }
/* Promotion : colonne de 4 pièces posée sur la case de promotion, reste de l'échiquier assombri */
.board .promo { position: absolute; inset: 0; background: rgba(10, 8, 30, .52); display: none; z-index: 20; animation: fade-in .12s ease; }
.board .promo.show { display: block; }
.piece.masque { visibility: hidden; }
.promo .col { position: absolute; width: 12.5%; height: 56.25%; display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)) minmax(0, .5fr); background: #fff; border-radius: 10px; box-shadow: 0 10px 26px rgba(0, 0, 0, .5), 0 0 0 2px rgba(0, 0, 0, .12); overflow: hidden; }
.promo .col.haut { grid-template-rows: minmax(0, .5fr) repeat(4, minmax(0, 1fr)); }
.promo .col button { display: block; position: relative; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; color: #5a5873; font: inherit; }
.promo .col button.choix:hover, .promo .col button.choix:focus-visible { background: #dfe4ff; outline: none; }
.promo .col button.choix:active { background: #c9d1ff; }
.promo .col button .piece { position: absolute; top: 4%; left: 4%; width: 92%; height: 92%; transform: none; }
.promo .col .annuler { background: #eceef6; font-size: clamp(14px, 4.4cqi, 22px); font-weight: 800; line-height: 1; }
.promo .col .annuler:hover, .promo .col .annuler:focus-visible { background: #dcdfea; outline: none; }

/* Effets de capture sur la pièce prise */
.piece.fx-splat svg { animation: fx-splat .42s ease-in forwards; transform-origin: 50% 90%; }
@keyframes fx-splat { 0% { transform: none; } 35% { transform: scale(1.18, .78); } 100% { transform: scale(1.7, .05); opacity: 0; } }
.piece.fx-glitch svg { animation: fx-glitch .42s steps(2) forwards; }
@keyframes fx-glitch {
  0% { transform: none; }
  20% { transform: translate(-6%, 2%); filter: drop-shadow(4px 0 0 #ff2bd6) drop-shadow(-4px 0 0 #2bf3ff); }
  40% { transform: translate(5%, -3%); clip-path: inset(10% 0 40% 0); }
  60% { transform: translate(-3%, 4%); clip-path: inset(50% 0 5% 0); opacity: .8; }
  100% { transform: scale(.2); opacity: 0; clip-path: inset(45% 0 45% 0); }
}
.piece.fx-dust svg { animation: fx-dust .45s ease-in forwards; }
@keyframes fx-dust { to { transform: translateY(12%) scale(.7); opacity: 0; } }

/* ===== Thèmes de plateau ===== */
.th-classique {
  --face: none;
  --sq-l: #ecd6b3; --sq-d: #b4825a; --sq-l-text: #f3e3c8; --sq-d-text: #8b5f3d;
  --hl-last: rgba(255, 214, 92, .45); --hl-sel: rgba(255, 214, 92, .7); --dot: rgba(40, 24, 12, .32);
  --w-o: #3a2a1e; --w-f: url(#g-cl-w); --w-d: #9a7a58;
  --b-o: #120c08; --b-f: url(#g-cl-b); --b-d: #c9a47a;
}
.th-potager {
  --face: inline;
  --sq-l: #e9f4c9; --sq-d: #9dcb63; --sq-l-text: #eef7d6; --sq-d-text: #6a9a35;
  --hl-last: rgba(255, 200, 60, .5); --hl-sel: rgba(255, 170, 40, .62); --dot: rgba(46, 80, 20, .36);
  --w-o: #5a2a0c; --w-f: url(#g-po-w); --w-d: #2e8f45;
  --b-o: #22103d; --b-f: url(#g-po-b); --b-d: #47c065;
}
.th-neon {
  --face: none;
  --sq-l: #1c2554; --sq-d: #0d1331; --sq-l-text: #2e3a78; --sq-d-text: #4c5aa8;
  --hl-last: rgba(70, 243, 255, .22); --hl-sel: rgba(255, 82, 220, .32); --dot: rgba(160, 230, 255, .45);
  --w-o: #46f3ff; --w-f: url(#g-ne-w); --w-d: #46f3ff; --w-filter: drop-shadow(0 0 2px #46f3ff) drop-shadow(0 0 6px rgba(70, 243, 255, .55));
  --b-o: #ff52dc; --b-f: url(#g-ne-b); --b-d: #ff52dc; --b-filter: drop-shadow(0 0 2px #ff52dc) drop-shadow(0 0 6px rgba(255, 82, 220, .55));
}
body.th-neon .board .sq { box-shadow: inset 0 0 0 .5px rgba(90, 120, 255, .35); }
body.th-neon .board { box-shadow: 0 0 0 2px #2b3a8a, 0 0 28px -6px rgba(70, 243, 255, .5); }

/* ===== Puzzles ===== */
.pz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pz-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .84rem; font-weight: 700; color: var(--muted); }
.storm-hud { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.storm-hud .big { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.storm-hud .lbl { color: var(--muted); font-size: .85rem; }
.combo { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.combo > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--sun)); transition: width .25s; }
.time-bonus { color: var(--mint); font-weight: 800; }

/* ===== Fenêtres ===== */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); background: rgba(15, 12, 40, .5); }
.modal-wrap.show { display: flex; animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; } }
.modal { background: var(--surface); color: var(--ink); border-radius: 24px; padding: 22px; width: min(520px, 100%); max-height: 100%; overflow-y: auto; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); animation: modal-in .28s cubic-bezier(.2,1.3,.5,1); }
@keyframes modal-in { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.modal h2 { font-size: 1.7rem; margin-bottom: 6px; }
.modal .lead { color: var(--muted); }
.modal .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.modal .row .btn { flex: 1 1 140px; }
.result-title { font-size: clamp(2.2rem, 7vw, 3.2rem) !important; }
.result-title.win { color: var(--mint); } .result-title.loss { color: var(--berry); }
.gains { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.gain { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); font-weight: 700; }
.moments { display: grid; gap: 8px; margin-top: 14px; }
.moment { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); font-size: .94rem; }
.level-list { display: grid; gap: 10px; margin-top: 16px; }
.level-list .choice { width: 100%; }
.help-list { display: grid; gap: 10px; margin-top: 12px; }
.help-item { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; }
.help-item .piece { position: static; width: 48px; height: 48px; transform: none; }
.help-item p { font-size: .95rem; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.theme-card { text-align: left; border: 2px solid var(--line); border-radius: 18px; background: var(--surface); padding: 10px; cursor: pointer; box-shadow: 0 3px 0 var(--line); }
.theme-card[aria-pressed="true"] { border-color: var(--royal); box-shadow: 0 3px 0 var(--royal-deep); }
.theme-card .mini { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.theme-card .mini div { aspect-ratio: 1; display: grid; place-items: center; }
.theme-card .mini .piece { position: static; width: 90%; height: 90%; transform: none; }
.theme-card b { display: block; }
.theme-card span { color: var(--muted); font-size: .86rem; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 700; opacity: 0; transition: .25s; z-index: 200; pointer-events: none; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.credits { color: var(--muted); font-size: .86rem; margin-top: 18px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); gap: 14px; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .board-col { width: min(100%, 620px, calc(100vh - 210px)); min-width: 260px; }
  .side { max-width: 620px; width: 100%; justify-self: center; }
}
@supports (height: 100dvh) {
  @media (max-width: 720px) { .board-col { width: min(100%, 620px, calc(100dvh - 210px)); } }
}
@media (max-width: 720px) { #s-game .board-col { width: min(100%, 620px, calc(100vh - 256px)); } }
@supports (height: 100dvh) {
  @media (max-width: 720px) { #s-game .board-col { width: min(100%, 620px, calc(100dvh - 256px)); } }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-strip { justify-self: stretch; max-width: none; }
  .modes { grid-template-columns: minmax(0, 1fr); }
  .mode.primary { grid-template-columns: 64px 1fr; }
  .mode.primary .m-ico { width: 64px; height: 64px; }
  .mode.primary .opp-chip { grid-column: 1 / -1; justify-self: start; }
  .app { padding-top: 8px; }
  .moves { max-height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.mode.primary .stars { color: var(--sun) !important; }
.mode.primary .stars .off { opacity: .35; }
.opp-chip > span:last-child { line-height: 1.25; }
.board.locked .piece { cursor: default; }
.board:not(.locked) { cursor: pointer; }
.side .btn .ico { width: 1.1em; height: 1.1em; }
.actions .btn span { overflow: hidden; text-overflow: ellipsis; }
.review-bar .icon-btn { width: 38px; height: 38px; box-shadow: none; }
.player-card .stat b { font-size: 1.25rem; }

.piece.mini { position: relative; display: inline-block; width: 1.6em; height: 1.6em; vertical-align: -0.42em; transform: none; margin-right: 1px; }
.san { white-space: nowrap; }
.moves button.cur .piece.mini { filter: drop-shadow(0 0 1px #fff); }

/* ===== V2 : canard, roque, étoiles, académie, distance ===== */
.piece.duck { --po: #6b4300; --pf: url(#g-duck); --pd: #b8740a; filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.mark.castle { background: rgba(255, 197, 61, .3); }
.mark.castle::after { content: ""; position: absolute; inset: 9%; border-radius: 50%; border: 4px dashed #d99a00; }
.mark.duckable { background: rgba(255, 214, 64, .2); }
.mark.duckable::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(214, 150, 0, .6); }
.mark.star::after { content: ""; position: absolute; inset: 18%; background: linear-gradient(#ffe27a, #ffb300); clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); animation: star-bob 1.6s ease-in-out infinite; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
@keyframes star-bob { 50% { transform: translateY(-7%) scale(1.07); } }
.isle { display: grid; gap: 10px; }
.isle h3 { font-size: 1.3rem; }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.lesson-btn { text-align: left; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; box-shadow: 0 3px 0 var(--line); display: grid; gap: 4px; }
.lesson-btn:active { transform: translateY(3px); box-shadow: none; }
.lesson-btn.done { border-color: var(--mint); box-shadow: 0 3px 0 var(--mint); }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); border: 2px dashed var(--royal); }
.code-box .code { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; letter-spacing: .14em; line-height: 1.1; }
.code-box .lbl { color: var(--muted); font-size: .85rem; }
.code-box .code-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.code-input.pseudo-input { width: 100%; max-width: 22ch; letter-spacing: .02em; text-transform: none; font-size: 1.15rem; }
.code-input { font: inherit; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; letter-spacing: .22em; text-transform: uppercase; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); width: 9ch; }
.online { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); display: inline-block; }
.online.offline { background: var(--line); }
.av img { width: 100%; height: 100%; border-radius: 10px; object-fit: cover; }
.ask-note { font-size: .8rem; color: var(--muted); }
#game-remote { display: grid; gap: 8px; }
#game-remote[hidden], #ac-lesson[hidden], #ac-map[hidden] { display: none; }

/* ===== Extensions : accueil et univers regroupés ===== */
.home-top { display: grid; gap: 12px; margin-bottom: 14px; }
.reprise-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 2px solid var(--royal); }
.reprise-card h3 { font-size: 1.1rem; }
.reprise-card .hint { color: var(--muted); font-size: .92rem; }
.reprise-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.lien-abime { color: var(--berry) !important; font-weight: 700; }
.theme-groups { display: grid; gap: 10px; }
.theme-family { margin: 8px 0 2px; font-family: var(--font-display); font-size: 1rem; color: var(--muted); }

/* ---- module 31-parcours.css ---- */
/* ===== Parcours débutant (module 31) =====
   Jetons définis dans les trois blocs (clair, sombre système, sombre forcé) ; contrastes texte/fond
   mesurés par tests/e2e_parcours.py (>= 4,5:1). */
:root {
  --pc-voie: #c9cde6;
  --pc-num-bg: #2f4bd8; --pc-num-ink: #ffffff;
  --pc-ok-bg: #0f7a54; --pc-ok-ink: #ffffff;
  --pc-ferme-bg: #e3e5f1; --pc-ferme-ink: #4a4768;
  --pc-faux-bg: #fde8ee; --pc-faux-ink: #a3123a;
  --pc-bon-bg: #e2f6ee; --pc-bon-ink: #0b5e40;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pc-voie: #3d3968;
    --pc-num-bg: #7086ff; --pc-num-ink: #0f0d26;
    --pc-ok-bg: #3dd49b; --pc-ok-ink: #0f0d26;
    --pc-ferme-bg: #2b2850; --pc-ferme-ink: #c3bfe6;
    --pc-faux-bg: #4a1d2c; --pc-faux-ink: #ffc2d1;
    --pc-bon-bg: #173d31; --pc-bon-ink: #b6f3da;
  }
}
:root[data-theme="dark"] {
  --pc-voie: #3d3968;
  --pc-num-bg: #7086ff; --pc-num-ink: #0f0d26;
  --pc-ok-bg: #3dd49b; --pc-ok-ink: #0f0d26;
  --pc-ferme-bg: #2b2850; --pc-ferme-ink: #c3bfe6;
  --pc-faux-bg: #4a1d2c; --pc-faux-ink: #ffc2d1;
  --pc-bon-bg: #173d31; --pc-bon-ink: #b6f3da;
}

#pc-carte[hidden], #pc-lecon[hidden] { display: none; }
.pc-carte { display: grid; gap: 14px; max-width: 820px; }
.pc-tete-carte { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: start; }
.pc-tete-carte .owl, .pc-commence .owl { width: 64px; height: 64px; }
.pc-tete-carte h3 { font-size: 1.25rem; margin-bottom: 4px; }
.pc-tete-carte .hint { color: var(--muted); }
.pc-continuer { margin-top: 12px; max-width: 100%; }
.pc-continuer span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-fini { margin-top: 8px; font-weight: 700; }

.pc-voie { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 10px; position: relative; }
.pc-voie::before { content: ""; position: absolute; left: 25px; top: 18px; bottom: 18px; width: 4px; border-radius: 4px; background: var(--pc-voie); }
.pc-etape { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.pc-etape.courante { border: 2px solid var(--royal); }
.pc-etape-tete { width: 100%; display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; background: none; border: 0; cursor: pointer; border-radius: 18px; }
.pc-etape-tete[disabled] { cursor: not-allowed; }
.pc-num { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  background: var(--pc-num-bg); color: var(--pc-num-ink); }
.pc-etape.faite .pc-num { background: var(--pc-ok-bg); color: var(--pc-ok-ink); }
.pc-etape.fermee .pc-num { background: var(--pc-ferme-bg); color: var(--pc-ferme-ink); }
.pc-etape.fermee { background: var(--surface-2); box-shadow: none; }
.pc-etape.fermee .pc-etape-txt b { color: var(--muted); }
.pc-etape-txt { display: grid; gap: 2px; min-width: 0; }
.pc-etape-txt b { font-size: 1.02rem; }
.pc-etape-sous { color: var(--muted); font-size: .88rem; }
.pc-etape-corps { padding: 0 14px 14px 70px; display: grid; gap: 10px; }
.pc-regle { color: var(--muted); font-size: .9rem; }
.pc-ex { position: relative; }
.pc-type { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pc-test { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.pc-test .hint { flex: 1 1 220px; color: var(--muted); font-size: .9rem; }
.pc-astuces summary { cursor: pointer; font-weight: 700; }
.pc-astuces ul { margin: 6px 0 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: .93rem; }
.pc-libre { color: var(--muted); font-size: .92rem; }
.pc-lien { background: none; border: 0; padding: 0; color: var(--royal); text-decoration: underline; cursor: pointer; font-weight: 700; }

.pc-lecon.pc-sans-plateau { grid-template-columns: minmax(0, 620px); }
.pc-lecon.pc-sans-plateau .board-col { display: none; }
.pc-panel { display: grid; gap: 12px; }
.pc-ex-tete { display: grid; gap: 2px; }
.pc-ex-tete b { font-family: var(--font-display); font-size: 1.15rem; }
.pc-ex-tete .hint { color: var(--muted); font-size: .85rem; }
.pc-lecon-card summary { cursor: pointer; font-weight: 700; }
.pc-lecon-card p { margin-top: 8px; font-size: .94rem; }
.pc-lecon-card .hint { color: var(--muted); }
.pc-lecon-card a { color: var(--royal); font-weight: 700; }
.pc-bravo { text-align: center; display: grid; gap: 4px; }
.pc-etoiles { font-size: 2.2rem; line-height: 1.1; }
.pc-bravo .hint { color: var(--muted); }
.pc-bonus { list-style: none; margin: 6px 0 0; padding: 0; text-align: left; display: grid; gap: 2px; font-size: .92rem; color: var(--muted); }
.pc-bonus li.ok { color: var(--ink); font-weight: 700; }
.pc-quiz { display: grid; gap: 10px; }
.pc-question { font-weight: 700; font-size: 1.02rem; }
.pc-choix { display: grid; gap: 8px; }
.pc-choix-btn { width: 100%; }
.pc-choix-btn.faux { background: var(--pc-faux-bg); color: var(--pc-faux-ink); border-color: var(--pc-faux-ink); box-shadow: none; }
.pc-choix-btn.barre span { text-decoration: line-through; }
.pc-choix-btn.barre { color: var(--muted); box-shadow: none; }
.pc-choix-btn.bon { background: var(--pc-bon-bg); color: var(--pc-bon-ink); border-color: var(--pc-bon-ink); }
.pc-choix-btn[disabled] { cursor: default; }
.pc-piege { display: grid; gap: 10px; }
.pc-piege .hint, .pc-avant .hint, .pc-jeu .hint { color: var(--muted); font-size: .9rem; }
.pc-nav .btn { flex: 1 1 120px; }
.pc-avant { display: grid; gap: 8px; }
.pc-avant ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: .93rem; }
.pc-adv { font-weight: 700; font-size: 1.05rem; }
.pc-jeu { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pc-jeu .hint { flex: 1 1 160px; }

.pc-commence { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px 14px; align-items: center; border: 2px solid var(--royal); }
.pc-commence h3 { font-size: 1.2rem; }
.pc-commence .hint { color: var(--muted); font-size: .92rem; }
.pc-commence .xpbar { margin: 8px 0 4px; }
.pc-commence .pc-mini { font-size: .82rem; }
.pc-commence-txt { min-width: 0; }
@media (max-width: 560px) {
  .pc-commence { grid-template-columns: 56px 1fr; }
  .pc-commence .owl { width: 56px; height: 56px; }
  .pc-commence-btn { grid-column: 1 / -1; width: 100%; }
  .pc-etape-corps { padding: 0 12px 12px 12px; }
  .pc-tete-carte { grid-template-columns: 52px 1fr; }
  .pc-tete-carte .owl { width: 52px; height: 52px; }
  .pc-continuer { width: 100%; }
}
.pc-fin-partie { display: grid; gap: 6px; margin-top: 10px; padding: 12px; border: 2px solid var(--royal); border-radius: 14px; }
.pc-fin-partie .hint { color: var(--muted); }

.pc-regle-item { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.help-item.pc-regle-item { grid-template-columns: 48px 1fr auto; }
.pc-regles { display: grid; gap: 10px; margin-top: 8px; }
.pc-regles p { font-size: .95rem; }
.pc-essayer { min-height: 36px; }
@media (max-width: 420px) {
  .help-item.pc-regle-item { grid-template-columns: 40px 1fr; }
  .help-item.pc-regle-item .piece { width: 40px; height: 40px; }
  .pc-regle-item .pc-essayer { grid-column: 2; justify-self: start; }
  .pc-regles .pc-regle-item { grid-template-columns: 1fr; }
  .pc-regles .pc-essayer { justify-self: start; }
}

/* ---- module 51-debrief.css ---- */
/* ===== Débrief (module 51) =====
   Une couleur par catégorie de coup (comme chess.com) : jetons --cat-* définis dans les trois blocs
   (clair, sombre système, sombre forcé). Le symbole est toujours écrit en --cat-encre sur la couleur
   (contraste ≥ 4,5:1 mesuré par tests/e2e_debrief.py) ; le liseré --cat-bord détache la pastille du fond. */
:root {
  --cat-brillant: #1baca6; --cat-seul: #5c8bb0; --cat-meilleur: #81b64c; --cat-excellent: #96bc4b; --cat-bon: #95b776;
  --cat-theorie: #a88865; --cat-force: #a3a3a3; --cat-imprecision: #f7c045; --cat-erreur: #ffa459; --cat-manquee: #ff7769; --cat-gaffe: #fa412d;
  --cat-encre: #15122e; --cat-bord: rgba(21, 18, 46, .42);
  --db-blanc: #f7f4ea; --db-noir: #45406a; --db-milieu: rgba(29, 26, 63, .35); --db-meilleur-fl: rgba(22, 150, 90, .82); --db-cur: #2f4bd8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cat-brillant: #1baca6; --cat-seul: #5c8bb0; --cat-meilleur: #81b64c; --cat-excellent: #96bc4b; --cat-bon: #95b776;
    --cat-theorie: #a88865; --cat-force: #a3a3a3; --cat-imprecision: #f7c045; --cat-erreur: #ffa459; --cat-manquee: #ff7769; --cat-gaffe: #fa412d;
    --cat-encre: #15122e; --cat-bord: rgba(255, 255, 255, .45);
    --db-blanc: #ebe8f7; --db-noir: #262249; --db-milieu: rgba(255, 255, 255, .35); --db-meilleur-fl: rgba(61, 212, 155, .82); --db-cur: #ffd45e;
  }
}
:root[data-theme="dark"] {
  --cat-brillant: #1baca6; --cat-seul: #5c8bb0; --cat-meilleur: #81b64c; --cat-excellent: #96bc4b; --cat-bon: #95b776;
  --cat-theorie: #a88865; --cat-force: #a3a3a3; --cat-imprecision: #f7c045; --cat-erreur: #ffa459; --cat-manquee: #ff7769; --cat-gaffe: #fa412d;
  --cat-encre: #15122e; --cat-bord: rgba(255, 255, 255, .45);
  --db-blanc: #ebe8f7; --db-noir: #262249; --db-milieu: rgba(255, 255, 255, .35); --db-meilleur-fl: rgba(61, 212, 155, .82); --db-cur: #ffd45e;
}

/* Pastilles */
.db-pas { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; font-size: .78rem; font-weight: 800; line-height: 1;
  color: var(--cat-encre); border: 1.5px solid var(--cat-bord); flex: none; letter-spacing: -.04em; font-family: var(--font-ui); }
.db-pas.petite { width: 1.35em; height: 1.35em; font-size: .7rem; }
.db-pas.sur-case { position: absolute; width: 5.2%; height: 5.2%; font-size: clamp(8px, 2.5cqi, 15px); box-shadow: 0 1px 4px rgba(0, 0, 0, .45); animation: db-pop .25s ease-out; }
@keyframes db-pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.db-pas.cat-brillant { background: var(--cat-brillant); } .db-pas.cat-seul { background: var(--cat-seul); } .db-pas.cat-meilleur { background: var(--cat-meilleur); }
.db-pas.cat-excellent { background: var(--cat-excellent); } .db-pas.cat-bon { background: var(--cat-bon); } .db-pas.cat-theorie { background: var(--cat-theorie); }
.db-pas.cat-force { background: var(--cat-force); } .db-pas.cat-imprecision { background: var(--cat-imprecision); } .db-pas.cat-erreur { background: var(--cat-erreur); }
.db-pas.cat-manquee { background: var(--cat-manquee); } .db-pas.cat-gaffe { background: var(--cat-gaffe); }

/* En-tête */
#s-debrief .hint { color: var(--muted); font-size: .9rem; }
.db-tete { display: grid; gap: 12px; margin-bottom: 12px; }
.db-res { display: grid; gap: 2px; }
.db-res b { font-family: var(--font-display); font-size: 1.25rem; }
.db-prog { display: grid; gap: 2px; }
.db-prog .xpbar { margin: 4px 0 0; height: 8px; }
.db-prog-txt { font-weight: 700; color: var(--muted); font-size: .92rem; }
.db-joueurs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.db-joueur { display: grid; justify-items: center; text-align: center; padding: 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.db-joueur.moi { border-color: var(--royal); }
.db-nom { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.db-precision { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1.1; }
.db-phases { font-size: .78rem; color: var(--muted); }
.db-cats { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.db-cats th { font-size: .85rem; color: var(--muted); font-weight: 700; padding: 2px 4px; }
.db-cats td { padding: 3px 4px; border-top: 1px solid var(--line); }
.db-cats td.n { width: 3.5em; text-align: center; font-weight: 800; font-size: 1.05rem; }
.db-cats td.n.zero { color: var(--muted); font-weight: 400; opacity: .7; }
.db-cat-nom { display: flex; align-items: center; gap: 8px; }

/* Courbe */
.db-courbe-boite { padding: 8px; margin-bottom: 14px; }
.db-courbe { cursor: pointer; line-height: 0; }
.db-courbe svg { display: block; border-radius: 10px; overflow: hidden; }
.db-c-fond { fill: var(--db-noir); }
.db-c-blanc { fill: var(--db-blanc); }
.db-c-milieu { stroke: var(--db-milieu); stroke-width: 1; stroke-dasharray: 4 4; }
.db-c-cur { stroke: var(--db-cur); stroke-width: 2.5; }
.db-c-pt { stroke: var(--cat-bord); stroke-width: 1; }
.db-c-pt.cat-imprecision { fill: var(--cat-imprecision); } .db-c-pt.cat-erreur { fill: var(--cat-erreur); } .db-c-pt.cat-manquee { fill: var(--cat-manquee); }
.db-c-pt.cat-gaffe { fill: var(--cat-gaffe); } .db-c-pt.cat-brillant { fill: var(--cat-brillant); } .db-c-pt.cat-seul { fill: var(--cat-seul); }

/* Échiquier, barre d'évaluation, flèches */
#s-debrief .board-col { width: min(100%, calc(100vh - 230px)); }
@supports (height: 100dvh) { #s-debrief .board-col { width: min(100%, calc(100dvh - 230px)); } }
.db-plateau { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 6px; align-items: stretch; }
.db-barre { position: relative; border-radius: 6px; overflow: hidden; background: var(--db-blanc); border: 1px solid var(--line); }
.db-barre > span { position: absolute; left: 0; right: 0; top: 0; background: var(--db-noir); transition: height .35s ease; }
.db-barre.inverse { background: var(--db-noir); }
.db-barre.inverse > span { background: var(--db-blanc); }
.db-barre.inconnue { opacity: .45; }
.db-fleches { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.db-fl { stroke: rgba(0, 0, 0, .3); stroke-width: 2; opacity: .88; }
.db-fl.meilleur-fl { fill: var(--db-meilleur-fl); }
.db-fl.cat-brillant { fill: var(--cat-brillant); } .db-fl.cat-seul { fill: var(--cat-seul); } .db-fl.cat-meilleur { fill: var(--cat-meilleur); }
.db-fl.cat-excellent { fill: var(--cat-excellent); } .db-fl.cat-bon { fill: var(--cat-bon); } .db-fl.cat-imprecision { fill: var(--cat-imprecision); }
.db-fl.cat-erreur { fill: var(--cat-erreur); } .db-fl.cat-manquee { fill: var(--cat-manquee); } .db-fl.cat-gaffe { fill: var(--cat-gaffe); }
.db-calque { z-index: 8; }
.db-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.db-fautes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.db-fautes .btn { min-width: 0; }

/* Explication, coups annotés, bilan */
.db-bulle { line-height: 1.5; }
.db-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.db-actions .btn { flex: 1 1 auto; }
.db-coups { max-height: 300px; }
.db-coups button { gap: 5px; }
.db-coups button.cur .db-pas { border-color: var(--royal-ink); }
.db-coups .db-var { display: block; grid-column: 1 / -1; padding: 6px 8px; margin: 2px 0 4px 2.4em; border-left: 3px solid var(--sun); background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: .92rem; }
.db-var-txt { margin-right: 8px; }
.db-bilan { display: grid; gap: 12px; margin-top: 14px; }
.db-bilan h3 { font-size: 1.1rem; margin-bottom: 6px; }
.db-bilan ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.db-bilan li .db-pas { vertical-align: middle; margin-right: 2px; }
.db-axe { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; display: grid; gap: 6px; }
.db-axe:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.db-axe .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.db-fin { display: grid; gap: 6px; margin-top: 14px; }
.db-fin-etat { color: var(--muted); font-size: .9rem; text-align: center; }
@media (max-width: 720px) {
  #s-debrief .board-col { width: min(100%, 620px); }
  .db-precision { font-size: 1.7rem; }
}

/* ---- module 52-coach.css ---- */
/* ===== Mon coach, séance du jour, exercices (module 52) =====
   Jetons propres au module, définis dans les trois blocs (clair, sombre système, sombre forcé). */
:root { --mc-ok: #12805c; --mc-rate: #b4234a; --mc-msg-moi: #e6ebff; --mc-msg-hibou: #f3efff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --mc-ok: #3dd49b; --mc-rate: #ff6f8e; --mc-msg-moi: #2c3266; --mc-msg-hibou: #322b5c; }
}
:root[data-theme="dark"] { --mc-ok: #3dd49b; --mc-rate: #ff6f8e; --mc-msg-moi: #2c3266; --mc-msg-hibou: #322b5c; }

#s-coach .hint, #s-exo .hint, .mc-carte-accueil .hint { color: var(--muted); font-size: .9rem; }
.mc-corps { display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.mc-corps h3 { font-size: 1.15rem; margin-bottom: 6px; }
.mc-tete { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; }
.mc-seance-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mc-items { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.mc-item { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.mc-etat { width: 1.4em; text-align: center; font-weight: 800; color: var(--muted); }
.mc-item.fait-ok .mc-etat, .mc-item.fait-aide .mc-etat { color: var(--mc-ok); }
.mc-item.fait-rate .mc-etat { color: var(--mc-rate); }
.mc-item.fait-ok span:nth-child(2), .mc-item.fait-aide span:nth-child(2) { color: var(--muted); }
.mc-seance-pied { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mc-motif { border-top: 1px solid var(--line); padding: 10px 0; }
.mc-motif:first-of-type { border-top: 0; }
.mc-motif summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.mc-motif summary b { font-size: 1.02rem; }
.mc-motif > p { margin: 8px 0; }
.mc-astuces { margin: 6px 0; padding-left: 1.2em; display: grid; gap: 4px; }
.mc-exemples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.mc-liens { font-size: .9rem; margin: 6px 0; }
.mc-liens a { color: var(--royal); font-weight: 700; }
.mc-motif .row, .mc-parler .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.mc-forces ul, .mc-parties ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.mc-parties li .link { margin-left: 6px; }
.mc-faq-champ, .mc-champ { width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); }
.mc-faq-champ:focus, .mc-champ:focus { outline: none; border-color: var(--royal); }
.mc-faq-liste { display: grid; gap: 4px; margin-top: 8px; }
.mc-q { border-top: 1px solid var(--line); padding: 8px 0; }
.mc-q summary { cursor: pointer; font-weight: 700; }
.mc-q p { margin-top: 6px; }
.mc-champ { resize: vertical; min-height: 64px; margin: 8px 0; }
.mc-fil { display: grid; gap: 6px; }
.mc-msg { padding: 8px 12px; border-radius: 14px; max-width: 92%; }
.mc-msg.moi { justify-self: end; background: var(--mc-msg-moi); }
.mc-msg.hibou { justify-self: start; background: var(--mc-msg-hibou); }
.mc-carte-accueil { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; }
.mc-carte-accueil .owl { width: 56px; height: 56px; }
.ex-panneau { display: grid; gap: 12px; }
@media (max-width: 520px) {
  .mc-carte-accueil { grid-template-columns: 48px 1fr; }
  .mc-carte-accueil .btn { grid-column: 1 / -1; }
  .mc-carte-accueil .owl { width: 48px; height: 48px; }
}

/* ---- module 60-entre-amis.css ---- */
/* ===== Entre amis (module 60) : zone de la partie, réactions, confirmation, prémoves, Tes amis =====
   Jetons propres au module, définis dans les trois blocs (clair, sombre système, sombre forcé) ; contrastes mesurés
   par tests/e2e_amis.py. */
:root {
  --am-carte-fond: #fff4d1; --am-carte-bord: #d99a00; --am-carte-encre: #2a1f00;
  --am-annonce-fond: #e9edff; --am-annonce-encre: #1d1a3f; --am-alerte: #a3173c;
  --am-pre: rgba(224, 68, 106, .42); --am-pre-sel: rgba(224, 68, 106, .62); --am-cercle: rgba(22, 166, 115, .9);
  --am-bulle-fond: #ffffff; --am-bulle-encre: #1d1a3f; --am-atoi: #12805c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --am-carte-fond: #3a3016; --am-carte-bord: #c99a1c; --am-carte-encre: #ffeab0;
    --am-annonce-fond: #2a2c5c; --am-annonce-encre: #eeebff; --am-alerte: #ff8fa6;
    --am-pre: rgba(255, 111, 142, .42); --am-pre-sel: rgba(255, 111, 142, .62); --am-cercle: rgba(61, 212, 155, .9);
    --am-bulle-fond: #26234a; --am-bulle-encre: #eeebff; --am-atoi: #3dd49b;
  }
}
:root[data-theme="dark"] {
  --am-carte-fond: #3a3016; --am-carte-bord: #c99a1c; --am-carte-encre: #ffeab0;
  --am-annonce-fond: #2a2c5c; --am-annonce-encre: #eeebff; --am-alerte: #ff8fa6;
  --am-pre: rgba(255, 111, 142, .42); --am-pre-sel: rgba(255, 111, 142, .62); --am-cercle: rgba(61, 212, 155, .9);
  --am-bulle-fond: #26234a; --am-bulle-encre: #eeebff; --am-atoi: #3dd49b;
}

.amis-zone { display: grid; gap: 8px; }
.amis-zone[hidden], .am-confirmer[hidden] { display: none; }
.am-annonce { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--am-annonce-fond); color: var(--am-annonce-encre); font-size: .92rem; border-left: 4px solid var(--royal); }
.am-ligne { margin: 0; font-size: .92rem; color: var(--ink); }
.am-ligne.am-alerte { color: var(--am-alerte); font-weight: 700; }
.am-carte { display: grid; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--am-carte-fond); color: var(--am-carte-encre); border: 2px solid var(--am-carte-bord); }
.am-carte p { margin: 0; font-weight: 700; font-size: .95rem; }
.am-carte.demande { animation: am-appel 1.2s ease-in-out 3; }
.am-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.am-reactions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-between; }
.am-reac { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 1.35rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.am-reac:active { transform: scale(.92); }
.am-reac:disabled { opacity: .45; cursor: default; }
.am-reac:focus-visible { outline: 3px solid var(--royal); outline-offset: 2px; }

/* Bulles des réactions, au-dessus de l'échiquier */
#s-game .board-col { position: relative; }
.am-bulles { position: absolute; left: 0; right: 0; top: 54px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 30; }
.am-bulle { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--am-bulle-fond); color: var(--am-bulle-encre); border: 2px solid var(--line); box-shadow: var(--shadow); font-weight: 700; animation: am-monte 3.2s ease forwards; }
.am-bulle-emo { font-size: 1.7rem; line-height: 1; }
.am-bulle.moi { font-size: .85rem; padding: 4px 12px; animation-duration: 1.6s; }
.am-bulle.moi .am-bulle-emo { font-size: 1.1rem; }
.am-bulle.fixe { animation: am-fondu 3.2s linear forwards; }
@keyframes am-monte { 0% { transform: translateY(18px) scale(.7); opacity: 0; } 12% { transform: translateY(0) scale(1.1); opacity: 1; } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
@keyframes am-fondu { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes am-appel { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--am-carte-bord) 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .am-bulle { animation: am-fondu 3.2s linear forwards; } .am-carte.demande { animation: none; } }

/* Boutons au long libellé (« Oups, je peux rejouer ? », « Je reviens dans 5 min ») : toute la largeur, jamais tronqués */
.actions .am-large { grid-column: 1 / -1; }

/* Coup provisoire (« Confirmer mes coups ») */
.am-confirmer { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 10px; border-radius: 14px; background: var(--surface); border: 2px solid var(--royal); }
.am-conf-txt { flex: 1; font-weight: 700; }

/* Prémoves, cercles et crayon */
.board .mark.am-pre { background: var(--am-pre); }
.board .mark.am-pre-sel { background: var(--am-pre-sel); }
.board .mark.am-pre-dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26%; height: 26%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--am-pre-sel); }
.board .mark.am-cercle::after { content: ""; position: absolute; inset: 7%; border-radius: 50%; border: 5px solid var(--am-cercle); }
.board .mark.am-crayon { box-shadow: inset 0 0 0 4px var(--sun-deep); border-radius: 6px; }

/* Création d'une partie, Tes parties, Tes amis */
.am-options { display: grid; gap: 14px; }
.am-sous { display: grid; gap: 2px; padding: 4px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); }
.am-sous .hint { margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
.am-perso { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.am-nombre { width: 5.5em; font: inherit; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); }
.am-partie.a-toi { border-color: var(--am-atoi); border-width: 2px; }
.am-atoi { color: var(--am-atoi); font-weight: 800; }
.am-lien-amis { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.am-lien-amis .hint, .am-ami .hint, .am-defi .hint { color: var(--muted); font-size: .9rem; margin: 2px 0 0; }
.am-amis { display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.am-ami, .am-defi { display: grid; gap: 6px; }
.am-ami.a-toi { border-color: var(--am-atoi); border-width: 2px; }
.am-score { margin: 0; font-weight: 700; }
.am-fin { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.am-fin .hint { flex-basis: 100%; text-align: center; color: var(--muted); font-size: .9rem; margin: 0; }
.am-echauffer-local { margin-top: 10px; }
@media (max-width: 520px) {
  .am-reac { width: 42px; height: 42px; font-size: 1.2rem; }
  .am-lien-amis { grid-template-columns: 1fr; }
}
