/* =========================================================
   NEXUS — maquette : feuille de style commune
   5 styles graphiques, un par faction (appliqués automatiquement,
   voir applyAutoTheme() dans app.js) :
   - grimoire  : Chevaliers (L'Ordre de l'Aube)
   - gothique  : Démons & Vampires (La Cour Écarlate)
   - ruche     : Extraterrestres (L'Essaim de Kryll)
   - arcane    : Magiciens & Sorciers (Le Cercle d'Arcane)
   - neon      : Faction du futur (Le Protocole Oméga)
   Grimoire reste le thème par défaut (page de connexion, avant
   tout choix de faction).
   ========================================================= */

/* ---------- Chevaliers : Grimoire ancien (par défaut) ---------- */
:root, [data-theme="grimoire"] {
  --bg: #17100a;
  --bg-2: #2a1d12;
  --panel: rgba(44, 30, 18, .9);
  --panel-border: rgba(201, 160, 92, .5);
  --text: #f1e4c8;
  --text-dim: #bfa883;
  --accent: #c99a4a;
  --accent-2: #b8342a;        /* sceau de cire */
  --danger: #e0573f;
  --ok: #9cc46a;
  --btn-text: #24170b;
  --radius: 4px;
  --font-title: 'IM Fell English SC', 'Cinzel', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --glow: 0 0 18px rgba(201, 154, 74, .25);
  --bg-grad: radial-gradient(ellipse at 50% 0%, #4a3219 0%, transparent 60%),
             radial-gradient(ellipse at 50% 100%, #0b0704 0%, transparent 60%),
             linear-gradient(#17100a, #17100a);
}

/* ---------- Démons & Vampires : Château Gothique ---------- */
[data-theme="gothique"] {
  --bg: #0d0608;
  --bg-2: #2a0a12;
  --panel: rgba(30, 8, 14, .9);
  --panel-border: rgba(224, 48, 63, .5);
  --text: #f0dcd8;
  --text-dim: #a67178;
  --accent: #e0303f;
  --accent-2: #6b2a8a;        /* sceau violet, magie noire */
  --danger: #ff4d4d;
  --ok: #6fae5e;
  --btn-text: #1a0508;
  --radius: 3px;
  --font-title: 'Cinzel', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --glow: 0 0 20px rgba(224, 48, 63, .35);
  --bg-grad: radial-gradient(ellipse at 50% 100%, #4a0f1a 0%, transparent 60%),
             radial-gradient(ellipse at 50% 0%, #1a0208 0%, transparent 70%),
             linear-gradient(#0d0608, #0d0608);
}

/* ---------- Extraterrestres : La Ruche ---------- */
[data-theme="ruche"] {
  --bg: #0a0d07;
  --bg-2: #1c2410;
  --panel: rgba(20, 24, 10, .88);
  --panel-border: rgba(255, 138, 42, .45);
  --text: #f0e8d0;
  --text-dim: #9a9470;
  --accent: #ff8a2a;
  --accent-2: #a8ff3e;        /* bioluminescence */
  --danger: #ff4d3a;
  --ok: #a8ff3e;
  --btn-text: #140a02;
  --radius: 10px;
  --font-title: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --glow: 0 0 20px rgba(255, 138, 42, .4);
  --bg-grad: radial-gradient(ellipse at 20% 20%, #2a3a0f 0%, transparent 55%),
             radial-gradient(ellipse at 80% 80%, #3a1a05 0%, transparent 55%),
             linear-gradient(#0a0d07, #0a0d07);
}

/* ---------- Magiciens & Sorciers : La Tour de Cristal ---------- */
[data-theme="arcane"] {
  --bg: #0a0618;
  --bg-2: #1c1038;
  --panel: rgba(22, 14, 42, .88);
  --panel-border: rgba(166, 107, 255, .45);
  --text: #ece4ff;
  --text-dim: #9d8fc4;
  --accent: #a66bff;
  --accent-2: #5be3ff;        /* reflet cristallin */
  --danger: #ff5d7a;
  --ok: #6bffcf;
  --btn-text: #140a2a;
  --radius: 2px;
  --font-title: 'Cinzel', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --glow: 0 0 24px rgba(166, 107, 255, .4);
  --bg-grad: radial-gradient(ellipse at 50% 0%, #3a1f6e 0%, transparent 60%),
             radial-gradient(ellipse at 50% 100%, #0a0618 0%, transparent 60%),
             linear-gradient(#0a0618, #0a0618);
}

/* ---------- Faction du futur : Néon stellaire ----------
   Couleur d'accent alignée exactement sur la faction (#4fe3d0). */
[data-theme="neon"] {
  --bg: #04050c;
  --bg-2: #0b0f22;
  --panel: rgba(8, 12, 30, .85);
  --panel-border: rgba(79, 227, 208, .45);
  --text: #e4f7ff;
  --text-dim: #7d93b3;
  --accent: #4fe3d0;
  --accent-2: #ff3ec8;
  --danger: #ff4d6d;
  --ok: #3dffa8;
  --btn-text: #02121a;
  --radius: 2px;
  --font-title: 'Orbitron', 'Segoe UI', sans-serif;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
  --glow: 0 0 22px rgba(79, 227, 208, .35);
  --bg-grad: linear-gradient(rgba(79, 227, 208, .05) 1px, transparent 1px) 0 0 / 40px 40px,
             linear-gradient(90deg, rgba(79, 227, 208, .05) 1px, transparent 1px) 0 0 / 40px 40px,
             radial-gradient(ellipse at 50% 120%, #2a0a4a 0%, transparent 60%),
             linear-gradient(#04050c, #04050c);
}


/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  /* position + z-index : crée un contexte d'empilement propre à <body>.
     Sans ça, un enfant "fixed" en z-index négatif (.page-bg, .shards) se
     retrouve comparé au fond de <html> lui-même et peint DESSOUS — bug de
     double-fond html/body connu. Avec ce contexte, le z-index négatif ne
     joue plus que contre le fond de <body>, et s'affiche bien derrière le
     contenu en flux normal (titres, textes) comme prévu. */
  position: relative;
  z-index: 0;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background .4s, color .4s;
}
h1, h2, h3, .title { font-family: var(--font-title); letter-spacing: .04em; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; color: var(--accent); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent-2); }
.dim { color: var(--text-dim); }

/* ---------- Emplacements d'images ---------- */
.ph {
  position: relative;
  background-color: var(--bg-2);
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 12px, transparent 12px 24px);
  background-size: cover;
  background-position: center;
  border: 1px dashed var(--panel-border);
  overflow: hidden;
}
.ph-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font: 600 11px/1.3 Consolas, monospace;
  color: var(--text-dim);
  background: rgba(0,0,0,.45);
  padding: 4px 8px; border-radius: 4px;
  white-space: nowrap; pointer-events: none;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.ph.ph-loaded { border-style: solid; background-size: cover; }
.ph.ph-loaded .ph-label { display: none; }

/* Fond plein écran */
.page-bg { position: fixed; inset: 0; z-index: -2; border: 0; opacity: .55; }
.page-bg .ph-label { top: auto; bottom: 70px; transform: translateX(-50%); }
.page-bg.ph-loaded { opacity: 1; }
.page-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, var(--bg) 100%); }

/* ---------- Éclats flottants ---------- */
.shards { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.shards i {
  position: absolute; bottom: -20px;
  width: var(--size); height: calc(var(--size) * 2);
  background: var(--accent-2);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  opacity: 0; filter: drop-shadow(0 0 6px var(--accent-2));
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: .7; }
  90% { opacity: .4; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* ---------- Panneaux ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.5), var(--glow);
  backdrop-filter: blur(6px);
  padding: 28px;
  position: relative;
}
[data-theme="grimoire"] .panel { box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 40px rgba(0,0,0,.45); }
[data-theme="grimoire"] .panel::before {
  content: ''; position: absolute; inset: 6px; border: 1px solid rgba(201,154,74,.25); border-radius: 2px; pointer-events: none;
}
[data-theme="neon"] .panel { clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px)); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-title); font-size: 1rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; text-decoration: none;
  padding: 13px 26px; border: 0; border-radius: var(--radius); cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
  color: var(--btn-text);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, #000), 0 0 20px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .1s, filter .2s, box-shadow .2s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn:disabled { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--panel-border); box-shadow: none; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: 6px; letter-spacing: .03em; }
.field input {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--text);
  background: rgba(0,0,0,.35); border: 1px solid var(--panel-border); border-radius: var(--radius);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.field.error input { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: .8rem; margin-top: 4px; min-height: 1em; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: .9rem; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text-dim); cursor: pointer; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px 28px; background: rgba(0,0,0,.35); border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10;
}
.brand { width: 150px; height: 46px; border: 0; background-color: transparent; background-image: none; background-size: contain; background-repeat: no-repeat; }
.brand .ph-label { display: none; }
.brand-txt { font-family: var(--font-title); font-size: 1.6rem; font-weight: 900; letter-spacing: .25em; color: var(--accent); line-height: 46px; text-shadow: var(--glow); }
.brand.ph-loaded .brand-txt { visibility: hidden; }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 6px 14px; color: var(--text-dim); }
.steps li b { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--panel-border); font-size: .75rem; }
.steps li.current { color: var(--accent); }
.steps li.current b { background: var(--accent); color: var(--btn-text); border-color: var(--accent); }
.steps li.done b { background: color-mix(in srgb, var(--ok) 30%, transparent); border-color: var(--ok); color: var(--ok); }
.who { display: flex; gap: 14px; align-items: center; font-size: .9rem; }

/* Barre du haut — mode "en jeu" (Citadelle, carte, combat…) */
.game-nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.game-nav-link {
  font-family: var(--font-title); font-size: .85rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-dim); text-decoration: none; border: 0; background: transparent; cursor: pointer;
  padding: 8px 16px; border-radius: var(--radius); transition: background .2s, color .2s;
}
.game-nav-link:hover { color: var(--text); background: rgba(255,255,255,.06); }
.game-nav-link.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.game-nav-link.soon { opacity: .6; }
.game-nav-link.soon::after { content: ' ⏳'; font-size: .75em; }
.nav-minijeux::before { content: '🎮 '; font-size: .95em; }
.nav-minijeux::after { content: ' ▾'; font-size: .8em; }
.nav-minijeux.ouvert { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Menu déroulant « Mini-jeux » (accès direct, sans passer par la carte) */
.minijeux-menu {
  position: fixed; z-index: 90; width: min(420px, calc(100vw - 16px)); max-height: calc(100vh - 90px); overflow-y: auto;
  padding: 14px !important; text-align: left; box-shadow: 0 18px 40px rgba(0,0,0,.55); animation: fade .15s;
}
.minijeux-menu[hidden] { display: none; }
.minijeux-titre { display: flex; flex-direction: column; gap: 2px; margin: 0 4px 10px; }
.minijeux-titre b { font-family: var(--font-title); color: var(--accent); letter-spacing: .05em; text-transform: uppercase; }
.minijeux-titre small { color: var(--text-dim); font-size: .8rem; }
.minijeux-liste { display: flex; flex-direction: column; gap: 6px; }
.minijeu {
  display: grid; grid-template-columns: 44px 1fr; grid-template-areas: "ico txt" "ico rec"; column-gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid transparent; color: var(--text); text-decoration: none;
  background: rgba(255,255,255,.03); transition: background .15s, border-color .15s;
}
.minijeu:hover, .minijeu:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); outline: none; }
.minijeu-ico { grid-area: ico; width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.5rem; border-radius: 50%; background: rgba(0,0,0,.3); border: 1px solid var(--panel-border); }
.minijeu-txt { grid-area: txt; display: flex; flex-direction: column; line-height: 1.25; }
.minijeu-txt b { font-family: var(--font-title); font-size: .95rem; }
.minijeu-txt em { font-style: normal; color: var(--accent); font-size: .78rem; }
.minijeu-txt small { color: var(--text-dim); font-size: .8rem; }
.minijeu-record { grid-area: rec; font-size: .75rem; color: var(--text-dim); margin-top: 3px; }
.minijeux-note { margin: 10px 4px 0; font-size: .75rem; color: var(--text-dim); }
.resources { display: flex; gap: 8px; }
.resource {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px;
  background: rgba(0,0,0,.35); border: 1px solid var(--panel-border); border-radius: 20px; font-size: .9rem;
}
.resource .res-ico { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.resource .res-ico .ph-label { display: none; }
.resource b { color: var(--accent); }

/* ---------- Notifications ---------- */
.toast {
  position: fixed; left: 50%; top: 24px; transform: translate(-50%, -150%);
  background: var(--panel); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 22px; border-radius: var(--radius); z-index: 100; transition: transform .3s;
  box-shadow: var(--glow);
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* =========================================================
   ÉCRAN 1 : CONNEXION
   ========================================================= */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px 80px; }
.login-box { width: 100%; max-width: 430px; }
.logo-big { height: 150px; margin: 0 auto 18px; border: 0; background-color: transparent; background-image: none; background-size: contain; background-repeat: no-repeat; display: grid; place-items: center; }
.logo-big .ph-label { top: auto; bottom: 0; transform: translateX(-50%); }
.logo-big .logo-txt { font-family: var(--font-title); font-size: 3.6rem; font-weight: 900; letter-spacing: .3em; color: var(--accent); text-shadow: var(--glow), 0 4px 0 rgba(0,0,0,.5); padding-left: .3em; }
.logo-big.ph-loaded .logo-txt { visibility: hidden; }
.tagline { text-align: center; color: var(--text-dim); margin: -6px 0 22px; font-style: italic; }
.tabs { display: flex; margin: -8px -8px 22px; border-bottom: 1px solid var(--panel-border); }
.tabs button {
  flex: 1; background: none; border: 0; color: var(--text-dim); padding: 12px; cursor: pointer;
  font-family: var(--font-title); font-size: 1rem; letter-spacing: .06em; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.form { display: none; }
.form.active { display: block; animation: fade .3s; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sep { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: .8rem; margin: 18px 0; }
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--panel-border); }
.footer-note { text-align: center; color: var(--text-dim); font-size: .8rem; margin-top: 18px; }
.online { display: inline-flex; align-items: center; gap: 6px; }
.online::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* =========================================================
   ÉCRAN 2 : CHOIX DE FACTION
   ========================================================= */
.container { max-width: 1280px; margin: 0 auto; padding: 30px 24px 90px; }
.page-head { text-align: center; margin-bottom: 26px; }
.page-head p { color: var(--text-dim); max-width: 640px; margin: 0 auto; }

.faction-grid { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 22px; }
.faction-card {
  --fc: var(--accent);
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--panel-border); overflow: hidden; background: var(--bg-2);
  transition: transform .25s, box-shadow .25s, border-color .25s;
  text-align: left; padding: 0; color: inherit; font: inherit;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .faction-card:hover:not(.locked) { transform: translateY(-6px); border-color: var(--fc); box-shadow: 0 0 28px color-mix(in srgb, var(--fc) 45%, transparent); }
}
.faction-card.selected { border: 2px solid var(--fc); box-shadow: 0 0 36px color-mix(in srgb, var(--fc) 60%, transparent); transform: translateY(-6px); }
.faction-card .banner { position: absolute; inset: 0; border: 0; }
.faction-card .banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.9) 100%); }
.faction-card .banner .ph-label { top: 30%; }
.faction-card .emblem { position: relative; width: clamp(46px, 42%, 76px); aspect-ratio: 1; height: auto; margin: 0 auto 10px; border-radius: 50%; border: 2px solid var(--fc); background-color: rgba(0,0,0,.5); }
.faction-card .emblem .ph-label { font-size: 8px; white-space: normal; text-align: center; width: 64px; }
.faction-card .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 8px 14px; z-index: 2; text-align: center; }
.faction-card .info h3 { color: var(--fc); margin: 0 0 4px; font-size: clamp(.82rem, 1.4vw, 1.02rem); line-height: 1.2; }
.faction-card .info span { display: block; font-size: .72rem; line-height: 1.3; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }
.faction-card.locked { cursor: not-allowed; filter: grayscale(1); opacity: .55; }
.faction-card.locked .lock { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 2.4rem; z-index: 3; }

