/*
 * Fusions de Monstres : pages où l'on joue (progression, expédition, défi du
 * jour, entraînement).
 *
 * La taille d'une case (--case) se cale sur la largeur ET sur la hauteur
 * disponibles : les deux plateaux restent visibles ensemble, du téléphone au
 * grand écran. Trois dispositions :
 *   - écran large : plateaux empilés à gauche, commandes à droite ;
 *   - écran étroit : tout empilé, le bouton de bataille collé en bas ;
 *   - téléphone couché : les deux plateaux côte à côte, premières lignes au centre.
 *
 * Padding horizontal de #app : toujours 24 px, le banner partagé sort du
 * conteneur avec des marges négatives calées sur cette valeur.
 */

* { box-sizing: border-box; }

body.page-fm {
  --el-feu: #f87171;
  --el-eau: #60a5fa;
  --el-terre: #a3d977;
  --el-air: #e9d5ff;
  --fm-fond: #0f0a1f;
  --fm-carte: #1a1133;
  --fm-trait: rgba(167, 139, 250, 0.22);
  --fm-or: #fbbf24;
  --fm-violet: #a78bfa;
  --case: clamp(38px, min(calc((100vw - 430px) / 5), calc((100dvh - 410px) / 6)), 84px);
  margin: 0;
  padding: 60px 12px 28px;
  background: linear-gradient(180deg, var(--fm-fond) 0%, #1a0d2e 100%);
  color: #e5e7eb;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.page-fm #app {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 22px;
  background: var(--fm-carte);
  border: 1px solid var(--fm-trait);
  border-radius: 14px;
}

.page-fm h1 { font-size: 1.35rem; color: var(--fm-or); margin: 0; }
.page-fm h2 { font-size: 1.15rem; color: var(--fm-or); margin: 0 0 10px; }
.page-fm h3 { font-size: 1rem; color: var(--fm-or); margin: 0 0 10px; }
.page-fm #app a { color: #c4b5fd; }
.page-fm [hidden] { display: none !important; }

.page-fm footer { text-align: center; font-size: 0.82rem; color: #9ca3af; margin-top: 26px; line-height: 1.7; }
.page-fm #app footer a { color: #cbd5e1; }
.credit-icones { font-size: 0.72rem; opacity: 0.75; }

/* ---- En-tête : titre et modes ------------------------------------------- */
.fm-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 10px 0 12px; }
.fm-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.fm-modes a {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--fm-trait);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.fm-modes a:hover { background: rgba(167, 139, 250, 0.14); }
.fm-modes a[aria-current="page"] { background: #7c3aed; border-color: #a78bfa; color: #fff !important; }

.fm-intro, .fm-pied-jeu { color: #cbd5e1; font-size: 0.9rem; line-height: 1.6; margin: 0 0 12px; }
.fm-pied-jeu { margin: 16px 0 0; text-align: center; }
.date-titre { color: #c4b5fd; font-weight: 600; margin: 0 0 12px; }
.fm-note { color: #a8a3b8; font-size: 0.85rem; margin: 8px 0; }

/* ---- Boutons --------------------------------------------------------------- */
.fm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid #a78bfa;
  border-radius: 12px;
  background: #7c3aed;
  color: #fff !important;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.fm-btn:hover:not(:disabled) { background: #8b5cf6; }
.fm-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fm-btn.secondaire { background: rgba(167, 139, 250, 0.1); border-color: var(--fm-trait); color: #e5e7eb !important; font-weight: 600; }
.fm-btn.secondaire:hover:not(:disabled) { background: rgba(167, 139, 250, 0.22); }
.fm-btn.danger { background: #b91c1c; border-color: #f87171; }
.fm-btn-grand { min-height: 52px; padding: 12px 28px; font-size: 1.05rem; }
.fm-btn-combat { width: 100%; min-height: 54px; background: #dc2626; border-color: #f87171; font-size: 1.05rem; }
.fm-btn-combat:hover:not(:disabled) { background: #ef4444; }
.fm-btn-coffre { width: 100%; }
.fm-btn-coffre.pret { background: #b45309; border-color: var(--fm-or); color: #fff !important; }
.fm-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 14px 0 0; }
.fm-lien { background: none; border: 0; color: #a8a3b8; font: inherit; font-size: 0.82rem; text-decoration: underline; cursor: pointer; padding: 10px 4px; align-self: center; }
.fm-lien:hover { color: #e5e7eb; }

.page-fm button:focus-visible, .page-fm a:focus-visible, .fm-case:focus-visible, .page-fm input:focus-visible {
  outline: 3px solid var(--fm-or);
  outline-offset: 2px;
}

/* ---- Avant-partie, textes -------------------------------------------------- */
.fm-avant, .fm-chargement, .defi-intro {
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid var(--fm-trait);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 14px;
  line-height: 1.6;
  font-size: 0.93rem;
  color: #d6d3e4;
}
.fm-avant p, .defi-intro p { margin: 0 0 10px; }
.fm-avant ul, .defi-intro ul { margin: 0 0 10px; padding-left: 20px; }
.fm-avant li, .defi-intro li { margin: 4px 0; }
.fm-chargement { text-align: center; }
.defi-intro { margin-top: 16px; }

.classement-section {
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 16px;
  margin: 16px 0 0;
}
.classement-invite, .classement-lien { text-align: center; margin: 10px 0 0; font-size: 0.9rem; }

/* ---- Tableau de bord -------------------------------------------------------- */
.fm-hud { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; margin: 0 0 10px; }
.fm-hud-case {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 78px;
  padding: 5px 12px;
  border: 1px solid var(--fm-trait);
  border-radius: 10px;
  background: rgba(15, 10, 31, 0.5);
}
.fm-hud-nom { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: #a8a3b8; }
.fm-hud-case strong { color: var(--fm-or); font-size: 1.05rem; }
.fm-outils { display: flex; gap: 6px; margin-left: auto; }
.fm-outil {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--fm-trait);
  border-radius: 10px;
  background: rgba(15, 10, 31, 0.5);
  color: #e5e7eb;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.fm-outil:hover:not(:disabled) { background: rgba(167, 139, 250, 0.2); }
.fm-outil:disabled { opacity: 0.35; cursor: not-allowed; }

.fm-alerte {
  margin: 0 0 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #f87171;
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ---- Table : arène et panneau ------------------------------------------------ */
.fm-table { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }

.fm-arene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--fm-trait);
  border-radius: 14px;
  background: rgba(15, 10, 31, 0.45);
}
.fm-camp { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.fm-camp-titre { margin: 0; font-size: 0.78rem; font-weight: 700; color: #cbd5e1; text-align: center; line-height: 1.35; }
.fm-camp-note { display: block; font-weight: 400; color: #a8a3b8; font-size: 0.74rem; }
.fm-face { margin: 2px 0; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fm-or); display: flex; align-items: center; gap: 8px; width: 100%; }
.fm-face::before, .fm-face::after { content: ""; flex: 1; height: 1px; background: rgba(251, 191, 36, 0.35); }

.fm-plateau {
  display: grid;
  grid-template-columns: repeat(5, var(--case));
  grid-auto-rows: var(--case);
  gap: 5px;
  user-select: none;
  -webkit-user-select: none;
}
.fm-case {
  position: relative;
  border: 1px solid var(--fm-trait);
  border-radius: 10px;
  background: rgba(167, 139, 250, 0.07);
}
.fm-case[data-rang="0"] { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.35); }
.fm-plateau-joueur .fm-case { cursor: pointer; }
.fm-case.depart { opacity: 0.3; }
.fm-case.choisi { border-color: var(--fm-or); box-shadow: 0 0 0 2px var(--fm-or); }
.fm-case.ap-fusion { border-color: #22c55e; background: rgba(34, 197, 94, 0.22); }
.fm-case.ap-deplacement, .fm-case.ap-echange { border-color: var(--fm-violet); background: rgba(167, 139, 250, 0.26); }
.fm-case.ap-trop-cher { border-color: #ef4444; background: rgba(239, 68, 68, 0.2); }
.fm-case[data-cout]::after {
  content: attr(data-cout);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 6px;
  background: #0f0a1f;
  border: 1px solid currentColor;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
}
.fm-case.ap-fusion::after { color: #86efac; }
.fm-case.ap-trop-cher::after { color: #fca5a5; }
.fm-case.ap-echange::after { color: #ddd6fe; }
.fm-case.fusionne { animation: fm-eclat 0.45s ease-out; }
.fm-case.frappe { filter: brightness(1.5); }
@keyframes fm-eclat {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.9); }
  100% { box-shadow: 0 0 0 14px rgba(251, 191, 36, 0); }
}

/* ---- Monstres ------------------------------------------------------------------ */
.fm-monstre { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.fm-monstre[data-e="feu"], .fm-best-case[data-e="feu"], .fm-best-titre[data-e="feu"] { color: var(--el-feu); }
.fm-monstre[data-e="eau"], .fm-best-case[data-e="eau"], .fm-best-titre[data-e="eau"] { color: var(--el-eau); }
.fm-monstre[data-e="terre"], .fm-best-case[data-e="terre"], .fm-best-titre[data-e="terre"] { color: var(--el-terre); }
.fm-monstre[data-e="air"], .fm-best-case[data-e="air"], .fm-best-titre[data-e="air"] { color: var(--el-air); }
.fm-sil { width: 74%; height: 74%; }
.fm-sil svg { width: 100%; height: 100%; display: block; }
.fm-el { position: absolute; left: 2px; bottom: 5px; font-size: calc(var(--case) * 0.24); line-height: 1; }
.fm-niv {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 6px;
  border: 1px solid var(--fm-or);
  background: var(--fm-fond);
  color: var(--fm-or);
  font-size: calc(var(--case) * 0.2);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}
.fm-pv { position: absolute; left: 5px; right: 5px; bottom: 1px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); overflow: hidden; display: none; }
.fm-pv i { display: block; height: 100%; width: 100%; background: #22c55e; }
.fm-pv i.bas { background: #ef4444; }
.fm-en-combat .fm-pv { display: block; }
.fm-monstre.ko { opacity: 0.28; filter: grayscale(1); }

.fm-fantome { position: fixed; z-index: 10080; transform: translate(-50%, -50%); opacity: 0.9; inset: auto; }
.fm-fantome .fm-pv { display: none; }

.fm-degats {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-weight: 800;
  font-size: calc(var(--case) * 0.26);
  text-shadow: 0 0 3px #000, 0 0 6px #000;
  pointer-events: none;
  z-index: 5;
  animation: fm-monte 0.7s forwards;
}
.fm-degats.fort { color: #fde047; font-size: calc(var(--case) * 0.32); }
.fm-degats.faible { color: #9ca3af; }
@keyframes fm-monte {
  0% { opacity: 0; transform: translate(-50%, 0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -26px); }
}
.fm-projectile { position: fixed; border-radius: 50%; z-index: 900; pointer-events: none; background: currentColor; box-shadow: 0 0 8px currentColor; }
.fm-projectile[data-e="feu"] { color: var(--el-feu); }
.fm-projectile[data-e="eau"] { color: var(--el-eau); }
.fm-projectile[data-e="terre"] { color: var(--el-terre); }
.fm-projectile[data-e="air"] { color: var(--el-air); }

/* ---- Panneau de commandes -------------------------------------------------------- */
.fm-panneau { display: flex; flex-direction: column; gap: 10px; }
.fm-bloc { border: 1px solid var(--fm-trait); border-radius: 12px; padding: 10px; background: rgba(167, 139, 250, 0.05); }
.fm-bloc-titre { display: block; margin: 0 0 8px; font-size: 0.84rem; font-weight: 700; color: #d6d3e4; }
.fm-prix { color: var(--fm-or); white-space: nowrap; }
.fm-invocation { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.fm-invoquer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--fm-trait);
  background: rgba(15, 10, 31, 0.5);
  color: #e5e7eb;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.fm-invoquer[data-element="feu"] { border-color: var(--el-feu); }
.fm-invoquer[data-element="eau"] { border-color: var(--el-eau); }
.fm-invoquer[data-element="terre"] { border-color: var(--el-terre); }
.fm-invoquer[data-element="air"] { border-color: var(--el-air); }
.fm-invoquer:hover:not(:disabled) { background: rgba(167, 139, 250, 0.2); }
.fm-invoquer:disabled { opacity: 0.4; cursor: not-allowed; }
.fm-cycle { margin: 8px 0 0; font-size: 0.74rem; color: #a8a3b8; text-align: center; }
.fm-choix-niveau { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 0.9rem; }
.fm-choix-niveau #fm-prix-invocation { color: var(--fm-or); }
.fm-bloc input[type="range"] { width: 100%; accent-color: #a78bfa; min-height: 30px; }
.fm-aide { margin: 0; font-size: 0.8rem; line-height: 1.45; color: #ddd6fe; }
.fm-zone-vente {
  min-height: 46px;
  border: 2px dashed #f472b6;
  border-radius: 12px;
  background: rgba(236, 72, 153, 0.1);
  color: #fbcfe8;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.fm-zone-vente.survol { background: rgba(236, 72, 153, 0.35); border-style: solid; }
.fm-gain { margin: -4px 0 0; text-align: center; font-size: 0.78rem; color: #a8a3b8; }
.fm-astuce { margin: 0; font-size: 0.78rem; line-height: 1.5; color: #a8a3b8; }

/* ---- Fenêtres ---------------------------------------------------------------------- */
.fm-fenetre {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 3, 12, 0.78);
}
.fm-carte {
  position: relative;
  width: min(100%, 460px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px 22px 20px;
  border: 1px solid var(--fm-violet);
  border-radius: 16px;
  background: var(--fm-carte);
  text-align: center;
  line-height: 1.55;
}
.fm-carte-large { width: min(100%, 760px); text-align: left; }
.fm-carte p { margin: 0 0 10px; }
.fm-fermer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--fm-trait);
  border-radius: 50%;
  background: transparent;
  color: #e5e7eb;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.fm-fermer:hover { background: rgba(167, 139, 250, 0.2); }
#fm-bilan-titre { font-size: 1.7rem; }
#fm-bilan-titre[data-issue="defaite"] { color: #f87171; }
.fm-bilan-gain { color: var(--fm-or); font-weight: 700; font-size: 1.1rem; }
.fm-bilan-lignes { margin: 0 0 16px; padding: 0; list-style: none; font-size: 0.9rem; color: #d6d3e4; }
.fm-bilan-lignes li { margin: 6px 0; }
.fm-fin-score { font-size: 1.8rem; font-weight: 800; color: var(--fm-or); }
.fm-fin-rang { font-weight: 600; color: #ddd6fe; }
.fm-bonus-choix { display: grid; gap: 8px; }
.fm-btn-bonus { width: 100%; background: rgba(167, 139, 250, 0.12); }
.fm-conflit-ligne { text-align: left; padding: 8px 10px; border: 1px solid var(--fm-trait); border-radius: 10px; font-size: 0.88rem; }
.fm-conflit-ligne strong { display: block; color: var(--fm-or); }
.fm-regles ul { margin: 0 0 16px; padding-left: 20px; font-size: 0.9rem; }
.fm-regles li { margin: 8px 0; }

/* Bestiaire */
.fm-best-ligne { margin: 0 0 12px; }
.fm-best-titre { margin: 0 0 6px; font-weight: 700; font-size: 0.9rem; }
.fm-best-cases { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
.fm-best-case {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 2px;
  border: 1px solid var(--fm-trait);
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.06);
  text-align: center;
}
.fm-best-case .fm-sil { width: 34px; height: 34px; }
.fm-best-case.inconnu { opacity: 0.45; min-height: 74px; justify-content: center; }
.fm-best-niv { font-size: 0.7rem; font-weight: 700; color: #e5e7eb; }
.fm-best-stats { font-size: 0.62rem; color: #a8a3b8; line-height: 1.25; }

/* ---- Arène : fiche, derniers combats, écrans de la table ------------------------------- */
.fm-ar-chiffres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.fm-ar-chiffres p { margin: 0; padding: 8px 6px; border: 1px solid var(--fm-trait); border-radius: 10px; background: rgba(15, 10, 31, 0.5); text-align: center; }
.fm-ar-chiffres span { display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: #a8a3b8; }
.fm-ar-chiffres strong { color: var(--fm-or); font-size: 1rem; }
.fm-ar-fiche #fm-ar-message { text-align: center; }
.fm-ar-historique h3 { margin: 0 0 10px; }
.fm-ar-historique ul { margin: 0; padding: 0; list-style: none; }
.fm-ar-combat { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--fm-trait); font-size: 0.88rem; }
.fm-ar-combat:first-child { border-top: 0; }
.fm-ar-combat-texte { flex: 1; min-width: 0; }
.fm-ar-delta { font-weight: 800; min-width: 3ch; text-align: right; }
.fm-ar-combat.gagne .fm-ar-delta { color: #4ade80; }
.fm-ar-combat.perdu .fm-ar-delta { color: #f87171; }
.fm-ar-date { color: #a8a3b8; font-size: 0.78rem; white-space: nowrap; }
.fm-ar-revoir-btn { min-height: 36px; padding: 4px 12px; font-size: 0.82rem; }
/* Défense : pas d'adversaire en face. Revoir : rien à composer. */
.fm-ar-defense .fm-camp-ennemi, .fm-ar-defense .fm-face { display: none; }
.fm-ar-revoir .fm-panneau, .fm-ar-revoir .fm-hud-case { display: none; }
.fm-ar-revoir .fm-table { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) {
  .fm-ar-chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fm-ar-combat { flex-wrap: wrap; gap: 4px 10px; }
  .fm-ar-combat-texte { flex-basis: 100%; }
}

/* ---- Messages ------------------------------------------------------------------------ */
.fm-messages { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 10070; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.fm-toast {
  padding: 9px 16px;
  border-radius: 12px;
  border: 1px solid var(--fm-violet);
  background: #150d2b;
  color: #e5e7eb;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.fm-toast.visible { opacity: 1; }
.fm-toast.bien { border-color: var(--fm-or); color: var(--fm-or); }
.fm-toast.alerte { border-color: #f87171; color: #fecaca; }

/* ---- Écran étroit : tout empilé, bataille collée en bas ---------------------------------- */
@media (max-width: 760px) {
  body.page-fm {
    --case: clamp(40px, min(calc((100vw - 104px) / 5), calc((100dvh - 250px) / 6)), 78px);
    padding: 56px 8px 96px;
  }
  .page-fm #app { padding: 28px 24px 18px; }
  /* Le banner porte déjà le nom du jeu et l'onglet actif celui du mode : le titre ferait doublon. */
  .fm-zone-jeu ~ footer, .page-fm footer { margin-top: 18px; }
  .fm-entete { margin: 8px 0 8px; }
  .fm-entete h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fm-modes { flex-wrap: nowrap; overflow-x: auto; margin: 0 -24px; padding: 2px 24px 6px; scrollbar-width: none; }
  .fm-modes::-webkit-scrollbar { display: none; }
  .fm-modes a { white-space: nowrap; min-height: 36px; display: inline-flex; align-items: center; }
  .fm-hud { gap: 4px; }
  .fm-hud-case strong { font-size: 0.95rem; }
  .fm-outils { width: auto; gap: 4px; }
  .fm-camp-note { font-size: 0.7rem; }
  /* Sur un écran étroit, l'invocation passe AU-DESSUS des plateaux : on invoque et on voit
     le monstre arriver sans faire défiler la page. */
  .fm-table { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
  .fm-panneau { display: contents; }
  .fm-bloc-invocation { order: -1; padding: 8px; }
  .fm-bloc-invocation .fm-cycle { display: none; }
  .fm-arene { padding: 4px; border: 0; background: none; }
  .fm-hud-case { min-width: 0; flex: 1 1 auto; padding: 4px 8px; }
  .fm-invocation { grid-template-columns: repeat(4, 1fr); }
  .fm-invoquer { flex-direction: column; gap: 2px; font-size: 0.74rem; min-height: 52px; }
  .fm-btn-combat {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    z-index: 800;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6);
  }
  .fm-best-cases { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .fm-messages { bottom: 76px; }
  .fm-carte { padding: 22px 16px 18px; }
}

/* ---- Téléphone couché : plateaux côte à côte, premières lignes au centre ------------------- */
@media (orientation: landscape) and (max-height: 540px) {
  body.page-fm {
    --case: clamp(30px, calc((100dvh - 172px) / 5), 64px);
    padding: 8px 8px 8px;
  }
  .page-fm #app { padding: 8px 24px 8px; max-width: none; }
  .page-fm .jeu-banner, .page-fm h1 { display: none; }
  /* La barre de compte occupe le coin en haut à droite : l'en-tête lui laisse la place. */
  .fm-entete { margin: 0 460px 6px 0; min-height: 40px; }
  .fm-modes { flex-wrap: nowrap; overflow-x: auto; margin: 0; padding: 2px 0; scrollbar-width: none; }
  .fm-modes a { white-space: nowrap; }
  .fm-camp-titre { font-size: 0.7rem; }
  .fm-table { display: grid; grid-template-columns: auto minmax(180px, 1fr); gap: 10px; align-items: start; }
  .fm-panneau { display: flex; }
  .fm-bloc-invocation { order: 0; }
  .fm-arene { flex-direction: row; align-items: flex-end; gap: 6px; padding: 4px 6px 6px; border: 0; background: none; }
  .fm-camp { gap: 3px; }
  .fm-plateau { grid-template-columns: none; grid-auto-columns: var(--case); grid-template-rows: repeat(5, var(--case)); grid-auto-flow: column; }
  .fm-face { align-self: stretch; width: 2px; margin: 0 2px; background: rgba(251, 191, 36, 0.45); }
  .fm-face::before, .fm-face::after, .fm-face span { display: none; }
  .fm-camp-note { display: none; }
  .fm-camp-joueur { flex-direction: column-reverse; }
  .fm-hud { margin-bottom: 4px; }
  .fm-outils { width: auto; margin-left: auto; }
  .page-fm footer, .fm-pied-jeu { margin-top: 10px; }
  .fm-hud-case { padding: 2px 8px; }
  .fm-outil { min-width: 40px; min-height: 40px; }
  .fm-invocation { grid-template-columns: repeat(4, 1fr); }
  .fm-invoquer { flex-direction: column; gap: 0; font-size: 0.7rem; min-height: 44px; }
  .fm-astuce, .fm-cycle, .fm-gain { display: none; }
  .fm-btn-combat { position: static; min-height: 46px; box-shadow: none; }
  .fm-panneau { gap: 6px; }
  .fm-messages { bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .fm-case.fusionne, .fm-degats { animation: none; }
  .fm-projectile { display: none; }
}
