/* Mise en page : carte à gauche, panneaux de jeu à droite ; une seule colonne sur téléphone.
   La carte garde des teintes fixes (pastels de zones, encre sombre) dans les deux thèmes ;
   tout le reste passe par ces jetons. */
:root {
  --bg: #f6f1e7; --panel: #fffdf8; --ink: #2b2622; --muted: #7a7066; --line: #d9cfbd;
  --sea: #dfe9ea; --terre: #efe7d4;
  --err-bg: #fde7e3; --err-ink: #7a1d10; --err-line: #e8a79c;
  --warn-bg: #fff4d6; --warn-ink: #6b4e00; --warn-line: #e6cb7c;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px)); --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1c19; --panel: #292521; --ink: #efe8dc; --muted: #a39a8d; --line: #453f38; --sea: #1c2a2d; --terre: #2b2824;
    --err-bg: #3a1f1a; --err-ink: #f3b8ab; --err-line: #6e3428;
    --warn-bg: #352b14; --warn-ink: #ecd394; --warn-line: #6b5520;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1c19; --panel: #292521; --ink: #efe8dc; --muted: #a39a8d; --line: #453f38; --sea: #1c2a2d; --terre: #2b2824;
  --err-bg: #3a1f1a; --err-ink: #f3b8ab; --err-line: #6e3428;
  --warn-bg: #352b14; --warn-ink: #ecd394; --warn-line: #6b5520;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, sans-serif; }
header { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; padding-block: 12px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); border-bottom: 1px solid var(--line); }
h1 { margin: 0; font: 700 22px Georgia, serif; letter-spacing: .02em; }
h2 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tag { color: var(--muted); font-size: 13px; }
.controls { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button, select { font: inherit; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
button { cursor: pointer; }
#alertes { margin: 10px var(--gutter-r) 0 var(--gutter-l); padding: 10px 14px; border-radius: 8px; background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--err-line); }
#alertes.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
main { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding-block: 16px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
main > * { min-width: 0; }
#carte { width: 100%; height: auto; background: var(--sea); border: 1px solid var(--line); border-radius: 10px; }
aside section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
aside ul { list-style: none; margin: 0; padding: 0; }
aside li { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 14px; }
aside li .bonus { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.muted { color: var(--muted); margin: 0; }
#info h3 { margin: 0; font: 700 17px Georgia, serif; }
#info p { margin: 2px 0; }
footer { padding-block: 4px 18px; padding-left: var(--gutter-l); padding-right: var(--gutter-r); color: var(--muted); font-size: 12px; max-width: 900px; }

/* Carte */
#carte .fond { fill: var(--sea); }
.alentours text { fill: var(--muted); opacity: .55; font: italic 13px Georgia, serif; text-anchor: middle; letter-spacing: .06em; pointer-events: none; }
.alentours text.mer { fill: #5f8aa8; opacity: .8; letter-spacing: .25em; }
.region-ombre { fill: var(--terre); }
.terr { cursor: pointer; outline: none; }
.terr path.zone { stroke-width: .8; transition: filter .12s; }
.terr:hover path.zone, .terr:focus-visible path.zone { filter: brightness(1.1) saturate(1.15); }
.terr path.proprio { fill: none; stroke-width: 10; stroke-linecap: round; opacity: .8; pointer-events: none; }
.terr.estompe, .badge.estompe { opacity: .4; }
.sans-noms .badge .nom { display: none; }
.depts path { fill: none; stroke: var(--ink); stroke-opacity: .28; stroke-width: 1; stroke-dasharray: 5 4; pointer-events: none; }
.depts path { stroke-opacity: .18; }
/* Bords : fins dans une zone, épais entre deux zones */
.bords path { fill: none; pointer-events: none; stroke-linecap: round; stroke-linejoin: round; }
.bords .bord-territoire { stroke: #fff; stroke-opacity: .7; stroke-width: 1; }
.bords .bord-zone-halo { stroke: #fff; stroke-opacity: .65; stroke-width: 6; }
.bords .bord-zone { stroke: #2b2622; stroke-opacity: .9; stroke-width: 3.2; }
.bords .region-trait { stroke: #2b2622; stroke-opacity: .9; stroke-width: 2.6; }
.zone-focus path { fill: none; stroke-width: 7; stroke-linecap: round; opacity: 0; pointer-events: none; transition: opacity .15s; }
.zone-focus path.actif { opacity: 1; }
.zone-noms text { font: 800 10px system-ui, sans-serif; letter-spacing: .04em; text-anchor: middle; dominant-baseline: central;
  paint-order: stroke; stroke: rgba(255,255,255,.8); stroke-width: 3.5px; stroke-linejoin: round; pointer-events: none; transition: opacity .15s; }
.zone-noms text.estompe { opacity: .25; }
.zone-noms text.actif { font-size: 11px; }
.sans-zones .zone-noms { display: none; }
.surbrillance path { fill: none; pointer-events: none; stroke: none; stroke-linejoin: round; }
.surbrillance path.voisin { stroke: var(--ink); stroke-width: 3; stroke-opacity: .85; }
.surbrillance path.survol { stroke: var(--ink); stroke-width: 4.5; }
.surbrillance path.source { stroke: var(--ink); stroke-width: 5; }
.surbrillance path.cible { stroke: #ffc928; stroke-width: 4.5; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { stroke-opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .surbrillance path.cible { animation: none; } }
.liens line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: 0; pointer-events: none; }
.show-liens .liens line { opacity: .45; }
.liens line.actif { opacity: .9; stroke-width: 2.5; stroke-dasharray: none; }
.badge { pointer-events: none; }
.badge circle { stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.badge .troupes { fill: #fff; font: 700 15px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: rgba(0,0,0,.35); stroke-width: 3px; }
.badge .nom { fill: #2b2622; font: 600 10.5px system-ui, sans-serif; text-anchor: middle; paint-order: stroke; stroke: rgba(255,250,240,.9); stroke-width: 3px; stroke-linejoin: round; }
@media (max-width: 800px) { main { grid-template-columns: 1fr; } }

/* Configuration, barre d'action, journal */
.setup { display: grid; gap: 6px; }
.setup .ligne { display: flex; align-items: center; gap: 8px; }
.setup select { margin-left: auto; }
#barre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 52px; }
#barre .qui { font-weight: 700; display: flex; align-items: center; gap: 6px; }
#barre .consigne { color: var(--muted); }
#barre .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#barre input[type=number] { width: 64px; font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
button.primaire { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button:disabled { opacity: .5; cursor: default; }
#journal { max-height: 190px; overflow: auto; font-size: 13px; }
#journal li { display: block; padding: 1px 0; color: var(--muted); }
#journal li:first-child { color: var(--ink); }
.victoire { font-weight: 700; color: var(--ink); }
.de { display: inline-block; min-width: 1.2em; text-align: center; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); margin: 0 1px; }

#cartes { display: grid; gap: 6px; }
.carte { text-align: left; display: grid; gap: 2px; width: 100%; }
.carte span { font-size: 12px; color: var(--muted); }
.carte.active { border-color: #ffd24a; box-shadow: 0 0 0 2px #ffd24a; }
label.bouton { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); cursor: pointer; }

#passage { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: grid; place-items: center; text-align: center;
  padding: env(safe-area-inset-top, 0px) var(--gutter-r) env(safe-area-inset-bottom, 0px) var(--gutter-l); }
#passage[hidden] { display: none; }
#passage h2 { margin: 6px 0 12px; font: 700 34px Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--ink); display: flex; gap: 10px; align-items: center; justify-content: center; }
#passage .swatch { width: 22px; height: 22px; border-radius: 6px; }
#passage button { margin-top: 14px; padding: 10px 22px; font-size: 16px; }
#mission p { margin: 2px 0; }

/* Légende des zones : interactive */
#legende li { cursor: pointer; margin: 0; border-radius: 6px; padding: 3px 4px; margin: 0 -4px; display: grid; grid-template-columns: 12px 1fr auto; column-gap: 8px; row-gap: 3px; align-items: center; }
#legende li:hover, #legende li.actif { background: color-mix(in srgb, var(--ink) 8%, transparent); }
#legende li.fige { outline: 2px solid var(--ink); outline-offset: -2px; }
#legende li .controle { grid-column: 2 / 4; display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
#legende li .controle span { display: block; height: 100%; }
#legende li .etat { grid-column: 2 / 4; font-size: 12px; color: var(--muted); margin-top: -2px; }
#legende li .swatch { grid-row: 1; }
#sec-zones { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
#sec-zones ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px; }
#sec-zones li { font-size: 14px; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
#coller { display: grid; gap: 6px; }
#coller textarea { width: 100%; min-height: 70px; font: 12px ui-monospace, monospace; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
@media (max-width: 480px) { h1 { font-size: 19px; } #barre .actions { margin-left: 0; } }

/* Zoom de la carte */
#carte-cadre { position: relative; }
#carte { display: block; touch-action: pan-y; }
#carte.zoome { touch-action: none; cursor: grab; }
#carte.deplace, #carte.deplace .terr { cursor: grabbing; }
.zoom-controls { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.zoom-controls button { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; display: grid; place-items: center; background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.zoom-controls button:disabled { opacity: .4; cursor: default; }
@media (pointer: coarse) { .zoom-controls button { width: 42px; height: 42px; } }
#coller[hidden] { display: none; }

/* Jeu en ligne */
#sec-en-ligne input { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); min-width: 0; flex: 1; }
#sec-en-ligne .ligne label { flex: none; }
#code-partie { text-transform: uppercase; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
#serveur-url { width: 100%; margin-top: 6px; font-size: 12px; }
.code-partie { font: 700 20px ui-monospace, monospace; letter-spacing: .15em; }
#en-ligne-etat .places { list-style: none; margin: 6px 0; padding: 0; }
#en-ligne-etat .places li { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 14px; }
#en-ligne-etat .places .bonus { margin-left: auto; color: var(--muted); font-size: 12px; }
.erreur { color: var(--err-ink); margin: 0; }
#en-ligne-actions[hidden] { display: none; }