/* Panneau de la faction sélectionnée : emblème + nom, accroche, bonus, bouton */
.faction-detail { --fc: var(--accent); max-width: 760px; margin: 0 auto; }
.faction-detail.empty { text-align: center; color: var(--text-dim); padding: 32px 20px; }
.fd-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.fd-head .ph { width: 64px; height: 64px; flex: none; border-radius: 50%; border: 2px solid var(--fc); background-color: rgba(0,0,0,.4); }
.fd-head .ph .ph-label { display: none; }
.fd-head h2 { margin: 0; color: var(--fc); line-height: 1.15; }
.fd-head .univers { margin: 4px 0 0; color: var(--text-dim); font-style: italic; font-size: .92rem; }
.faction-detail blockquote { margin: 0 0 16px; padding-left: 14px; border-left: 3px solid var(--fc); font-family: var(--font-title); font-size: 1.05rem; }
.fd-bonus { padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--fc) 55%, transparent); border-radius: var(--radius); background: color-mix(in srgb, var(--fc) 10%, rgba(0,0,0,.3)); }
.fd-bonus .section-title { margin-top: 0; }
.fd-bonus p { margin: 0; }
.faction-detail .actions { margin-top: 20px; }

/* Choix de faction sur ordinateur : tout tient dans l'écran, sans défilement.
   Les cartes prennent la hauteur restante ; le bonus et le bouton sont côte à côte. */
@media (min-width: 861px) {
  body.faction-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body.faction-page .container { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; padding-top: 16px; padding-bottom: 20px; }
  body.faction-page .page-head { margin-bottom: 14px; }
  body.faction-page .page-head h1 { margin: 0; }
  body.faction-page .faction-grid { flex: 1 1 auto; min-height: 0; max-height: 420px; margin-bottom: 18px; padding-top: 8px; }
  body.faction-page .faction-card { aspect-ratio: auto; height: 100%; min-height: 0; }
  body.faction-page .faction-detail { flex: none; max-width: 980px; width: 100%; padding: 20px 26px; }
  body.faction-page .fd-head { margin-bottom: 10px; }
  body.faction-page .faction-detail blockquote { margin-bottom: 12px; }
  body.faction-page .fd-bottom { display: flex; align-items: center; gap: 20px; }
  body.faction-page .fd-bottom .fd-bonus { flex: 1; }
  body.faction-page .fd-bottom .actions { margin-top: 0; flex: none; }
}
@media (min-width: 861px) and (max-height: 820px) {
  body.faction-page .container { padding-top: 10px; padding-bottom: 14px; }
  body.faction-page .page-head { margin-bottom: 6px; }
  body.faction-page .page-head h1 { font-size: 1.7rem; }
  body.faction-page .faction-detail { padding: 14px 22px; }
  body.faction-page .fd-head .ph { width: 52px; height: 52px; }
  body.faction-page .fd-head h2 { font-size: 1.35rem; }
  body.faction-page .fd-bonus { padding: 10px 14px; }
  body.faction-page .fd-bonus .section-title { margin-bottom: 4px; }
}

