/* Pages hors partie : connexion, administration, statistiques */
body.page { height: auto; min-height: 100vh; display: block; }
body.page header a:not(.btn) { color: #f3ead8; }
.page-main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 40px; }
.page-main h2 { font: 600 20px Georgia, serif; margin: 22px 0 8px; }
.page-main h3 { font: 600 16px Georgia, serif; margin: 16px 0 6px; }
.page-main .card { margin-bottom: 14px; }
.small { font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; font-weight: 600; border-bottom: 2px solid var(--line); padding: 5px 6px; white-space: nowrap; }
table.list td { border-bottom: 1px solid #eee5d4; padding: 5px 6px; vertical-align: top; }
table.list tr.hl td { background: #fff3c4; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 9px; font-size: 12px; font-weight: 600; background: #e6dfd0; color: var(--ink); }
.pill.pending { background: #f6e0a6; color: #7a5410; }
.pill.open { background: #d8ecd9; color: var(--good); }
.pill.refused, .pill.suspended { background: #f3c9c4; color: var(--bad); }
.pill.admin { background: #3a3128; color: #f3ead8; }
.row-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.row-acts button { padding: 2px 8px; font-size: 12.5px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 6px 0; }
.form-row label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
input[type=text], input[type=email], input[type=number], select, textarea { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); }
input[type=number] { width: 90px; }
.msg { padding: 8px 10px; border-radius: 4px; margin: 8px 0; }
.msg.ok { background: #d8ecd9; color: #1f5a33; }
.msg.err { background: #f6d5d0; color: #7a2018; }
.msg.info { background: #f1ead8; color: var(--ink); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat-tile { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.stat-tile b { display: block; font: 600 24px Georgia, serif; }
.bar { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: #e6dfd0; min-width: 120px; }
.bar span { display: block; height: 100%; }
.bar .u { background: var(--union); } .bar .c { background: var(--csa); } .bar .d { background: #b8ad95; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 6px 0 12px; }

/* page de connexion */
.login-wrap { max-width: 440px; margin: 7vh auto 30px; padding: 0 16px; }
.login-wrap .card { padding: 18px 20px; }
.login-wrap h1 { font: 600 26px Georgia, serif; margin: 0 0 4px; text-align: center; }
.login-wrap .sub { text-align: center; color: var(--muted); margin-bottom: 14px; }
.login-wrap label { display: block; margin: 10px 0 3px; font-weight: 600; }
.login-wrap input[type=text], .login-wrap input[type=email], .login-wrap textarea { width: 100%; }
.login-wrap .code { font-size: 26px; letter-spacing: 8px; text-align: center; }
.login-wrap .btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.login-wrap .btns button.primary { flex: 1; padding: 8px; }
.login-tabs { display: flex; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.login-tabs button { flex: 1; border: 0; background: none; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 600; color: var(--muted); }
.login-tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
@media (max-width: 640px) {
  table.list { font-size: 12.5px; }
  .hide-sm { display: none; }
}

/* ---------- page d'accueil ---------- */
.home-grid { max-width: 1280px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.home-grid main { display: block; min-height: 0; }
.home-grid main > .card, .home-side > .card { margin-bottom: 14px; }
.home-side { width: auto; padding: 0; display: block; }
.home h2 { font: 600 20px Georgia, serif; margin: 0 0 8px; }
.home h3 { font: 600 16px Georgia, serif; margin: 14px 0 2px; }
.home-side h3 { margin-top: 0; }
.cat-sub { margin: 0 0 8px; }
.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; }
.map-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; }
.map-card:hover { border-color: var(--accent); filter: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.map-card svg { width: 100%; height: 104px; display: block; background: #e8e4d2; border-radius: 3px; margin-bottom: 3px; }
.map-card b { font: 600 14.5px Georgia, serif; }
.map-card .pill { margin-top: 2px; }
.r-row, .s-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-top: 1px solid #eee5d4; }
.r-row:first-child, .s-row:first-child { border-top: 0; }
.r-row.hl { background: #fff6d6; border-radius: 4px; }
.r-row.quiet { opacity: .85; }
.r-ico { width: 22px; text-align: center; font-size: 16px; color: var(--muted); }
.r-txt { flex: 1; min-width: 0; }
.r-row button, .r-row .btn, .s-row button, .s-row .btn { padding: 3px 10px; font-size: 13px; }
.r-row .btn.primary-link, a.btn.primary-link { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.mini-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.mini-tiles div { background: #f1ead8; border-radius: 4px; padding: 6px 8px; }
.mini-tiles b { display: block; font: 600 20px Georgia, serif; }
.b-row { padding: 5px 0; border-top: 1px solid #eee5d4; font-size: 13.5px; }
.b-row:first-child { border-top: 0; }
@media (max-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .maps { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .map-card svg { height: 80px; }
}

/* ---------- page Bataille ---------- */
.battle-page { max-width: 1280px; margin: 0 auto; padding: 12px 16px 40px; }
.battle-page .back { display: inline-block; margin: 2px 0 8px; color: var(--accent); text-decoration: none; font-size: 13.5px; }
.hero h1 { font: 600 28px Georgia, serif; margin: 0; }
.hero .sub { color: var(--muted); margin: 2px 0 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.battle-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; align-items: start; }
.battle-main .card { margin-bottom: 14px; }
.battle-main h2, .play h2 { font: 600 19px Georgia, serif; margin: 0 0 8px; }
.battle-main p { margin: 4px 0 8px; line-height: 1.5; }
#bMap { width: 100%; height: auto; max-height: 70vh; display: block; background: #e8e4d2; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.forces { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.forces h3 { margin: 0 0 4px; }
.forces h3 .small { font: 400 12.5px "Segoe UI", system-ui, sans-serif; }
.play { position: sticky; top: 12px; }
.play fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.play legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tiles.three { grid-template-columns: 1fr 1fr 1fr; }
.tile { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.tile:hover { border-color: #b9a98a; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile b { font-size: 14px; }
.tile span { font-size: 12px; color: var(--muted); }
.tile .swatch { display: inline-block; width: 22px; height: 6px; border-radius: 2px; margin-bottom: 3px; }
.tile:has(input:checked) { border: 2px solid var(--accent); padding: 7px 9px; background: #fff6ee; }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg label { flex: 1; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 6px 4px; font-size: 13.5px; border-left: 1px solid var(--line); }
.seg label:first-child span { border-left: 0; }
.seg label:has(input:checked) span { background: var(--accent); color: #fff; font-weight: 600; }
.seg label:has(input:focus-visible) span { outline: 2px solid var(--ink); outline-offset: -3px; }
.hint { margin: 6px 0 0; }
.players { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; max-height: 210px; overflow-y: auto; }
.player { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.player input { margin: 0; }
.player .small { margin-left: auto; }
.player:has(input:checked) { border-color: var(--accent); background: #fff6ee; }
.play input[type=text] { width: 100%; }
.check { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: start; cursor: pointer; font-weight: 600; }
.check input { grid-row: span 2; margin: 3px 0 0; }
.check .small { grid-column: 2; font-weight: 400; }
.summary { background: #f1ead8; border-radius: 6px; padding: 8px 10px; font-size: 13.5px; margin-bottom: 10px; }
.go { width: 100%; padding: 10px; font-size: 15px; }
@media (max-width: 960px) {
  .battle-grid { grid-template-columns: minmax(0, 1fr); }
  .play { position: static; order: -1; }
}

/* ---------- composants communs à toutes les pages (y compris les fenêtres du jeu) ---------- */
.page-wrap { max-width: 1280px; margin: 0 auto; padding: 12px 16px 40px; }
.page-head .back, .hero .back { display: inline-block; margin: 2px 0 8px; color: var(--accent); text-decoration: none; font-size: 13.5px; }
.page-head h1 { font: 600 28px Georgia, serif; margin: 0; }
.page-head .sub { color: var(--muted); margin: 2px 0 10px; }
.page-head { margin-bottom: 6px; }
body.page .card > h2, body.page section.card h2 { font: 600 19px Georgia, serif; margin: 0 0 8px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row .with-icon .ico, button.with-icon .ico { width: 16px; height: 16px; }
button.icon, a.btn.icon { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; }
button.icon .ico, a.btn.icon .ico { width: 16px; height: 16px; }
.dlg-head { padding-bottom: 6px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.dlg-head b { font: 600 19px Georgia, serif; }
.dlg-head button.icon { border-color: transparent; background: none; }
.dlg-head button.icon:hover { background: #efe6d2; }
/* interrupteur (cases à cocher oui / non) */
input.switch, .field input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 10px; background: #cfc6b2; position: relative; cursor: pointer; transition: background .15s; vertical-align: middle; flex-shrink: 0; margin: 0; border: 0; padding: 0; }
input.switch::before, .field input[type=checkbox]::before { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s; }
input.switch:checked, .field input[type=checkbox]:checked { background: var(--accent); }
input.switch:checked::before, .field input[type=checkbox]:checked::before { left: 18px; }
input.switch:focus-visible, .field input[type=checkbox]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.filters-card .filters { margin: 0; gap: 10px 18px; }
.filters-card .seg { min-width: 300px; }
.stat-grid { margin-bottom: 14px; }
.card-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-title-row h2 { margin: 0 !important; }
body.page section.card { margin-bottom: 14px; }
table.list tr:hover td { background: #fbf6ea; }
table.list th { color: var(--muted); font-size: 12.5px; text-transform: none; }
@media (max-width: 640px) { .filters-card .seg { min-width: 0; width: 100%; } }
.ret-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px 110px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid #eee5d4; font-size: 13.5px; }
.ret-row input { width: 80px; }
.row-acts { align-items: center; }
.row-acts button { height: 26px; }
#fCreate { align-items: end; }
#fCreate .switch-row { padding-bottom: 6px; }
@media (max-width: 640px) { .ret-row { grid-template-columns: 1fr; gap: 2px; } }
.home-grid > .page-head { grid-column: 1 / -1; margin: 0; }
.r-ico .ico { width: 18px; height: 18px; margin: 0 auto; }
.form-row label.switch-row { flex-direction: row; align-items: center; }

.seg span { white-space: nowrap; }
.filters-card .seg { min-width: 0; }
.filters-card .seg span { padding: 6px 16px; }

/* ---------- didacticiel : panneau du sergent instructeur (jeu.html?lecon=N) ---------- */
#tutoBox { position: fixed; left: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - var(--head-h, 56px) - 24px); overflow: auto;
  background: var(--paper); border: 2px solid #3a3128; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.28); z-index: 30; padding: 0 12px 10px; font-size: 14px; line-height: 1.45; }
#tutoBox.folded { padding-bottom: 0; }
#tutoBox .tuto-head { display: flex; align-items: center; gap: 8px; margin: 0 -12px; padding: 6px 8px 6px 12px; background: #3a3128; color: #f3ead8; position: sticky; top: 0; }
#tutoBox .tuto-who { font: 600 14px Georgia, serif; }
#tutoBox .tuto-step { font-size: 12px; opacity: .8; margin-left: auto; }
#tutoBox .tuto-fold { background: transparent; border: 0; color: #f3ead8; font-size: 14px; padding: 0 4px; cursor: pointer; }
#tutoBox .tuto-bar { height: 4px; background: #e2d9c6; margin: 0 -12px 8px; }
#tutoBox.folded .tuto-bar { margin-bottom: 0; }
#tutoBox .tuto-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
#tutoBox h4 { margin: 4px 0 6px; font: 600 16px Georgia, serif; }
#tutoBox p { margin: 0 0 7px; }
#tutoBox .tuto-do { background: #fff4d6; border-left: 3px solid var(--warn); padding: 5px 8px; border-radius: 3px; }
#tutoBox .tuto-bravo { background: #e1f0e2; color: var(--good); border-radius: 4px; padding: 4px 8px; margin-bottom: 7px; font-weight: 600; }
#tutoBox .tuto-medal { font: 600 18px Georgia, serif; color: var(--accent); text-align: center; padding: 6px; border: 1px dashed var(--accent); border-radius: 6px; }
#tutoBox .tuto-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
#tutoBox .tuto-links { margin-left: auto; font-size: 12px; color: var(--muted); }
#tutoBox .tuto-wait { color: var(--warn); font-weight: 600; }
#tutoBox .linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12px; }
#tutoBox table.tuto-terrain { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#tutoBox table.tuto-terrain th, #tutoBox table.tuto-terrain td { border-bottom: 1px solid var(--line); padding: 3px 4px; text-align: left; vertical-align: top; }
#tutoSpots { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
.tuto-spot { position: fixed; border: 3px solid #f0b400; border-radius: 8px; box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 0 14px 4px rgba(240,180,0,.6); animation: tutoPulse 1.4s ease-in-out infinite; }
.tuto-spot.round { border-radius: 50%; }
.tuto-spot.dim { box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 0 0 9999px rgba(20,16,10,.35); }
@keyframes tutoPulse { 50% { border-color: #ffe27a; } }

/* accueil : les leçons du didacticiel */
.tuto-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tuto-card { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; }
a.tuto-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.tuto-card.soon { opacity: .6; }
.tuto-card .tuto-n { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.tuto-card b { font: 600 15px Georgia, serif; }
#tutoBox .tuto-log { background: #f3eee2; border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; margin-bottom: 8px; font-size: 12.5px; line-height: 1.4; }
#tutoBox .tuto-log b { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
