/* BATTLE-P2-SCREEN (20/11): the practice ground (js/views/battleground.js). Oblique 6 x 8 board with no perspective, tiles
   56 x 44 at 390 px (--k scales it on wider screens), turn bar on top, thumb bar at the bottom. */
.bg { position: fixed; inset: 0; z-index: 92;   /* above .cs-back (90), under the in-game confirm (95) and the tip (1000) */ display: flex; flex-direction: column; align-items: center; overflow: hidden;
  padding: env(safe-area-inset-top) 0 0; color: var(--text); --k: 1;
  background: radial-gradient(120% 70% at 50% 42%, #253029 0, #161c1b 60%, #0f1312 100%); }
.bg > * { width: 100%; max-width: 720px; }
.bg-top { display: flex; align-items: center; gap: 6px; height: 56px; padding: 4px 6px; flex: none; }
.bg-bar { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.bg-b { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 2px var(--b, var(--line)); background: #0d1112; }
.bg-b.mine { --b: var(--self); } .bg-b.foe { --b: var(--enemy); }
.bg-b.now { width: 48px; height: 48px; box-shadow: 0 0 0 3px var(--b), 0 0 14px var(--b); }
.bg-b > b { position: absolute; bottom: -5px; right: -4px; font-size: 10px; line-height: 13px; padding: 0 3px; border-radius: 2px;
  background: #0d1112; color: var(--text); }
.bg-face { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 15%; display: block; }
.bg-face.beast { background-size: 800% 400%; background-position: 0 0; background-repeat: no-repeat; }
.bg-cyc { display: flex; align-items: center; gap: 3px; font-size: 13px; color: var(--dim); flex: none; }
.bg-cyc .gi { width: 16px; height: 16px; }
.bg-shut { flex: none; }
.sq-practice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px;
  padding: 2px 0; border-block: 1px solid #394745; }
.sq-practice[hidden] { display: none; }
.sq-practice .sq-practice-go { width: 144px; min-height: 44px; padding-inline: 10px; gap: 6px; color: #e0eee7;
  border: 1px solid #60847b; border-radius: 5px; background: #253733; font-size: 13px; white-space: nowrap; }
.sq-practice-modes { display: inline-flex; }
.sq-practice-modes button { min-width: 44px; min-height: 44px; padding: 4px 8px; border-radius: 0; border: 1px solid #44514e;
  background: #1b2324; color: #c3cfc8; font-size: 12px; }
.sq-practice-modes button:first-child { border-radius: 5px 0 0 5px; }
.sq-practice-modes button:last-child { border-radius: 0 5px 5px 0; margin-inline-start: -1px; }
.sq-practice-modes button[aria-pressed="true"] { border-color: #9db1a5; color: #fff1cf; background: #35453e; position: relative; }
.bg-practice-level { display: flex; align-items: center; gap: 8px; padding: 2px 8px; font-size: 12px; line-height: 16px; }
.bg-difficulty { color: #cdd9d0; }
.bg-difficulty[data-mode="veteran"] { color: #efc98e; }
.bg-reserve { color: #bac5c0; }

.bg-stage { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; align-items: center; padding: calc(34px * var(--k)) 0 calc(10px * var(--k)); }
.bg-board { position: relative; }
.bg-tiles, .bg-units, .bg-fx { position: absolute; inset: 0; }
.bg-units, .bg-fx { pointer-events: none; }

/* a tile: a parallelogram (5 px shift per row), 1 px gap = the grid line */
.bg-t { position: absolute; min-width: 0; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0; display: grid; place-items: center;
  clip-path: polygon(calc(var(--sh) + 1px) 1px, calc(100% - 1px) 1px, calc(100% - var(--sh) - 1px) calc(100% - 1px), 1px calc(100% - 1px));
  background: var(--g1); cursor: pointer; transition: background-color .2s, filter .2s; -webkit-tap-highlight-color: transparent; }
.bg-t:not(:disabled):active { translate: none; margin: 0; border: 0; }
.bg-tiles { --g1: #3c4a35; --g2: #36432f; }
.bg-tiles[data-kind="tree"] { --g1: #2f4a2c; --g2: #2a4227; }
.bg-tiles[data-kind="water"] { --g1: #34463f; --g2: #2f3f39; }
.bg-tiles[data-kind="rock"] { --g1: #48463b; --g2: #423f35; }
.bg-t.odd { background: var(--g2); }
.bg-t.high { background: linear-gradient(180deg, rgba(255, 240, 200, .16) 0 74%, rgba(0, 0, 0, .38) 74%), var(--g1); }
.bg-t.block { background: #1f2421; cursor: default; }
.bg-blk { width: 26px; height: 26px; fill: none; stroke: #8d9a8c; stroke-width: 1.6; stroke-linejoin: round; }
.bg-tiles[data-kind="water"] .bg-blk { stroke: #6fa6b8; }
.bg-hi { position: absolute; right: calc(var(--sh) + 3px); top: 2px; width: 12px; height: 12px; fill: none; stroke: rgba(255, 236, 190, .55); stroke-width: 2.4; }
.bg-t.reach { background: linear-gradient(0deg, rgba(43, 181, 160, .34), rgba(43, 181, 160, .34)), var(--g1); animation: bg-glow 1.6s ease-in-out infinite; }
.bg-t.reach.high { background: linear-gradient(180deg, rgba(43, 181, 160, .42) 0 74%, rgba(0, 0, 0, .38) 74%), var(--g1); }
.bg-t.sel { background: linear-gradient(0deg, rgba(63, 208, 185, .75), rgba(63, 208, 185, .75)), var(--g1); animation: none; }
.bg-t.tgt { background: linear-gradient(0deg, rgba(226, 96, 58, .62), rgba(226, 96, 58, .62)), var(--g1); animation: bg-glow 1s ease-in-out infinite; }
.bg-t.tgt2 { background: linear-gradient(0deg, rgba(226, 96, 58, .22), rgba(226, 96, 58, .22)), var(--g1); }
@keyframes bg-glow { 50% { filter: brightness(1.22); } }

/* a company: anchored on its footprint's centre */
.bg-u { position: absolute; width: 0; height: 0; transition: left .33s ease-in-out, top .33s ease-in-out, opacity .5s; }
.bg-ring { position: absolute; left: calc(-24px * var(--k)); top: calc(-11px * var(--k)); width: calc(48px * var(--k)); height: calc(22px * var(--k));
  border-radius: 50%; border: 2px solid var(--rc); opacity: .55; z-index: 1; }
.bg-u.big .bg-ring { left: calc(-50px * var(--k)); top: calc(-24px * var(--k)); width: calc(100px * var(--k)); height: calc(48px * var(--k)); }
.bg-u.mine { --rc: var(--self); } .bg-u.foe { --rc: var(--enemy); }
.bg-u.active .bg-ring { opacity: 1; box-shadow: 0 0 12px var(--rc), inset 0 0 8px var(--rc); animation: bg-glow 1.2s ease-in-out infinite; }
.bg-beast { position: absolute; width: var(--f); height: var(--f); left: calc(var(--f) / -2); top: calc(var(--f) * -.78);
  background-size: calc(var(--f) * 8) calc(var(--f) * 4); background-repeat: no-repeat; background-position: 0 0;
  animation: bg-cyc 1.1s steps(8) infinite; transition: translate .14s ease-out; }
.bg-beast[data-row="attack"] { background-position-y: calc(var(--f) * -1); animation-duration: .5s; }
.bg-beast[data-row="hit"] { background-position-y: calc(var(--f) * -2); animation-duration: .45s; }
.bg-beast[data-row="death"] { background-position-y: calc(var(--f) * -3); animation: bg-cyc .7s steps(7) 1 forwards; }
@keyframes bg-cyc { from { background-position-x: 0; } to { background-position-x: calc(var(--f) * -8); } }
.bg-beast[data-row="death"] { animation-name: bg-die; }
@keyframes bg-die { from { background-position-x: 0; } to { background-position-x: calc(var(--f) * -7); } }
.bg-troop { position: absolute; height: calc(54px * var(--k)); width: auto; left: 50%; bottom: calc(-10px * var(--k)); translate: -50% 0;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .55)); transition: translate .14s ease-out; }
.bg-u.foe .bg-troop { transform: scaleX(-1); }
.bg-u.strike .bg-beast { translate: var(--lx) var(--ly); }
.bg-u.strike .bg-troop { translate: calc(-50% + var(--lx)) var(--ly); }
.bg-u.hurt .bg-beast, .bg-u.hurt .bg-troop { filter: brightness(1.9) saturate(.3); }
.bg-u.dead { opacity: 0; }
.bg-u.is-beast.dead { opacity: .3; transition-delay: .8s; }
.bg-u.dead .bg-n, .bg-u.dead .bg-ring, .bg-u.dead .bg-pv, .bg-u.dead .bg-cmd { display: none; }
.bg-u.left-behind { opacity: .4; }
.bg-ghost { opacity: .75; filter: drop-shadow(0 0 6px var(--self)); }
.bg-n { position: absolute; top: calc(7px * var(--k)); left: 0; translate: -50% 0; font-size: 12px; line-height: 15px; padding: 0 4px; border-radius: 2px;
  background: rgba(10, 14, 14, .85); color: var(--text); box-shadow: inset 0 -2px 0 var(--rc); white-space: nowrap; z-index: 2000; }
.bg-u.big .bg-n { top: calc(20px * var(--k)); font-size: 13px; }
.bg-cmd { position: absolute; top: calc(7px * var(--k) - 21px); left: -10px;   /* centred on its own count, never in a neighbour's tile */ width: 20px; height: 20px; display: grid; place-items: center;
  border-radius: 50%; background: var(--gold); color: #1d1606; z-index: 2000; }
.bg-cmd .gi { width: 14px; height: 14px; }
.bg-cmd[hidden] { display: none; }
.bg-u .bg-lone { width: calc(35px * var(--k)); height: calc(35px * var(--k)); object-fit: cover; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold); }
.bg-lone + .bg-cmd { left: calc(12px * var(--k)); top: calc(-25px * var(--k) - 5px); width: 14px; height: 14px; }
.bg-lone + .bg-cmd .gi { width: 10px; height: 10px; }
.bg-n .gi, .bg-b b .gi, .bg-who b .gi, .bg-pop .gi, .bg-log-row b .gi {
  width: .9em; height: .9em; margin-right: 2px; vertical-align: -.08em; color: var(--gold);
}
.bg-pv { position: absolute; bottom: calc(44px * var(--k)); left: 0; translate: -50% 0; display: flex; align-items: center; gap: 2px;
  padding: 1px 5px; border-radius: 2px; background: #2a0f08; color: #ffd2c2; font-size: 13px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--enemy); z-index: 2001; }
.bg-u.is-troop .bg-pv { bottom: calc(50px * var(--k)); }
.bg-u.big .bg-pv { bottom: calc(30px * var(--k)); }
.bg-u .bg-pv.in-footprint { bottom: 0; }
.bg-pv-cmd { display: inline-flex; align-items: center; gap: 1px; margin-left: 3px; color: var(--gold); }
.bg-pv .gi, .bg-pv svg { width: 14px; height: 14px; }
.bg-ctr.up { color: #6be37d; } .bg-ctr.down { color: #ff8c6b; }
.bg-side { fill: none; stroke: var(--gold); stroke-width: 2.4; }
.bg-pop { position: absolute; translate: -50% 0; font-weight: 800; font-size: 17px; color: #ffb39c; text-shadow: 0 1px 2px #000;
  animation: bg-pop .9s ease-out forwards; }
.bg-pop.mine { color: #ff7a5c; }
@keyframes bg-pop { from { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } to { opacity: 0; transform: translateY(-26px); } }

/* who acts + the chosen target's numbers */
.bg-info { display: flex; align-items: center; justify-content: center; gap: 14px; height: 54px; flex: none; }
.bg-who { position: relative; width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 2px var(--self); }
.bg-who > b { position: absolute; bottom: -4px; right: -8px; font-size: 11px; padding: 0 3px; border-radius: 2px; background: #0d1112; }
.bg-stat { display: flex; align-items: center; gap: 4px; font-size: 15px; }
.bg-stat .gi { width: 18px; height: 18px; color: var(--dim); }
.bg-stat.bad .gi { color: var(--enemy); width: 22px; height: 22px; }
.bg-board.refused { animation: bg-shake .36s ease-in-out; }
@keyframes bg-shake { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }

.bg-thumbs { display: flex; gap: 8px; justify-content: center; flex: none;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
.bg-th { min-width: 64px; min-height: 52px; flex: 1; max-width: 120px; }
.bg-th .gi { width: 24px; height: 24px; }
.bg-th.on { background: linear-gradient(160deg, #3fd0b9 0 55%, #2bb5a0 55%); color: #04211c; }
.bg-x2 { font-size: 18px; font-weight: 800; }
.bg-x2[aria-pressed="true"] { color: var(--gold); }

.bg-end { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 10px; flex: none;
  padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.bg-end-line { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.bg-end-mark { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; flex: none; }
.bg-end-mark .gi { width: 36px; height: 36px; }
.bg-end-mark.win { color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(224, 178, 58, .5); }
.bg-end-mark.lost { color: var(--enemy); box-shadow: 0 0 0 2px var(--enemy); }
.bg-end-mark.fled { color: var(--dim); box-shadow: 0 0 0 2px var(--line); }
.bg-end-side { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.bg-end-u { position: relative; width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px var(--self); }
.bg-end-side.foe .bg-end-u { box-shadow: 0 0 0 2px var(--enemy); }
.bg-end-u.gone { opacity: .45; }
.bg-end-u > b { position: absolute; bottom: -6px; left: 50%; translate: -50% 0; font-size: 10px; padding: 0 3px; border-radius: 2px; background: #0d1112; white-space: nowrap; }
.bg-end-row { display: flex; gap: 10px; width: 100%; justify-content: center; margin-top: 6px; }

/* the entry on the camp sheet: one round symbol */
button.bg-go { width: 48px; height: 48px; min-width: 48px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; }
button.bg-go .gi { width: 24px; height: 24px; }
@media (prefers-reduced-motion: reduce) { .bg-t.reach, .bg-t.tgt, .bg-u.active .bg-ring { animation: none; } .bg-beast { animation: none; } }
/* toasts (z 50) stay readable over the practice ground */
body:has(> .bg) #toasts { z-index: 96; }

/* BATTLE-P2-SCREEN-SPACE: the last strikes under the board (faces + -N), in the phone's free height */
.bg-log { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; min-height: 0; padding: 2px 0 4px; }
.bg-log-row { display: flex; align-items: center; gap: 6px; font-size: 14px; opacity: .55; }
.bg-log-row:first-child { opacity: 1; }
.bg-log-f { width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 2px var(--rc); }
.bg-log-f.mine { --rc: var(--self); } .bg-log-f.foe { --rc: var(--enemy); }
.bg-log-row .gi, .bg-log-row svg { width: 16px; height: 16px; color: var(--dim); }
.bg-log-row b { min-width: 34px; color: #ffb39c; }
.bg-log-row b.gone { color: var(--gold); }
@media (max-height: 760px) { .bg-log-row:nth-child(n+3) { display: none; } }

/* BATTLE-P2-ORDER-BUTTON (21/11): the commander's order, first in the thumb bar. Ready = gold symbol; armed = gold plate (the
   next strike / Wait carries it); cooling = a dimmed symbol, the turns left in a corner and a ring that empties as it comes back.
   No looping animation: the ring is a static conic gradient redrawn on each render. */
.bg-ord { position: relative; color: var(--gold); }
.bg-ord .bg-ord-i { width: 26px; height: 26px; fill: currentColor; }
.bg-ord[data-kind="charge"] .bg-ord-i, .bg-ord[data-kind="taunt"] .bg-ord-i, .bg-ord[data-kind="rally"] .bg-ord-i {
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.bg-ord[aria-pressed="true"] { background: linear-gradient(160deg, #e9c46a 0 55%, #d4a843 55%); color: #1d1606;
  box-shadow: 0 0 0 2px #fff3c4, 0 0 14px rgba(233, 196, 106, .7); }
.bg-ord.cooling { color: var(--dim); }
.bg-ord.cooling::before { content: ""; position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; translate: -50% -50%;
  border-radius: 50%; pointer-events: none;
  background: conic-gradient(#e9c46a calc(var(--cd) * 360deg), rgba(233, 196, 106, .18) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 80%, #000 83%); mask: radial-gradient(closest-side, transparent 80%, #000 83%); }
.bg-ord.cooling:disabled { opacity: 1; }
.bg-ord.cooling .bg-ord-i { opacity: .45; }
.bg-ord.dead { opacity: .35; }
.bg-ord-cd { position: absolute; top: 3px; right: 4px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 3px; border-radius: 9px;
  font-size: 12px; font-weight: 800; text-align: center; background: #0d1112; color: var(--gold); box-shadow: 0 0 0 1px rgba(233, 196, 106, .6); }
.bg-ord-cd:empty { display: none; }
.bg.bg-armed .bg-t.tgt { box-shadow: inset 0 0 0 2px var(--gold); }
.bg-pv.armed { box-shadow: 0 0 0 2px var(--gold); color: #fff1c9; }
.bg-pv .bg-pv-ord { fill: none; stroke: var(--gold); stroke-width: 2.4; }
/* order effects on a company: small symbols beside its count */
.bg-fxs { position: absolute; top: calc(7px * var(--k)); left: 0; translate: calc(-50% + 30px) 0; display: flex; gap: 1px; z-index: 2000; }
.bg-fxs:empty { display: none; }
.bg-fx1 { width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: rgba(10, 14, 14, .9); }
.bg-fx1 svg { width: 12px; height: 12px; fill: currentColor; }
.bg-fx1.taunt svg { fill: none; stroke: currentColor; stroke-width: 2.4; }
.bg-fx1.shield { color: #8fd3ff; } .bg-fx1.stun { color: #f5e16a; } .bg-fx1.burn { color: #ff8c4b; } .bg-fx1.taunt { color: #e9c46a; }
.bg-u.big .bg-fxs { top: calc(20px * var(--k)); }
.bg-u.ordered .bg-ring { opacity: 1; box-shadow: 0 0 16px var(--gold), inset 0 0 10px var(--gold); }
.bg-pop-ord svg { width: 28px; height: 28px; fill: var(--gold); stroke: #1d1606; stroke-width: 1; }
.bg-log-ord { width: 16px; height: 16px; fill: var(--gold); flex: none; }
.bg-u.dead .bg-fxs { display: none; }
