:root {
  --bg: #efe9dc; --paper: #fbf8f1; --ink: #2b2620; --muted: #776d60; --line: #d6ccb8;
  --union: #2f4f8f; --csa: #5f5b55; --accent: #a8442a; --good: #2f7d4a; --bad: #a8322a; --warn: #b07a1c;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); height: 100vh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #3a3128; color: #f3ead8; flex-wrap: wrap; }
.title { font: 600 18px Georgia, serif; }
.title span { font-weight: 400; font-size: 14px; opacity: .7; }
.status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.side-badge, .phase-badge { padding: 2px 10px; border-radius: 10px; font-weight: 600; }
.side-badge.union { background: var(--union); }
.side-badge.confederate { background: var(--csa); }
.phase-badge { background: #5b4d3e; }
.actions { margin-left: auto; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
button { font: inherit; padding: 5px 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 4px; cursor: pointer; }
button:hover { filter: brightness(.95); }
button:disabled { opacity: .45; cursor: default; }
a.btn { font: inherit; padding: 5px 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 4px; text-decoration: none; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.on { background: #f2d675; }
main { flex: 1; display: flex; min-height: 0; }
#mapWrap { flex: 1; position: relative; overflow: hidden; min-width: 0; }
#mapScroll { position: absolute; inset: 0; overflow: auto; }
#mapScroll.grab { cursor: grabbing; }
#mapScroll.grab * { cursor: grabbing !important; }
#map { display: block; width: 100%; height: 100%; }
/* affichage illustré : la toile reste collée à la partie visible, le défilement de #mapScroll la déplace */
#mapPixi { display: none; position: sticky; left: 0; top: 0; cursor: pointer; }
#mapTools { position: absolute; right: 12px; bottom: 12px; z-index: 4; display: flex; flex-direction: column; gap: 3px; padding: 4px; background: rgba(251,248,241,.88); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
#mapTools button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
#mapTools .sep { height: 1px; background: var(--line); margin: 2px 3px; }
#mapTools button.on { background: #f2d675; }
#renderMenu { position: absolute; right: calc(100% + 6px); width: 210px; padding: 6px; background: #fbf8f1; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 3px; }
#renderMenu[hidden] { display: none; }
#renderMenu .rm-title { font-size: 12px; font-weight: 600; color: #6b5d4a; padding: 2px 4px 4px; }
#mapTools #renderMenu button { width: auto; height: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; text-align: left; }
#renderMenu button small { font-size: 11px; color: #6b5d4a; font-weight: normal; }
#renderMenu button:disabled { opacity: .45; cursor: not-allowed; }
body.no-aside aside { display: none; }
body.no-aside #aiBanner, body.no-aside #summaryCard { left: 50%; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.actions .sep { width: 1px; align-self: stretch; background: rgba(243,234,216,.25); margin: 2px 4px; }
.actions .icon { display: inline-grid; place-items: center; }
button.with-icon { display: inline-flex; align-items: center; gap: 6px; }
button.with-icon .ico { width: 16px; height: 16px; }
#hoverInfo { position: fixed; left: 16px; bottom: 14px; z-index: 3; background: rgba(251,248,241,.94); border: 1px solid var(--line); padding: 4px 8px; border-radius: 4px; font-size: 13px; pointer-events: none; }
#hoverInfo:empty { display: none; }
#hoverInfo .no-charge { display: inline-block; max-width: 290px; color: #8a3a10; }
aside { width: 380px; display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 8px 0; min-height: 0; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.card-head { font-weight: 600; display: flex; justify-content: space-between; margin-bottom: 6px; }
.log-card { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#log { overflow-y: auto; flex: 1; }
.entry { border-left: 3px solid var(--line); padding: 4px 8px; margin-bottom: 6px; background: #fff; }
.entry .t { font-weight: 600; }
.entry .l { font-size: 13px; }
.tabs { align-items: center; }
.tab { border: 0; background: none; padding: 3px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
#roster { overflow-y: auto; flex: 1; }
#battle { overflow-y: auto; flex: 1; font-size: 13.5px; }
#battle h4 { font: 600 15px Georgia, serif; margin: 12px 0 4px; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
#battle h3 { font: 600 16px Georgia, serif; margin: 2px 0 2px; }
#battle p { margin: 4px 0 6px; }
#battle table { width: 100%; border-collapse: collapse; }
#battle td { padding: 2px 4px; border-bottom: 1px solid #eee5d4; }
#battle .ok { color: var(--good); font-weight: 600; }
#battle .bad { color: var(--bad); font-weight: 600; }
.r-side { font: 600 15px Georgia, serif; margin: 8px 0 2px; padding: 4px 8px; color: #fff; border-radius: 4px; }
.r-side .small { color: #f3ead8; display: block; font-family: "Segoe UI", system-ui, sans-serif; }
.r-div { margin: 8px 0 2px; font-weight: 600; }
.r-div .small { font-weight: 400; display: block; }
table.roster { width: 100%; border-collapse: collapse; font-size: 13px; }
table.roster td { padding: 2px 4px; border-bottom: 1px solid #eee5d4; vertical-align: middle; }
table.roster tr.uref { border-bottom: 0; }
table.roster tr.uref:hover { background: #fbe9a6; }
table.roster tr.gone { color: #999; text-decoration: line-through; }
table.roster tr.selected { background: #fff3c4; }
.r-type { font-size: 11px; color: var(--muted); width: 28px; }
.pips { white-space: nowrap; }
.pip { display: inline-block; width: 7px; height: 7px; border: 1px solid #555; margin-right: 1px; background: #fff; }
.pip.hit { background: #c0281e; }
.tag.ok { background: #d8ecd9; color: var(--good); }
.tag.engaged { background: #f3c9c4; color: var(--bad); }
.tag.moves { background: #2a8a4a; color: #fff; }
.uref { border-bottom: 1px dotted #8a7a60; cursor: pointer; }
.uref:hover { background: #fbe9a6; border-bottom-color: #e0a800; }
/* Noms d'unités et de généraux, partout (journal, fiche de tour, bulles, panneaux, bandeau de l'IA…) : couleur du camp.
   L'étiquette a son propre fond clair : elle reste lisible sur les fonds sombres (bandeau violet, notifications). */
.uref.side-union, .uref.side-confederate { font-weight: 600; padding: 0 3px; border-radius: 3px; border-bottom: 0; text-shadow: none; }
.uref.side-union { color: var(--union); background: #e3eaf7; box-shadow: inset 2px 0 0 var(--union); }
.uref.side-confederate { color: #4a4640; background: #e9e6e0; box-shadow: inset 2px 0 0 var(--csa); }
.uref.side-union:hover, .uref.side-confederate:hover { background: #fbe9a6; }
h3 .uref.side-union, h3 .uref.side-confederate { padding: 0 5px; }
.entry .note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.entry.good { border-color: var(--good); }
.entry.bad { border-color: var(--bad); }
.entry.warn { border-color: var(--warn); }
.entry.turn { border-color: #3a3128; background: #f3ead8; }
.entry.info { border-color: var(--union); }
.entry.ai { border-color: #7a4fa0; background: #f6f0fb; }
.opt { display: block; padding: 6px 4px; }
.save-new { display: flex; gap: 6px; margin: 8px 0; }
.save-new input { flex: 1; font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 4px; }
#savesList { max-height: 50vh; overflow-y: auto; }
table.saves { width: 100%; border-collapse: collapse; font-size: 13px; }
table.saves th, table.saves td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.saves th { background: #f3ead8; }
table.saves td.acts { white-space: nowrap; text-align: right; }
table.saves td.acts button { padding: 2px 7px; font-size: 12px; }
table.saves tr.current td:first-child { font-weight: 600; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #3a3128; color: #fff; padding: 8px 16px; border-radius: 6px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; }
.status-ok { color: var(--good); }
.status-warn { color: var(--warn); }
.scen-box { display: flex; gap: 12px; align-items: flex-start; padding: 4px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
#newPreview { width: 300px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 4px; }
.scen-box p { margin: 0 0 6px; }
.terrain-swatch { display: inline-block; width: 12px; height: 12px; border: 1px solid #998; vertical-align: -2px; margin-right: 3px; }
#panel .linkbtn { background: none; border: 0; padding: 0; color: #2f4f8f; text-decoration: underline; cursor: pointer; font-size: 13px; }
@media (max-width: 640px) { .scen-box { flex-direction: column; } #newPreview { width: 100%; } }
dialog.confirm-dlg { width: min(460px, 92vw); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.ai-badge { background: #7a4fa0; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.small { font-size: 12px; color: var(--muted); font-weight: 400; }
#panel h3 { margin: 0 0 4px; font: 600 16px Georgia, serif; }
#panel .sub { color: var(--muted); margin-bottom: 8px; }
#panel table { width: 100%; border-collapse: collapse; margin: 6px 0; }
#panel td { padding: 2px 4px; border-bottom: 1px solid #eee5d4; vertical-align: top; }
#panel td:first-child { color: var(--muted); width: 45%; }
#panel .btns { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
#panel .hint { background: #f6efd9; border-radius: 4px; padding: 6px 8px; font-size: 13px; margin-top: 6px; }
#panel .why { color: var(--bad); font-size: 13px; margin-top: 4px; }
.tag { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 12px; font-weight: 600; margin-right: 4px; }
.tag.shaken { background: #f3c9c4; color: var(--bad); }
.tag.dis { background: #f5ddb0; color: #7a5410; }
.tag.col { background: #e9dcc0; color: #6b4f2a; }
.tag.done { background: #ddd; color: #555; }
dialog { width: min(760px, 92vw); border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
#rulesBody table { width: 100%; border-collapse: collapse; font-size: 13px; }
#rulesBody td, #rulesBody th { border: 1px solid var(--line); padding: 3px 6px; text-align: left; }
#rulesBody h4 { margin: 12px 0 4px; }
svg text { font-family: "Segoe UI", system-ui, sans-serif; pointer-events: none; }
.hex { stroke: rgba(90,78,55,.28); stroke-width: .6; cursor: pointer; }
#map.nogrid .hex { stroke: transparent; }
#map .uname { display: none; }
#map.names .uname, #map .uname.show, #map .uname.hshow { display: inline; }
#summaryCard h4 { cursor: move; user-select: none; }
#summaryCard h4::before { content: '⠿'; color: #b3a588; margin-right: 6px; font-family: 'Segoe UI Symbol', sans-serif; }
#summaryCard.dragged { transform: none; }
@media (max-width: 900px) { main { flex-direction: column; } aside { width: auto; padding: 0 8px 8px; } #mapWrap { min-height: 62vh; } }
#panel { max-height: 48vh; overflow-y: auto; }
kbd { display: inline-block; font: 600 10px "Segoe UI", sans-serif; padding: 0 4px; margin-left: 4px; border: 1px solid #b9ad95; border-bottom-width: 2px; border-radius: 3px; background: #fff; color: #5b4d3e; vertical-align: 1px; }
button.primary kbd { background: rgba(255,255,255,.85); }
#panel details { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 4px; }
#panel summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.bubble { position: fixed; z-index: 20; width: 260px; background: rgba(255,253,246,.94); border: 1px solid #c9bb9b; border-left: 4px solid #8a7a60; border-radius: 6px; padding: 6px 9px; font-size: 12.5px; line-height: 1.35; box-shadow: 0 3px 10px rgba(0,0,0,.18); cursor: pointer; transition: opacity .8s; }
.bubble.good { border-left-color: var(--good); }
.bubble.bad { border-left-color: var(--bad); }
.bubble.warn { border-left-color: var(--warn); }
.bubble.fade { opacity: 0; }

/* ---------- effets, bandeau IA, résumé, bilan ---------- */
#mapInner { position: relative; width: 100%; height: 100%; }
#fx { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.smoke { fill: #e9e6df; transform-box: fill-box; transform-origin: center; animation: smoke 2.8s ease-out forwards; }
.smoke.art { fill: #dcd8cf; animation-duration: 3.6s; }
@keyframes smoke { 0% { opacity: .85; transform: scale(.3); } 60% { opacity: .55; } 100% { opacity: 0; transform: scale(2.4) translateY(-6px); } }
.flash { fill: #ffcf4a; transform-box: fill-box; transform-origin: center; animation: flash .35s ease-out forwards; }
@keyframes flash { 0% { opacity: 1; transform: scale(.5); } 100% { opacity: 0; transform: scale(1.8); } }
/* impacts sur la cible (affichage classique) */
.smoke.dark { fill: #3d362e; opacity: 0; animation: smoke 2.4s ease-out forwards; }
.flash.burst { fill: #ffd25a; opacity: 0; }
.clod { fill: #5e4a32; opacity: 0; animation: clod .7s ease-out forwards; }
@keyframes clod { 0% { opacity: 1; transform: translate(0, 0); } 60% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)); } }
.dust { fill: #cdb98e; opacity: 0; transform-box: fill-box; transform-origin: 50% 80%; animation: dust .9s ease-out forwards; }
@keyframes dust { 0% { opacity: .85; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.8, 2.2) translateY(-3px); } }
.fireline { stroke: #b0281e; stroke-width: 1.6; stroke-dasharray: 5 4; fill: none; animation: fire 1.4s ease-out forwards; }
@keyframes fire { 0% { opacity: .9; } 100% { opacity: 0; } }
.ai-ring { fill: none; stroke: #7a4fa0; stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: ring 1s ease-in-out infinite; }
@keyframes ring { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.15); } }
#aiBanner { position: fixed; top: calc(var(--head-h, 50px) + 8px); left: calc((100% - 388px) / 2); transform: translateX(-50%); z-index: 6; width: max-content; max-width: 60%; background: #7a4fa0; color: #fff; padding: 4px 14px; border-radius: 14px; font-weight: 600; font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
#summaryCard { position: fixed; top: calc(var(--head-h, 50px) + 42px); left: calc((100% - 388px) / 2); transform: translateX(-50%); z-index: 7; width: min(560px, 90vw); background: #fffdf6; border: 1px solid var(--line); border-left: 4px solid #3a3128; border-radius: 6px; padding: 8px 12px; font-size: 13px; box-shadow: 0 3px 10px rgba(0,0,0,.15); }
#summaryCard h4 { margin: 0 0 4px; font: 600 15px Georgia, serif; }
#summaryCard ul { margin: 4px 0; padding-left: 18px; }
#summaryCard .sum-btns { text-align: right; margin-top: 4px; }
.todo-badge { padding: 2px 10px; border-radius: 10px; background: #2a8a4a; font-weight: 600; font-size: 13px; cursor: pointer; }
.todo-badge:empty { display: none; }
#hoverInfo.follow { position: fixed; bottom: auto; }
.bubble { transform: translateX(-50%); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #c9bb9b; }
.bubble.below::after { bottom: auto; top: -8px; border-top: 0; border-bottom: 8px solid #c9bb9b; }
#statsBody table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 6px 0; }
#statsBody th, #statsBody td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
#statsBody .winner { font: 600 18px Georgia, serif; margin: 6px 0; }

@media (max-width: 900px) { #aiBanner, #summaryCard { left: 50%; } }
.actions .icon { min-width: 34px; height: 30px; padding: 0 7px; }

.face-arrow { cursor: pointer; pointer-events: all; }
.face-arrow:hover circle { fill: #ffef8a; stroke-width: 2; }
table.roster tr.gone { cursor: pointer; }

/* ---------- version en ligne ---------- */
#onlineInfo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #24425f; padding: 3px 6px 3px 10px; border-radius: 12px; font-size: 13px; }
#onlineInfo button { padding: 1px 8px; font-size: 12.5px; }
#onlineInfo .small { color: #d4dbe4; }
#onlineInfo .err { color: #ffb4a8; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9a9187; margin-right: 4px; vertical-align: 1px; }
.dot.on { background: #4cc46a; box-shadow: 0 0 0 2px rgba(76,196,106,.25); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }
.account-nav { display: inline-flex; gap: 6px; align-items: center; }
.account-nav .small { color: #e6dccb; }
#onlineDlg { width: min(860px, 96vw); }
#onlineDlg h4 { margin: 14px 0 6px; font: 600 15px Georgia, serif; }
#onlineDlg .msg { padding: 6px 10px; border-radius: 4px; margin: 8px 0; }
#onlineDlg .msg.ok { background: #d8ecd9; } #onlineDlg .msg.err { background: #f6d5d0; }
a.btn.with-icon { display: inline-flex; align-items: center; gap: 6px; }
a.btn.with-icon .ico { width: 16px; height: 16px; }
.badge[hidden] { display: none; }
/* en-tête compact : textes courts, détails dans les infobulles */
a.title { color: inherit; text-decoration: none; white-space: nowrap; }
.badge-host { position: relative; }
.badge-host .badge { position: absolute; top: -6px; right: -6px; min-width: 16px; padding: 0 4px; font-size: 10.5px; line-height: 16px; }
#onlineInfo .icon { display: inline-grid; place-items: center; width: 28px; height: 24px; padding: 0; }
#onlineInfo .icon .ico { width: 15px; height: 15px; }
.actions .with-icon .ico { width: 16px; height: 16px; }
.who { color: #e6dccb; font-size: 13px; align-self: center; margin-left: 4px; }
.status > span { white-space: nowrap; }
@media (max-width: 900px) { .lbl-txt { display: none; } }
@media (max-width: 640px) { .title span { display: none; } }
[hidden] { display: none !important; }   /* « caché » l'emporte toujours sur la mise en page */
.entry .note .ico { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }
#panel .btns button.with-icon { justify-content: center; }
.save-new button.with-icon .ico, .dlg-btns .with-icon .ico { width: 16px; height: 16px; }
/* nom d'un camp, même étiquette que les noms d'unités du journal (sans clic) */
.side-tag { font-weight: 600; padding: 0 3px; border-radius: 3px; }
.side-tag.side-union { color: var(--union); background: #e3eaf7; box-shadow: inset 2px 0 0 var(--union); }
.side-tag.side-confederate { color: #4a4640; background: #e9e6e0; box-shadow: inset 2px 0 0 var(--csa); }

/* Brouillard de guerre : rideau entre les tours (deux joueurs sur le même écran) */
#fogCurtain { position: fixed; inset: 0; z-index: 900; background: #2f2a24; display: flex; align-items: center; justify-content: center; }
#fogCurtain[hidden] { display: none; }
#fogCurtain .fog-card { background: #fffdf6; border-radius: 8px; padding: 22px 28px; max-width: 440px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
#fogCurtain h2 { margin: 0 0 10px; font: 600 22px Georgia, serif; }
#fogCurtain button { margin-top: 10px; font-size: 15px; padding: 8px 22px; }
