/* Couleurs de l'interface : une variable par rôle, redéfinies par thème (body.skin-xxx) */
:root {
  --page: #0b1020;
  --panel-a: #2a1d0e; --panel-b: #1a1209; --panel-c: #140d06;
  --border: #b8913a; --accent: #f2c14e; --accent-dark: #6b3d0a; --muted: #c9a75a; --faint: #8a7a55;
  --btn: #3a2a14; --btn-border: #7a5a22; --btn-on-text: #1a1209;
  --text: #e8e2c8; --text-soft: #d6cba6; --mana: #c4b5fd;
}
body.skin-halloween {
  --page: #0d0618;
  --panel-a: #2a1238; --panel-b: #160a20; --panel-c: #10071a;
  --border: #f97316; --accent: #fb923c; --accent-dark: #4c1d95; --muted: #c084fc; --faint: #8b6aa8;
  --btn: #3b1a4a; --btn-border: #7e3f8f; --btn-on-text: #1a0b22;
  --text: #f3e8ff; --text-soft: #e9d5ff; --mana: #f0abfc;
}
body.skin-galaxie {
  --page: #05060f;
  --panel-a: #111827; --panel-b: #030712; --panel-c: #020617;
  --border: #ffe81f; --accent: #ffe81f; --accent-dark: #000; --muted: #fde68a; --faint: #a3a07a;
  --btn: #1f2937; --btn-border: #4b5563; --btn-on-text: #030712;
  --text: #f8fafc; --text-soft: #e5e7eb; --mana: #7dd3fc;
}
body.skin-noel {
  --page: #04101f;
  --panel-a: #7f1d1d; --panel-b: #450a0a; --panel-c: #2a0606;
  --border: #facc15; --accent: #f8fafc; --accent-dark: #14532d; --muted: #bbf7d0; --faint: #86a98f;
  --btn: #14532d; --btn-border: #22c55e; --btn-on-text: #14532d;
  --text: #fef2f2; --text-soft: #fee2e2; --mana: #bae6fd;
}
body.skin-farwest {
  --page: #1c0f08;
  --panel-a: #5c3317; --panel-b: #3b1f0e; --panel-c: #2a1509;
  --border: #d97706; --accent: #fbbf24; --accent-dark: #7c2d12; --muted: #fcd34d; --faint: #a8865a;
  --btn: #4a2a12; --btn-border: #92400e; --btn-on-text: #2a1509;
  --text: #fef3c7; --text-soft: #fde68a; --mana: #fca5a5;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page); color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; user-select: none; }
canvas#view { position: fixed; inset: 0; display: block; cursor: crosshair; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 18px;
  padding: 0 14px; background: linear-gradient(var(--panel-a), var(--panel-b)); border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 12px #0008; z-index: 5; }
.brand { font-weight: 900; letter-spacing: 3px; color: var(--accent); text-shadow: 2px 2px 0 var(--accent-dark); font-size: 20px; line-height: 1.1; }
.brand small { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); text-shadow: none; font-weight: 400; }
.mana { display: flex; align-items: center; gap: 8px; }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.bar { width: 160px; height: 12px; background: #000a; border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #60a5fa, #a78bfa, #f0abfc); transition: width .2s; }
#manaTxt { min-width: 44px; color: var(--mana); }
.balance { display: flex; align-items: center; gap: 8px; }
.track { width: 140px; height: 12px; background: #ef4444; border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.track i { display: block; height: 100%; width: 50%; background: #3b82f6; transition: width .3s; }
#popTxt { font-size: 13px; min-width: 80px; }
.ctrl { display: flex; gap: 4px; }
.ctrl button { background: var(--btn); border: 1px solid var(--btn-border); border-radius: 4px; padding: 5px 9px; font-size: 13px; }
.ctrl { margin-left: auto; }

/* ---------- Barre du bas : terrain, ordres, pouvoirs ---------- */
#toolbar { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; align-items: stretch; z-index: 5;
  padding: 6px 8px 8px; background: linear-gradient(var(--panel-a), var(--panel-b)); border: 2px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px #000a; }
#toolbar .grp { display: flex; gap: 5px; align-items: flex-end; position: relative; padding: 12px 8px 0; }
#toolbar .grp + .grp { border-left: 1px solid var(--btn-border); }
#toolbar .glbl { position: absolute; top: -2px; left: 8px; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
#powers { display: flex; gap: 5px; }
.pw.tool { width: 60px; }
@media (max-width: 1180px) { .pw { width: 62px; } .pw.tool { width: 52px; } .pw .nm { font-size: 8.5px; } }
.pw { position: relative; width: 74px; height: 66px; background: var(--btn); border: 1px solid var(--btn-border); border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
.pw .ic { font-size: 22px; line-height: 1; }
.pw .nm { font-size: 9.5px; text-align: center; line-height: 1.05; }
.pw .co { font-size: 10px; color: var(--mana); }
.pw .k { position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--muted); }
.pw.on { background: var(--border); color: var(--btn-on-text); border-color: var(--accent); }
.pw.on .co, .pw.on .k { color: var(--btn); }
.pw:disabled { opacity: .38; cursor: not-allowed; }
.pw:not(:disabled):hover { border-color: var(--accent); }

#minimap { position: fixed; right: 12px; top: 64px; background: #000c; border: 2px solid var(--border); border-radius: 6px; z-index: 5; cursor: pointer; }
#info { position: fixed; left: 12px; bottom: 112px; font-size: 12px; background: #000a; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--btn-border); z-index: 5; max-width: 340px; pointer-events: none; }
#info:empty { display: none; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center;
  gap: 6px; z-index: 6; pointer-events: none; }
.toast { background: var(--panel-b); border: 1px solid var(--border); border-radius: 6px; padding: 6px 14px; font-size: 14px;
  box-shadow: 0 2px 10px #0008; transition: opacity .5s, transform .5s; animation: pop .25s ease-out; }
.toast.enemy { border-color: #ef4444; color: #fecaca; }
.toast.epic { font-size: 22px; font-weight: 900; letter-spacing: 2px; color: #fde047; border-color: #fde047; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

#pause { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; font-size: 60px; font-weight: 900;
  letter-spacing: 12px; color: var(--accent); text-shadow: 4px 4px 0 #000; pointer-events: none; z-index: 4; }
#pause.show { display: flex; }

/* ---------- Overlay ---------- */
#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #050814b0; z-index: 10; }
#overlay.hidden { display: none; }
.panel { background: linear-gradient(var(--panel-a), var(--panel-c)); border: 3px solid var(--border); border-radius: 12px; padding: 26px 34px;
  max-width: 640px; text-align: center; box-shadow: 0 10px 40px #000; }
.panel.hidden { display: none; }
.panel h1 { margin: 0 0 6px; font-size: 46px; letter-spacing: 6px; color: var(--accent); text-shadow: 3px 3px 0 var(--accent-dark); }
.panel h1 small { display: block; font-size: 15px; letter-spacing: 4px; color: var(--muted); text-shadow: none; }
.sub { color: var(--text-soft); line-height: 1.45; }
.rules { text-align: left; font-size: 14px; line-height: 1.6; color: var(--text); padding-left: 20px; }
.skins { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 4px 0 6px; }
.skins button { background: var(--btn); border: 1px solid var(--btn-border); border-radius: 20px; padding: 4px 14px; font-size: 14px; }
.diff { display: flex; gap: 10px; justify-content: center; margin: 18px 0 8px; }
.diff button, #btnAgain { background: var(--btn); border: 2px solid var(--btn-border); border-radius: 8px; padding: 10px 22px; font-size: 17px; font-weight: 700; }
.diff button:hover, #btnAgain:hover, .skins button:hover { border-color: var(--accent); }
button.primary { background: var(--border); color: var(--btn-on-text); border-color: var(--accent); }
.hint { font-size: 12px; color: var(--faint); font-style: italic; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
#endStats { font-size: 13px; color: var(--muted); }

/* ---------- Écran de fin et replay ---------- */
.ask { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ask.hidden { display: none; }
.ask p { margin: 0; font-size: 17px; }
.ask button, #btnReplayAgain { background: var(--btn); border: 2px solid var(--btn-border); border-radius: 8px; padding: 8px 20px; font-size: 15px; font-weight: 700; }
.ask button.primary { background: var(--border); color: var(--btn-on-text); border-color: var(--accent); }
.hidden { display: none !important; }
#replayBar { display: none; position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; align-items: center; gap: 8px;
  padding: 10px 12px; background: linear-gradient(var(--panel-a), var(--panel-b)); border: 2px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px #000a; }
body.replaying #replayBar { display: flex; }
body.replaying #toolbar { display: none; }
#replayBar .glbl { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
#replayBar button { background: var(--btn); border: 1px solid var(--btn-border); border-radius: 6px; padding: 6px 12px; font-size: 15px; min-width: 44px; }
#replayBar button:hover { border-color: var(--accent); }
.rpTimeline { display: flex; flex-direction: column; gap: 2px; }
#rpGraph { background: #0008; border-radius: 4px; }
#rpSlider { width: 420px; accent-color: var(--accent); }
#rpTime { font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; }

/* ---------- Conquête ---------- */
#conquestBox { margin: 14px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cqNav { display: flex; align-items: center; gap: 12px; }
.cqNav button, .cqCode button { background: var(--btn); border: 1px solid var(--btn-border); border-radius: 6px; padding: 6px 12px; font-size: 16px; }
.cqNav button:disabled { opacity: .3; cursor: default; }
#cqInfo { min-width: 330px; text-align: center; line-height: 1.5; }
.cqCode { display: flex; gap: 6px; }
#cqCode { background: #0006; color: var(--text); border: 1px solid var(--btn-border); border-radius: 6px; padding: 6px 10px; font: inherit;
  text-transform: uppercase; letter-spacing: 2px; width: 190px; }
#cqPlay { background: var(--border); color: var(--btn-on-text); border: 2px solid var(--accent); border-radius: 8px; padding: 10px 22px; font-size: 17px; font-weight: 700; }
.pw.locked { opacity: .25; }
.pw.locked::after { content: '🔒'; position: absolute; top: 2px; right: 3px; font-size: 10px; }
/* Écran titre plus haut que la fenêtre (portable) : le panneau défile */
.panel { max-height: calc(100vh - 24px); overflow-y: auto; }