/* Tablette : 5 cartes en ligne, plus basses */
@media (max-width: 1100px) {
  .faction-grid { gap: 10px; }
  .faction-card { aspect-ratio: 3 / 4; }
}
/* Mobile : les cartes défilent horizontalement (glisser du doigt) */
@media (max-width: 640px) {
  .faction-grid {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px;
    margin: 0 -24px 18px; padding: 10px 24px 14px; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .faction-grid::-webkit-scrollbar { display: none; }
  .faction-card { flex: 0 0 42%; aspect-ratio: 2 / 3; scroll-snap-align: center; }
  .faction-card.selected { transform: none; }
  .fd-head .ph { width: 52px; height: 52px; }
  .faction-detail .actions .btn { width: 100%; }
}

.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* =========================================================
   ÉCRAN 3 : CRÉATION DU HÉROS
   ========================================================= */
.hero-layout { display: grid; grid-template-columns: 1fr 1.15fr; gap: 28px; align-items: start; }
.hero-stage { position: relative; padding: 0; overflow: hidden; }
.hero-portrait { aspect-ratio: 3 / 4; border: 0; border-radius: var(--radius); background-position: center top; }
.hero-portrait::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.85)); }
.hero-caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px; z-index: 2; text-align: center; }
.hero-caption h2 { margin: 0; }
.hero-caption .classe { color: var(--text-dim); text-transform: uppercase; letter-spacing: .15em; font-size: .8rem; }
.skin-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--panel-border); background: rgba(0,0,0,.55); color: var(--text); font-size: 1.3rem; cursor: pointer; }
.skin-nav:hover { border-color: var(--accent); color: var(--accent); }
.skin-nav.prev { left: 12px; }
.skin-nav.next { right: 12px; }

.section-title { font-family: var(--font-title); color: var(--accent); font-size: .95rem; letter-spacing: .1em; text-transform: uppercase; margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; }
.section-title:first-child { margin-top: 0; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--panel-border); }
.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.skin {
  border: 1px solid var(--panel-border); border-radius: var(--radius); background: rgba(0,0,0,.3);
  padding: 0; cursor: pointer; color: inherit; font: inherit; text-align: center; overflow: hidden; transition: border-color .2s, box-shadow .2s;
}
.skin .ph { aspect-ratio: 3 / 4; border: 0; border-bottom: 1px solid var(--panel-border); }
.skin .ph .ph-label { font-size: 8px; white-space: normal; width: 90%; text-align: center; }
.skin span { display: block; padding: 8px 6px; font-size: .82rem; }
.skin.selected { border-color: var(--accent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 40%, transparent); }
.skin.selected span { color: var(--accent); }
.skin-desc { color: var(--text-dim); font-size: .9rem; font-style: italic; margin: 10px 0 0; }

/* Création du héros sur ordinateur : tout tient dans l'écran, sans défilement.
   La page occupe la hauteur de la fenêtre ; le portrait et les vignettes
   d'apparence s'adaptent à la place restante. */
@media (min-width: 861px) {
  body.hero-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body.hero-page .container { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; padding-top: 16px; padding-bottom: 20px; }
  body.hero-page .page-head { margin-bottom: 14px; }
  body.hero-page .page-head h1 { margin: 0; }
  body.hero-page .hero-layout { flex: 1; min-height: 0; align-items: stretch; }
  body.hero-page .hero-stage { min-height: 0; }
  body.hero-page .hero-portrait { aspect-ratio: auto; height: 100%; }
  body.hero-page .hero-layout > .panel:last-child { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 20px 26px; justify-content: center; }
  body.hero-page .section-title { margin: 14px 0 8px; }
  body.hero-page .skins { flex: 1; min-height: 90px; max-height: 360px; }
  body.hero-page .skin { display: flex; flex-direction: column; min-height: 0; }
  body.hero-page .skin .ph { aspect-ratio: auto; flex: 1; min-height: 60px; background-position: center 20%; }
  body.hero-page .skin-desc { margin-top: 8px; }
  body.hero-page .actions { margin-top: 18px !important; }
}
/* Écrans d'ordinateur peu hauts (portables 720–800 px) : titre et marges plus compacts */
@media (min-width: 861px) and (max-height: 820px) {
  body.hero-page .container { padding-top: 10px; padding-bottom: 14px; }
  body.hero-page .page-head { margin-bottom: 8px; }
  body.hero-page .page-head h1 { font-size: 1.7rem; }
  body.hero-page .hero-layout > .panel:last-child { padding: 14px 22px; }
  body.hero-page .faction-recap { padding: 8px 12px; }
  body.hero-page .section-title { margin: 10px 0 6px; }
  body.hero-page .skin span { padding: 5px 6px; }
  body.hero-page .skin-desc + p { font-size: .8rem !important; line-height: 1.35; }
  body.hero-page .actions { margin-top: 12px !important; }
}

.stats { display: grid; gap: 10px; }
.stat { display: grid; grid-template-columns: 90px 1fr 26px; gap: 12px; align-items: center; font-size: .9rem; }
.stat .bar { height: 10px; background: rgba(0,0,0,.4); border-radius: 10px; overflow: hidden; border: 1px solid var(--panel-border); }
.stat .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 10px; transition: width .4s; }
.stat b { text-align: right; color: var(--accent); }
.branches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.branch { border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 12px 8px; text-align: center; background: rgba(0,0,0,.25); font-size: .88rem; }
.branch .ph { width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px; }
.branch .ph .ph-label { display: none; }
.faction-recap { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--panel-border); border-radius: var(--radius); background: rgba(0,0,0,.25); margin-bottom: 4px; }
.faction-recap .ph { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.faction-recap .ph .ph-label { display: none; }
.faction-recap .grow { flex: 1; }
.faction-recap h3 { margin: 0; }

/* =========================================================
   ÉCRAN 4 : CITADELLE
   ========================================================= */
.res-summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.res-sum {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); font-size: .9rem;
}
.res-sum .res-ico { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.res-sum .res-ico .ph-label { display: none; }
.res-sum b { color: var(--accent); }

.cit-tabs {
  display: flex; gap: 4px; margin-bottom: 24px; padding: 6px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.cit-tabs button {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer;
  color: var(--text-dim); padding: 11px 18px; font-family: var(--font-title); font-size: .92rem;
  letter-spacing: .05em; white-space: nowrap; border-radius: calc(var(--radius) + 2px);
  transition: color .2s, background-color .2s;
}
.cit-tabs button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.cit-tabs button.active { color: var(--bg); background: var(--accent); font-weight: 600; }
.cit-tabs .tab-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.15);
  color: inherit; font-family: var(--font-body); font-size: .72rem; font-weight: 600;
}
.cit-tabs button.active .tab-badge { background: rgba(0,0,0,.2); border-color: rgba(0,0,0,.25); }
.tab-panel { animation: fade .25s; }
.tab-panel[hidden] { display: none; }

.chantier-banner {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px; padding: 12px 18px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--glow); font-size: .9rem;
}
.chantier-banner[hidden] { display: none; }
.chantier-banner .bar { flex: 1; height: 10px; background: rgba(0,0,0,.4); border-radius: 10px; overflow: hidden; border: 1px solid var(--panel-border); }
.chantier-banner .bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 1s linear; }
.chantier-banner b { color: var(--accent); white-space: nowrap; }

.batiments-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 10px; }
.batiment-card { display: flex; flex-direction: column; text-align: center; }
.batiment-card .ph { aspect-ratio: 1; border-radius: var(--radius); margin-bottom: 10px; }

