.battle-heading { display:flex; align-items:center; justify-content:space-between; gap:20px; margin:16px 0 28px; }
.battle-heading h2 { font-size:clamp(27px,4vw,42px); letter-spacing:-.04em; margin:8px 0; }
.battle-heading p { margin-bottom:0; }
.battle-lobby { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; margin-bottom:24px; }
.battle-lobby .panel > button { display:block; margin-top:14px; width:100%; }
.battle-friend-label { display:block; margin:24px 0 8px; font-size:13px; }
.battle-friends { display:flex; flex-wrap:wrap; gap:10px; }
.battle-friend { display:flex; flex-direction:column; align-items:center; gap:6px; flex:0 1 104px; min-width:0; padding:12px 8px; border:1px solid var(--line); border-radius:12px; background:var(--bg); text-align:center; }
.battle-friend .avatar { width:40px; height:40px; font-size:16px; }
.battle-friend strong { font-size:12px; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.battle-friend button { width:100%; padding:6px 8px; font-size:12px; }
.battle-online { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); }
.battle-online span { width:8px; height:8px; border-radius:50%; background:var(--accent); }
.battle-queue { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:14px; padding:12px 14px; border:1px solid var(--accent); border-radius:10px; }
.battle-queue div { display:flex; flex-direction:column; gap:2px; }
.battle-queue span { font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.battle-queue-hint { margin:8px 0 0; font-size:12px; color:var(--muted); }
.battle-queue-hint .link-button { font-size:12px; min-height:44px; }
/* Found quick match: big countdown, an orange bar that empties in 30 s, two large choices. */
dialog.quick-found-dialog { width:min(420px,calc(100vw - 32px)); text-align:center; border-top:4px solid var(--accent); }
.quick-found-dialog h2 { padding:0; margin:4px 0 6px; font-size:28px; }
.quick-found-dialog > p { margin:0; color:var(--muted); }
.quick-found-dialog .eyebrow { color:var(--accent-ink); }
.quick-found-timer { display:flex; justify-content:center; align-items:baseline; gap:4px; margin:20px 0 10px; font-variant-numeric:tabular-nums; }
.quick-found-timer strong { font-size:56px; line-height:1; }
.quick-found-timer span { color:var(--muted); font-weight:650; }
.quick-found-bar { height:6px; border-radius:3px; overflow:hidden; background:var(--line); }
.quick-found-bar i { display:block; height:100%; background:var(--accent); transform-origin:left; transition:transform .25s linear; }
.quick-found-actions { display:grid; grid-template-columns:2fr 1fr; gap:10px; margin-top:20px; }
.quick-found-actions button { min-height:52px; font-size:16px; }
.quick-found-dialog .quick-found-wait { margin-top:20px; color:var(--ink); font-weight:650; }
@media (prefers-reduced-motion:no-preference) {
  .quick-found-dialog[open] { animation:quick-found-in .25s ease-out; }
  @keyframes quick-found-in { from { transform:scale(.94); opacity:0; } }
}
@media (prefers-reduced-motion:reduce) { .quick-found-bar i { transition:none; } }
.battle-history,.battle-log { margin-top:24px; border-top:1px solid var(--line); padding-top:16px; }
.battle-leaderboard { margin-bottom:24px; min-width:0; }
.battle-leaderboard-scroll { max-height:540px; overflow:auto; scrollbar-color:var(--muted) var(--panel); }
.battle-leaderboard table { width:100%; border-collapse:collapse; font-size:14px; font-variant-numeric:tabular-nums; }
.battle-leaderboard th,.battle-leaderboard td { padding:12px; border-bottom:1px solid var(--line); text-align:right; }
.battle-leaderboard th:nth-child(2) { text-align:left; }
.battle-leaderboard thead th { position:sticky; top:0; z-index:1; background:var(--panel); color:var(--muted); font-size:12px; }
.battle-leaderboard .battle-leaderboard-rank { width:56px; color:var(--muted); }
.battle-leaderboard tbody tr:nth-child(-n+3) .battle-leaderboard-rank { color:var(--accent-ink); font-weight:700; }
.battle-leaderboard-player { display:flex; align-items:center; gap:12px; min-height:44px; width:fit-content; max-width:100%; color:var(--ink); text-decoration:none; }
.battle-leaderboard-player:hover { text-decoration:underline; }
.battle-leaderboard-player .avatar { flex-shrink:0; }
.battle-leaderboard-player > span:last-child { overflow-wrap:anywhere; }
.battle-leaderboard-player small { display:block; color:var(--accent-ink); font-size:12px; }
.battle-leaderboard-self { background:color-mix(in srgb,var(--accent) 10%,var(--panel)); }
@media(max-width:600px) {
 .battle-leaderboard { padding:16px 14px; }
 .battle-leaderboard .battle-leaderboard-rank { width:28px; }
 .battle-leaderboard th,.battle-leaderboard td { padding:10px 4px; }
 .battle-leaderboard table { font-size:12px; }
 .battle-leaderboard-player { gap:6px; }
 .battle-leaderboard-player .avatar { display:none; }
}
.battle-root summary { cursor:pointer; padding:12px 0; font-weight:600; }
.battle-deck-head { display:flex; align-items:end; flex-wrap:wrap; gap:16px; margin-bottom:20px; }
.battle-deck-head label { flex:1 1 250px; font-size:13px; }
.battle-deck-head select { display:block; width:100%; margin-top:8px; }
#deck-count { font-size:13px; padding-bottom:14px; }
.battle-deck-filters { display:flex; gap:12px; margin-bottom:14px; }
.battle-deck-filters input { flex:1; min-width:0; }
.battle-deck-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:20px; }
.deck-item { min-width:0; }
.deck-item .battle-card { width:100%; }
.deck-quantity { display:flex; align-items:center; justify-content:space-between; gap:6px; padding-top:8px; }
.deck-quantity span { font-size:12px; font-variant-numeric:tabular-nums; }
.deck-quantity button { min-width:36px; padding:8px; }
.battle-top { display:flex; justify-content:space-between; flex-wrap:wrap; gap:12px; padding:14px 18px; border-radius:12px 12px 0 0; background:var(--ink); color:var(--bg); font-size:12px; }
#battle-clock { font-variant-numeric:tabular-nums; font-weight:700; }
.playmat { border:1px solid var(--line); border-radius:0 0 16px 16px; overflow:hidden; background:linear-gradient(90deg,transparent 23px,color-mix(in srgb,var(--line) 22%,transparent) 24px),linear-gradient(transparent 23px,color-mix(in srgb,var(--line) 22%,transparent) 24px),var(--panel); background-size:24px 24px; }
.playmat-row { display:grid; grid-template-columns:140px minmax(0,1fr) 140px; gap:20px; padding:20px; }
.playmat-hero { display:flex; flex-direction:column; align-items:center; gap:12px; }
.battle-player { display:flex; align-items:center; gap:8px; width:100%; }
.battle-player strong { font-size:12px; overflow-wrap:anywhere; }
.battle-player .avatar { flex-shrink:0; width:28px; height:28px; font-size:13px; }
.battle-discard { font-size:10px; width:100%; padding:10px 4px; border-style:dashed; background:var(--panel); }
.battle-deck-chip { display:block; box-sizing:border-box; width:100%; margin-bottom:-6px; padding:10px 4px; border:1px dashed var(--line); border-radius:9px; background:var(--panel); color:var(--ink); font-size:10px; font-weight:650; text-align:center; }
.playmat-network { min-width:0; }
.battle-zone-title { display:flex; justify-content:space-between; gap:10px; font-size:10px; letter-spacing:.08em; color:var(--muted); margin:0 0 10px; }
.battle-zone-title span { letter-spacing:0; font-size:10px; text-align:right; }
.battle-stops,.battle-communes { display:flex; align-items:center; gap:10px; overflow-x:auto; padding:4px 3px 12px; min-height:70px; }
.battle-stops { min-height:155px; }
.zone-empty { font-size:12px; color:var(--muted); padding:20px; border:1px dashed var(--line); border-radius:10px; width:100%; text-align:center; }
.playmat-score { display:flex; flex-direction:column; justify-content:center; align-items:flex-end; gap:8px; border-left:1px solid var(--line); padding-left:12px; min-width:0; }
.playmat-score > span { font-size:9px; letter-spacing:.1em; color:var(--muted); }
.playmat-score > strong { font-size:clamp(17px,2.1vw,30px); letter-spacing:-.04em; overflow-wrap:anywhere; }
.playmat-score > small { font-size:10px; color:var(--muted); }
.friendly .playmat-score > strong { color:var(--accent-ink); }
.battle-center { padding:16px 20px; border-block:1px solid var(--line); background:var(--bg); display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; }
.battle-center p { font-size:12px; margin:8px 0; }
.battle-center h3 { margin:0; }
.battle-center .row-actions { flex-wrap:wrap; }
#counter-total { font-size:12px; width:100%; }
.battle-stack { font-size:11px; margin:8px 0 0; padding-left:20px; }
.battle-card.chosen { outline:3px solid var(--accent); outline-offset:1px; }
.battle-hand-zone { margin-top:20px; }
.battle-hand { display:flex; align-items:start; gap:14px; overflow-x:auto; padding:8px 3px 16px; }
.battle-hand small { display:block; margin-top:8px; color:var(--muted); font-size:10px; }
.battle-hand [data-battle=play] { box-shadow:0 0 0 2px var(--accent); }
.battle-log ol { font-size:12px; line-height:1.8; }
.battle-rules { font-size:13px; line-height:1.6; padding-left:20px; }
.battle-rules li { margin-bottom:12px; }
.battle-rules-goal { font-size:15px; }
.battle-rules-short { font-size:14px; }
.battle-rules-details { border-top:1px solid var(--line); margin-top:8px; }
.battle-rules-details summary { min-height:44px; color:var(--accent-ink); }
#battle-dialog { max-width:650px; }
@media(max-width:900px) { .playmat-row { grid-template-columns:105px minmax(0,1fr) 95px; gap:12px; padding:14px; } .playmat-score strong { font-size:19px; } }
@media(max-width:600px) {
 .battle-heading { align-items:start; flex-direction:column; }
 .battle-lobby { grid-template-columns:1fr; }
 .playmat-row { grid-template-columns:84px minmax(0,1fr); gap:12px; padding:12px; }
 .playmat-score { grid-column:1/-1; border-left:0; border-top:1px solid var(--line); padding:10px 0 0; flex-direction:row; justify-content:space-between; align-items:center; }
 .playmat-score strong { font-size:24px; }
 .battle-stops { min-height:125px; }
 .battle-player { flex-direction:column; gap:4px; text-align:center; }
 .battle-zone-title { flex-wrap:wrap; }
 .battle-center { padding:14px; }
 .battle-deck-filters { flex-wrap:wrap; }
 .battle-deck-filters select { max-width:100%; }
 .battle-top { font-size:11px; }
}

