:root {
  --bg: #120d18;
  --bg2: #1c1526;
  --panel: #211a2d;
  --panel2: #2a2138;
  --line: #3a2f4c;
  --text: #f1e8da;
  --muted: #a99bb8;
  --gold: #f5c451;
  --gold2: #d9952b;
  --red: #ff5d73;
  --cyan: #4fd6ff;
  --green: #7cf08a;
  --purple: #b38cff;
  /* Code couleur des stats (panneau, plateau, règles, récompenses) */
  --c-spd: #4ade80;
  --c-atk: #ff6b4a;
  --c-def: #4fa8ff;
  --c-rng: #b38cff;
  --c-hp: #ff4d6d;
  --c-hero: #3fe0c5;
  --radius: 14px;
  --pixel: 'Pixelify Sans', system-ui, sans-serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 20% -10%, #3a1f4f55, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #4f2a1a55, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Gestes : pas de sélection ni de menu d'appui long, pas de zoom au double tap, le glisser ne fait pas défiler */
#app { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tiles, .tile, .ent { touch-action: manipulation; }
.st-tile, .pool-tok, .ent.hero { touch-action: none; }
[data-k="spd"] { --k: var(--c-spd); }
[data-k="atk"] { --k: var(--c-atk); }
[data-k="def"] { --k: var(--c-def); }
[data-k="rng"] { --k: var(--c-rng); }
[data-k="hp"], [data-k="heal"] { --k: var(--c-hp); }
.kc-spd { color: var(--c-spd); } .kc-atk { color: var(--c-atk); } .kc-def { color: var(--c-def); } .kc-rng { color: var(--c-rng); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
/* Focus clavier visible (pas au clic souris) */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; max-width: 1180px; margin: 0 auto;
}
.logo, .title { font-family: var(--pixel); font-weight: 700; letter-spacing: .5px; }
.logo { font-size: 24px; }
.logo span, .title span { color: var(--gold); text-shadow: 0 0 18px #f5c45166; }
.hud { display: flex; align-items: center; gap: 8px; }
.chip {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--muted);
}
.chip b { color: var(--text); font-family: var(--pixel); font-size: 16px; margin-left: 4px; }
.chip small { color: var(--muted); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); font-size: 18px; transition: transform .15s, background .15s;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--panel2); }
.icon-btn.off { opacity: .4; filter: grayscale(1); }
/* HUD mobile (masqué sur ordinateur) */
.hud-m { display: none; align-items: center; gap: 8px; width: 100%; }
.hud-m .chip { padding: 4px 10px; font-size: 13px; color: var(--text); white-space: nowrap; }
.hud-btn { height: 44px; min-width: 44px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
#btn-progress { margin-left: auto; }
#btn-progress .chip { display: inline-flex; align-items: center; height: 32px; font-family: var(--pixel); font-size: 15px; }
#btn-menu.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--panel); font-size: 20px; font-weight: 700; }

/* ---------- Mise en page ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px;
  max-width: 1180px; margin: 0 auto; padding: 0 20px 30px;
}
.board-col { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; position: relative; }

/* Piste des niveaux */
.track { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.lv {
  width: 34px; height: 40px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px;
  opacity: .55; transition: all .3s;
}
.lv small { font-size: 9px; color: var(--muted); font-family: var(--pixel); }
.lv.done { opacity: 1; background: #1f3a2a; border-color: #3c7a50; color: var(--green); }
.lv.cur { opacity: 1; border-color: var(--gold); box-shadow: 0 0 0 2px #f5c45155, 0 0 18px #f5c45155; transform: translateY(-3px); }
.lv.goal { opacity: .8; border-style: dashed; border-color: var(--gold2); }
.lv.goal.done { border-style: solid; background: #4a3a10; }

/* Carte du monstre */
.monster-card {
  width: min(100%, 560px); display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #000a, #0006); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px;
}
.mc-left { display: flex; align-items: center; gap: 10px; }
.mc-emoji { font-size: 34px; filter: drop-shadow(0 3px 4px #000a); animation: idle 2.4s ease-in-out infinite; }
.mc-name { font-family: var(--pixel); font-size: 18px; }
.mc-count span { font-size: 14px; margin-right: 2px; transition: all .4s; }
.mc-count span.dead { filter: grayscale(1) brightness(.4); }
.mc-stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mc-stats span { font-size: 15px; white-space: nowrap; }
.mc-stats b { font-family: var(--pixel); font-size: 20px; margin-left: 2px; color: var(--k); }

/* ---------- Plateau ---------- */
.board-frame {
  width: min(100%, 560px, calc(100vh - 270px)); min-width: 280px;
  padding: 10px; border-radius: 18px;
  background: linear-gradient(180deg, #0b080f, #000);
  box-shadow: 0 0 0 2px #2c2238, 0 20px 50px #000c, inset 0 0 30px #000;
}
.board { position: relative; width: 100%; aspect-ratio: 1; container-type: inline-size; border-radius: 8px; overflow: visible; }
.tiles { position: absolute; inset: 0; display: grid; grid-template: repeat(5, 1fr) / repeat(5, 1fr); border-radius: 8px; overflow: hidden; }
.tile { position: relative; filter: brightness(calc(.9 + var(--v) * .04)); transition: box-shadow .2s, filter .2s; }

.theme-sand .tile {
  background:
    radial-gradient(circle at calc(20% + var(--v) * 12%) 30%, #ffffff22, transparent 35%),
    radial-gradient(circle at 70% 80%, #5a3a1433, transparent 40%),
    linear-gradient(135deg, #cfa66a, #a87b45);
  box-shadow: inset 0 0 0 1px #5a381366, inset 0 -5px 10px #5a381344;
}
.theme-sand .tile.wall {
  background:
    linear-gradient(135deg, transparent 45%, #0002 46% 48%, transparent 49%),
    linear-gradient(145deg, #d6d9dd, #8b9096);
  box-shadow: inset 7px 7px 0 #ffffff40, inset -7px -7px 0 #0000004d, 0 0 0 3px #a87b45 inset;
}
.theme-crypt .tile {
  background:
    radial-gradient(circle at calc(30% + var(--v) * 10%) 60%, #ffffff10, transparent 40%),
    linear-gradient(135deg, #4b3522, #2e1f10);
  box-shadow: inset 0 0 0 1px #00000088, inset 0 -5px 10px #0006;
}
.theme-crypt .tile.wall {
  background:
    radial-gradient(circle at 25% 30%, #5ec46a 0 6%, transparent 7%),
    radial-gradient(circle at 70% 65%, #4aa856 0 5%, transparent 6%),
    repeating-linear-gradient(0deg, #6b6872 0 22%, #3b3840 22% 25%),
    #6b6872;
  box-shadow: inset 4px 4px 0 #ffffff25, inset -4px -4px 0 #0005;
}
.tile.stairs {
  background:
    repeating-linear-gradient(90deg, #f0c33a 0 11%, #9c6f0c 11% 16%),
    #f0c33a !important;
  box-shadow: inset 0 0 18px #000a, inset 0 0 0 1px #0008 !important;
}
.tile.stairs::before { content: '⇣'; position: absolute; right: 6%; top: 2%; font-size: 6cqw; color: #4a3300aa; }

.tile.reach { cursor: pointer; box-shadow: inset 0 0 0 2px #4ade80aa, inset 0 0 24px #4ade8055 !important; filter: brightness(1.12); }
.tile.reach:hover { box-shadow: inset 0 0 0 3px #fff, inset 0 0 30px #ffffff66 !important; filter: brightness(1.3); }
.tile.reach.danger { box-shadow: inset 0 0 0 2px #ff4d6daa, inset 0 0 24px #ff4d6d55 !important; }
.tile.reach.danger:hover { box-shadow: inset 0 0 0 3px #fff, inset 0 0 30px #ff4d6d88 !important; }
/* Badges aux couleurs des stats : coût en Vitesse (vert), dégâts prévus (rose), case sûre (✓ discret) */
.tile.reach::before {
  content: '👢' attr(data-cost); position: absolute; left: 4%; top: 4%;
  font: 700 3.2cqw/1.25 var(--pixel); color: #062512; background: var(--c-spd);
  padding: 0 .8cqw 0 .4cqw; border-radius: 1.2cqw; box-shadow: 0 .3cqw 0 #0006;
}
.tile.reach[data-dmg]::after {
  content: attr(data-dmg); position: absolute; right: 5%; bottom: 5%;
  font: 700 3.4cqw/1.25 var(--pixel); padding: 0 .7cqw; border-radius: 1.2cqw;
}
.tile.reach.danger::after { content: '−' attr(data-dmg) '❤'; background: var(--c-hp); color: #2a0410; box-shadow: 0 .3cqw 0 #0006; }
.tile.reach.safe::after { color: var(--c-spd); text-shadow: 0 1px 2px #000, 0 0 3px #000; opacity: .85; }
/* Aperçu (glisser d'un jeton) : contour en pointillés, rien n'est encore joué */
.tile.reach.preview { box-shadow: inset 0 0 24px #4ade8033 !important; outline: 2px dashed #4ade80dd; outline-offset: -4px; }
.tile.reach.danger.preview { box-shadow: inset 0 0 24px #ff4d6d33 !important; outline-color: #ff4d6ddd; }
/* Aperçu de déplacement : case encadrée de blanc */
.tiles .tile.pending { box-shadow: inset 0 0 0 3px #fff, inset 0 0 30px #ffffff66 !important; filter: brightness(1.3); }
/* Zone de menace d'un monstre (appui long ou survol) */
.tiles .tile.threat { box-shadow: inset 0 0 0 200px #ff1e3c40, inset 0 0 0 1px #ff5d7388 !important; }

/* Entités */
.entities, .fx { position: absolute; inset: 0; pointer-events: none; }
.fx { z-index: 5; }
.ent {
  position: absolute; left: 0; top: 0; width: 20%; height: 20%;
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  transition: transform .18s cubic-bezier(.3,.7,.4,1);
  display: grid; place-items: center; z-index: 2;
}
.ent.spawn { animation: spawn .5s cubic-bezier(.3,1.6,.5,1) backwards; }
.ent .sprite { width: 80%; height: 80%; display: grid; place-items: center; position: relative; }
.ent .sprite::before {
  content: ''; position: absolute; bottom: 4%; left: 18%; right: 18%; height: 14%;
  background: radial-gradient(#000a, transparent 70%); border-radius: 50%;
}
.ent .emo {
  font-size: 11cqw; line-height: 1; position: relative;
  filter: drop-shadow(0 .6cqw .4cqw #000b);
  animation: idle 2s ease-in-out infinite;
}
.ent.monster .emo { animation-duration: 1.6s; }
.ent.hero .emo { filter: drop-shadow(0 0 1.2cqw #4fd6ffaa) drop-shadow(0 .6cqw .4cqw #000b); }
/* Barre de vie en crans sous le sprite : un cran par PV max (rouge monstre, vert-cyan héros) */
.ent .hp {
  position: absolute; left: 15%; right: 15%; bottom: 3%; height: max(6px, 1.9cqw);
  display: flex; gap: max(1px, .35cqw); padding: max(1px, .3cqw);
  background: #000c; border-radius: max(2px, .6cqw); box-shadow: 0 0 0 1px #ffffff1a;
}
.hpbar i { flex: 1; min-width: 0; border-radius: 1px; background: #3a2f4c; }
.ent.monster .hp i.on { background: linear-gradient(180deg, #ff8c9c, #ff2a47); }
.ent.hero .hp i.on { background: linear-gradient(180deg, #9ff7e8, var(--c-hero)); }
.hpbar i.lost { animation: segLost .32s ease; }
.hpbar i.gain { animation: segGain .4s ease; }
.ent .tag {
  position: absolute; top: -2%; left: 50%; transform: translateX(-50%);
  font: 700 3.2cqw/1.25 var(--pixel); white-space: nowrap; color: #2a0700;
  padding: 0 1cqw; border-radius: 1.2cqw; background: var(--c-atk); box-shadow: 0 .3cqw 0 #0006;
  opacity: 0; transition: opacity .2s;
}
.ent.target, .ent.target-dim { pointer-events: auto; }
.ent.monster { pointer-events: auto; cursor: help; }
.ent.target { cursor: crosshair; }
.ent.target .tag { opacity: 1; animation: bob 1s ease-in-out infinite; }
.ent.target .sprite::after {
  content: ''; position: absolute; inset: -4%; border-radius: 50%;
  border: .6cqw dashed var(--red); animation: spin 4s linear infinite;
}
.ent.target:hover .sprite { transform: scale(1.12); transition: transform .15s; }
.ent.target-dim .tag { opacity: 1; background: #666; color: #ddd; }
.ent.preview .sprite::after { border-style: dotted; animation: none; opacity: .75; }
.ent.hero { pointer-events: auto; cursor: grab; }
.ent.ghost { opacity: .5; pointer-events: none; transition: none; z-index: 1; }
.ent.ghost .emo { animation: none; }
.path-dot {
  position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #fff;
  transform: translate(-50%, -50%); box-shadow: 0 0 0 2px #0006; pointer-events: none; z-index: 1;
}
.board.fast .ent { transition-duration: .05s; }
/* Bulle d'infos au-dessus d'un monstre ou d'une case */
.bubble {
  position: absolute; z-index: 8; transform: translate(-50%, calc(-100% - 6px)); pointer-events: none;
  background: #000e; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
  font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 8px 20px #000a;
}
.bubble.below { transform: translate(-50%, 6px); }
.ent.active .emo { filter: drop-shadow(0 0 1.5cqw #ff5d73) drop-shadow(0 .6cqw .4cqw #000b); }
.ent.hurt .sprite { animation: hurt .45s ease; }
.ent.dying { animation: die .5s ease forwards; }

/* Effets */
.float {
  position: absolute; transform: translate(-50%, -50%); z-index: 6;
  font: 700 5cqw var(--pixel); white-space: nowrap; pointer-events: none;
  text-shadow: 0 2px 0 #000, 0 0 8px #000; animation: floatUp 1.1s ease-out forwards;
}
.float.dmg { color: #ffd25a; font-size: 6.5cqw; }
.float.hurt { color: var(--red); font-size: 7cqw; }
.float.atk { color: #ffb6c1; font-size: 4cqw; animation-duration: .8s; }
.float.block { color: var(--cyan); }
.float.safe { color: var(--green); font-size: 4cqw; }
.proj { position: absolute; font-size: 6cqw; z-index: 7; filter: drop-shadow(0 0 6px #fff8); }
/* Bouclier de défense : croissant bleu translucide tourné vers l'attaquant (son bord droit fait face au coup) */
.shield {
  position: absolute; z-index: 6; width: 8cqw; height: 19cqw; pointer-events: none; border-radius: 50%;
  translate: -50% -50%; rotate: var(--rot);   /* propriétés séparées : scale (animations) reste dans le repère du bouclier */
  border-right: 1.3cqw solid #e4f6ff;
  background: radial-gradient(ellipse 120% 64% at 100% 50%, #bfe8ffdd, #4fa8ff99 50%, #4fa8ff55 72%, #4fa8ff30 100%);
  box-shadow: 1.2cqw 0 2.6cqw -.2cqw #4fd6ffee, inset -1cqw 0 1.4cqw #ffffff99;
  filter: drop-shadow(0 0 1cqw #4fa8ff);
  animation: shieldIn .2s cubic-bezier(.3,1.6,.5,1) both, shieldShimmer .9s ease-in-out .2s infinite;
}
.shield::before, .shield::after { content: ''; position: absolute; inset: 0; border-radius: 50%; }
/* Trame hexagonale discrète */
.shield::before {
  background: repeating-linear-gradient(60deg, transparent 0 1.3cqw, #ffffff30 1.3cqw 1.55cqw),
    repeating-linear-gradient(-60deg, transparent 0 1.3cqw, #ffffff30 1.3cqw 1.55cqw);
  -webkit-mask: linear-gradient(90deg, transparent 20%, #000); mask: linear-gradient(90deg, transparent 20%, #000);
}
.shield.hit { animation: shieldHit .32s ease both; }
.shield.cracked { border-right-color: #b9d4ee; }
/* Fissures : visibles quand le coup passe */
.shield.cracked::after {
  opacity: 0; transition: opacity .1s;
  background: linear-gradient(112deg, transparent 44%, #fff 45% 48%, transparent 49%) 0 0 / 100% 55% no-repeat,
    linear-gradient(64deg, transparent 50%, #fff 51% 54%, transparent 55%) 0 45% / 100% 55% no-repeat,
    linear-gradient(160deg, transparent 40%, #ffffffcc 41% 44%, transparent 45%) 0 100% / 100% 40% no-repeat;
}
.shield.cracked.hit { animation: shieldCrack .4s ease both; }
.shield.cracked.hit::after { opacity: 1; }
.shield.out { animation: shieldOut .3s ease forwards; }
.confetti { position: fixed; top: -20px; height: 12px; z-index: 100; border-radius: 2px; pointer-events: none; }
/* Éléments des attaques (fx.js) : placés par transform, invisibles tant que leur animation n'a pas commencé */
.fxe { position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; z-index: 6; line-height: 1; white-space: nowrap; will-change: transform, opacity; }
.fxe.proj { z-index: 7; }
.proj svg { display: block; overflow: visible; }
.proj .arrow { width: 2.2em; height: .55em; filter: drop-shadow(0 0 .06em #000) drop-shadow(0 0 .25em #7cf08a); }
.fxe.bat { filter: drop-shadow(0 0 .05em #000) drop-shadow(0 0 .25em #ff2a47); }
.fxe.flame { filter: drop-shadow(0 0 .3em #ff7a1f); }
.fxe.paw { filter: drop-shadow(0 0 .08em #fff) drop-shadow(0 0 .2em #ffd6a8); }
.fxe.sparkly { filter: drop-shadow(0 0 .25em #ff9ff3) drop-shadow(0 0 .1em #fff); }
/* Souffle du dragon : cône de chaleur en dégradé, ouvert vers la cible */
.cone {
  transform-origin: 0 0; clip-path: polygon(0 42%, 100% 0, 100% 100%, 0 58%);
  background: linear-gradient(90deg, #fff6c8, #ffb347 25%, #ff5a1fcc 60%, #ff3d1f00);
  filter: blur(2px);
}
.proj .shuriken { width: 1em; height: 1em; }
.orb { display: grid; place-items: center; width: 1.2em; height: 1.2em; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 18%, #d6b8ff 32%, #9a5cff88 58%, transparent 72%); }
.dot { border-radius: 30%; }
.dot.bit { box-shadow: 0 0 0 .25cqw #0000002e; }
.dot.streak { border-radius: 1cqw; box-shadow: 0 0 0 .2cqw #0004, 0 0 1cqw currentColor; }
.dot.soft { border-radius: 50%; filter: blur(1px); }
.dot.drop { border-radius: 50% 0 50% 50%; box-shadow: 0 0 1cqw #ff2a47; }
.dot.smoke { border-radius: 50%; filter: blur(3px); }
.dot.twinkle { text-shadow: 0 0 1cqw currentColor, 0 0 2.5cqw currentColor; }
.dot.ghost { filter: drop-shadow(0 0 1.2cqw #4fd6ff) saturate(.4) brightness(1.4); }
.glow { border-radius: 50%; background: radial-gradient(circle, #fff 0 10%, currentColor 32%, transparent 70%); }
.ring { border-radius: 50%; border: 1cqw solid currentColor; box-shadow: 0 0 0 .25cqw #00000040, 0 0 1.6cqw currentColor, inset 0 0 1.2cqw currentColor; }
.ring.quakering { box-shadow: 0 0 0 .4cqw #3a200c66, inset 0 0 0 .4cqw #3a200c55, 0 0 2cqw currentColor; }
/* Entailles : fin contour sombre (lisible sur le sable clair) puis halo de leur couleur */
.slash { filter: drop-shadow(0 0 .2cqw #000c) drop-shadow(0 0 1cqw currentColor); }
.slash svg { display: block; width: 100%; height: 100%; overflow: visible; }
.fxs svg { position: absolute; left: 0; top: 0; overflow: visible; }
.fxs path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.bolt { filter: drop-shadow(0 0 1.5cqw #b38cff); }
.silk path, .cracks path { stroke-dasharray: 1; }
.silk { filter: drop-shadow(0 0 .6cqw #fff); }
.beam {
  height: 3.4cqw; transform-origin: 0 0; border-radius: 2cqw;
  background: linear-gradient(180deg, transparent, #ffb84d 22%, #fff6c8 40%, #fff 50%, #fff6c8 60%, #ffb84d 78%, transparent);
  box-shadow: 0 0 2.5cqw #ffd25a, 0 0 5cqw #ff9a3d88;
}
.webby { filter: brightness(2.2) drop-shadow(0 0 .8cqw #fff); }

.board-frame.shake { animation: shake .45s ease; }
.board-frame.quake { animation: quake .3s ease; }
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, #ff1e3c88 100%);
}
.vignette.flash { animation: flash .6s ease; }

.toast {
  position: absolute; bottom: -6px; left: 50%; transform: translate(-50%, 10px);
  background: #000d; border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; white-space: nowrap; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Panneau ---------- */
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hero-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.pop { animation: pop .35s ease; display: inline-block; }

/* Jetons d'énergie : un chiffre dans une forme. Neutre (doré, dé arrondi), puis forme et couleur de la stat. */
.tok {
  --shape: inset(0 round 24%); --edge: #8a5a12; --ink: #2a1600;
  --fill: linear-gradient(160deg, #fff0b8, #f5c451 45%, #d9952b);
  position: relative; display: grid; place-items: center; flex: none;
  width: var(--ts, 56px); height: var(--ts, 56px);
  filter: drop-shadow(0 calc(var(--ts, 56px) * .05) 0 #0008) drop-shadow(0 calc(var(--ts, 56px) * .08) calc(var(--ts, 56px) * .1) #0006);
}
.tok::before, .tok::after { content: ''; position: absolute; inset: 0; clip-path: var(--shape); }
.tok::before { background: var(--edge); }
.tok::after { inset: 7%; background: radial-gradient(circle at 32% 24%, #ffffff99, transparent 40%), var(--fill); }
.tok b { position: relative; z-index: 1; font: 700 calc(var(--ts, 56px) * .5) / 1 var(--pixel); color: var(--ink); text-shadow: 0 1px 0 #ffffff66; }
/* Vitesse : chevron vert */
.tok-spd {
  --shape: polygon(0 6%, 58% 6%, 100% 50%, 58% 94%, 0 94%, 24% 50%); --edge: #14592c; --ink: #052410;
  --fill: linear-gradient(160deg, #b6f9cc, #4ade80 50%, #1f9e50);
}
.tok-spd::after { inset: 9% 8% 9% 7%; }
.tok-spd b { transform: translateX(10%); font-size: calc(var(--ts, 56px) * .44); }
/* Attaque : losange rouge-orange */
.tok-atk {
  --shape: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); --edge: #8a2410; --ink: #2a0700;
  --fill: linear-gradient(160deg, #ffc2b2, #ff6b4a 50%, #d63d1c);
}
.tok-atk::after { inset: 9%; }
.tok-atk b { font-size: calc(var(--ts, 56px) * .42); }
/* Défense : écu bleu */
.tok-def {
  --shape: polygon(50% 0, 100% 9%, 100% 46%, 94% 68%, 79% 86%, 50% 100%, 21% 86%, 6% 68%, 0 46%, 0 9%);
  --edge: #163f78; --ink: #04172e; --fill: linear-gradient(160deg, #c2e2ff, #4fa8ff 50%, #2672d0);
}
.tok-def b { margin-top: -12%; font-size: calc(var(--ts, 56px) * .46); }
.tok.rolling { animation: tumble .28s linear infinite; }
.tok.landed { animation: land .4s cubic-bezier(.3,1.7,.5,1); }
.tok.swapped { animation: land .35s cubic-bezier(.3,1.7,.5,1); }
/* Petits jetons dans le texte (règles) */
.tok-mini { --ts: 24px; display: inline-grid; vertical-align: middle; margin: -4px 1px 0; }

/* Barre des stats unifiée, seule interface du tour (voir docs/ui-v3.md) :
   ligne 1 = vie en crans + réserve des jetons ; ligne 2 = 4 tuiles qui sont aussi les emplacements.
   Hauteurs fixes : seul le contenu change, jamais la taille ni la position. */
.statbar { display: flex; flex-direction: column; gap: 6px; }
.sb-top { display: flex; align-items: center; gap: 10px; height: 52px; }
.hprow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 22px; padding: 0 2px; }
.hprow.hit { animation: shake .45s ease; }
.hp-ico { color: var(--c-hp); font-size: 17px; line-height: 1; text-shadow: 0 0 8px #ff4d6d88; }
#hero-hp { flex: 1; min-width: 0; height: 14px; display: flex; gap: 3px; }
#hero-hp i { border-radius: 3px; background: #0009; box-shadow: inset 0 0 0 1px #ffffff14; }
#hero-hp i.on { background: linear-gradient(180deg, #a8f8ea, var(--c-hero) 60%, #23a891); box-shadow: inset 0 -3px 0 #0003, 0 0 8px #3fe0c544; }
#hp-num { font: 700 18px var(--pixel); min-width: 34px; text-align: right; }

/* Réserve : 3 places fixes ; une place vidée reste en fantôme pointillé très discret */
.pool { flex: none; display: flex; gap: 6px; align-items: center; padding: 1px; border-radius: 14px; transition: box-shadow .15s; }
.pool.drop-target { box-shadow: 0 0 0 2px var(--gold), 0 0 18px #f5c451aa; }
.pool.nudge { animation: nope .3s ease; }
.pool-tok {
  --ts: 48px; width: 50px; height: 50px; padding: 0; border: 0; background: none; border-radius: 12px;
  display: grid; place-items: center; transition: transform .15s;
}
.pool-tok:not(.empty):hover { transform: translateY(-3px) rotate(-3deg); }
.pool-tok.empty { box-shadow: inset 0 0 0 2px #ffffff0d; outline: 2px dashed #ffffff1f; outline-offset: -5px; pointer-events: none; }
.pool-tok.lifted { outline: 2px dashed #ffffff55; outline-offset: -2px; }
.pool-tok.lifted .tok { opacity: 0; }

.st-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.st-tile {
  --ts: 28px; position: relative; height: 96px; padding: 4px 3px 9px; border-radius: 12px; min-width: 0;
  border: 2px solid color-mix(in srgb, var(--k) 45%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--k) 20%, var(--bg2)), var(--bg2) 80%);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px;
  touch-action: none; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.st-tile:not(.locked):not([data-k="rng"]):hover { transform: translateY(-2px); border-color: var(--k); }
.ts-ico { position: absolute; left: 5px; top: 4px; font-size: 15px; line-height: 1; }
.ts-tok { position: absolute; right: 3px; top: 3px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; }
/* Emplacement vide : pointillés aux couleurs de la stat */
.tok-well { width: 26px; height: 26px; border-radius: 8px; border: 2px dashed color-mix(in srgb, var(--k) 70%, transparent); background: #0005; }
.ts-val { font: 700 30px/1 var(--pixel); color: var(--k); text-shadow: 0 2px 0 #0009; white-space: nowrap; }
.ts-val i { font-style: normal; font-size: .72em; color: color-mix(in srgb, var(--k) 55%, var(--muted)); }
.ts-val s { color: var(--muted); font-size: .55em; text-decoration-thickness: 2px; margin-right: 2px; }
.ts-help { font-size: 11.5px; font-weight: 700; color: var(--text); white-space: nowrap; }
.ts-base { font-size: 11px; color: var(--muted); white-space: nowrap; }
.st-tile.empty { background: linear-gradient(180deg, color-mix(in srgb, var(--k) 12%, var(--bg2)), var(--bg2) 80%); }
.st-tile.empty .ts-help { color: var(--muted); font-weight: 600; }
.ts-bar { position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px; background: #0008; overflow: hidden; }
.ts-bar i { display: block; height: 100%; background: var(--k); transition: width .45s cubic-bezier(.3,.7,.4,1); }
.st-tile.locked::after { content: '🔒'; position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font-size: 11px; line-height: 1; }
/* Guide : la tuile qui recevra le prochain jeton tapé pulse doucement */
.st-tile.cur { border-color: var(--k); animation: guidePulse 1.2s ease-in-out infinite; }
.st-tile.cur .tok-well { animation: wellPulse 1.2s ease-in-out infinite; }
.st-tile.cur .ts-help { color: var(--k); font-weight: 800; }
.st-tile.drop-target { border-color: var(--gold); box-shadow: 0 0 0 3px #f5c45155, 0 0 18px #f5c451aa; transform: translateY(-3px); animation: none; }
.st-tile[data-k="rng"].drop-target { border-color: var(--red); box-shadow: 0 0 0 3px #ff5d7355, 0 0 18px #ff5d7388; transform: none; }
.st-tile.lifted .ts-tok { outline: 2px dashed #ffffff55; outline-offset: 1px; }
.st-tile.lifted .ts-tok .tok { opacity: 0; }
/* La tuile 🛡️ pulse avec le bouclier pendant la riposte */
.st-tile.guard { animation: guardPulse .55s ease; }
.st-tile.nope { animation: nope .25s ease; }
#drag-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.drag-ghost { --ts: 64px; position: absolute; left: 0; top: 0; width: 64px; height: 64px; will-change: transform; }
.drag-ghost .tok { filter: drop-shadow(0 12px 12px #000c); }

/* Boutons */
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 6px 8px; }
/* Consigne : sous-libellé du bouton principal */
.hint { grid-column: 2; margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; min-height: 16px; line-height: 1.3; }
.btn {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 12px 14px;
  font-weight: 700; transition: transform .12s, filter .15s, opacity .2s;
}
.btn:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.15); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.primary {
  background: linear-gradient(180deg, #ffd66b, var(--gold2)); color: #2a1600; border-color: #ffdf8a;
  box-shadow: 0 4px 0 #8a5a12, 0 8px 20px #f5c45133; font-family: var(--pixel); font-size: 17px;
}
.btn.primary.pulse { animation: glow 1.8s ease-in-out infinite; }
.btn.primary small { display: block; font: 600 11px/1.2 var(--sans); }
.btn.big { width: 100%; padding: 15px; font-size: 20px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.halo { animation: halo .5s ease 2; }

/* Oracle : une ligne de hauteur réservée sous le plateau, même vide */
.oracle {
  height: 22px; margin-top: -4px; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; color: var(--purple); white-space: nowrap;
}
.oracle b { font-family: var(--pixel); font-size: 16px; }
.oracle small { color: var(--muted); font-size: 12px; }
.oracle .bad { color: var(--red); }
.oracle .good { color: var(--green); }
.oracle .cue { color: var(--text); }

/* Journal : replié sur sa dernière ligne, clic pour déplier */
.log {
  background: #0005; border: 1px solid var(--line); border-radius: 12px; padding: 8px 28px 8px 10px; position: relative;
  min-height: 44px; max-height: 170px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 3px; cursor: pointer;
}
.log::after { content: '▾'; position: absolute; right: 10px; top: 7px; color: var(--muted); transition: transform .2s; }
.log.open::after { transform: rotate(180deg); }
.log:not(.open) { overflow: hidden; }
.log:not(.open) .log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log:not(.open) .log-line:not(:first-child) { display: none; }
.log-line { color: var(--muted); animation: slideIn .3s ease; }
.log-line:first-child { color: var(--text); }
.log-line.good { color: var(--green); }
.log-line.bad { color: var(--red); }
.log-line.lvl { color: var(--gold); font-weight: 700; }

/* ---------- Bandeaux de phase & overlays ---------- */
/* Une bande traverse l'écran : entre à gauche (en biais), se pose, repart à droite. Couleur selon la phase. */
.banner {
  position: fixed; inset: 0; z-index: 60; display: grid; align-items: center; overflow: hidden;
  pointer-events: none; visibility: hidden;
}
.banner.show, .banner.out { visibility: visible; }
.banner.show { pointer-events: auto; cursor: pointer; }
.banner::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .25s;
  background: radial-gradient(ellipse 120% 45% at 50% 50%, #07040bcc, #07040b55 70%, transparent);
}
.banner.show::before { opacity: 1; }
.bn-band {
  --bn: #4a3208; --bn2: #9c6a12; --edge: #f5c451; --ink: #ffe39a;
  position: relative; width: 100%; padding: 16px 16px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px;
  background: linear-gradient(90deg, transparent, var(--bn) 9%, var(--bn2) 50%, var(--bn) 91%, transparent);
  box-shadow: 0 0 50px #000c;
  transform: translateX(-108%) skewX(-12deg);
}
/* Liserés pixel en haut et en bas de la bande */
.bn-band::before, .bn-band::after {
  content: ''; position: absolute; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--edge) 0 14px, transparent 14px 20px);
  -webkit-mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.bn-band::before { top: 0; } .bn-band::after { bottom: 0; }
.banner.show .bn-band { transform: none; transition: transform .36s cubic-bezier(.2,1.3,.4,1); }
.banner.out .bn-band { transform: translateX(108%) skewX(-12deg); transition: transform .22s cubic-bezier(.6,0,.9,.4); }
.bn-ico { font-size: clamp(40px, 11vw, 70px); line-height: 1; filter: drop-shadow(0 0 10px #ffffff66) drop-shadow(0 4px 0 #0009); }
.banner.show .bn-ico { animation: bnIco .55s cubic-bezier(.3,1.7,.5,1) .12s backwards, bnBob 1s ease-in-out .7s infinite; }
.bn-text { text-align: center; min-width: 0; }
.banner h2 {
  margin: 0; font: 700 clamp(30px, 8.4vw, 64px)/1.02 var(--pixel); color: var(--ink); letter-spacing: 1px; text-wrap: balance;
  text-shadow: 3px 0 #000, -3px 0 #000, 0 3px #000, 0 -3px #000, 2px 2px #000, -2px 2px #000, 2px -2px #000, -2px -2px #000, 0 7px 0 #0008;
}
.banner.show h2 { animation: bnTitle .45s cubic-bezier(.3,1.6,.5,1) .06s backwards; }
.banner p {
  margin: 6px 0 0; font: 600 clamp(16px, 4.6vw, 22px)/1.2 var(--pixel); color: #fff;
  text-shadow: 2px 0 #000, -2px 0 #000, 0 2px #000, 0 -2px #000, 0 3px 0 #0008;
}
.banner p .op { font: 800 1.05em var(--sans); font-style: normal; }
.bn-extra { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; }
.bn-extra:empty { display: none; }
/* Mini-stats du monstre (début de niveau) */
.bn-extra span[data-k] {
  font: 600 15px/1 var(--pixel); background: #000a; border: 1px solid color-mix(in srgb, var(--k) 50%, transparent);
  border-radius: 8px; padding: 4px 8px; white-space: nowrap;
}
.bn-extra span[data-k] b { color: var(--k); font-size: 19px; margin-left: 3px; }
.banner.show .bn-extra span[data-k] { animation: dealIn .4s cubic-bezier(.3,1.5,.5,1) backwards; }
.banner.show .bn-extra span:nth-child(2) { animation-delay: .05s; } .banner.show .bn-extra span:nth-child(3) { animation-delay: .1s; }
.banner.show .bn-extra span:nth-child(4) { animation-delay: .15s; } .banner.show .bn-extra span:nth-child(5) { animation-delay: .2s; }
/* Les 3 jetons tirés tombent dans le bandeau « Votre tour » */
.bn-die { --ts: 50px; display: grid; }
.banner.show .bn-die { animation: dieFall .55s cubic-bezier(.3,1.5,.5,1) calc(.14s + var(--i) * .1s) backwards; }
/* Couleurs des phases */
.bn-turn .bn-band { --bn: #173d24; --bn2: #4f7a1c; --edge: #d7e85a; --ink: #f2ffc2; }
.bn-monsters .bn-band { --bn: #2e0710; --bn2: #6e0f22; --edge: #ff5d73; --ink: #ffd6dc; }
.bn-block .bn-band { --bn: #0a2647; --bn2: #1e5fae; --edge: #8fd4ff; --ink: #e2f4ff; }
.bn-hurt .bn-band { --bn: #3d0610; --bn2: #b0182f; --edge: #ff9aa8; --ink: #fff; }
.bn-safe .bn-band { --bn: #0d3520; --bn2: #1e7a45; --edge: #7cf08a; --ink: #e3ffe6; }
.banner.show.bn-hurt .bn-band { animation: bnShake .4s ease .36s; }
.banner.show.bn-block .bn-ico { animation: bnIco .55s cubic-bezier(.3,1.7,.5,1) .12s backwards, bnShine 1.1s ease-in-out .6s infinite; }
.banner.show.bn-monsters .bn-ico { animation: bnIco .55s cubic-bezier(.3,1.7,.5,1) .12s backwards, bnGrowl .5s ease-in-out .6s infinite; }

.overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; padding: 16px;
  background: #07040bcc; backdrop-filter: blur(6px); opacity: 0; pointer-events: none;
  visibility: hidden; transition: opacity .3s, visibility 0s linear .3s;
  overflow-y: auto;
}
.overlay.show { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity .3s; }
.modal {
  position: relative; width: min(100%, 640px); margin: auto; background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 30px 80px #000;
  transform: translateY(20px) scale(.97); transition: transform .35s cubic-bezier(.3,1.4,.5,1);
}
.overlay.show .modal { transform: none; }
.modal-title { font: 700 30px var(--pixel); margin: 0 0 6px; color: var(--gold); text-align: center; }
.sub { text-align: center; color: var(--muted); margin: 0 0 18px; }

.start { text-align: center; width: min(100%, 520px); }
.start-icon { font-size: 54px; animation: idle 2s ease-in-out infinite; }
.title { font-size: clamp(36px, 8vw, 52px); margin: 4px 0; line-height: 1; }
.tagline { color: var(--muted); margin: 6px 0 18px; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #0006;
  color: var(--text); font: 600 16px var(--sans); outline: none;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #f5c45133; }
.avatars { display: flex; gap: 6px; flex-wrap: wrap; }
.av {
  width: 46px; height: 46px; font-size: 26px; border-radius: 12px; border: 2px solid var(--line); background: #0004;
  transition: transform .15s;
}
.av:hover { transform: translateY(-3px); }
.av.sel { border-color: var(--gold); background: #f5c45122; transform: scale(1.08); }
.av-style { margin: 6px 0 0; font: 600 14px var(--pixel); color: var(--gold); min-height: 1.3em; }
.av-style small { font: 400 12px var(--sans); color: var(--muted); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode {
  padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: #0004; font-weight: 700;
  display: flex; flex-direction: column; gap: 2px;
}
.mode small { font-weight: 400; font-size: 11.5px; color: var(--muted); }
.mode.sel { border-color: var(--gold); background: #f5c45118; }
.hof { margin-top: 16px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px; }
.hof h3 { margin: 0 0 8px; font: 700 18px var(--pixel); text-align: center; }
.hof ol { margin: 0; padding-left: 26px; max-height: 210px; overflow-y: auto; }
.hof li { padding: 4px 0; display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 14px; }
.hof li:nth-child(1)::marker { color: var(--gold); }
.hof .res { font-weight: 700; color: var(--gold); }
.hof .turns { color: var(--muted); font-size: 12.5px; }
.hof .empty { display: block; color: var(--muted); list-style: none; margin-left: -26px; text-align: center; }

.rewards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.reward {
  border: 2px solid var(--line); background: #0004; border-radius: 14px; padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: dealIn .45s cubic-bezier(.3,1.5,.5,1) backwards; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.reward { border-top: 4px solid var(--k); }
.reward:not(:disabled):hover { transform: translateY(-6px) rotate(-1deg); border-color: var(--k); box-shadow: 0 10px 24px color-mix(in srgb, var(--k) 30%, transparent); }
.reward:disabled { opacity: .35; }
.r-ico { font-size: 30px; }
.r-title { font: 700 15px var(--pixel); color: var(--k); }
.reward .cur { font-size: 13px; color: var(--muted); }
.reward .cur b { color: var(--green); }
.r-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }
.next { margin-top: 16px; text-align: center; font-size: 14px; color: var(--muted); }
.next b { color: var(--text); }
.next .mini { display: block; margin-top: 4px; }

.end { text-align: center; }
.end-icon { font-size: 70px; }
.end .btn.ghost { margin-top: 10px; text-decoration: underline; }
.end-icon.win { animation: float 2s ease-in-out infinite; filter: drop-shadow(0 0 20px var(--gold)); }
.end-icon.lose { animation: sink 1s ease; }
.end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 20px; }
.end-stats div { background: #0004; border-radius: 12px; padding: 10px 4px; }
.end-stats b { display: block; font: 700 26px var(--pixel); color: var(--gold); }
.end-stats small { color: var(--muted); font-size: 12px; }

.rules { max-height: 88vh; overflow-y: auto; line-height: 1.55; }
.rules h3 { font: 700 17px var(--pixel); margin: 16px 0 4px; color: var(--text); }
.rules p, .rules li { color: #d8cde4; font-size: 14.5px; }
.rules ul { padding-left: 20px; margin: 4px 0; }
.rules .credit { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; }
.close {
  position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2);
}

/* Feuille du bas (mobile) : Menu ou Progression */
.sheet-back {
  position: fixed; inset: 0; z-index: 75; background: #07040b99; opacity: 0; visibility: hidden;
  transition: opacity .22s, visibility 0s linear .22s;
}
.sheet-back.show { opacity: 1; visibility: visible; transition: opacity .22s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 70vh; max-height: 70dvh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; padding: 0 16px env(safe-area-inset-bottom); box-shadow: 0 -20px 50px #000a;
  transform: translateY(100%); transition: transform .22s cubic-bezier(.3,.7,.4,1);
}
.sheet-back.show .sheet { transform: none; }
.sheet-head { height: 28px; flex: none; display: grid; place-items: center; touch-action: none; cursor: grab; margin: 0 48px; }
.sheet-head::before { content: ''; width: 36px; height: 4px; border-radius: 2px; background: var(--muted); opacity: .6; }
.sheet .close { top: 8px; right: 10px; width: 44px; height: 44px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 16px; }
.sheet-title { font: 700 22px var(--pixel); color: var(--gold); margin: 0 0 12px; }
.sheet-sub { font: 700 16px var(--pixel); margin: 16px 0 6px; }
.sheet-row {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between;
  background: #0004; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; margin-bottom: 8px; font-weight: 700;
}
.sheet-row i { font-style: normal; color: var(--muted); }
.sw { width: 40px; height: 22px; border-radius: 11px; background: #0008; position: relative; transition: background .15s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.sheet-row[aria-checked="true"] .sw { background: #3c7a50; }
.sheet-row[aria-checked="true"] .sw::after { transform: translateX(18px); background: #fff; }
.sheet-log { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.sheet .monster-card { width: 100%; }
.sheet-track { display: grid; grid-template-columns: repeat(7, 40px); gap: 6px; justify-content: center; margin-top: 14px; }
.sheet-track .lv { width: 40px; height: 40px; }

/* ---------- Animations ---------- */
@keyframes idle { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -20%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spawn { from { transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0) rotate(-30deg); opacity: 0; } }
@keyframes hurt {
  0% { filter: brightness(3) saturate(0); transform: translateX(0); }
  20% { transform: translateX(-10%); } 40% { transform: translateX(10%); }
  60% { transform: translateX(-6%); filter: brightness(1.5) sepia(1) hue-rotate(-50deg) saturate(5); }
  100% { filter: none; transform: none; }
}
@keyframes die {
  30% { transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(1.3) rotate(10deg); filter: brightness(3); }
  100% { transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)) scale(0) rotate(-90deg); opacity: 0; }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  20% { opacity: 1; transform: translate(-50%, -80%) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -220%) scale(1); }
}
@keyframes shake {
  0%,100% { transform: translate(0,0); } 15% { transform: translate(-8px, 4px) rotate(-1deg); }
  30% { transform: translate(7px, -5px) rotate(1deg); } 45% { transform: translate(-6px, 3px); }
  60% { transform: translate(5px, -2px); } 80% { transform: translate(-2px, 1px); }
}
@keyframes quake { 0%,100% { transform: none; } 25% { transform: translate(-3px, 2px); } 50% { transform: translate(3px, -2px); } 75% { transform: translate(-1px, 1px); } }
@keyframes flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tumble {
  0% { transform: rotate(0) translateY(0) scale(1); }
  25% { transform: rotate(90deg) translateY(-8px) scale(1.06); }
  50% { transform: rotate(180deg) translateY(0) scale(.95); }
  75% { transform: rotate(270deg) translateY(-5px) scale(1.04); }
  100% { transform: rotate(360deg) translateY(0) scale(1); }
}
@keyframes land { 0% { transform: scale(1.45) rotate(-18deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); color: #fff; } 100% { transform: scale(1); } }
@keyframes glow { 0%,100% { box-shadow: 0 4px 0 #8a5a12, 0 0 0 0 #f5c45100; } 50% { box-shadow: 0 4px 0 #8a5a12, 0 0 22px 4px #f5c45166; } }
@keyframes segLost { 0%, 45% { background: #fff; box-shadow: 0 0 6px #fff; } 100% { background: #3a2f4c; } }
@keyframes segGain { 0% { background: #fff; transform: scaleY(1.8); } }
@keyframes guidePulse { 0%,100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--k) 30%, transparent); } 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--k) 45%, transparent), 0 0 18px color-mix(in srgb, var(--k) 55%, transparent); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } }
@keyframes wellPulse { 50% { border-color: var(--k); background: color-mix(in srgb, var(--k) 22%, #0005); } }
@keyframes guardPulse {
  0%,100% { box-shadow: none; }
  35% { transform: scale(1.06); border-color: #bfe6ff; box-shadow: 0 0 0 3px #4fa8ff88, 0 0 22px #4fd6ffcc; }
}
@keyframes shieldIn { from { scale: .1 .4; opacity: 0; } 60% { scale: 1.2 1.05; opacity: 1; } to { scale: 1; opacity: 1; } }
@keyframes shieldShimmer { 50% { filter: drop-shadow(0 0 1.8cqw #8fd4ff) brightness(1.2); } }
@keyframes shieldHit { 0% { scale: 1; filter: brightness(3); } 30% { scale: .7 1.12; } 65% { scale: 1.12 .96; } 100% { scale: 1; filter: none; } }
@keyframes shieldCrack { 0% { filter: brightness(2.5); } 25% { transform: rotate(6deg); } 50% { transform: rotate(-5deg); } 100% { opacity: .8; filter: saturate(.7) drop-shadow(0 0 1cqw #4fa8ff); } }
@keyframes shieldOut { to { opacity: 0; scale: 1.35 1.1; } }
@keyframes bnIco { from { transform: scale(0) rotate(-35deg); } }
@keyframes bnBob { 50% { transform: translateY(-8%) rotate(-6deg); } }
@keyframes bnShine { 50% { transform: scale(1.1); filter: drop-shadow(0 0 14px #8fd4ff) drop-shadow(0 4px 0 #0009); } }
@keyframes bnGrowl { 25% { transform: rotate(-8deg) scale(1.06); } 75% { transform: rotate(8deg) scale(1.06); } }
@keyframes bnTitle { from { transform: scale(1.8); opacity: 0; letter-spacing: 10px; } }
@keyframes bnShake { 20% { transform: translate(-10px, 3px); } 40% { transform: translate(9px, -3px); } 60% { transform: translate(-6px, 2px); } 80% { transform: translate(3px, 0); } }
@keyframes dieFall { from { transform: translateY(-140px) rotate(-220deg) scale(.6); opacity: 0; } 70% { opacity: 1; } }
@keyframes dealIn { from { transform: translateY(40px) rotate(8deg) scale(.8); opacity: 0; } }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
@keyframes sink { from { transform: translateY(-40px); opacity: 0; } }
@keyframes nope { 20% { transform: translateX(-5px) rotate(-4deg); } 40% { transform: translateX(5px) rotate(4deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes halo { 0%,100% { box-shadow: 0 0 0 0 #f5c45100; } 50% { box-shadow: 0 0 0 4px #f5c451aa, 0 0 18px #f5c451aa; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  /* Bandeaux : simple fondu, sans traversée */
  .bn-band, .banner.out .bn-band { transform: none; opacity: 0; transition: opacity .2s; }
  .banner.show .bn-band { opacity: 1; transition: opacity .2s; }
}

/* ---------- Mobile ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; padding: 0 12px 24px; }
  .board-frame { width: min(100%, 560px); }
  .log { max-height: 120px; }
  .rewards { grid-template-columns: repeat(3, 1fr); }
  /* Barre d'action collée en bas de l'écran, toujours visible */
  .layout { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 8px 12px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--line); box-shadow: 0 -8px 20px #0008;
  }
  .actions .btn { min-height: 46px; }
}
@media (max-width: 520px) {
  .topbar { padding: 6px 12px; }
  .logo { font-size: 18px; }
  .chip { padding: 5px 8px; font-size: 12px; }
  .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .track { gap: 2px; }
  .lv { width: 24px; height: 32px; font-size: 12px; }
  .mc-stats { gap: 6px; }
  .mc-stats span { font-size: 13px; }
  .mc-stats b { font-size: 16px; }
  .board-frame { padding: 6px; min-width: 0; }
  /* Compact : plateau + dés + barre d'action tiennent sur un écran de 812 px */
  .layout { gap: 8px; }
  .board-col { gap: 6px; }
  .monster-card { padding: 4px 10px; }
  .mc-emoji { font-size: 24px; }
  .mc-name { font-size: 15px; }
  .mc-count span { font-size: 12px; }
  .hero-card { padding: 8px; }
  .actions { padding-top: 6px; gap: 4px 8px; }
  .actions .btn { padding: 10px 12px; }
  .hint { grid-column: 1 / -1; font-size: 12px; }
  .rewards { grid-template-columns: repeat(2, 1fr); }
  .end-stats { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 20px 16px; }
}

/* ---------- Disposition mobile : ≤ 920 px (téléphone, tablette) ou paysage bas (voir docs/mobile-ux.md) ---------- */
/* Un écran sans défilement : HUD | plateau | ligne de statut | barre des stats | barre d'action */
@media (max-width: 920px), (orientation: landscape) and (max-height: 500px) {
  :root { --chrome: calc(44px + 28px + 154px + 60px + 4 * 6px + env(safe-area-inset-top) + env(safe-area-inset-bottom)); }
  html, body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; overscroll-behavior: none; }
  #app {
    height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto; row-gap: 6px;
    padding: env(safe-area-inset-top) 8px 0 8px;
  }
  .layout, .board-col, .panel { display: contents; }
  .logo, .hud, #track, #monster-card, #log, #hint, #toast { display: none; }

  /* A. HUD */
  .topbar { height: 44px; padding: 0; margin: 0; max-width: none; width: 100%; }
  .hud-m { display: flex; }

  /* B. Plateau carré, centré dans l'espace restant */
  .board-frame {
    width: min(calc(100vw - 16px), calc(100vh - var(--chrome)), 560px);
    width: min(calc(100vw - 16px), calc(100dvh - var(--chrome)), 560px);
    min-width: 0; padding: 4px; border-radius: 12px; justify-self: center; align-self: center;
  }

  /* C. Ligne de statut : une ligne, hauteur réservée */
  .oracle {
    height: 28px; margin: 0; display: block; min-width: 0; text-align: center; line-height: 28px;
    overflow: hidden; text-overflow: ellipsis; font-size: 14px;
  }

  /* D. Barre des stats unifiée (vie + réserve, 4 tuiles) : hauteur fixe, le plateau ne bouge pas */
  .hero-card { height: 154px; padding: 0; background: none; border: 0; border-radius: 0; }

  /* E. Barre d'action dans le flux de la grille */
  .actions {
    position: static; grid-template-columns: 60px 1fr; gap: 8px; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    background: none; border: 0; box-shadow: none;
  }
  .actions .btn { height: 48px; min-height: 48px; padding: 0 10px; }
  #btn-undo { font-size: 20px; }
  #btn-undo .lbl { display: none; }

  /* Tablette : les commandes gardent la largeur du plateau */
  .topbar, .oracle, .hero-card, .actions { width: 100%; max-width: 560px; justify-self: center; }
}

/* Paysage bas : plateau à gauche, commandes à droite (zone du pouce droit) */
@media (orientation: landscape) and (max-height: 500px) {
  #app {
    grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; column-gap: 12px;
    padding: 8px max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
  .board-frame { grid-column: 1; grid-row: 1 / -1; width: calc(100vh - 16px); width: calc(100dvh - 16px); align-self: start; }
  .topbar { grid-column: 2; grid-row: 1; }
  .oracle { grid-column: 2; grid-row: 2; }
  .hero-card { grid-column: 2; grid-row: 4; }
  .actions { grid-column: 2; grid-row: 5; }
}

/* Très étroit : la réserve passe au-dessus de la barre de vie, dans le même bloc, à hauteur fixe */
@media (max-width: 339px) {
  :root { --chrome: calc(44px + 28px + 182px + 60px + 4 * 6px + env(safe-area-inset-top) + env(safe-area-inset-bottom)); }
  .sb-top { flex-direction: column; align-items: stretch; height: 80px; gap: 4px; }
  .pool { order: -1; justify-content: center; }
  .hero-card { height: 182px; }
}