/* Bâtiment de ressources non construit : pas d'image, juste un voile mystérieux */
.ph-mystery {
  aspect-ratio: 1; border-radius: var(--radius); margin-bottom: 10px;
  position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, var(--bg-2) 0%, var(--bg) 85%);
  border: 1px dashed var(--panel-border);
  display: flex; align-items: center; justify-content: center;
}
.ph-mystery::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.025) 0 12px, transparent 12px 24px);
}
.ph-mystery span {
  position: relative; font-family: var(--font-title); font-size: 2.2rem; line-height: 1;
  color: var(--text-dim); opacity: .55; animation: mystery-pulse 2.6s ease-in-out infinite;
}
@keyframes mystery-pulse { 0%, 100% { opacity: .3; } 50% { opacity: .65; } }
.batiment-card h3 { margin: 0 0 2px; font-size: 1rem; }
.batiment-card .statut { font-size: .78rem; color: var(--text-dim); margin-bottom: 10px; min-height: 1.2em; }
.batiment-card .statut.locked { color: var(--text-dim); display: flex; align-items: center; justify-content: center; gap: 6px; }
.batiment-card .statut.locked svg { flex: none; opacity: .8; }
.batiment-card .statut.max { color: var(--ok); }
.batiment-card .btn { margin-top: auto; width: 100%; font-size: .82rem; padding: 10px; }
.batiment-card .cout { font-size: .76rem; color: var(--text-dim); margin-top: 6px; min-height: 1.2em; }
.batiment-card .eco-rate { font-size: .85rem; color: var(--accent); font-weight: 600; margin: -6px 0 8px; }
.batiment-card .eco-bar {
  width: 100%; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--panel-border); margin-bottom: 10px;
}
.batiment-card .eco-bar i { display: block; height: 100%; background: var(--accent); }
/* =========================================================
   Portrait rond d'une troupe (visage + épaules)
   — cadrage réglé par TROUPES_DETAILS[...].focus dans data.js
   ========================================================= */
.unit-portrait {
  position: relative; display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--fc, var(--accent)) 28%, var(--bg-2)) 0%, var(--bg) 85%);
  border: 2px solid color-mix(in srgb, var(--fc, var(--accent)) 70%, transparent);
  box-shadow: inset 0 0 14px rgba(0,0,0,.6);
}
.unit-portrait img { position: absolute; max-width: none; height: auto; pointer-events: none; user-select: none; }
.unit-portrait em { display: none; }
.unit-portrait.missing img { display: none; }
.unit-portrait.missing em {
  display: flex; position: absolute; inset: 0; align-items: center; justify-content: center; text-align: center;
  font: 600 9px/1.2 Consolas, monospace; font-style: normal; color: var(--text-dim); padding: 8px; word-break: break-all;
}