body.in-battle .rules, body.in-battle footer { display:none; }
body.in-battle .battle-heading { margin:8px 0 18px; }
@media(max-width:600px) {
 body.in-battle .battle-heading { flex-direction:row; align-items:center; gap:8px; }
 body.in-battle .battle-heading h2 { font-size:24px; }
 body.in-battle .battle-heading .eyebrow { font-size:8px; }
 body.in-battle .battle-heading .row-actions { flex-direction:column; }
 body.in-battle .battle-heading button { padding:8px; font-size:11px; }
 .zone-empty { padding:10px; font-size:10px; }
 .battle-communes { min-height:50px; }
}

.battle-layout { display:grid; grid-template-columns:minmax(0,1fr) 250px; gap:20px; align-items:start; }
.battle-main { min-width:0; }
.battle-layout .battle-log { margin:0; padding:18px; border:1px solid var(--line); border-radius:14px; position:sticky; top:20px; }
.battle-log h3 { margin:0 0 16px; font-size:16px; }
.battle-log ol { max-height:65vh; overflow-y:auto; padding:0; list-style:none; overflow-wrap:anywhere; }
.battle-log li { padding:10px 0; border-bottom:1px solid var(--line); }
.battle-log small { color:var(--muted); }
@media(max-width:1000px) { .battle-layout {grid-template-columns:1fr;} .battle-layout .battle-log {position:static;} .battle-log ol {max-height:220px;} }

.turn-banner { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; padding:14px 18px; background:var(--panel); border-inline:1px solid var(--line); border-left:4px solid var(--line); }
.turn-banner strong { font-size:16px; }
.turn-banner span { font-size:11px; color:var(--muted); }
.turn-banner.your-turn { border-left-color:var(--accent); background:color-mix(in srgb,var(--accent) 10%,var(--bg)); }
.playmat-row.active-player { box-shadow:inset 4px 0 var(--accent); }
.playmat-row.active-player .battle-player strong { color:var(--accent-ink); }
.turn-budget { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.action-budget { padding:6px 9px; border:1px solid var(--accent); border-radius:6px; font-size:11px; }
.action-budget.spent { border-color:var(--line); color:var(--muted); }
.contested-card { display:flex; flex-direction:column; align-items:center; gap:10px; flex:0 0 150px; margin:auto; }
.contested-card .eyebrow { font-size:9px; margin:0; }
.contested-card small { font-size:10px; text-align:center; max-width:150px; overflow-wrap:anywhere; }
.reaction-details { flex:1 1 230px; min-width:0; }
.reaction-details h3 { color:var(--accent-ink); }
.reaction-outcome { padding:10px; background:color-mix(in srgb,var(--accent) 9%,var(--bg)); border-left:3px solid var(--accent); }
.waiting-message { color:var(--muted); font-size:12px; }
.battle-center .battle-stack:empty { display:none; }
.battle-center .row-actions button { white-space:normal; }
@media(max-width:600px) {
 .turn-banner { padding:12px; flex-direction:column; align-items:flex-start; }
 .contested-card { flex-basis:100%; }
 .reaction-details { flex-basis:100%; }
 .reaction-details .row-actions { flex-direction:column; align-items:stretch; }
}

.battle-last-action { margin:12px 0 0; padding:10px 14px; border-left:3px solid var(--accent); font-size:12px; background:var(--panel); min-height:36px; }
.battle-last-action:empty { display:none; }
.reaction-choices { max-width:100%; padding-block:6px 12px; }

@media(max-width:600px) {
 .playmat.reacting .playmat-row { grid-template-columns:66px minmax(0,1fr); padding:10px; gap:10px; }
 .playmat.reacting .battle-stops { min-height:0; }
 .playmat.reacting .battle-stops .zone-empty { margin:0; padding:8px; }
 .playmat.reacting .battle-zone-title { margin-bottom:4px; }
 .playmat.reacting .playmat-hero { gap:7px; }
 .playmat.reacting .playmat-score { padding-top:6px; }
}

/* Deck builder: browse on the left, assemble on the right. */
.deck-workspace { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:24px; align-items:start; }
.deck-collection,.deck-sidebar { min-width:0; border:1px solid var(--line); border-radius:16px; background:var(--panel); }
.deck-collection > header { padding:20px 20px 0; }
.deck-collection h3,.deck-sidebar h3 { margin:0 0 8px; }
.deck-collection header p { font-size:12px; color:var(--muted); }
.deck-filter-grid { padding:8px 20px 16px; display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.deck-filter-grid input { grid-column:1/-1; }
.deck-filter-grid select,.deck-filter-grid input { min-width:0; width:100%; font-size:12px; }
.deck-filter-grid #battle-sort { grid-column:1/-1; }
.deck-collection-scroll { max-height:65vh; overflow-y:auto; overscroll-behavior:contain; padding:0 20px 20px; scrollbar-gutter:stable; }
.deck-family h4 { display:flex; align-items:baseline; justify-content:space-between; flex-wrap:wrap; gap:8px; margin:20px 0 12px; padding-bottom:8px; border-bottom:1px solid var(--line); font-size:14px; }
.deck-family h4 span { font-size:10px; font-weight:400; color:var(--muted); }
.deck-collection-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(125px,1fr)); gap:20px 14px; }
.deck-stock { display:block; font-size:10px; color:var(--muted); margin:8px 0; }
.deck-add { width:100%; padding:8px; font-size:12px; }
.deck-sidebar { position:sticky; top:16px; padding:18px; }
.deck-sidebar-head { display:flex; flex-direction:column; gap:12px; }
.deck-sidebar-head #deck-count { padding:0; font-size:12px; }
.deck-sidebar-head > button { width:100%; }
.deck-hero-visual { display:flex; align-items:center; gap:14px; padding:18px 0; border-bottom:1px solid var(--line); margin-bottom:12px; }
.deck-hero-visual > .battle-card { width:85px; }
.deck-hero-visual > div { min-width:0; }
.deck-hero-visual .eyebrow { font-size:9px; margin:0 0 8px; }
.deck-hero-visual strong { font-size:16px; }
.deck-hero-visual p,.deck-hero-visual small { font-size:11px; }
.deck-hero-visual small { display:block; color:var(--muted); margin-top:8px; }
.deck-hero-visual button:not(.battle-card) { font-size:11px; padding:8px; }
.deck-generator { width:100%; font-size:11px; padding:10px; }
.deck-selected { max-height:48vh; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; padding-right:4px; }
.deck-row { border-bottom:1px solid var(--line); padding:10px 0; }
.deck-row-name { display:flex; align-items:center; gap:8px; width:100%; border:0; background:transparent; padding:0; text-align:left; font-size:12px; }
.deck-row-name > span:nth-child(2) { flex:1; min-width:0; overflow-wrap:anywhere; }
.deck-row-name small { display:block; font-size:9px; font-weight:400; color:var(--muted); margin-top:3px; }
.deck-row-name strong { font-size:12px; font-variant-numeric:tabular-nums; white-space:nowrap; margin-left:auto; }
.deck-mini { display:grid; place-items:center; flex:0 0 26px; height:36px; border:1px solid var(--common-tone); color:var(--common-tone); border-radius:4px; font-size:17px; }
.deck-mini.inhabituel { color:var(--unusual-tone); border-color:currentColor; }
.deck-mini.rare { color:var(--rare-tone); border-color:currentColor; }
.deck-mini.epique { color:var(--epic-tone); border-color:currentColor; }
.deck-mini.legendaire { color:var(--legend-tone); border-color:currentColor; }
.deck-row-controls { display:flex; justify-content:space-between; align-items:center; margin-top:8px; }
.deck-trash { display:grid; place-items:center; padding:8px; min-width:34px; }
.deck-stepper { display:flex; align-items:center; gap:10px; }
.deck-stepper button { min-width:34px; min-height:34px; padding:5px; }
.deck-stepper span { min-width:16px; font-size:12px; text-align:center; font-variant-numeric:tabular-nums; }
.deck-empty { font-size:12px; color:var(--muted); padding:8px 0; }
.hero-options { display:grid; grid-template-columns:repeat(auto-fill,minmax(100px,1fr)); gap:18px; padding:8px 4px; max-height:65vh; overflow-y:auto; }
.hero-options .battle-card { width:100%; }
.hero-options small { display:block; text-align:center; font-size:11px; margin-top:8px; }
.deck-hover { position:fixed; width:230px; max-width:calc(100vw - 16px); z-index:100; pointer-events:none; filter:drop-shadow(0 12px 24px #0005); }
.deck-hover[hidden] { display:none; }
@media(max-width:900px) { .deck-workspace { grid-template-columns:minmax(0,1fr) 300px; gap:14px; } .deck-collection > header { padding:14px 14px 0; } .deck-filter-grid { padding:8px 14px 12px; } .deck-collection-scroll {padding:0 14px 14px;} }
@media(max-width:700px) {
 .deck-workspace {grid-template-columns:1fr;}
 .deck-sidebar {position:static;}
 .deck-collection-scroll {max-height:55vh;}
 .deck-selected {max-height:55vh;}
 .deck-stepper button,.deck-trash {min-width:44px;min-height:44px;}
 .deck-hover {display:none;}
}

.challenge-expiry {display:block;margin-top:5px;color:var(--muted);font-size:12px;font-variant-numeric:tabular-nums;}

/* In-match chat (friend matches). */
.battle-side { display:flex; flex-direction:column; gap:16px; min-width:0; position:sticky; top:20px; }
.battle-layout .battle-side .battle-log { position:static; }
.battle-side .battle-log ol { max-height:35vh; }
.battle-chat { border:1px solid var(--line); border-radius:14px; background:var(--panel); overflow:hidden; }
.battle-chat-toggle { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; min-height:44px; padding:10px 16px; border:0; border-radius:0; background:transparent; color:var(--ink); font-weight:600; text-align:left; }
.battle-chat-toggle::after { content:'▾'; margin-left:auto; color:var(--muted); }
.battle-chat-toggle[aria-expanded="false"]::after { content:'▸'; }
.battle-chat-badge { min-width:22px; padding:2px 7px; border-radius:11px; background:var(--accent); color:var(--bg); font-size:11px; text-align:center; font-variant-numeric:tabular-nums; }
.battle-chat-badge[hidden],.battle-chat-body[hidden] { display:none; }
.battle-chat-list { list-style:none; margin:0; padding:8px 12px; height:180px; overflow-y:auto; overscroll-behavior:contain; border-top:1px solid var(--line); font-size:12px; line-height:1.4; overflow-wrap:anywhere; }
.battle-chat-list:empty::before { content:'Aucun message. Dis bonjour !'; color:var(--muted); }
.battle-chat-list li { margin:6px 0; padding:6px 9px; border-radius:10px; background:var(--bg); max-width:88%; width:fit-content; }
.battle-chat-list li b { display:block; font-size:10px; color:var(--muted); }
.battle-chat-list li.mine { margin-left:auto; background:color-mix(in srgb,var(--accent) 14%,var(--bg)); }
.battle-chat-list li.mine b { color:var(--accent-ink); text-align:right; }
.battle-chat-form { display:flex; gap:6px; padding:8px; border-top:1px solid var(--line); }
.battle-chat-form input { flex:1; min-width:0; min-height:44px; font-size:16px; }
.battle-chat-form button { min-height:44px; padding:8px 12px; }
@media(max-width:1000px) { .battle-side { position:static; } .battle-side .battle-log ol { max-height:220px; } }

.tutorial-coach { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; padding:14px 18px; border-inline:1px solid var(--line); border-left:4px solid var(--accent); background:color-mix(in srgb,var(--accent) 14%,var(--panel)); }
.tutorial-coach .eyebrow { flex-basis:100%; margin:0; }
.tutorial-coach p:not(.eyebrow) { flex:1 1 320px; margin:0; font-size:14px; line-height:1.45; }
.tutorial-target { outline:3px solid var(--accent); outline-offset:3px; animation:tutorial-pulse 1.4s ease-in-out infinite; }
.tutorial-highlight { animation:tutorial-pulse 1.8s ease-in-out infinite; }
@keyframes tutorial-pulse { 0%,100% { box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 55%,transparent); } 50% { box-shadow:0 0 0 8px color-mix(in srgb,var(--accent) 0%,transparent); } }
@media(prefers-reduced-motion:reduce) { .tutorial-target,.tutorial-highlight { animation:none; } }

/* Deck manager: selected deck as a CSS 3D deck box, hero line on the front face. */
.deck-manager { display:grid; grid-template-columns:230px minmax(0,1fr); gap:28px; align-items:center; margin-bottom:24px; }
.deckbox-stage { --box-w:148px; --box-h:212px; --box-d:52px; position:relative; display:grid; place-items:center; height:290px; perspective:900px; }
.deckbox { position:relative; width:var(--box-w); height:var(--box-h); transform-style:preserve-3d; transform:rotateX(-12deg) rotateY(-32deg); transition:transform .6s cubic-bezier(.2,.7,.2,1); }
.deck-manager:hover .deckbox,.deck-manager:focus-within .deckbox { transform:rotateX(-8deg) rotateY(-14deg) translateY(-6px); }
.deckbox-face { position:absolute; left:50%; top:50%; box-sizing:border-box; border-radius:5px; backface-visibility:hidden; }
.deckbox-front,.deckbox-back { width:var(--box-w); height:var(--box-h); margin:calc(var(--box-h) / -2) 0 0 calc(var(--box-w) / -2); }
.deckbox-front { transform:translateZ(calc(var(--box-d) / 2)); display:grid; place-items:center; padding:9px; background:linear-gradient(160deg,#e3672a,var(--card-brand-orange) 55%,#a63d10); box-shadow:inset 0 0 0 1px rgb(255 255 255 / .18); }
.deckbox-front .battle-card { width:100%; pointer-events:none; box-shadow:0 3px 12px rgb(0 0 0 / .35); }
.deckbox-front .battle-card:hover { transform:none; }
.deckbox-empty { color:#fff; font-size:48px; font-weight:800; }
.deckbox-back { transform:rotateY(180deg) translateZ(calc(var(--box-d) / 2)); background:#8a330c; }
.deckbox-left,.deckbox-right { width:var(--box-d); height:var(--box-h); margin:calc(var(--box-h) / -2) 0 0 calc(var(--box-d) / -2); background:linear-gradient(90deg,#953810,#a83f12); }
.deckbox-right { transform:rotateY(90deg) translateZ(calc(var(--box-w) / 2)); display:grid; place-items:center; overflow:hidden; }
.deckbox-left { transform:rotateY(-90deg) translateZ(calc(var(--box-w) / 2)); }
.deckbox-right span { writing-mode:vertical-rl; transform:rotate(180deg); max-height:88%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#fff; font-size:12px; font-weight:800; }
.deckbox-top { width:var(--box-w); height:var(--box-d); margin:calc(var(--box-d) / -2) 0 0 calc(var(--box-w) / -2); transform:rotateX(90deg) translateZ(calc(var(--box-h) / 2)); display:grid; place-items:center; background:linear-gradient(#d9601f,#c64c16); }
.deckbox-top span { color:#fff; font-size:10px; font-weight:800; letter-spacing:.14em; }
.deckbox-shadow { position:absolute; bottom:18px; left:50%; width:180px; height:24px; margin-left:-90px; border-radius:50%; background:radial-gradient(closest-side,rgb(0 0 0 / .3),transparent); pointer-events:none; }
.deck-manager-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:16px; }
.deck-manager-head > div { min-width:0; }
.deck-manager-head h3 { margin:6px 0; font-size:clamp(20px,2.4vw,26px); letter-spacing:-.02em; overflow-wrap:anywhere; }
.deck-manager-head p { margin:0; font-size:13px; }
.deck-manager-head > button { flex-shrink:0; }
.deck-choices { display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:10px; max-height:310px; margin:0; padding:2px; overflow-y:auto; list-style:none; }
.deck-choice { display:flex; min-width:0; border:1px solid var(--line); border-radius:12px; background:var(--bg); overflow:hidden; }
.deck-choice.active { border-color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent); }
.deck-choice-main { display:flex; flex:1; align-items:center; gap:10px; min-width:0; min-height:58px; padding:10px 12px; border:0; border-radius:0; background:transparent; color:var(--ink); text-align:left; }
.deck-choice-main:hover { background:var(--hover); }
.deck-choice-icon { display:grid; place-items:center; flex:0 0 28px; height:38px; border-radius:4px; background:var(--card-brand-orange); color:#fff; font-size:14px; box-shadow:3px 0 0 #953810; }
.deck-choice-text { flex:1; min-width:0; }
.deck-choice-text strong,.deck-choice-text small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.deck-choice-text strong { font-size:14px; }
.deck-choice-text small { margin-top:3px; font-size:11px; font-weight:400; color:var(--muted); }
.deck-choice-text small b { color:var(--accent-ink); }
.deck-choice-actions { display:flex; border-left:1px solid var(--line); }
.deck-choice-actions button { min-width:44px; min-height:44px; padding:6px 10px; border:0; border-radius:0; font-size:12px; }
.deck-choice-actions button + button { border-left:1px solid var(--line); }
.deck-sidebar-head label { display:block; margin:0 0 6px; }
.deck-sidebar-head input { width:100%; margin-bottom:8px; }
@media(max-width:700px) {
  .deck-manager { grid-template-columns:1fr; gap:8px; }
  .deckbox-stage { --box-w:124px; --box-h:178px; --box-d:44px; height:240px; }
  .deck-manager-head { flex-direction:column; }
  .deck-manager-head > button { width:100%; }
}
@media(prefers-reduced-motion:reduce) { .deckbox { transition:none; } .deck-manager:hover .deckbox,.deck-manager:focus-within .deckbox { transform:rotateX(-12deg) rotateY(-32deg); } }

/* Board v2: fits one laptop screen. Compact bar, zones side by side, control column with an LED timer. */
body.in-battle main { max-width:1680px; padding-inline:24px; }
body.in-battle .battle-bar { margin:6px 0 10px; }
.battle-bar h2 { font-size:22px; margin:2px 0 0; }
.battle-bar .eyebrow { margin:0; }
.battle-bar .row-actions button { padding:8px 12px; font-size:12px; }
.battle-layout { grid-template-columns:minmax(0,1fr) 260px; gap:16px; }
.battle-layout .battle-log { top:8px; }
.playmat { border-radius:16px; }
.playmat-row { grid-template-columns:auto minmax(0,1fr) minmax(0,1fr); gap:14px; padding:12px 14px; align-items:start; }
.playmat-hero { flex-direction:row; align-items:flex-start; gap:10px; }
.playmat-side { display:flex; flex-direction:column; gap:5px; width:94px; min-width:0; }
.playmat-side .battle-player { gap:6px; }
.playmat-side .battle-player .avatar { width:22px; height:22px; font-size:11px; }
.playmat-side .battle-player strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.playmat-side .battle-deck-chip,.playmat-side .battle-discard { margin:0; padding:6px 4px; }
.playmat-side .playmat-score { align-items:flex-start; gap:0; padding:0; border:0; }
.playmat-side .playmat-score > strong { font-size:22px; line-height:1.1; }
.playmat-zone { min-width:0; border-radius:12px; transition:background .15s,box-shadow .15s; }
.playmat-zone .battle-zone-title { margin-bottom:6px; }
.battle-stops,.battle-communes { min-height:0; gap:8px; padding:2px 2px 6px; }
.playmat-zone .zone-empty { padding:12px 8px; }
.playmat-zone.drop-ok { box-shadow:inset 0 0 0 2px var(--accent); background:color-mix(in srgb,var(--accent) 8%,transparent); }
.playmat-zone.drop-over { background:color-mix(in srgb,var(--accent) 18%,transparent); }
.battle-center { display:grid; grid-template-columns:minmax(0,1fr) 200px; align-items:center; gap:16px; padding:12px 16px; }
.battle-center.your-turn { background:color-mix(in srgb,var(--accent) 6%,var(--bg)); }
.playmat.reacting .battle-center { grid-template-columns:auto minmax(0,1fr) 200px; }
.battle-center-main { min-width:0; }
.battle-center-main h3 { font-size:18px; }
.battle-center .turn-budget { margin:8px 0; }
.battle-center p.battle-last-action { margin:6px 0 0; padding:2px 0 2px 10px; min-height:0; background:none; font-size:11px; color:var(--muted); }
.contested-card { flex:none; margin:0; }
.reaction-details h3 { font-size:16px; }
.reaction-details p { margin:4px 0; }
.battle-control { display:flex; flex-direction:column; align-items:stretch; gap:8px; align-self:stretch; justify-content:center; }
.battle-round { display:flex; justify-content:space-between; align-items:baseline; gap:8px; margin:0; font-size:13px; }
.battle-round b { font-size:20px; letter-spacing:-.02em; }
.battle-round span { font-size:11px; color:var(--muted); }
.battle-control > button { width:100%; min-height:44px; }
.battle-control .waiting-message { text-align:center; padding:12px 0; }
@keyframes led-blink { 50% { opacity:.35; } }
.battle-hand-zone { margin-top:10px; }
.battle-hand { gap:12px; padding:6px 3px 10px; }
.battle-hand small { margin-top:5px; }
@media(max-width:1000px) {
  .playmat-row { grid-template-columns:auto minmax(0,1fr); }
  .playmat-row .playmat-zone:last-child { grid-column:2; }
}
@media(max-width:700px) {
  body.in-battle main { padding-inline:14px; }
  .playmat-row { grid-template-columns:1fr; gap:10px; padding:10px; }
  .playmat-row .playmat-zone:last-child { grid-column:auto; }
  .playmat-side { width:auto; flex:1; }
  .battle-center,.playmat.reacting .battle-center { grid-template-columns:1fr; }
  .battle-control { flex-direction:row; flex-wrap:wrap; align-items:center; }
  .battle-round { flex-direction:column; gap:0; }
  .battle-control > button,.battle-control .waiting-message { flex:1; }
}
.playmat-chips { display:flex; gap:5px; }
.playmat-chips > * { flex:1; min-width:0; }
.playmat-side .playmat-score > span { font-size:8px; }
.battle-center { padding-block:10px; }
/* End-of-match recap, shared by both players, chat on the side. */
.battle-result { padding:24px; text-align:center; }
.battle-result.win { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 7%,var(--panel)); }
.battle-result-reason { margin:0 0 20px; color:var(--muted); }
.battle-result-players { display:flex; align-items:center; justify-content:center; gap:20px; flex-wrap:wrap; }
.battle-result-player { position:relative; display:flex; flex-direction:column; align-items:center; gap:6px; min-width:150px; padding:18px 16px 14px; border:1px solid var(--line); border-radius:14px; background:var(--bg); }
.battle-result-player.winner { border:2px solid var(--accent); }
.battle-result-player .avatar { width:44px; height:44px; font-size:18px; }
.battle-result-player strong small { color:var(--muted); font-weight:400; }
.battle-result-score { display:flex; flex-direction:column; font-size:30px; font-weight:800; letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.battle-result-score small { font-size:10px; font-weight:400; letter-spacing:.08em; color:var(--muted); text-transform:uppercase; }
.battle-result-badge { position:absolute; top:-11px; padding:2px 10px; border-radius:999px; background:var(--accent); color:var(--on-accent); font-size:11px; font-weight:700; }
.battle-result-versus { font-size:13px; font-weight:700; color:var(--muted); text-transform:uppercase; }
.battle-result-rewards { margin:22px 0 6px; font-size:15px; }
.battle-history .friend-row > button { flex:none; min-height:44px; padding:8px 14px; font-size:12px; }
/* Motion: dragged and ejected cards live in a fixed ghost above the page. */
.card-ghost { position:fixed; z-index:60; pointer-events:none; }
.card-ghost.dragging { cursor:grabbing; }
.card-ghost-stamp { position:absolute; top:42%; left:50%; padding:4px 10px; border:3px solid #d1281a; border-radius:6px; background:rgb(255 255 255 / .9); color:#d1281a; font-size:14px; font-weight:900; text-transform:uppercase; letter-spacing:.04em; transform:translate(-50%,-50%) rotate(-14deg); white-space:nowrap; }
.battle-hand .draggable-card { cursor:grab; }
.battle-hand .drag-source { opacity:.3; }
/* The contested stop hovers above the board, waiting to know where it lands. */
@keyframes contested-float { 0%,100% { transform:translateY(0) rotate(-1deg); box-shadow:0 10px 18px rgb(0 0 0 / .18); } 50% { transform:translateY(-9px) rotate(1deg); box-shadow:0 22px 28px rgb(0 0 0 / .14); } }
@media(prefers-reduced-motion:reduce) { .contested-card .battle-card { animation:none; } }
.playmat-chips > * { white-space:nowrap; padding-inline:2px; }
.sr-only { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.battle-match-clock { margin:0; text-align:center; font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
/* Bonus links drawn on hover, from the card to what boosts it. */
.card-links { position:fixed; inset:0; width:100vw; height:100vh; z-index:55; pointer-events:none; overflow:visible; }
.card-links path { fill:none; stroke:var(--accent); stroke-width:2.5; stroke-dasharray:6 5; stroke-linecap:round; }
.card-links circle { fill:var(--accent); }
@media(prefers-reduced-motion:no-preference) { .card-links path { animation:link-dash 1s linear infinite; } }
@keyframes link-dash { to { stroke-dashoffset:-11; } }

/* Board v3: one card face everywhere (card.js), bigger cards, control panel on the left of the center strip. */
.battle-root { --hero-card:clamp(84px,min(7.6vw,14vh),140px); --zone-card:clamp(80px,min(7.2vw,13.5vh),132px); --hand-card:clamp(88px,min(7.6vw,14vh),136px); }
.battle-card { flex:none; width:var(--zone-card); }
.battle-card:hover,.battle-card:focus-visible,.battle-card.linked { z-index:3; }
.battle-card.chosen { outline:3px solid var(--accent); outline-offset:2px; }
.battle-card.linked { outline:2px solid var(--accent); outline-offset:2px; }
.battle-card.tapped .tcg-face { opacity:.5; }
.battle-badges { position:absolute; z-index:3; top:14cqw; right:3cqw; display:flex; flex-direction:column; align-items:flex-end; gap:1.5cqw; }
.battle-reunited { padding:.6cqw 2.6cqw; border-radius:3cqw; background:var(--tone); color:var(--bg); font-size:7.5cqw; font-weight:750; font-variant-numeric:tabular-nums; }
.battle-tapped { position:absolute; z-index:3; top:44%; left:0; right:0; padding:2.5cqw 0; background:var(--ink); color:var(--bg); text-align:center; font-size:8cqw; font-weight:700; }
.playmat-hero > .battle-card,.deck-hero-visual > .battle-card { width:var(--hero-card); }
.deck-item .battle-card,.hero-options .battle-card,.deckbox-front .battle-card,.card-ghost .battle-card { width:100%; }
.card-ghost .battle-card { box-shadow:0 18px 34px rgb(0 0 0 / .3); }
.deck-hover .tcg-card { width:100%; }
/* Zones hold up to 5 cards; when they run out of room the cards overlap like a fanned row instead of shrinking. */
.battle-stops,.battle-communes { display:flex; align-items:flex-start; gap:0; overflow:visible; min-height:calc(var(--zone-card) * 88 / 63 + 8px); padding:2px 0 6px; }
.battle-stops > .battle-card + .battle-card,.battle-communes > .battle-card + .battle-card { margin-left:min(10px,calc((100% - var(--n,1) * var(--zone-card)) / max(1,var(--n,1) - 1))); }
.contested-card .battle-card { width:calc(var(--zone-card) + 16px); box-shadow:0 5px 20px color-mix(in srgb,var(--accent) 18%,transparent); animation:contested-float 1.8s ease-in-out infinite; }
.reaction-choices { min-height:0; flex-wrap:wrap; gap:10px; }
.reaction-choices > .battle-card + .battle-card { margin-left:0; }
.battle-hand > div { flex:none; width:var(--hand-card); }
.battle-hand .battle-card { width:100%; }
.battle-center { grid-template-columns:230px minmax(0,1fr); }
.playmat.reacting .battle-center { grid-template-columns:230px auto minmax(0,1fr); }
.battle-control { padding-right:16px; border-right:1px solid var(--line); }
/* Scoreboard: a full dot-matrix display (public/led.js). Unlit dots cover the whole width, like a TPG on-board screen. */
.led-panel { display:flex; flex-direction:column; gap:0; padding:7px 9px 4px; border:2px solid #3b3935; border-radius:8px; background:#121110; box-shadow:inset 0 2px 12px rgb(0 0 0 / .75); }
.led-row { width:100%; }
.led-text { display:block; width:100%; height:auto; }
.led-on { fill:#ffb21e; filter:drop-shadow(0 0 .35px rgb(255 168 20 / .9)); }
.led-off { fill:#34312d; }
#led-me .led-on { fill:#ffd23a; }
.led-clock .led-on { fill:#ff8a1e; }
.led-panel.urgent .led-clock .led-on { fill:#ff5a1f; }
.led-panel.urgent .led-clock .led-text { animation:led-blink 1s steps(2,jump-none) infinite; }
.led-panel.idle .led-clock .led-on { fill:#9c7a35; }
@keyframes led-blink { 50% { opacity:.35; } }
@media(prefers-reduced-motion:reduce) { .contested-card .battle-card,.led-panel.urgent .led-clock .led-text { animation:none; } }
@media(max-width:700px) {
  .battle-root { --hero-card:84px; --zone-card:80px; --hand-card:100px; }
  .battle-center,.playmat.reacting .battle-center { grid-template-columns:1fr; }
  .battle-control { padding:0 0 12px; border-right:0; border-bottom:1px solid var(--line); }
  .led-panel { flex:1 1 100%; }
}
.battle-center-main { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:20px; align-items:center; }
.battle-center-main > :not(.battle-turn-action) { grid-column:1; }
.battle-turn-action { grid-column:2; grid-row:1 / span 4; }
.battle-turn-action button { min-height:52px; padding-inline:24px; }
.battle-control { gap:6px; }
@media(max-width:700px) { .battle-center-main { grid-template-columns:1fr; } .battle-turn-action { grid-column:1; grid-row:auto; } .battle-turn-action button { width:100%; } }
@media(max-width:1000px) { .battle-layout { grid-template-columns:1fr; } .battle-layout .battle-log { position:static; } }

/* Keyword chips (kw() in battle-ui.js): one tone per mechanic, readable in both themes. */
:root { --kw-tour:#b94300; --kw-reaction:#1f5fbf; --kw-blocage:#a3470b; --kw-contre:#8a5a00; --kw-battue:#c0262d; --kw-renfort:#7a3fc4; --kw-territoire:#1d7a3d; --kw-reunis:#0b7285; }
@media (prefers-color-scheme: dark) { :root { --kw-tour:#ff9c58; --kw-reaction:#86b6ff; --kw-blocage:#ffab6e; --kw-contre:#f2c260; --kw-battue:#ff8a8f; --kw-renfort:#c9a6ff; --kw-territoire:#72d394; --kw-reunis:#62d0e0; } }
.kw { --tone-kw:var(--kw-tour); display:inline-block; padding:1px 9px; border:1px solid color-mix(in srgb,var(--tone-kw) 45%,transparent); border-radius:999px; background:color-mix(in srgb,var(--tone-kw) 14%,var(--bg)); color:var(--tone-kw); font-size:.88em; font-weight:750; line-height:1.5; white-space:nowrap; vertical-align:baseline; }
.kw-reaction { --tone-kw:var(--kw-reaction); } .kw-blocage { --tone-kw:var(--kw-blocage); } .kw-contre { --tone-kw:var(--kw-contre); } .kw-battue { --tone-kw:var(--kw-battue); }
.kw-renfort { --tone-kw:var(--kw-renfort); } .kw-territoire { --tone-kw:var(--kw-territoire); } .kw-reunis { --tone-kw:var(--kw-reunis); }
/* "Comment jouer": one tinted row per idea, the chip as its title. */
.rules-steps { display:grid; gap:8px; margin:14px 0; padding:0; list-style:none; }
.rules-step { display:grid; grid-template-columns:150px minmax(0,1fr); align-items:start; gap:4px 14px; padding:10px 12px; border-left:4px solid var(--tone-kw); border-radius:10px; background:color-mix(in srgb,var(--tone-kw) 7%,var(--panel)); }
.rules-step > .kw, .rules-step > span { justify-self:start; }
.rules-step > span { display:flex; flex-wrap:wrap; gap:4px; }
.rules-step p { margin:0; font-size:14px; line-height:1.45; }
@media(max-width:600px) { .rules-step { grid-template-columns:1fr; } }

/* Cards lift on hover (x1.2, like picking a card up), and keep the collection's holo tilt (card-effects.js). */
.battle-card { transition:scale .18s ease-out,filter .18s ease-out,opacity .18s ease-out,box-shadow .18s ease-out; }
@media(hover:hover) { :is(.playmat,.battle-hand) .battle-card:hover { scale:1.2; z-index:4; box-shadow:0 16px 28px -14px rgb(0 0 0 / .45); } }
.friendly .battle-card,.friendly .playmat-hero > .battle-card { transform-origin:center bottom; }
.rival .battle-card { transform-origin:center top; }
.playmat-hero > .battle-card { transform-origin:left center; }
.battle-hand .battle-card { transform-origin:center bottom; }
/* The hand scrolls sideways: give lifted cards room above without growing the layout. */
@media(hover:hover) { .battle-hand { pointer-events:none; padding-top:calc(var(--hand-card) * 88 / 63 * .2 + 52px); margin-top:calc(var(--hand-card) * 88 / 63 * -.2 - 46px); padding-inline:calc(var(--hand-card) * .1 + 3px); } .battle-hand > div { pointer-events:auto; } }
/* Not playable right now: black and white. */
.battle-card.unusable { filter:grayscale(1); opacity:.6; }
@media(hover:hover) { .battle-card.unusable:hover { opacity:.85; } }
/* Reacting: what you can engage grows in place, the rest turns grey; the centre stays the same size. */
.picking .battle-card.usable { scale:1.2; z-index:3; box-shadow:0 0 0 2px var(--accent),0 12px 24px -10px color-mix(in srgb,var(--accent) 60%,transparent); }
.picking .battle-card.usable.chosen { outline:3px solid var(--accent); outline-offset:3px; box-shadow:0 0 0 3px var(--bg),0 0 22px color-mix(in srgb,var(--accent) 70%,transparent); }
.picking .battle-communes > .battle-card + .battle-card { margin-left:min(calc(var(--zone-card) * .2 + 10px),calc((100% - var(--n,1) * var(--zone-card) * 1.2) / max(1,var(--n,1) - 1))); }
.playmat.reacting .battle-center { grid-template-columns:230px auto minmax(0,1fr); }
.contested-card .battle-card { width:calc(var(--zone-card) * .8); }
.contested-card small { max-width:calc(var(--zone-card) * .9); }
/* Wraps on the space it actually has: target, explanation, then the buttons go below when the strip is narrow. */
.reaction-details { display:flex; flex-wrap:wrap; align-items:center; gap:8px 20px; min-width:0; }
.reaction-details > .waiting-message { flex:1 1 100%; }
.reaction-target { display:flex; flex:0 0 auto; flex-direction:column; gap:4px; min-width:150px; }
.reaction-target > span:first-child { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
.reaction-target strong { font-size:clamp(34px,4vw,52px); line-height:1; letter-spacing:-.04em; color:var(--accent-ink); font-variant-numeric:tabular-nums; }
.reaction-meter { display:block; height:8px; border-radius:99px; background:color-mix(in srgb,var(--ink) 12%,transparent); overflow:hidden; }
.reaction-meter i { display:block; width:0; height:100%; border-radius:inherit; background:var(--muted); transition:width .2s ease-out,background .2s; }
.reaction-meter.ok i { background:var(--accent); }
.reaction-target #counter-total { width:auto; font-size:12px; font-variant-numeric:tabular-nums; }
.reaction-info { flex:1 1 260px; min-width:0; }
.reaction-info h3 { display:flex; flex-wrap:wrap; align-items:center; gap:6px 8px; margin:0 0 4px; font-size:16px; }
.reaction-info p { margin:4px 0; font-size:12px; }
.reaction-info .reaction-outcome { padding:6px 10px; }
.reaction-actions { display:flex; flex:1 0 190px; flex-direction:column; gap:8px; max-width:260px; }
.reaction-actions button { min-height:44px; white-space:nowrap; }
@media(max-width:700px) { .reaction-actions { flex-basis:100%; max-width:none; } .picking .battle-card.usable { scale:1.12; } }
@media(prefers-reduced-motion:reduce) { .battle-card,.reaction-meter i { transition:none; } }
/* Two lines per player, as before the side-by-side board: stops on the first, communes on the second.
   Each zone gets the full width, so five cards never spill onto the neighbouring zone. Zone cards are a bit smaller to keep the height. */
.battle-root { --zone-card:clamp(72px,min(6.6vw,11vh),120px); }
.playmat-row,.playmat.reacting .playmat-row { grid-template-columns:auto minmax(0,1fr); row-gap:8px; }
.playmat-row .playmat-zone,.playmat-row .playmat-zone:last-child { grid-column:2; }
.playmat-row .playmat-hero { grid-row:1 / span 2; }
@media(max-width:700px) {
  .playmat-row,.playmat.reacting .playmat-row { grid-template-columns:1fr; }
  .playmat-row .playmat-zone,.playmat-row .playmat-zone:last-child { grid-column:auto; }
  .playmat-row .playmat-hero { grid-row:auto; }
}
.picking .playmat-hero > .battle-card.usable { scale:1.1; transform-origin:left top; }
/* The hand stays on screen: it sticks to the bottom of the viewport while the board scrolls under it,
   and settles back in place at the end of the page. Phones pin it in the duel layout instead (see "Mobile duel" below). */
@media(min-width:701px) and (min-height:600px) {
  .battle-root { --hand-card:clamp(80px,min(6.8vw,12.5vh),124px); }
  .battle-hand-zone { position:sticky; bottom:0; z-index:20; margin-top:10px; pointer-events:none; }
  .battle-hand-zone .battle-hand > div { pointer-events:auto; }
  .battle-hand-zone .battle-zone-title { margin:0; }
  .battle-hand-zone .battle-hand { padding-bottom:8px; }
}
@media(min-width:701px) and (min-height:600px) { .friendly .battle-communes { scroll-margin-bottom:calc(var(--hand-card) * 88 / 63 + 80px); } }

/* Same hand on your turn and when reacting: playable cards in colour with an orange ring, the rest grey; only hover lifts. */
.picking .battle-hand .battle-card.usable { scale:1; box-shadow:0 0 0 2px var(--accent); }
@media(hover:hover) { .picking .battle-hand .battle-card.usable:hover { scale:1.2; } }
.picking .battle-hand .battle-card.usable.chosen { box-shadow:0 0 0 3px var(--accent),0 0 18px color-mix(in srgb,var(--accent) 60%,transparent); }
/* Hints under hand cards ("Ajouter à la ligne", "Renfort : +300", why it cannot be played): only on hover or keyboard focus. */
.battle-hand > div > small { opacity:0; transition:opacity .15s ease-out; }
.battle-hand > div:hover > small,.battle-hand > div:focus-within > small { opacity:1; }
/* Smooth lift: card.css sets the tilt transition on button cards, so scale/filter join it here. */
button.battle-card { transition:transform .18s ease-out,scale .22s cubic-bezier(.2,.8,.2,1),filter .18s ease-out,opacity .18s ease-out,box-shadow .22s ease-out; }
@media(prefers-reduced-motion:reduce) { button.battle-card,.battle-hand > div > small { transition:none; } }
@media(min-width:701px) and (min-height:600px) {
  /* No backdrop behind the stuck hand: its cards stay opaque (grey, not see-through) so the board never shows through. */
  .battle-hand .battle-card.unusable { opacity:1; filter:grayscale(1) brightness(.92); }
  .battle-hand-zone .battle-zone-title { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
}
/* Reinforcements tucked behind the floating contested stop, fanned to the right; the strip keeps its size. */
.contested-stack { position:relative; display:grid; justify-items:start; align-items:center; }
.contested-stack:has(.contested-support) { padding-right:calc(var(--zone-card) * .7); }
.contested-stack > .contested-main { position:relative; z-index:2; }
.contested-card .contested-support { position:absolute; z-index:1; top:calc(18% + var(--i,0) * 12%); left:calc(var(--zone-card) * .6 + var(--i,0) * var(--zone-card) * .24); width:calc(var(--zone-card) * .58); animation-delay:-.6s; }
.contested-card .contested-support.mine { box-shadow:0 0 0 2px var(--accent),0 8px 16px -8px rgb(0 0 0 / .4); }
.contested-card .contested-support.theirs { box-shadow:0 0 0 2px var(--muted),0 8px 16px -8px rgb(0 0 0 / .4); }

/* The CSP (style-src 'self') ignores inline style attributes: per-element values come from classes. */
.n-0,.n-1 { --n:1; } .n-2 { --n:2; } .n-3 { --n:3; } .n-4 { --n:4; } .n-5 { --n:5; }
.support-1 { --i:1; } .support-2 { --i:2; } .support-3 { --i:3; } .support-4 { --i:4; }
.tone-tour { --tone-kw:var(--kw-tour); } .tone-blocage { --tone-kw:var(--kw-blocage); } .tone-battue { --tone-kw:var(--kw-battue); } .tone-renfort { --tone-kw:var(--kw-renfort); } .tone-territoire { --tone-kw:var(--kw-territoire); }

/* The hero line is easy to miss as a reinforcement: a "Renfort" tag and a soft pulse while it can be engaged. */
.battle-card.hero-callout::after { content:"Renfort"; position:absolute; z-index:4; left:50%; bottom:-9px; transform:translateX(-50%); padding:2px 9px; border-radius:999px; background:var(--kw-renfort); color:#fff; font-size:11px; font-weight:750; white-space:nowrap; box-shadow:0 2px 6px rgb(0 0 0 / .3); }
.battle-card.hero-callout.chosen::after { content:"Engagée ✓"; }
@media(prefers-color-scheme:dark) { .battle-card.hero-callout::after { color:#1b1030; } }
@keyframes hero-pulse { 0%,100% { box-shadow:0 0 0 2px var(--kw-renfort),0 0 0 0 color-mix(in srgb,var(--kw-renfort) 55%,transparent); } 50% { box-shadow:0 0 0 2px var(--kw-renfort),0 0 0 10px color-mix(in srgb,var(--kw-renfort) 0%,transparent); } }
.picking .battle-card.hero-callout:not(.chosen) { animation:hero-pulse 1.6s ease-in-out infinite; }
.reaction-line-only { padding:6px 10px; border-left:3px solid var(--kw-renfort); border-radius:0 8px 8px 0; background:color-mix(in srgb,var(--kw-renfort) 12%,transparent); }
@media(prefers-reduced-motion:reduce) { .picking .battle-card.hero-callout:not(.chosen) { animation:none; box-shadow:0 0 0 3px var(--kw-renfort); } }

/* Round counter and LED scoreboard live above the log: the centre strip only holds the turn and its action. */
.battle-center,.battle-center.your-turn { grid-template-columns:minmax(0,1fr); }
.playmat.reacting .battle-center { grid-template-columns:auto minmax(0,1fr); }
.battle-side > .battle-control { padding:14px 16px; border:1px solid var(--line); border-radius:14px; background:var(--panel); }
.battle-layout > .battle-side { position:sticky; top:8px; }
@media(max-width:1000px) {
  .battle-layout > .battle-side { display:contents; }
  .battle-side > .battle-control { order:-1; flex-direction:row; flex-wrap:wrap; align-items:center; }
  .battle-side > .battle-control .battle-round { flex:0 0 auto; flex-direction:column; gap:0; }
  .battle-side > .battle-control .led-panel { flex:0 1 340px; }
}

/* Decluttered board: quiet counters, short zone titles, empty zones as a faint outline only. */
.battle-bar { align-items:center; }
.battle-bar .eyebrow { font-size:11px; }
.playmat-counts { display:flex; flex-wrap:wrap; gap:2px 8px; margin:0; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums; }
.playmat-side .battle-discard { min-height:44px; padding:0; border:0; background:none; color:var(--muted); font-size:11px; font-weight:600; text-align:left; text-decoration:underline dotted; text-underline-offset:3px; }
.playmat-side .battle-discard:hover { color:var(--ink); }
.battle-zone-title { justify-content:flex-start; gap:6px; font-size:11px; letter-spacing:.02em; }
.battle-zone-title span { color:color-mix(in srgb,var(--muted) 70%,transparent); }
.playmat-zone .zone-empty { min-height:calc(var(--zone-card) * 88 / 63 - 8px); padding:0; border:1px dashed color-mix(in srgb,var(--line) 70%,transparent); background:none; }
.battle-log h3 { font-size:14px; margin-bottom:8px; }

/* The strip between the two playmats keeps one height (the reaction's) so the boards never jump. */
@media(min-width:701px) {
  .battle-center:not(.done) { min-height:max(132px,calc(var(--zone-card) * .8 * 88 / 63 + 26px)); box-sizing:border-box; padding-block:10px; align-content:center; }
  .battle-center:not(.done) .battle-stack { max-height:3.6em; overflow-y:auto; }
}
/* An empty zone is exactly as tall as a zone holding cards, so rows keep their height as cards arrive. */
.playmat-zone .zone-empty { box-sizing:border-box; min-height:0; height:calc(var(--zone-card) * 88 / 63); margin:0; }
/* Reaction strip: the floating contested stop sits in the middle, what to beat on its left, the chain and buttons on its right. */
@media(min-width:701px) {
  .playmat.reacting .battle-center { grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); grid-template-rows:auto auto; column-gap:28px; row-gap:8px; }
  .playmat.reacting .reaction-details { display:contents; }
  .playmat.reacting .contested-card { grid-column:2; grid-row:1 / span 2; justify-self:center; align-self:center; }
  .playmat.reacting .reaction-target { grid-column:1; grid-row:1 / span 2; justify-self:end; align-self:center; text-align:right; }
  .playmat.reacting .reaction-target .reaction-meter { width:100%; }
  .playmat.reacting .reaction-info { grid-column:3; grid-row:1; align-self:end; }
  .playmat.reacting .reaction-actions,.playmat.reacting .reaction-details > .waiting-message { grid-column:3; grid-row:2; align-self:start; flex-direction:row; flex-wrap:wrap; max-width:none; }
  .playmat.reacting .reaction-actions button { flex:1 1 auto; min-height:40px; }
}

/* What a card brings, big above it on hover or focus ("+400", "🛡 431", "↻ Pioche"): the number you need at a glance. */
.battle-card[data-gain]::before { content:attr(data-gain); position:absolute; z-index:6; left:50%; bottom:calc(100% + 6px); padding:3px 10px; border-radius:10px; background:var(--ink); color:var(--bg); font-size:20px; font-weight:800; letter-spacing:-.02em; line-height:1.2; white-space:nowrap; font-variant-numeric:tabular-nums; box-shadow:0 6px 16px -6px rgb(0 0 0 / .5); opacity:0; pointer-events:none; transform:translate(-50%,4px); transition:opacity .15s ease-out,transform .15s ease-out; }
.battle-card[data-gain]:is(:hover,:focus-visible)::before { opacity:1; transform:translate(-50%,0); }
.battle-card.unusable[data-gain]::before { background:var(--muted); }
@media(prefers-reduced-motion:reduce) { .battle-card[data-gain]::before { transition:none; } }

/* Landing burst (burst() in battle-ui.js): stars, shock rings and light rays above the board, never catching clicks. */
.landing-burst { position:fixed; z-index:70; width:0; height:0; pointer-events:none; }
.burst-spark { position:absolute; left:0; top:0; line-height:1; text-shadow:0 0 5px currentColor; }
.burst-ring { position:absolute; left:0; top:0; width:120px; height:120px; border:3px solid; border-radius:50%; }
.burst-ray { position:absolute; left:-2px; top:-150px; width:4px; height:150px; border-radius:4px; background:linear-gradient(transparent,#ffe08a 70%,#fffbe8); transform-origin:50% 100%; }

/* Duel mode: the board owns the whole site (no top bar, no tabs) until the player leaves the match. */
body.in-battle .topbar,body.in-battle .tabs,body.in-battle .intro { display:none; }
body.in-battle #toast { z-index:80; }
body.in-battle main { padding-top:8px; }

/* Big moments (moments() in battle-ui.js): banner, score pop-ups, confetti. */
.battle-banner { position:fixed; z-index:70; inset:38% 0 auto; display:flex; justify-content:center; pointer-events:none; }
.battle-banner span { padding:12px 34px; border-radius:14px; background:var(--accent); color:var(--on-accent); font-size:clamp(24px,6vw,44px); font-weight:900; letter-spacing:-.02em; text-transform:uppercase; box-shadow:0 18px 40px rgb(0 0 0 / .3); animation:banner-in 1.4s cubic-bezier(.2,.8,.2,1) both; }
.battle-banner.block span { background:#d1281a; color:#fff; }
.battle-banner.counter span { background:#8a5a00; color:#fff; }
.battle-banner.reaction span { background:#1f5fbf; color:#fff; }
.battle-banner.round span { background:#121110; color:#ffb21e; border:2px solid #3b3935; font-family:ui-monospace,monospace; }
.battle-banner.win span { background:linear-gradient(135deg,#ffd23a,#ff6600); color:#241300; font-size:clamp(32px,9vw,64px); }
@keyframes banner-in { 0% { opacity:0; transform:translateX(-60vw) skewX(-18deg); } 18% { opacity:1; transform:translateX(12px) skewX(4deg); } 26% { transform:none; } 78% { opacity:1; transform:scale(1.04); } 100% { opacity:0; transform:translateX(60vw) skewX(-18deg); } }
.score-pop { position:fixed; z-index:70; pointer-events:none; font-size:26px; font-weight:900; font-variant-numeric:tabular-nums; text-shadow:0 2px 0 rgb(0 0 0 / .35); transform:translate(-50%,-50%); animation:score-pop 1.2s cubic-bezier(.2,.8,.3,1) forwards; }
.score-pop.up { color:#ffd23a; } .score-pop.down { color:#ff5a4f; }
@keyframes score-pop { 0% { opacity:0; transform:translate(-50%,-30%) scale(.4); } 20% { opacity:1; transform:translate(-50%,-70%) scale(1.35); } 100% { opacity:0; transform:translate(-50%,-260%) scale(1); } }
.battle-confetti { position:fixed; inset:0; z-index:69; pointer-events:none; overflow:hidden; }
.battle-confetti i { position:absolute; top:0; border-radius:2px; }
.battle-center.your-turn .battle-turn-action .primary { animation:turn-glow 1.6s ease-in-out infinite; }
@keyframes turn-glow { 0%,100% { box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 60%,transparent); } 50% { box-shadow:0 0 0 8px transparent; } }
@keyframes sheet-in { from { opacity:0; transform:translateY(-24px) scale(.96); } to { opacity:1; transform:none; } }
@media(prefers-reduced-motion:reduce) { .battle-banner,.score-pop,.battle-confetti { display:none; } .battle-center.your-turn .battle-turn-action .primary,body.in-battle .playmat.picking .battle-center { animation:none; } }

/* Mobile duel: one screen, no page scroll. Status on top, both networks in compact rows, the hand pinned at the bottom,
   the block/counter panel (when I react) floating as a modal over the rival network (my communes and hand stay tappable underneath). */
@media(max-width:700px) {
  body.in-battle { overflow:hidden; }
  body.in-battle .battle-root { --hero-card:clamp(46px,min(15vw,10dvh),74px); --zone-card:clamp(42px,min(13.5vw,9.4dvh),68px); --hand-card:clamp(56px,min(18vw,12.5dvh),86px);
    position:fixed; inset:0; z-index:40; display:flex; flex-direction:column; height:100dvh; padding:calc(env(safe-area-inset-top) + 4px) 8px calc(env(safe-area-inset-bottom) + 2px); background:var(--bg); overflow:hidden; }
  body.in-battle .battle-root > .battle-bar { flex:none; flex-direction:row; align-items:center; margin:0 0 4px; }
  body.in-battle .battle-root > .battle-bar .row-actions { flex-direction:row; }
  body.in-battle .battle-root > .battle-bar button { min-height:36px; padding:6px 10px; }
  body.in-battle .battle-layout { display:flex; flex-direction:column; flex:1; min-height:0; gap:4px; }
  body.in-battle .battle-root:has(.playmat) .battle-side { order:-1; flex:none; display:flex; align-items:center; gap:6px; }
  body.in-battle .battle-root:has(.playmat) .battle-side .battle-log { display:none; }
  body.in-battle .battle-control { flex:1; flex-direction:row; flex-wrap:nowrap; align-items:center; gap:8px; padding:0; border:0; }
  body.in-battle .battle-round { flex:none; flex-direction:column; font-size:10px; }
  body.in-battle .battle-round b { font-size:15px; }
  body.in-battle .led-panel { flex:1; max-width:240px; padding:3px 5px 2px; }
  body.in-battle .battle-root:has(.playmat) .battle-chat { position:fixed; z-index:45; right:8px; bottom:calc(var(--hand-card) * 88 / 63 + 40px); max-width:calc(100vw - 16px); box-shadow:0 8px 24px rgb(0 0 0 / .2); }
  body.in-battle .battle-root:has(.playmat) .battle-chat-toggle { min-height:40px; padding:8px 12px; }
  body.in-battle .battle-root:has(.playmat) .battle-chat-toggle::after { display:none; }
  body.in-battle .battle-root:has(.playmat) .battle-chat-body:not([hidden]) { width:min(320px,calc(100vw - 16px)); }
  body.in-battle .battle-main { flex:1; min-height:0; display:flex; flex-direction:column; }
  body.in-battle .tutorial-coach { flex:none; padding:6px 10px; gap:2px 8px; }
  body.in-battle .tutorial-coach p:not(.eyebrow) { font-size:12px; flex-basis:100%; }
  body.in-battle .tutorial-coach .eyebrow { display:none; }
  body.in-battle .playmat { flex:1; min-height:0; display:flex; flex-direction:column; justify-content:space-between; overflow-y:auto; overscroll-behavior:contain; }
  body.in-battle .playmat-row { display:grid; grid-template-columns:auto minmax(0,1.25fr) minmax(0,1fr); grid-template-areas:"side side side" "hero stops comm"; gap:2px 6px; padding:4px 6px; align-items:start; }
  body.in-battle .playmat.reacting .playmat-row { grid-template-columns:auto minmax(0,1.25fr) minmax(0,1fr); padding:4px 6px; gap:2px 6px; }
  body.in-battle .playmat-hero { display:contents; }
  body.in-battle .playmat-hero > .battle-card { grid-area:hero; width:var(--hero-card); }
  body.in-battle .playmat-side { grid-area:side; flex-direction:row; align-items:center; gap:8px; width:auto; }
  body.in-battle .playmat-side .battle-player { flex-direction:row; text-align:left; min-width:0; }
  body.in-battle .playmat-counts { display:flex; gap:8px; margin:0 0 0 auto; font-size:10px; color:var(--muted); }
  body.in-battle .playmat-side .battle-discard { min-height:32px; padding:4px 8px; font-size:10px; }
  body.in-battle .playmat-row > .playmat-zone:nth-child(2) { grid-area:stops; }
  body.in-battle .playmat-row > .playmat-zone:nth-child(3) { grid-area:comm; grid-column:auto; }
  body.in-battle .playmat-zone .battle-zone-title { margin-bottom:2px; font-size:9px; }
  body.in-battle .battle-stops,body.in-battle .battle-communes { min-height:calc(var(--zone-card) * 88 / 63 + 2px); padding:0; }
  body.in-battle .playmat-zone .zone-empty { padding:6px 4px; }
  body.in-battle .battle-center { display:flex; align-items:center; gap:8px; padding:4px 8px; }
  body.in-battle .battle-center-main { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:4px 8px; width:100%; }
  body.in-battle .battle-center-main h3 { margin:0; font-size:15px; }
  body.in-battle .battle-center-main p { margin:0; font-size:12px; }
  body.in-battle .battle-turn-action button { width:auto; min-height:44px; padding-inline:16px; }
  body.in-battle .playmat.picking::before { content:''; position:fixed; inset:0; z-index:48; background:rgb(0 0 0 / .45); pointer-events:none; }
  body.in-battle .playmat.picking .friendly { position:relative; z-index:49; background:var(--bg); border-radius:12px; }
  body.in-battle .battle-hand-zone.picking { position:relative; z-index:49; background:var(--bg); }
  body.in-battle .playmat.picking .battle-center { position:fixed; z-index:50; left:8px; right:8px; top:calc(env(safe-area-inset-top) + 8px); max-height:46dvh; overflow-y:auto; display:flex; align-items:center; gap:12px; padding:12px; border:2px solid var(--accent); border-radius:16px; background:var(--panel); box-shadow:0 20px 50px rgb(0 0 0 / .35); animation:sheet-in .28s cubic-bezier(.2,.8,.2,1); }
  body.in-battle .playmat.reacting .contested-card { flex:none; }
  body.in-battle .playmat.reacting .contested-card .battle-card { width:calc(var(--zone-card) + 14px); }
  body.in-battle .reaction-details { flex:1; display:flex; flex-direction:column; gap:6px; }
  body.in-battle .reaction-target strong { font-size:26px; }
  body.in-battle .reaction-details h3 { margin:0; font-size:14px; }
  body.in-battle .battle-stack { margin:0; padding-left:16px; font-size:11px; }
  body.in-battle .reaction-actions { display:flex; flex-direction:column; gap:6px; }
  body.in-battle .reaction-actions button { min-height:44px; width:100%; }
  body.in-battle .battle-hand-zone { flex:none; margin:0; padding-top:4px; border-top:1px solid var(--line); }
  body.in-battle .battle-hand-zone > .battle-zone-title { display:none; }
  body.in-battle .battle-hand { gap:6px; padding:2px 2px 4px; }
  body.in-battle .battle-hand small { margin-top:2px; font-size:9px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  body.in-battle .battle-root:not(:has(.playmat)) .battle-layout { overflow-y:auto; }
}