/* ---------- Onglet Recrutement ---------- */
.recrut-layout { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 18px; align-items: start; margin-bottom: 10px; }
.recrut-liste { padding: 18px; }
.recrut-liste h3 { margin-bottom: 10px; }
.recrut-row {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s;
}
.recrut-row:hover { background: rgba(255,255,255,.05); }
.recrut-row.active { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); }
.recrut-row.verrou .unit-portrait { filter: grayscale(.85) brightness(.6); }
.recrut-portrait { position: relative; flex: none; width: 64px; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 50%; }
.recrut-portrait:hover .unit-portrait, .recrut-row.active .unit-portrait { border-color: var(--accent); box-shadow: inset 0 0 14px rgba(0,0,0,.6), 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent); }
.recrut-portrait .niv {
  position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font: 700 .72rem/1 var(--font-title); font-style: normal;
  background: var(--accent); color: var(--btn-text); border: 2px solid var(--bg);
}
.recrut-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.recrut-info b { font-family: var(--font-title); font-size: .98rem; }
.recrut-info span { font-size: .78rem; color: var(--text-dim); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.recrut-info strong { color: var(--accent); }

.recrut-detail { padding: 22px; }
.fiche { display: grid; grid-template-columns: minmax(200px, 42%) 1fr; gap: 22px; }
.fiche-image .ph {
  aspect-ratio: 1; border-radius: var(--radius); background-size: contain; background-repeat: no-repeat;
  background-color: rgba(0,0,0,.25); animation: fade .3s;
}
.fiche-image .ph.ph-loaded { background-size: contain; }
.fiche-corps h2 { margin-bottom: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: .74rem; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--panel-border); color: var(--text-dim); }
.tag.fort { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.fiche-desc { font-style: italic; color: var(--text-dim); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stats div {
  text-align: center; padding: 8px 4px; border: 1px solid var(--panel-border); border-radius: var(--radius); background: rgba(0,0,0,.25);
}
.stats span { display: block; font-size: .7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.stats b { font-family: var(--font-title); font-size: 1.35rem; color: var(--accent); }
.traits { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.traits dt { font-weight: 700; white-space: nowrap; }
.traits dd { margin: 0; }
.traits .bon { color: var(--ok); }
.traits .mal { color: var(--danger); }
.traits .pouv { color: var(--accent); }

.fiche-bas { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--panel-border); }
.fiche-bat { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: .88rem; margin-bottom: 14px; }
.fiche-bat .btn { padding: 7px 14px; font-size: .74rem; }
.achat-verrou { display: flex; align-items: center; gap: 8px; margin: 0; }
.achat-infos { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.achat-infos > div { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; }
.achat-infos b { font-family: var(--font-title); font-size: 1.3rem; color: var(--accent); line-height: 1.1; }
.cout-ligne, .achat-total { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.cout-item { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.cout-item .res-ico { width: 20px; height: 20px; border-radius: 50%; border: 0; flex: none; }
.cout-item .res-ico .ph-label { display: none; }
.achat-ligne { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.qte { display: flex; align-items: center; gap: 6px; }
.qte .btn { padding: 8px 12px; font-size: .9rem; min-width: 38px; }
.qte input {
  width: 74px; padding: 8px; text-align: center; font: 600 1rem var(--font-body);
  background: rgba(0,0,0,.35); color: var(--text); border: 1px solid var(--panel-border); border-radius: var(--radius);
}
.qte input.trop { border-color: var(--danger); color: var(--danger); }
.achat-total { font-size: .9rem; }
#achat-total { display: inline-flex; flex-wrap: wrap; gap: 10px; }
#btn-acheter { margin-left: auto; padding: 12px 26px; }

/* ---------- Onglet Équipe du héros ---------- */
.equipe-layout { display: grid; grid-template-columns: minmax(320px, 1.15fr) 1fr; gap: 18px; align-items: start; margin-bottom: 10px; }
.equipe-heros { padding: 18px; }
.equipe-ring { position: relative; width: 100%; max-width: 520px; aspect-ratio: 1; margin: 0 auto; }
.ring-lignes { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-lignes line { stroke: var(--panel-border); stroke-width: .4; stroke-dasharray: 1.2 1.2; }
.ring-heros {
  position: absolute; left: 50%; top: 50%; width: 30%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2;
}
.heros-tete {
  width: 100%; aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--fc, var(--accent));
  box-shadow: 0 0 26px color-mix(in srgb, var(--fc, var(--accent)) 55%, transparent); margin-bottom: 6px;
}
.heros-tete .ph-label { font-size: 9px; white-space: normal; }
.ring-heros b { font-family: var(--font-title); font-size: .95rem; }
.ring-heros span { font-size: .72rem; }
.slot { position: absolute; width: 21%; transform: translate(-50%, -50%); text-align: center; }
.slot-unite { position: relative; border-radius: 50%; }
.slot.plein .slot-unite { cursor: grab; touch-action: none; }
.slot.vide .slot-unite {
  aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed var(--panel-border);
  background: var(--bg-2); color: var(--text-dim); font-size: 1.6rem;
}
.slot-n {
  position: absolute; right: -4px; bottom: -2px; min-width: 28px; padding: 2px 7px; border-radius: 14px;
  background: var(--accent); color: var(--btn-text); font: 700 .85rem/1.3 var(--font-body); border: 2px solid var(--bg);
}
.slot-nom { display: block; margin-top: 4px; font-size: .72rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.plein .slot-nom { color: var(--text); }
.equipe-total { text-align: center; margin: 10px 0 0; font-size: .9rem; color: var(--text-dim); }
.equipe-total b { color: var(--accent); }

.equipe-garnison { padding: 18px; transition: border-color .15s, box-shadow .15s; }
.equipe-aide { font-size: .82rem; }
.garnison-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.garnison-tile {
  position: relative; text-align: center; padding: 8px 6px; border: 1px solid var(--panel-border); border-radius: var(--radius);
  background: rgba(0,0,0,.25); cursor: grab; touch-action: none; transition: border-color .15s, transform .15s;
}
.garnison-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.garnison-tile .unit-portrait { width: 72%; margin: 0 auto 4px; }
.garnison-tile.vide { cursor: default; opacity: .4; touch-action: auto; }
.garnison-tile.vide:hover { border-color: var(--panel-border); transform: none; }
.g-nom { display: block; font-size: .72rem; line-height: 1.2; min-height: 2.4em; }
.g-n { font-family: var(--font-title); font-size: 1.1rem; color: var(--accent); }
.garnison-drop {
  margin-top: 14px; padding: 14px; text-align: center; font-size: .82rem; color: var(--text-dim);
  border: 2px dashed var(--panel-border); border-radius: var(--radius);
}
.equipe-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; font-size: .84rem; margin-bottom: 10px; }
.equipe-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
kbd { font: 600 .75rem Consolas, monospace; padding: 1px 5px; border: 1px solid var(--panel-border); border-radius: 3px; }

/* Glisser-déposer */
.drag-ghost { position: fixed; left: 0; top: 0; width: 72px; z-index: 100; pointer-events: none; filter: drop-shadow(0 8px 14px rgba(0,0,0,.6)); opacity: .92; }
.drag-source { opacity: .35; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
body.dragging .slot .slot-unite { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
body.dragging .equipe-garnison .garnison-drop { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.slot.drop-cible .slot-unite { box-shadow: 0 0 0 3px var(--accent), 0 0 22px var(--accent) !important; }
.equipe-garnison.drop-cible { border-color: var(--accent); box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 45%, transparent); }
.equipe-garnison.drop-cible .garnison-drop { border-color: var(--accent); color: var(--accent); }

/* Fenêtre « combien d'unités » */
#modal-qte .panel { width: min(420px, 100%); }
.qte-modal-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.qte-modal-row input[type=range] { flex: 1; accent-color: var(--accent); }
.qte-modal-row input[type=number] {
  width: 80px; padding: 8px; text-align: center; font: 600 1rem var(--font-body);
  background: rgba(0,0,0,.35); color: var(--text); border: 1px solid var(--panel-border); border-radius: var(--radius);
}

@media (max-width: 960px) {
  .recrut-layout, .equipe-layout { grid-template-columns: 1fr; }
  .recrut-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px; }
  .recrut-liste h3 { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .fiche { grid-template-columns: 1fr; }
  .fiche-image .ph { max-height: 320px; margin: 0 auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .achat-infos { grid-template-columns: repeat(3, 1fr); }
  .achat-infos > div:first-child { grid-column: 1 / -1; }
  #btn-acheter { margin-left: 0; width: 100%; }
  .slot-nom { font-size: .62rem; }
  .slot-n { font-size: .72rem; min-width: 22px; padding: 1px 5px; }
}

/* ---------- Onglet Bâtiments (vignettes + fiche) ---------- */
.bat-layout { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 18px; align-items: start; margin-bottom: 10px; }
.bat-liste { padding: 18px; }
.bat-chateau { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--panel-border); }
.bat-chateau h3 { margin-bottom: 4px; color: var(--accent); }
.bat-chateau p { font-size: .8rem; margin: 0; line-height: 1.35; }
.bat-groupe + .bat-groupe { margin-top: 14px; }
.bat-groupe h4 {
  margin: 0 0 8px; font: 600 .72rem var(--font-body); text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim);
}
.bat-vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.bat-vignette {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 6px 8px;
  background: rgba(0,0,0,.25); border: 1px solid var(--panel-border); border-radius: var(--radius); cursor: pointer;
  color: var(--text); font: inherit; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.bat-vignette:hover { border-color: var(--accent); transform: translateY(-2px); }
.bat-vignette.active { border-color: var(--accent); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, rgba(0,0,0,.25)); }
.bat-vignette .ph { width: 100%; aspect-ratio: 1; border-radius: calc(var(--radius) + 2px); border-style: solid; }
.bat-vignette .ph .ph-label { font-size: 8px; white-space: normal; }
.bat-vignette.non-construit .ph { filter: grayscale(.9) brightness(.45); }
.bv-nom { font-size: .7rem; line-height: 1.2; text-align: center; min-height: 2.4em; display: flex; align-items: center; }
.bv-niv, .bv-lock, .bv-chantier {
  position: absolute; top: 2px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font: 700 .74rem/1 var(--font-title); font-style: normal; border: 2px solid var(--bg);
}
.bv-niv { right: 2px; background: var(--accent); color: var(--btn-text); }
.bv-niv.ok { background: var(--ok); color: #10200a; }
.bv-lock { right: 2px; background: rgba(0,0,0,.75); color: var(--text-dim); }
.bv-chantier { left: 2px; background: var(--accent-2); color: #fff; animation: mystery-pulse 1.6s ease-in-out infinite; }

.bat-detail { padding: 22px; }
.bat-image { position: relative; }
.bat-image .ph { background-size: cover; }
.bat-image .ph.ph-loaded { background-size: cover; }
.bat-image.non-construit .ph { filter: grayscale(.85) brightness(.5); }
.bat-voile {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; background: rgba(0,0,0,.7); border: 1px solid var(--panel-border); font-size: .85rem; white-space: nowrap;
}
.pips { display: flex; gap: 6px; margin: -2px 0 10px; }
.pips i { width: 26px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.4); border: 1px solid var(--panel-border); }
.pips i.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent); }
.stats.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats small { display: block; font-size: .68rem; color: var(--text-dim); line-height: 1.2; }
.bat-jauge { height: 8px; border-radius: 4px; overflow: hidden; background: rgba(0,0,0,.4); border: 1px solid var(--panel-border); }
.bat-jauge i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 1s linear; }
.bat-fonction { padding: 12px 14px; border: 1px solid var(--panel-border); border-radius: var(--radius); background: rgba(0,0,0,.25); }
.bat-fonction p { margin: 4px 0 0; }
.bat-action { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.bat-cout { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.bat-bouton { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.bat-bouton .btn { padding: 12px 30px; }
.bat-bouton small { font-size: .74rem; text-align: right; }
.cout-item.manque { color: var(--danger); }
.ok-txt { color: var(--ok); font-weight: 600; }
.bat-chantier { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .9rem; }
.bat-chantier span { display: flex; align-items: center; gap: 6px; color: var(--accent); }
.bat-chantier .bar { flex: 1; min-width: 140px; height: 10px; background: rgba(0,0,0,.4); border-radius: 10px; overflow: hidden; border: 1px solid var(--panel-border); }
.bat-chantier .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 1s linear; }
.bat-chantier b { color: var(--accent); }
@media (max-width: 960px) {
  .bat-layout { grid-template-columns: 1fr; }
  .bat-vignettes { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}
@media (max-width: 640px) {
  .stats.stats-3 { grid-template-columns: repeat(3, 1fr); }
  .stats.stats-3 b { font-size: 1.05rem; }
  .bat-bouton { align-items: stretch; width: 100%; }
  .bat-bouton small { text-align: left; }
}

/* =========================================================
   ZONE EN TEMPS RÉEL — Carrefour des Mondes (zone.html)
   ========================================================= */
body.zone-page { overflow: hidden; height: 100vh; }
body.zone-page .shards { display: none; }
.z-viewport { position: fixed; left: 0; right: 0; bottom: 0; top: var(--zone-top, 70px); overflow: hidden; background: #03030a; cursor: pointer; touch-action: manipulation; }
.z-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.z-decor { position: absolute; left: 0; top: 0; pointer-events: none; }
.z-decor .z-ile { filter: drop-shadow(0 0 40px color-mix(in srgb, var(--fc) 25%, transparent)); }
.z-decor .z-anneau { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 2; }
.z-decor .z-joint { stroke: rgba(0,0,0,.25); stroke-width: 2; }
.z-decor .z-chemin { fill: none; stroke-width: 26; opacity: .13; stroke-linecap: round; }
.z-decor .z-rune { fill: var(--fc); opacity: .55; font: 700 20px serif; text-anchor: middle; }
.z-decor .z-bord { stroke: color-mix(in srgb, var(--fc) 50%, transparent); stroke-width: 3; }

/* Le cristal du Nexus au centre */
.z-nexus { position: absolute; width: 0; height: 0; pointer-events: none; }
.z-nexus-halo {
  position: absolute; left: -170px; top: -120px; width: 340px; height: 240px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(120, 230, 255, .35), transparent 70%); animation: z-pulse 3s ease-in-out infinite;
}
.z-nexus-cristal {
  position: absolute; left: -46px; top: -190px; width: 92px; height: 190px;
  background: linear-gradient(135deg, #e8fdff 0%, #6fe6ff 35%, #1a7fd0 70%, #0b3a78 100%);
  clip-path: polygon(50% 0, 100% 38%, 78% 100%, 22% 100%, 0 38%);
  filter: drop-shadow(0 0 22px #6fe6ff); animation: z-flotte 4s ease-in-out infinite;
}
.z-nexus i {
  position: absolute; width: 18px; height: 34px; background: linear-gradient(135deg, #e8fdff, #3fb8ff);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); filter: drop-shadow(0 0 8px #6fe6ff);
  animation: z-orbite 9s linear infinite;
}
.z-nexus i:nth-child(4) { animation-delay: -1.8s; } .z-nexus i:nth-child(5) { animation-delay: -3.6s; }
.z-nexus i:nth-child(6) { animation-delay: -5.4s; } .z-nexus i:nth-child(7) { animation-delay: -7.2s; }
@keyframes z-pulse { 0%, 100% { opacity: .6; transform: scale(1); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes z-flotte { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes z-orbite {
  0% { transform: translate(130px, -90px) scale(1); z-index: 2; }
  25% { transform: translate(0, -60px) scale(.7); }
  50% { transform: translate(-150px, -90px) scale(1); }
  75% { transform: translate(0, -130px) scale(1.2); }
  100% { transform: translate(130px, -90px) scale(1); }
}

/* Bulles spatio-temporelles */
.z-portail { position: absolute; width: 0; height: 0; cursor: pointer; }
.z-bulle {
  position: absolute; left: -75px; top: -175px; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), color-mix(in srgb, var(--pc) 45%, transparent) 35%, color-mix(in srgb, var(--pc) 20%, #000) 75%);
  box-shadow: 0 0 40px var(--pc), inset 0 0 30px color-mix(in srgb, var(--pc) 70%, #fff);
  border: 2px solid color-mix(in srgb, var(--pc) 70%, #fff); overflow: hidden;
  animation: z-flotte 3.6s ease-in-out infinite; transition: transform .2s;
}
.z-portail:nth-child(2n) .z-bulle { animation-delay: -1.2s; }
.z-portail:nth-child(3n) .z-bulle { animation-delay: -2.1s; }
.z-bulle-tourbillon {
  position: absolute; inset: -20%;
  background: conic-gradient(from 0deg, transparent, color-mix(in srgb, var(--pc) 80%, #fff), transparent 30%, transparent 50%, color-mix(in srgb, var(--pc) 80%, #fff), transparent 80%);
  opacity: .45; animation: z-tourne 6s linear infinite; mix-blend-mode: screen;
}
@keyframes z-tourne { to { transform: rotate(360deg); } }
.z-bulle-embleme { position: absolute; inset: 22%; border: 0; border-radius: 50%; background-color: transparent; background-image: none; background-size: contain; background-repeat: no-repeat; opacity: .85; }
.z-bulle-embleme .ph-label { display: none; }
.z-portail:hover .z-bulle { box-shadow: 0 0 70px var(--pc), inset 0 0 40px color-mix(in srgb, var(--pc) 70%, #fff); }
.z-portail::after {  /* socle lumineux au sol */
  content: ''; position: absolute; left: -70px; top: -16px; width: 140px; height: 32px; border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--pc, var(--accent)) 60%, transparent), transparent 70%);
}
.z-portail-nom {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); text-align: center; white-space: nowrap;
  padding: 3px 12px; border-radius: 12px; background: rgba(0,0,0,.6); border: 1px solid color-mix(in srgb, var(--pc, var(--accent)) 60%, transparent);
  line-height: 1.2; pointer-events: none;
}
.z-portail-nom b { display: block; font-family: var(--font-title); font-size: .9rem; color: var(--pc, var(--accent)); }
.z-portail-nom span { font-size: .7rem; color: var(--text-dim); }
.z-portail.natal .z-portail-nom { box-shadow: 0 0 12px var(--pc); }
.z-porte {
  position: absolute; left: -55px; top: -120px; width: 110px; height: 110px; display: grid; place-items: center;
  border-radius: 55px 55px 8px 8px; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 35%, #000), rgba(0,0,0,.8));
  border: 3px solid var(--accent); box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent), inset 0 0 30px color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: 2.6rem; color: var(--accent);
}

/* Joueurs */
.z-avatar { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.z-jeton {
  position: absolute; left: -30px; top: -66px; width: 60px; height: 60px; border-radius: 50%;
  border: 3px solid var(--ac); box-shadow: 0 0 14px color-mix(in srgb, var(--ac) 60%, transparent); background-color: #111;
  transition: transform .2s; cursor: pointer;
}
.z-jeton .ph-label { display: none; }
.z-avatar.marche .z-jeton { animation: z-pas .36s ease-in-out infinite alternate; }
@keyframes z-pas { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-5px) rotate(3deg); } }
.z-avatar:not(.marche) .z-jeton { animation: z-respire 3s ease-in-out infinite; }
@keyframes z-respire { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.z-ombre { position: absolute; left: -24px; top: -7px; width: 48px; height: 14px; border-radius: 50%; background: rgba(0,0,0,.45); pointer-events: none; }
.z-nomtag {
  position: absolute; left: 50%; top: -98px; transform: translateX(-50%); white-space: nowrap; text-align: center; line-height: 1.1;
  font-size: .72rem; text-shadow: 0 1px 3px #000, 0 0 6px #000; pointer-events: none;
}
.z-nomtag b { display: block; font-size: .8rem; color: #fff; }
.z-nomtag span { color: var(--ac); }
.z-avatar.moi .z-nomtag b { color: var(--accent); }
.z-avatar.moi .z-jeton { border-width: 4px; box-shadow: 0 0 22px var(--ac); }
.z-avatar.moi::before {
  content: ''; position: absolute; left: -32px; top: -10px; width: 64px; height: 20px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: .8; animation: z-pulse 2s ease-in-out infinite;
}
.z-bulle-chat {
  position: absolute; left: 50%; bottom: 102px; transform: translateX(-50%); max-width: 220px; width: max-content;
  padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.94); color: #1a1a1a; font: 500 .8rem/1.3 var(--font-body);
  box-shadow: 0 4px 12px rgba(0,0,0,.4); pointer-events: none; animation: fade .2s;
}
.z-bulle-chat::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-top-color: rgba(255,255,255,.94); border-bottom: 0; }
.z-bulle-chat[hidden] { display: none; }
.z-avatar.arrive .z-jeton { animation: z-apparait .9s ease-out; }
.z-avatar.part { transition: opacity .7s, transform .7s; opacity: 0; }
@keyframes z-apparait { from { transform: scale(0) rotate(-180deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.z-cible {
  position: absolute; width: 0; height: 0; z-index: 1; pointer-events: none;
}
.z-cible::before {
  content: ''; position: absolute; left: -22px; top: -9px; width: 44px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0;
}
.z-cible.on::before { animation: z-cible 1s ease-out; }
@keyframes z-cible { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.6); } }

/* Interface par-dessus la zone */
.z-hud-haut { position: fixed; top: calc(var(--zone-top, 70px) + 12px); left: 14px; z-index: 5000; pointer-events: none; }
.z-nom-zone { padding: 8px 14px; border-radius: var(--radius); background: rgba(0,0,0,.6); border: 1px solid var(--panel-border); backdrop-filter: blur(6px); }
.z-nom-zone b { display: block; font-family: var(--font-title); color: var(--accent); font-size: 1.05rem; }
.z-nom-zone span { font-size: .76rem; color: var(--text-dim); }
.z-minimap {
  position: fixed; top: calc(var(--zone-top, 70px) + 12px); right: 14px; width: 170px; z-index: 5000; cursor: crosshair;
  background: rgba(0,0,0,.65); border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: hidden;
}
.z-mm-ile { position: absolute; border-radius: 50%; background: rgba(255,255,255,.12); border: 1px solid color-mix(in srgb, var(--fc) 50%, transparent); }
.z-minimap i { position: absolute; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #ddd; }
.z-minimap i.z-mm-portail { width: 9px; height: 9px; margin: -4.5px; box-shadow: 0 0 5px currentColor; }
.z-minimap i.z-mm-nexus { width: 8px; height: 8px; margin: -4px; background: #6fe6ff; box-shadow: 0 0 6px #6fe6ff; }
.z-minimap i.moi { width: 7px; height: 7px; margin: -3.5px; background: var(--accent); box-shadow: 0 0 6px var(--accent); z-index: 2; }
.z-mm-vue { position: absolute; border: 1px solid rgba(255,255,255,.5); pointer-events: none; }
.z-chat {
  position: fixed; left: 14px; bottom: 14px; width: min(380px, calc(100vw - 28px)); z-index: 5000;
  background: rgba(0,0,0,.6); border: 1px solid var(--panel-border); border-radius: var(--radius); backdrop-filter: blur(6px); cursor: default;
}
.z-chat-log { height: 150px; overflow-y: auto; padding: 8px 10px; font-size: .82rem; line-height: 1.35; }
.z-chat-ligne + .z-chat-ligne { margin-top: 3px; }
.z-chat-ligne.systeme { color: var(--text-dim); font-style: italic; }
.z-chat-form { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--panel-border); }
.z-chat-form input {
  flex: 1; min-width: 0; padding: 8px 10px; background: rgba(255,255,255,.08); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: var(--radius); font: inherit; font-size: .85rem;
}
.z-chat-form .btn { padding: 8px 12px; font-size: .72rem; }
.z-carte-joueur { position: fixed; right: 14px; bottom: 14px; z-index: 5001; width: 290px; padding: 16px !important; cursor: default; }
.z-carte-joueur[hidden] { display: none; }
.z-fermer { position: absolute; right: 8px; top: 4px; background: none; border: 0; color: var(--text-dim); font-size: 1.4rem; cursor: pointer; z-index: 2; }
.z-cj-tete { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.z-cj-tete b { display: block; font-family: var(--font-title); font-size: 1.05rem; }
.z-cj-tete span { display: block; font-size: .78rem; }
.z-cj-jeton { width: 58px; height: 58px; border-radius: 50%; flex: none; border: 3px solid var(--ac); }
.z-cj-jeton .ph-label { display: none; }
.z-cj-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.z-cj-actions .btn { padding: 8px 6px; font-size: .68rem; line-height: 1.2; }
#modal-portail { z-index: 6000; }
.z-portail-fiche { max-width: 540px !important; text-align: center; border-color: var(--pc) !important; box-shadow: 0 0 50px color-mix(in srgb, var(--pc) 45%, transparent) !important; }
.z-portail-fiche h2 { color: var(--pc); margin: 10px 0 2px; }
.z-pf-sous { color: var(--text-dim); font-style: italic; margin-bottom: 10px; }
.z-pf-banniere {
  height: 150px; border-radius: var(--radius); margin: -6px -6px 0; display: flex; align-items: flex-end; justify-content: center;
  border-color: var(--pc); background-position: center 30%;
}
.z-pf-banniere > span:not(.ph-label) {
  position: relative; z-index: 1; margin-bottom: 10px; padding: 4px 12px; border-radius: 12px; background: rgba(0,0,0,.7);
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--pc);
}
.z-pf-banniere .ph-label { top: 30%; }
.z-pf-info { font-size: .85rem; padding: 10px 12px; border-radius: var(--radius); background: rgba(0,0,0,.3); border: 1px solid var(--panel-border); }
.z-warp {
  position: fixed; inset: 0; z-index: 7000; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #fff 0%, var(--pc, #fff) 30%, transparent 70%); transform: scale(.2);
}
.z-warp.on { animation: z-warp 1.1s ease-in forwards; }
@keyframes z-warp { 0% { opacity: 0; transform: scale(.2); } 50% { opacity: 1; transform: scale(2.5); } 100% { opacity: 0; transform: scale(4); } }
@media (max-width: 640px) {
  .z-minimap { width: 120px; }
  .z-chat-log { height: 90px; }
  .z-chat { width: calc(100vw - 28px); }
  .z-carte-joueur { left: 14px; right: 14px; width: auto; bottom: 170px; }
  .z-nom-zone b { font-size: .9rem; }
  .z-hud-haut { right: 146px; }
  .z-nom-zone span { font-size: .68rem; }
}

/* =========================================================
   CARTE D'AVENTURE (carte.html)
   ========================================================= */
body.carte-page { overflow: hidden; height: 100vh; }
body.carte-page .shards { display: none; }
.k-viewport { position: fixed; left: 0; right: 0; bottom: 0; top: var(--zone-top, 70px); background: #050508; touch-action: none; }
.k-viewport canvas { display: block; cursor: pointer; }
.k-hud { position: fixed; z-index: 50; background: rgba(0,0,0,.66); border: 1px solid var(--panel-border); border-radius: var(--radius); backdrop-filter: blur(6px); }
.k-hud-monde { top: calc(var(--zone-top, 70px) + 12px); left: 14px; padding: 8px 14px; pointer-events: none; }
.k-hud-monde b { display: block; font-family: var(--font-title); color: var(--accent); font-size: 1.05rem; }
.k-hud-monde span { font-size: .78rem; color: var(--text-dim); }
.k-hud-pm { top: calc(var(--zone-top, 70px) + 12px); right: 14px; padding: 10px 12px; width: 250px; }
.k-pm-txt { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; color: var(--text-dim); }
.k-pm-txt b { font-family: var(--font-title); font-size: 1.15rem; color: var(--accent); }
.k-pm-bar { height: 9px; margin: 4px 0; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; border: 1px solid var(--panel-border); }
.k-pm-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .3s; }
.k-hud-pm small { font-size: .7rem; }
.k-boutons { display: flex; gap: 6px; margin-top: 8px; }
.k-boutons .btn { padding: 6px 10px; font-size: .72rem; flex: 1; }
.k-debug { opacity: .7; }
.k-armee { left: 14px; bottom: 14px; padding: 10px 12px; width: 300px; }
.k-armee-tete { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.k-armee-jeton { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--fc); flex: none; }
.k-armee-jeton .ph-label { display: none; }
.k-armee-tete b { display: block; font-family: var(--font-title); }
.k-armee-tete span { display: block; font-size: .72rem; color: var(--text-dim); line-height: 1.3; }
.k-armee-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 6px; }
.k-armee-slots > div { position: relative; }
.k-armee-slots > div.vide { aspect-ratio: 1; border-radius: 50%; border: 2px dashed var(--panel-border); }
.k-armee-slots b { position: absolute; right: -4px; bottom: -4px; padding: 0 5px; border-radius: 8px; background: var(--accent); color: var(--btn-text); font-size: .68rem; border: 1px solid var(--bg); }
.k-armee small { display: block; font-size: .7rem; line-height: 1.3; }
.k-minimap { right: 14px; bottom: 14px; padding: 6px; line-height: 0; }
.k-minimap canvas { cursor: crosshair; border-radius: 4px; }
.k-fiche { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: 14px; width: min(440px, calc(100vw - 28px)); padding: 16px 18px !important; }
.k-fiche[hidden] { display: none; }
.k-fiche h3 { margin: 0 24px 6px 0; color: var(--accent); }
.k-fiche p { margin: 6px 0; font-size: .88rem; }
.k-fiche-case { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.k-fiche-case span { font-size: .72rem; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--panel-border); color: var(--text-dim); }
.k-fiche-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 10px; }
.k-fiche-actions .btn { padding: 10px 18px; }
.k-rouge { color: var(--danger); }
.k-orange { color: #ffb347; }
#k-modal { z-index: 100; }
/* Entrée dans une ville ou un château (23/11/2026) : image plein écran derrière la fenêtre */
#k-modal.k-fond-lieu { background-color: #000; background-position: center; background-size: cover; background-repeat: no-repeat; }   /* image : carte.js (ouvrirModal) */
#k-modal.k-fond-lieu .k-modal-panel { backdrop-filter: blur(3px); box-shadow: 0 10px 60px rgba(0,0,0,.7); }
.k-modal-panel { max-width: 600px !important; width: 100%; position: relative; }
.k-modal-panel h2 { margin-top: 0; }
.k-combat { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; margin: 12px 0; text-align: left; }
.k-combat h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.k-vs { align-self: center; font-family: var(--font-title); font-size: 1.4rem; color: var(--accent); }
.k-ligne-troupe { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .86rem; }
.k-ligne-troupe .unit-portrait { width: 34px; flex: none; }
.k-monstre { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(120,20,20,.6); border: 2px solid #ff5a4a; color: #ffd2c8; }
.k-onglets { display: flex; gap: 6px; margin: 10px 0 12px; border-bottom: 1px solid var(--panel-border); }
.k-onglets button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--text-dim); font: 600 .85rem var(--font-body); cursor: pointer; }
.k-onglets button.active { color: var(--accent); border-bottom-color: var(--accent); }
.k-article { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.06); text-align: left; }
.k-article > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.k-article span, .k-article small { font-size: .8rem; }
.k-article .btn { padding: 8px 14px; font-size: .72rem; white-space: nowrap; }
.k-marche-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.k-ville-res { margin: 12px 0 0; font-size: .8rem; color: var(--text-dim); }
@media (max-width: 760px) {
  .k-armee { display: none; }
  .k-hud-pm { width: 180px; padding: 8px 10px; }
  .k-hud-pm .k-pm-txt span { font-size: .68rem; }
  .k-hud-monde { max-width: calc(100vw - 222px); padding: 6px 10px; }
  .k-hud-monde b { font-size: .85rem; }
  .k-hud-monde span { font-size: .66rem; }
  .k-minimap canvas { width: 120px !important; height: auto !important; }
  .k-fiche { bottom: 120px; }
  .k-combat { grid-template-columns: 1fr; }
  .k-vs { justify-self: center; }
}

/* Carte : mission principale et donjons */
.k-mission-villes { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.k-mission-villes span { font-size: .68rem; padding: 2px 7px; border-radius: 10px; border: 1px solid rgba(255,90,74,.5); color: #ffb0a0; }
.k-mission-villes span.ok { border-color: var(--ok); color: var(--ok); }
.k-mission-ok { font-size: 3rem; color: var(--accent); text-align: center; line-height: 1; text-shadow: 0 0 20px var(--accent); }
.k-modal-donjon { max-width: 640px !important; text-align: left; max-height: calc(100vh - 60px); overflow-y: auto; border-color: #9a6cff !important; box-shadow: 0 0 50px rgba(150,90,255,.35) !important; }
.k-modal-donjon p, .k-modal-donjon h2, .k-modal-donjon h4, .k-modal-donjon li, .k-donjon-boss { text-align: left; }
.k-donjon-infos div { text-align: center !important; }
.k-donjon-tete { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.k-donjon-tete h2 { margin: 2px 0 0; color: #d9b8ff; }
.k-donjon-ico { flex: none; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; font-size: 1.8rem;
  background: radial-gradient(circle, rgba(170,90,255,.45), rgba(20,10,30,.9)); border: 2px solid #9a6cff; color: #f0e0ff; }
.k-donjon-type { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.k-donjon-infos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.k-donjon-infos div { text-align: center; padding: 8px 4px; border: 1px solid var(--panel-border); border-radius: var(--radius); background: rgba(0,0,0,.25); }
.k-donjon-infos span { display: block; font-size: .68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.k-donjon-infos b { font-size: .88rem; color: var(--accent); }
.k-modal-donjon h4 { margin: 12px 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.k-donjon-liste { margin: 0; padding-left: 18px; font-size: .88rem; }
.k-donjon-liste li { margin: 3px 0; }
.k-donjon-liste.loot li::marker { content: '✦  '; color: var(--accent); }
.k-donjon-boss { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius); background: rgba(120,20,30,.25); border: 1px solid rgba(255,90,74,.45); }
.k-donjon-boss span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #ff9a8a; }
.k-donjon-boss b { font-family: var(--font-title); font-size: 1.05rem; }
.k-donjon-boss p { margin: 4px 0 0; font-size: .85rem; }
@media (max-width: 640px) { .k-donjon-infos { grid-template-columns: 1fr; } }

/* Fenêtre de fin */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; place-items: center; z-index: 80; padding: 20px; }
.modal.show { display: grid; animation: fade .3s; }
.modal .panel { max-width: 520px; text-align: center; }

/* ---------- Responsive (mobile / future appli) ---------- */
@media (max-width: 860px) {
  .hero-layout { grid-template-columns: 1fr; }
  .steps li { padding: 6px; }
  .steps li:not(.current) { font-size: 0; gap: 0; }
  .steps li b { font-size: .75rem; }
  .hero-portrait { aspect-ratio: 4 / 5; }
  .game-nav-link:not(.active) { font-size: 0; padding: 8px 10px; }
  .game-nav-link.soon::after { font-size: .9rem; }
  .nav-minijeux::before { font-size: 1.1rem; }
  .nav-minijeux::after { content: none; }
  .minijeu { padding: 12px; }   /* cibles tactiles plus grandes */
}
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; }
  .brand { width: 100px; }
  .brand-txt { font-size: 1.1rem; }
  .who span { display: none; }
  .panel { padding: 20px; }
  .logo-big .logo-txt { font-size: 2.6rem; }
  .login-wrap { padding-bottom: 110px; }
  .batiments-grid { grid-template-columns: repeat(2, 1fr); }
  .chantier-banner { flex-wrap: wrap; }
  .res-summary { gap: 8px; }
  .res-sum { padding: 8px 12px; font-size: .82rem; }
  .cit-tabs { gap: 0; }
  .cit-tabs button { padding: 10px 12px; font-size: .82rem; }
}

/* =========================================================
   ESCOUADE sur la carte (21/11/2026) : panneau du héros, menu Escouade,
   ville (recruter, soigner), fenêtre de combat
   ========================================================= */
.k-armee-slots > div { position: relative; }
.k-slot-vie { position: absolute; left: 8%; right: 8%; bottom: -5px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.8); overflow: hidden; }
.k-slot-vie i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#7fe07a, #35a83a); }
.k-slot-vie.bas i { background: linear-gradient(#ffc36a, #e2781e); }
.k-armee-btns { display: flex; gap: 6px; margin-top: 10px; }
.k-armee-btns .btn { flex: 1; padding: 6px 8px; font-size: .78rem; }
.k-pastille { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; border-radius: 1em; background: var(--fc, #d8b25a); color: #1a1208; font-size: .75rem; margin-left: 4px; }
.esc-titre { margin: 14px 0 8px; font-size: 1rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.esc-titre .btn { padding: 4px 10px; font-size: .75rem; }
.esc-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.esc-carte { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: var(--radius, 8px); background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.08); cursor: pointer; transition: border-color .15s, background .15s; }
.esc-carte:hover { border-color: rgba(255,255,255,.25); }
.esc-carte.choisie { border-color: var(--fc, #d8b25a); background: rgba(216,178,90,.12); box-shadow: 0 0 0 1px var(--fc, #d8b25a); }
.esc-carte.vide { justify-content: center; min-height: 64px; border-style: dashed; color: var(--text-dim); font-size: .85rem; }
.esc-carte.vide.cible { border-color: var(--fc, #d8b25a); color: var(--text); }
.esc-carte .unit-portrait { width: 52px; height: 52px; flex: none; }
.esc-carte-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.esc-carte-txt b { font-size: .92rem; }
.esc-carte-txt small { color: var(--text-dim); font-size: .72rem; line-height: 1.25; }
.esc-etoiles { color: #ffd25a; font-size: .8rem; letter-spacing: -.05em; }
.esc-etoiles i { color: rgba(255,255,255,.18); font-style: normal; }
.esc-vie { position: relative; display: block; height: 7px; border-radius: 4px; background: rgba(0,0,0,.7); overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.esc-vie i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#7fe07a, #35a83a); border-radius: 4px; }
.esc-vie.bas i { background: linear-gradient(#ffc36a, #e2781e); }
.esc-vie.mini { display: inline-block; width: 60px; height: 5px; vertical-align: middle; margin: 0 6px; }
.esc-aide { margin-top: 12px; font-size: .82rem; }
.k-modal-escouade { max-width: 860px; width: 94vw; max-height: 88vh; overflow: auto; }
.k-modal-competences { max-width: 1180px; width: 96vw; max-height: 92vh; overflow: auto; padding-top: 34px; }
.k-recrue { display: flex; gap: 14px; align-items: flex-start; margin: 6px 0 12px; }
.k-recrue .unit-portrait { width: 84px; height: 84px; flex: none; }
.k-recrue > div { display: flex; flex-direction: column; gap: 4px; }
.k-recrue small { font-size: .8rem; }
.k-article .esc-carte { flex: 1; cursor: default; background: none; border: 0; padding: 0; }
.k-monstre-img { width: 40px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.6)); }
@media (max-width: 600px) { .esc-grille { grid-template-columns: 1fr; } .k-recrue .unit-portrait { width: 64px; height: 64px; } }
.esc-carte-txt, .k-recrue > div { text-align: left; }
.k-article .esc-carte { flex-direction: row !important; align-items: center !important; gap: 10px; }
.k-article .esc-carte .esc-carte-txt { display: flex; flex-direction: column; }
.k-modal-panel.k-modal-escouade { max-width: 860px !important; width: 94vw; max-height: 88vh; overflow: auto; }
.k-modal-panel.k-modal-competences { max-width: 1180px !important; width: 96vw; max-height: 92vh; overflow: auto; text-align: left; }

/* ---------- Châteaux délivrés : quêtes royales, champion (23/11/2026) ---------- */
.k-modal-panel.k-modal-chateau { max-width: 640px !important; max-height: 90vh; overflow-y: auto; text-align: left; }
.k-modal-panel.k-modal-journal { max-width: 640px !important; width: 94vw; max-height: 88vh; overflow-y: auto; text-align: left; }
.k-modal-chateau h2, .k-modal-journal h2 { text-align: center; }
.qr-corps { text-align: left; }
.qr-seigneur { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.qr-seigneur b { display: block; font-family: var(--font-title); font-size: 1.05rem; }
.qr-seigneur small { color: var(--text-dim); font-size: .8rem; }
.qr-ico { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 1.4rem;
  background: rgba(0,0,0,.35); border: 2px solid var(--fc, #d8b25a); }
.qr-parole { font-style: italic; color: var(--text); opacity: .92; margin: 6px 0 10px; line-height: 1.45; }
.qr-message { border-left: 3px solid var(--fc, #d8b25a); background: rgba(255,210,90,.07); padding: 6px 12px; margin: 6px 0 12px; border-radius: 0 8px 8px 0; }
.qr-message p { margin: 4px 0; }
.qr-message p:first-child { font-style: italic; }
.qr-quete { border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: rgba(0,0,0,.18); }
.qr-quete p { margin: 6px 0; }
.qr-quete.dispo { border-color: #d8b25a; box-shadow: 0 0 12px rgba(216,178,90,.18); }
.qr-quete.prete { border-color: #7dd36a; box-shadow: 0 0 12px rgba(125,211,106,.2); }
.qr-quete.finie, .qr-quete.verrou { opacity: .6; padding: 6px 12px; }
.qr-tete { display: flex; flex-direction: column; gap: 2px; }
.qr-tete b { font-size: .98rem; }
.qr-type { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.qr-obj { font-size: .88rem; }
.qr-pied { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .82rem; margin-top: 6px; }
.qr-pied .btn { padding: 8px 16px; font-size: .78rem; }
.qr-choix { display: flex; gap: 10px; flex-wrap: wrap; }
.qr-choix .btn { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; }
.qr-choix .btn small { font-size: .72rem; opacity: .85; text-transform: none; letter-spacing: 0; }
.qr-h4 { margin: 14px 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); }
.qr-tresors { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.qr-tresors > div { border: 1px solid var(--panel-border); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; background: rgba(0,0,0,.18); }
.qr-fiche-type { color: #ffd98a; font-size: .85rem; }
.k-armee-btns { flex-wrap: wrap; }

/* ---------- Mercenaires soudoyés (23/11/2026) ---------- */
.k-soudoyer { border: 1px dashed #d8b25a; border-radius: 10px; padding: 8px 12px; margin: 8px 0; text-align: left; font-size: .86rem; }
p.k-soudoyer { border-style: dotted; opacity: .85; }
.k-soudoyer-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.k-soudoyer-btns .btn { padding: 7px 12px; font-size: .74rem; }
.esc-carte.merc { border-color: #d8b25a !important; box-shadow: inset 0 0 0 1px rgba(216,178,90,.5); }
.merc-txt { color: #ffd25a; font-weight: 600; }
.k-armee-slots > div.merc .unit-portrait { outline: 2px solid #ffd25a; outline-offset: 1px; }
.unit-portrait.merc img { object-fit: cover; height: 100%; }

/* ---------- Musique (27/11/2026) : bouton 🔊 et volume ---------- */
.mus-zone { display: inline-flex; align-items: center; gap: 6px; }
.mus-btn { background: none; border: 1px solid var(--accent, rgba(255,255,255,.3)); border-radius: 999px; color: inherit;
  width: 34px; height: 34px; padding: 0; font-size: 1rem; line-height: 1; cursor: pointer; flex: none; }
.mus-btn.btn { width: auto; height: auto; padding: 6px 10px; border-radius: inherit; }
.mus-volume { width: 0; opacity: 0; transition: width .2s, opacity .2s; accent-color: var(--fc, #4fe3d0); }
.mus-zone:hover .mus-volume, .mus-volume:focus { width: 80px; opacity: 1; }
.mus-flottant { position: fixed; left: 12px; bottom: 12px; z-index: 50; }
.mus-flottant .mus-btn { background: rgba(0,0,0,.55); }
@media (hover: none) { .mus-volume { display: none; } }
