/* Levyhold battle sheet: the turn strip, the stage and its fighters, the hit feel, the skill bar and the result card.
   It loads after game.css and uses its tokens. Every timing the script plays (close-up, shake, flash, slides, the result card's
   entrance) is data/ui.yaml client's; the sheet holds layout, sizes and the CSS-only animations (the floats). */

/* ---- the battle view ------------------------------------------------------------------------------------------------------------ */
#battle { gap: var(--sp-2); position: relative; padding: var(--sp-2); container-type: size; --ring: 3px; }

/* ---- the turn strip: the centrepiece over the stage. A rail runs under the portraits; the unit acting now leads it, enlarged,
   with its name; each portrait has its turn meter under it. stage.js slides portraits to their new places when the order changes. */
.track { position: relative; display: flex; align-items: center; gap: var(--sp-3); min-height: 4.2em; padding: var(--sp-1) var(--sp-3);
  background: linear-gradient(to bottom, var(--steel-hi, var(--panel2)), var(--steel, var(--band))); border: var(--bw) solid var(--bevel-lo);
  border-radius: var(--r); }
.track-k { flex: none; font-size: var(--fs-xs); color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.btitle { flex: 0 1 auto; min-width: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; font-weight: 700; color: var(--gold); white-space: nowrap; }
/* the chapter's battle rule in one line under the turn track; the whole text on hover, focus or a long press */
.brule { margin: 0; padding: 0 var(--sp-3); font-size: var(--fs-sm); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: none; min-height: 0; }
.round { flex: none; font-size: var(--fs-sm); color: var(--dim); white-space: nowrap; padding: 0 var(--sp-2); }
.order { position: relative; list-style: none; margin: 0; padding: var(--sp-1) 0; display: flex; gap: var(--sp-2); min-height: 3.6em; align-items: center;
  overflow: hidden; flex: 1; min-width: 0; }
/* the rail the portraits ride on */
.order::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: var(--bw); background: var(--bevel-lo); pointer-events: none; }
/* a hero's face is round with its faction's edge, a foe's is square with a rust edge: the shape tells them apart, not the colour */
/* a portrait gives way (down to 1.2em) when the strip is narrower than the order, so the last ones never run off a phone screen */
.oc { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 2px; flex: 0 1 auto; min-width: 1.2em; }
.oc-face { position: relative; width: clamp(2.6em, 5.5cqh, 4.4em); max-width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm);
  border: var(--bw) solid var(--line); background: var(--panel2); overflow: hidden; }
.oc-face .spr { width: 100%; height: 100%; object-fit: cover; }
.oc.ally .oc-face { border-color: var(--co-wardens); border-radius: 50%; }
.oc.enemy .oc-face { border-color: var(--foe); border-radius: 0; border-width: 3px; }
.oc-m { width: 100%; height: 4px; }
.oc-m::-webkit-progress-value { background: var(--meter); }
.oc-m::-moz-progress-bar { background: var(--meter); }
.oc-name { display: none; }
/* the unit acting now: first and bigger, on a gold plate cut at an angle, its name beside the face */
.oc.now { grid-template-columns: auto minmax(0, auto); grid-template-rows: auto auto; align-items: center; justify-items: start; column-gap: var(--sp-2);
  flex: 0 0 auto; padding: 2px var(--sp-4) 2px 2px; margin-right: var(--sp-3); background: var(--gold); color: var(--gold-ink);
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.7em) 100%, 0 100%); }
.oc.now .oc-face { grid-row: 1 / span 2; width: clamp(3.4em, 7.5cqh, 6em); border-color: var(--gold-ink); }
.oc.now .oc-name { display: block; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; font-size: var(--fs-lg); }
.oc.now .oc-m { grid-column: 2; width: 100%; }
.oc.now.enemy { background: var(--foe); color: var(--chip-ink, var(--gold-ink)); }

/* ---- the stage: the chapter's ground, the fighters big on it ------------------------------------------------------------------- */
.stage { flex: 1 1 0; min-height: 0; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr); gap: clamp(12px, 4vw, 96px); align-items: stretch; padding: var(--sp-1) clamp(4px, 3vw, 64px) var(--sp-1);
  container-type: size; border: var(--bw) solid var(--bevel-lo); overflow: hidden; width: 100%; max-width: 200cqh; align-self: center;
  background:
    linear-gradient(to top, var(--bd-near), transparent) left 0 bottom 0 / 100% 6% no-repeat,
    linear-gradient(to bottom, var(--bd-fog), transparent) left 0 bottom 0 / 100% var(--floor) no-repeat,
    radial-gradient(ellipse 50% 100% at 50% 100%, var(--bd-far) 0 98%, transparent 100%) left -10% bottom var(--floor) / 45% 9% repeat-x,
    radial-gradient(ellipse 50% 100% at 50% 100%, var(--bd-far) 0 98%, transparent 100%) left 12% bottom var(--floor) / 30% 6% repeat-x,
    var(--ground) left 0 bottom 0 / calc(var(--px) * 32) var(--floor) repeat-x,
    linear-gradient(to bottom, var(--sky-top), var(--sky-low));
  image-rendering: pixelated; --floor: 88%; }
/* the floor tile covers all but a thin band of sky, so a back-row hero stands on the same ground as the front row */
.stage::before { content: ""; position: absolute; inset: auto 0 var(--floor) 0; height: var(--bw); background: var(--bevel-lo); pointer-events: none; }
/* a dark edge round the ground draws the eye to the middle (Darkest Dungeon's lantern light) */
/* a chapter rule's ambient strip (stage.js ruleFx): behind the fighters, from the stage's foot up, never past the horizon */
.brule-fx { position: absolute; left: 0; right: 0; bottom: 0; max-height: var(--floor); pointer-events: none; background-repeat: repeat;
  background-position: 0 100%; image-rendering: pixelated; z-index: 0; }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 6em var(--bd-near); }
:root[data-theme="light"] .stage { border-color: var(--line); }
:root[data-theme="light"] .stage::after { box-shadow: none; }
/* each side has as many rows as it needs (two units a row, set as data-rows): a unit shrinks to its row, so five enemies fit */
.side { position: relative; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr);
  gap: var(--sp-1) clamp(6px, 2vw, 32px); align-content: stretch; justify-items: center; align-items: end; }
.side[data-rows="2"] { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.side[data-rows="3"] { grid-template-rows: repeat(3, minmax(0, 1fr)); }
/* a side with fewer fighters than the other stands in its bottom rows, on the ground, not in the air */
.side[data-rows="2"][data-own="1"] > *, .side[data-rows="2"][data-own="2"] > * { grid-row: 2; }
.side[data-rows="3"][data-own="1"] > *, .side[data-rows="3"][data-own="2"] > * { grid-row: 3; }
.side[data-rows="3"][data-own="3"] > *:nth-child(-n+2), .side[data-rows="3"][data-own="4"] > *:nth-child(-n+2) { grid-row: 2; }
.side[data-rows="3"][data-own="3"] > *:nth-child(n+3), .side[data-rows="3"][data-own="4"] > *:nth-child(n+3) { grid-row: 3; }
.side[data-count="1"] { --cols: 1; } .side[data-count="2"] { --cols: 2; } .side[data-count="3"] { --cols: 3; }
.side[data-count="4"] { --cols: 4; } .side[data-count="5"] { --cols: 5; }
/* the front rank stands a step nearer the middle */
.side.ally > .unit:nth-child(even) { justify-self: end; }
.side.enemy > .unit:nth-child(odd) { justify-self: start; }
/* ---- a fighter: the art with the effect pills at its feet, then a foe's intent, then a slim band of name, HP and bars ---------- */
/* no box round a fighter: the art stands free on the ground; a ring at its feet marks the one acting and the ones a skill can reach */
.unit { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) var(--ih) auto auto; grid-template-columns: minmax(0, 1fr);
  justify-items: center; align-content: end; gap: 1px; width: 100%; max-width: 20em; height: 100%; min-height: var(--tap);
  padding: 0 var(--sp-1) 2px; background: transparent; border: var(--bw) solid transparent; border-radius: var(--r); cursor: pointer;
  --ih: calc(var(--fs-xs) * 2.4 + var(--bw) * 2 + var(--ring)); }
/* every fighter keeps the intent's room under its feet, a hero too and a foe with nothing planned, so both sides stand on one
   ground line (#395); the tag sits at the top of that room, right under the feet */
.unit > .intent { align-self: start; max-height: calc(var(--ih) - var(--ring)); overflow: hidden; }
/* and every plate is two lines high, its words at the foot: a long name that wraps its HP to a second line ("Reed Cutter") no longer
   lifts its fighter over a short one ("Mudling") */
.unit > .plate { line-height: 1.25; min-height: calc(var(--fs-xs) * 2.5 + 1px); align-content: flex-end; }
.unit > .fig { grid-area: 1 / 1; align-self: end; }     /* its foot on the plate, so the room above it is the whole row */
.unit > .sts { grid-area: 1 / 1; align-self: end; }
.unit > .intent { grid-area: 2 / 1; }
.unit > .plate { grid-area: 3 / 1; }
.unit > .bars { grid-area: 4 / 1; }
/* one rank a side (stage.js sets data-rows 1 while the bigger side has at most ui.client stage_rank_max fighters): a column each,
   the front pair nearest the middle (a hero's slots 2 and 4 on the right, a foe's 1 and 3 on the left), every fighter the stage's
   full height. A phone and a short screen keep their own row and order (below). */
.side[data-rows="1"] { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); column-gap: var(--sp-1); }
@media (min-width: 901px) {
  .side[data-rows="1"] > .unit:nth-child(even) { order: 1; }
  .side[data-rows="1"] > .unit { justify-self: center; }
  /* a fighter in a rank of four or five is narrow: the intent's icon and hit number on top, the line under them, so the number is never cut */
  .side[data-rows="1"][data-count="3"] .intent, .side[data-rows="1"][data-count="4"] .intent, .side[data-rows="1"][data-count="5"] .intent { flex-wrap: wrap; justify-content: center; row-gap: 0; text-align: center; }
  .side[data-rows="1"][data-count="3"] .intent-n, .side[data-rows="1"][data-count="4"] .intent-n, .side[data-rows="1"][data-count="5"] .intent-n { display: inline; }
  .side[data-rows="1"][data-count="3"] .intent-line, .side[data-rows="1"][data-count="4"] .intent-line, .side[data-rows="1"][data-count="5"] .intent-line { flex: 1 1 100%; }
  /* the room under the feet then holds the icon's line and two lines of words, on both sides */
  .stage:has(.side[data-rows="1"][data-count="3"], .side[data-rows="1"][data-count="4"], .side[data-rows="1"][data-count="5"]) .unit {
    --ih: calc(20px + var(--fs-xs) * 2.4 + var(--bw) * 2 + var(--ring)); }
}

/* the plate, the bars and the effect pills sit over the art, which may spill into them */
.unit > .plate, .unit > .bars, .unit > .sts { position: relative; z-index: 1; }
/* the low HUD: one thin line of name and HP, then the bars, on a dark band that fades out at its ends */
.plate { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 var(--sp-1); padding: 1px var(--sp-2) 0;
  background: linear-gradient(to right, transparent, var(--plate) 12%, var(--plate) 88%, transparent); color: var(--plate-ink); }
.unit .bars { padding: 0 var(--sp-2) 2px; background: linear-gradient(to right, transparent, var(--plate) 12%, var(--plate) 88%, transparent); }
.hpn { font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hp-max { opacity: 0.75; font-weight: 600; }
.uname { font-size: var(--fs-xs); font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the one acting: a gold line over its plate, its name in gold, and a gold ring on the ground at its feet */
.unit.acting .plate { color: var(--plate-hi); box-shadow: inset 0 var(--ring) 0 var(--gold); }
/* targets: a solid ring on the ground under the fighter, red under a foe, green under an ally a heal or buff can reach; the ring
   is there only for a target or the one acting, so its shape says it without the colour. A pointer over it thickens the ring. */
.unit.targetable .fig::before, .unit.acting .fig::before { background: transparent; border: var(--ring) solid var(--gold);
  box-shadow: 0 0 0 var(--bw) var(--spr-dark), inset 0 0 0 var(--bw) var(--spr-dark); }
.unit.enemy.targetable .fig::before { border-color: var(--bad); }
.unit.ally.targetable .fig::before { border-color: var(--good); }
.unit.targetable:hover .fig::before, .unit.targetable:focus-visible .fig::before { border-width: calc(var(--ring) * 2); }
/* a downed unit stays in its slot, greyed: the player sees who fell */
.unit.down .fig { filter: grayscale(1); opacity: 0.6; }
.unit.down .uname, .unit.down .bars, .unit.down .plate { opacity: 0.6; }
.st.downed { border: var(--bw) solid var(--line); color: var(--dim); }
.bars { display: grid; gap: 1px; width: 100%; }
.bar { height: 7px; }
.bar.hp::-webkit-progress-value { background: var(--hp); }
.bar.hp::-moz-progress-bar { background: var(--hp); }
.bar.sh { height: 3px; }
.bar.sh::-webkit-progress-value { background: var(--shield); }
.bar.sh::-moz-progress-bar { background: var(--shield); }
.bar.tm { height: 3px; }
.bar.tm::-webkit-progress-value { background: var(--meter); }
.bar.tm::-moz-progress-bar { background: var(--meter); }
.sts { display: flex; flex-wrap: wrap; gap: 2px; min-height: 1.4em; justify-content: center; max-width: 100%; }
/* an effect: a small square icon (WoW's buff row) with the turns left in its corner; a pill of words for Down, Revived and "+N" */
.st { position: relative; font-size: var(--fs-xs); font-weight: 800; padding: 1px var(--sp-1); line-height: 1.4; display: inline-flex; gap: 3px; align-items: center;
  background: var(--panel); color: var(--ink); white-space: nowrap; flex: none; max-width: 100%; }
.st.buff, .st.debuff { --st: clamp(18px, 5cqh, 40px); width: var(--st); height: var(--st); padding: 0; justify-content: center; background: var(--plate);
  color: var(--plate-ink); box-shadow: 0 0 0 1px var(--spr-dark); overflow: hidden; }
.st-ico { width: 100%; height: 100%; image-rendering: pixelated; object-fit: cover; }
.st-txt { font-size: 0.7em; line-height: 1; overflow: hidden; }
/* the turns left, bottom right; a stack count, top left; both outlined so they read on any icon */
.st-n, .st-x { position: absolute; line-height: 1; font-weight: 900; color: var(--plate-ink); -webkit-text-stroke: 3px var(--spr-dark); paint-order: stroke fill; }
.st-n { right: 0; bottom: 0; font-size: max(var(--fs-xs), calc(var(--st, 18px) * 0.5)); }
.st-x { left: 0; top: 0; font-size: var(--fs-xs); }
/* brought back by a revive this battle (until its next turn): a solid good edge and the word; the rest pill says how many are hidden */
.st.revived { border: var(--bw) solid var(--good); border-radius: var(--r); }
.st.more { border: var(--bw) solid var(--line); border-radius: var(--r); }
/* a buff (it helps) has a solid gold edge, a debuff (it harms) a dashed red one: the edge's line tells them apart without the colour */
.st.buff { border: var(--bw) solid var(--gold); border-radius: var(--r); }
.st.debuff { border: var(--bw) dashed var(--bad); border-radius: 0; }
.st .ico-sm { width: 12px; height: 12px; }
/* the intent: a dark tag just over the foe's HP plate, under its feet and never over the art: the action's icon and one short
   line ("Will hit Bram Hollis for 12"). It keeps its room while a turn plays (the line would be about the turn after), so nothing
   jumps when it comes back. */
.intent { display: flex; align-items: center; gap: var(--sp-1); max-width: 100%; min-width: 0; padding: 0 var(--sp-2) 0 2px; margin-top: var(--ring);
  background: var(--plate); color: var(--plate-ink); border: var(--bw) solid var(--foe); border-radius: var(--r); font-size: var(--fs-xs); font-weight: 700;
  line-height: 1.2; z-index: 1; }
.intent[hidden] { display: none; }
#battle[data-busy="1"] .intent { visibility: hidden; }
/* the art index's intent icons are 96 px framed squares: drawn at a quarter (24 px), a third (32 px) on big screens */
.intent-ico { flex: none; width: 20px; height: 20px; image-rendering: pixelated; }
@media (min-width: 2200px) { .intent-ico { width: 32px; height: 32px; } }
.intent-glyph { display: grid; place-items: center; font-size: var(--fs-sm); color: var(--bad); line-height: 1; }
.intent-n { display: none; font-weight: 900; font-size: var(--fs-sm); color: var(--bad); }
.intent-line { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.unit[data-intent="attack"] .intent, .unit[data-intent="aoe"] .intent { border-color: var(--bad); }
.unit[data-intent="stun"] .intent, .unit[data-intent="debuff"] .intent { border-style: dashed; border-color: var(--debuff); }
.unit[data-intent="shield"] .intent, .unit[data-intent="buff"] .intent, .unit[data-intent="heal"] .intent { border-color: var(--buff); border-radius: var(--r-pill); }

/* the figure: its slot rounded to 16 px, the step both art sizes (48 px heroes, 32 px foes) share; stage.js draws each sprite at
   the whole multiple of its own size nearest the fig, so the pixels stay square */
.fig { height: max(var(--sprite), round(down, 100%, var(--sprite-step))); max-height: calc(var(--sprite) * 8); min-height: 0; min-width: 0; aspect-ratio: 1;
  max-width: 100%; display: grid; place-items: end center; border-radius: 45% 45% 12% 12%; border: var(--bw) solid var(--line);
  color: var(--chip-ink); font-weight: 800; position: relative; }
.fig:has(.spr) { background: transparent; border-width: 0; }     /* the art gets the whole box, so it can draw at the next multiple */
/* the ground under the art: a soft shadow, and the ring when the fighter is a target or acting */
.fig::before { content: ""; position: absolute; left: 50%; bottom: 0; width: min(70%, 9em); height: min(14%, 1.6em); transform: translate(-50%, 40%);
  border-radius: 50%; background: var(--bevel-lo); pointer-events: none; }
.fig:not(:has(.spr))::before { display: none; }
.unit.targetable .fig::before, .unit.acting .fig::before { display: block; }
.fig.co-chapel { color: var(--chapel-ink); }
.ini { padding-bottom: 18%; font-size: var(--fs-lg); }
.spr { image-rendering: pixelated; }
/* a fighter: stage.js sets its width and height to a whole multiple of the sprite's own size (48 px heroes, 32 px foes) that fits the
   fig. The box is a zero-width spine at the fig's foot, out of the flow: the art hangs centred on it, so the art's clear canvas
   margins never count as spilling out of the stage, and the float lane rides at the art's head height. */
.sprbox { position: absolute; left: 50%; bottom: 0; width: 0; display: block; line-height: 0; }
.sprbox > .spr { display: block; position: relative; transform: translateX(-50%);
  filter: drop-shadow(1px 0 0 var(--spr-edge)) drop-shadow(-1px 0 0 var(--spr-edge)) drop-shadow(0 -1px 0 var(--spr-edge)); }
.sprbox > .ini { display: block; line-height: 1.35; width: max-content; transform: translateX(-50%); }
/* a foe gets a full light rim and a dark one outside it, so grey and near-black art (trolls, wights) reads on any ground */
.unit.enemy .sprbox > .spr { filter: drop-shadow(1px 0 0 var(--foe-rim)) drop-shadow(-1px 0 0 var(--foe-rim)) drop-shadow(0 1px 0 var(--foe-rim))
  drop-shadow(0 -1px 0 var(--foe-rim)) drop-shadow(1px 0 0 var(--spr-dark)) drop-shadow(-1px 0 0 var(--spr-dark)) drop-shadow(0 -1px 0 var(--spr-dark)); }
.unit.enemy .fig { border-radius: 45% 45% 12% 12%; }

/* ---- numbers and words over a fighter ----------------------------------------------------------------------------------------- */
/* the float lane starts over the fighter's head (the top of its art's canvas): numbers and words rise over the unit they name,
   clear of its face (#395), and never cover the pills under the figure */
.floats { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); z-index: var(--z-label); width: max-content; height: 1.4em;
  display: grid; justify-items: center; align-items: end; pointer-events: none; line-height: 1.2; }
/* a number is heavy, outlined in dark (--float-ol a side: the stroke is drawn under the fill, so it is twice that wide) and drawn
   big: the stage's height sets it (ui.client float_*, written by stage.js as --dmg-fs and --crit-fs), so a 4K stage gets 4K numbers */
.float { grid-area: 1 / 1; font-weight: 900; font-size: var(--dmg-fs, max(var(--fs-xl), 5.5cqh)); white-space: nowrap; line-height: 1;
  -webkit-text-stroke: calc(var(--float-ol, var(--bw)) * 2) var(--spr-dark); paint-order: stroke fill;
  text-shadow: 0 var(--float-ol, var(--bw)) 0 var(--spr-dark); animation: rise calc(var(--evt) * 2) ease-out forwards; }
.float.dmg { color: var(--bad); animation-name: pop; }
.float.crit { font-size: var(--crit-fs, max(var(--fs-2xl), 9cqh)); color: var(--gold); }
.float.heal { color: var(--good); animation-name: pop; }
.float.buff, .float.debuff, .float.note { font-size: max(var(--fs-sm), 2.6cqh); -webkit-text-stroke: var(--bw) var(--bg); }
.float.buff { color: var(--buff); }
.float.debuff { color: var(--debuff); }
.float.note { color: var(--ink); }
.float.revive { font-size: max(var(--fs-xl), 4cqh); }
/* "Crit" over the number: a small word, so the number is still the loudest thing */
.float-lead { display: block; font-size: 0.42em; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; }
/* one lane per fighter: the newest float stays at the foot of the lane and the ones before it stand a hit number's height higher
   each, measured in the number's size (--dmg-fs), so a small status word over a big number never lands on it */
.floats .float:nth-last-child(2) { margin-bottom: calc(var(--dmg-fs, 1em) * 1.1); }
.floats .float:nth-last-child(n+3) { margin-bottom: calc(var(--dmg-fs, 1em) * 2.2); }
@keyframes rise { from { transform: translateY(0.3em); opacity: 1; } 70% { opacity: 1; } to { transform: translateY(-0.6em); opacity: 0; } }
/* a hit's number lands big and settles, then rises and fades */
@keyframes pop { from { transform: scale(1.7); opacity: 1; } 14% { transform: scale(0.95); } 22% { transform: scale(1); } 70% { opacity: 1; }
  to { transform: translateY(-0.5em); opacity: 0; } }
/* the crit burst at the fighter's middle: the art index's strip when it has one, else a gold star of light drawn here */
.fx-burst { position: absolute; left: 0; bottom: 30%; width: clamp(48px, 16cqh, 192px); aspect-ratio: 1; transform: translateX(-50%); pointer-events: none;
  z-index: var(--z-label); overflow: hidden; line-height: 0;
  background: radial-gradient(circle, var(--plate-ink) 0 10%, var(--gold) 12% 26%, transparent 28%),
    conic-gradient(from 0deg, transparent 0 4%, var(--gold) 5% 7%, transparent 8% 29%, var(--gold) 30% 32%, transparent 33% 54%, var(--gold) 55% 57%,
      transparent 58% 79%, var(--gold) 80% 82%, transparent 83%);
  -webkit-mask: radial-gradient(circle, #000 0 48%, transparent 70%); mask: radial-gradient(circle, #000 0 48%, transparent 70%); }
.fx-burst.has-art { background: none; -webkit-mask: none; mask: none; }
.fx-strip { display: block; height: 100%; width: auto; max-width: none; image-rendering: pixelated; }
.fx-burst:not(.has-art) .fx-strip { visibility: hidden; }

.btip { position: absolute; left: 50%; top: var(--sp-2); transform: translateX(-50%); width: max-content; max-width: min(36em, 60%); z-index: var(--z-tip);
  margin: 0; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); background: var(--panel); border: var(--bw) solid var(--line); border-radius: var(--r);
  box-shadow: 0 var(--bw) 0 var(--bevel-lo); pointer-events: none; }
.btip.at-bar { top: auto; bottom: var(--sp-2); }
/* with motion on, stage.js plays the lean, the knock, the flash and the shake; these two classes are the reduced-motion stand-ins */
.lunge { outline: 3px solid var(--gold); outline-offset: -3px; }
/* a boss winding up its big blow: a red pulse round the fighter until it lets loose or is broken (statuses.yaml battle.windup_*) */
.unit.winding .fig { box-shadow: 0 0 0 2px var(--bad), 0 0 1.2em var(--bad); animation: windPulse 0.9s ease-in-out infinite alternate; }
@keyframes windPulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { .unit.winding .fig { animation: none; } }
.struck { outline: 3px solid var(--bad); outline-offset: -3px; }
#battle[data-speed="2"] { --evt: 210ms; }
#battle[data-speed="3"] { --evt: 140ms; }

/* the unit card: who a tapped or acting unit is, in numbers, over the stage's top corner */
.inspect { position: absolute; top: var(--sp-2); right: var(--sp-2); z-index: var(--z-tip); width: min(22em, 46%); max-height: calc(100% - var(--sp-4));
  padding: var(--sp-2) var(--sp-3); display: grid; gap: var(--sp-1); align-content: start; font-size: var(--fs-sm); overflow: hidden; }
.inspect:empty { display: none; }
.info { display: grid; gap: var(--sp-2); align-content: start; }
.info h3 { margin: 0; font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--sp-2); }
.effects { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-1); font-size: var(--fs-xs); }
.effects li { padding: var(--sp-1) var(--sp-2); }
.effects li.buff { border: 1px solid var(--buff); border-radius: var(--r-pill); }
.effects li.debuff { border: 1px dashed var(--debuff); border-radius: 0; }

/* ---- the action bar (WoW): the skills as square icon buttons in one framed bar, the key in each corner, a cooldown sweep, a gold edge
   on the chosen one, a grey wash when it cannot be used; Auto, speed and Retreat at the bar's right in the same steel ------------ */
.skillbar { --face: clamp(48px, 7.5cqh, 76px); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; justify-content: center;
  padding: var(--sp-1) var(--sp-2); background: linear-gradient(to bottom, var(--steel-hi), var(--steel)); background-clip: padding-box;
  border: calc(var(--px) * 3) solid var(--line); border-image: var(--frame-tile) 6 / calc(var(--px) * 3) stretch;
  box-shadow: inset 0 1px 0 var(--bevel-hi), inset 0 -2px 0 var(--bevel-lo); }
.utils { display: flex; gap: var(--sp-1); align-items: center; flex-wrap: wrap; justify-content: flex-end; padding-left: var(--sp-3); align-self: center; }
#auto { display: inline-flex; align-items: center; gap: var(--sp-2); background: transparent; border: var(--bw) dashed var(--line); box-shadow: none; }
#auto.on { background: var(--gold); color: var(--gold-ink); border: var(--bw) solid var(--gold); font-weight: 800; }
/* Retreat is the red danger button (frame.css .btn-stop); armed (the second press sends it), a light edge round it and the words ask */
#retreat[aria-pressed="true"] { box-shadow: inset 0 0 0 var(--bw) var(--stop-rim, var(--bad)), 0 0 0 var(--bw) var(--stop-rim, var(--bad)); }
.skills { display: flex; gap: var(--sp-2); flex: 1 1 auto; min-width: 0; justify-content: center; align-items: flex-end; }
.skill { position: relative; flex: none; width: calc(var(--face) + var(--sp-5)); display: grid; justify-items: center; gap: 2px; padding: 0;
  background: none; border: 0; box-shadow: none; min-height: 0; color: var(--ink); }
.skill:hover:not(:disabled) .sk-face { box-shadow: 0 0 0 var(--bw) var(--plate-hi), inset 0 0 0 var(--bw) var(--bevel-lo); }
.sk-face { position: relative; display: grid; place-items: center; width: var(--face); aspect-ratio: 1; overflow: hidden; background: var(--plate);
  border: calc(var(--bw) + 1px) solid var(--steel-rim); border-radius: 4px; box-shadow: inset 0 0 0 var(--bw) var(--bevel-lo); }
.sk-ico { width: 100%; height: 100%; image-rendering: pixelated; object-fit: cover; }
/* the chosen skill: a gold edge, thicker, with a gold glow inside */
.skill[aria-pressed="true"] { background: none; color: var(--ink); box-shadow: none; border: 0; }
.skill[aria-pressed="true"] .sk-face { border-color: var(--gold); box-shadow: 0 0 0 var(--bw) var(--gold), inset 0 0 0.6em var(--gold); }
.skill[aria-pressed="true"] .sk-name { color: var(--gold); }
/* the key, top left of the face */
.sk-face .sk-key { position: absolute; left: 1px; top: 1px; z-index: 3; min-width: 1.3em; }
/* cannot be used: a grey wash over the icon */
.skill:disabled { opacity: 1; cursor: not-allowed; }
.skill:disabled .sk-ico { filter: grayscale(1) brightness(0.6); }
.skill:disabled .sk-name { color: var(--dim); }
/* cooling down: a dark sweep over the part still to run (stage.js writes --sweep for each step), and the turns left over it */
.sk-sweep { position: absolute; inset: 0; z-index: 1; background: conic-gradient(var(--plate) 0 var(--sweep, 100%), transparent var(--sweep, 100%) 100%); }
.sk-cd { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; color: var(--plate-ink); font-weight: 900;
  font-size: calc(var(--face) * 0.42); -webkit-text-stroke: 4px var(--spr-dark); paint-order: stroke fill; }
/* a long skill name takes a second line rather than an ellipsis ("Pike Lu...", audit 2026-11-19 #7) */
.sk-name { max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; text-align: center;
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.2; }
.sk-wait { flex: 1 1 auto; min-height: var(--face); display: flex; align-items: center; justify-content: center; padding: 0 var(--sp-3);
  color: var(--dim); border: var(--bw) dashed var(--line); border-radius: var(--r); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sk-wait:empty { visibility: hidden; }

/* ---- unit frames (WoW): a row over the stage, the heroes' frames at its left, the target frame at its right ---------------------- */
.uframes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14em, 24em); gap: var(--sp-3); align-items: stretch; flex: none; }
.party { display: grid; grid-template-columns: repeat(4, minmax(0, 15em)); gap: var(--sp-2); min-width: 0; }
.uf { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: var(--sp-2); row-gap: 2px;
  align-items: center; min-width: 0; min-height: var(--tap); padding: 3px var(--sp-2) 3px 3px; text-align: left; color: var(--ink); cursor: pointer;
  background: linear-gradient(to bottom, var(--panel2), var(--band)); border: var(--bw) solid var(--bevel-lo); border-radius: 2em var(--r) var(--r) 2em;
  box-shadow: inset 0 1px 0 var(--bevel-hi); }
.uf-face { grid-row: 1 / span 3; position: relative; width: clamp(32px, 4.5cqh, 40px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  border: var(--bw) solid var(--steel-rim); background: var(--plate); font-size: var(--fs-xs); font-weight: 800; }
.uf-face > .spr { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; image-rendering: pixelated; }
/* the level: a round badge on the face's lower edge */
.uf-lv { position: absolute; right: -4px; bottom: -4px; min-width: 1.6em; padding: 0 2px; text-align: center; border-radius: 1em; font-size: var(--fs-xs); line-height: 1.3;
  font-weight: 900; background: var(--band); color: var(--gold); border: 1px solid var(--gold); }
.uf-lv[hidden] { display: none; }
.uf-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); font-weight: 800; }
.uf-hp { position: relative; display: grid; min-width: 0; font-size: var(--fs-xs); }
.uf-bar, .uf-tm { width: 100%; display: block; }
.uf-bar { height: 1.35em; border: 1px solid var(--spr-dark); }
.uf-bar::-webkit-progress-bar { background: var(--track); }
.uf-bar::-webkit-progress-value { background: var(--hp); }
.uf-bar::-moz-progress-bar { background: var(--hp); }
.uf.low .uf-bar::-webkit-progress-value { background: var(--bad); }
.uf.low .uf-bar::-moz-progress-bar { background: var(--bad); }
/* the numbers ride on the bar, in the middle, outlined */
.uf-hpt { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 900; line-height: 1; color: var(--plate-ink);
  -webkit-text-stroke: 3px var(--spr-dark); paint-order: stroke fill; white-space: nowrap; }
.uf-tm { height: 3px; }
.uf-tm::-webkit-progress-value { background: var(--meter); }
.uf-tm::-moz-progress-bar { background: var(--meter); }
/* the hero whose turn it is: a gold edge and name; a hero a heal can reach: a green edge; low HP: a red edge; one down: grey */
.uf.acting { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.uf.acting .uf-name { color: var(--gold); }
.uf.targetable { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.uf.low { border-color: var(--bad); }
.uf.down { filter: grayscale(1); opacity: 0.6; }
.uf:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
/* the target frame: a foe's square face with a rust edge (a hero's is round), the Tab chip, its effects and its intent */
.tframe { min-width: 0; display: grid; }
.tframe[hidden] { display: none; }
.uf.tf { grid-template-rows: auto auto auto auto; border-radius: var(--r) 2em 2em var(--r); }
.uf.tf.enemy { border-color: var(--foe); }
.uf.tf.enemy .uf-face { border-radius: 4px; border-color: var(--foe); }
.uf.tf.enemy .uf-face > .spr { border-radius: 2px; }
.uf.tf.enemy.targetable { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.uf.tf .uf-face { grid-row: 1 / span 4; }
.tf-head { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.tf-head .uf-name { flex: 1 1 auto; }
.tf-key { flex: none; }
.tf-sts { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; }
.tf-sts:empty, .tf-intent[hidden] { display: none; }
.tf-sts .st.buff, .tf-sts .st.debuff { --st: 18px; }
.tf-intent { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); font-weight: 700; color: var(--bad); }
/* Wide screens: the intent line sits beside the HP bar and the effects beside the name, so the frames row stays two lines high and
   the stage keeps its height (the four-line target frame cost the fighters a whole pixel multiple at 1366x768). */
@media (min-width: 901px) {
  .uf.tf { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto; }
  .uf.tf .uf-face { grid-row: 1 / span 2; }
  .uf.tf .tf-head { grid-column: 2; grid-row: 1; }
  .uf.tf .tf-sts { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  .uf.tf .uf-hp { grid-column: 2; grid-row: 2; }
  .uf.tf .tf-intent { grid-column: 3; grid-row: 2; }
  /* the target frame takes at most 40% of the row, so four hero frames keep their names at 1024 px ("Bram ...", audit 2026-11-19 #7) */
  .uframes { align-items: start; grid-template-columns: minmax(0, 1fr) minmax(16em, min(32em, 40%)); }
  .skill { width: calc(var(--face) * 2); }          /* the full name under the face: the wide bar has the room */
}
/* the fighter the target frame shows: a gold line under its plate, so the eye finds it on the stage */
.unit.tgt .plate { box-shadow: inset 0 calc(var(--ring) * -1) 0 var(--gold); }
.unit.acting.tgt .plate { box-shadow: inset 0 var(--ring) 0 var(--gold), inset 0 calc(var(--ring) * -1) 0 var(--gold); }

/* ---- the result: a framed card over the stage; the stage behind it is inert while it shows --------------------------------------- */
.endpanel { position: absolute; inset: 12% max(6%, calc(50% - 16em)) auto; z-index: var(--z-modal); padding: var(--pad) calc(var(--pad) * 1.5);
  display: grid; gap: var(--gap); box-shadow: 0 0 0 100vmax var(--veil); }
.endpanel.lost h3 { color: var(--bad); }
.endpanel h3 { margin: 0; font-size: var(--fs-2xl); color: var(--gold); text-align: center; letter-spacing: 0.04em; }
/* a win: the title on a banner cut at both ends, bigger and spaced out */
.endpanel.victory h3 { justify-self: center; padding: var(--sp-1) var(--sp-6, 2em); font-size: max(var(--fs-2xl), 2.2em);
  letter-spacing: 0.1em; background: var(--banner, var(--foe)); color: var(--banner-ink, var(--gold)); border-top: var(--bw) solid var(--gold);
  border-bottom: var(--bw) solid var(--gold); clip-path: polygon(0 0, 100% 0, calc(100% - 0.6em) 50%, 100% 100%, 0 100%, 0.6em 50%); }
.endpanel .kv li.note { justify-content: flex-start; border-bottom: none; }
.endpanel .kv li.first, .endpanel .kv li.joined, .endpanel .kv li.up .num { color: var(--gold); font-weight: 800; }
.endpanel .kv li.joined { align-items: center; gap: var(--sp-3); }
.endpanel .kv li.hint { color: var(--ink); }
.endpanel .kv li span:first-child { display: inline-flex; align-items: center; gap: var(--sp-2); }
/* a hero's row: the face, the name, the XP; a level gained in gold */
.rw-face { flex: none; width: 2em; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border-radius: 50%; border: var(--bw) solid var(--line);
  background: var(--panel2); font-size: var(--fs-xs); font-weight: 800; }
.rw-face .spr { width: 100%; height: 100%; object-fit: cover; }
.endpanel .kv li.up .rw-face { border-color: var(--gold); }
/* a level gained: a chip by the hero's name, gold with a solid edge */
.lv-chip { padding: 0 var(--sp-2); border: var(--bw) solid var(--gold); border-radius: var(--r-pill); background: var(--gold); color: var(--gold-ink);
  font-size: var(--fs-xs); font-weight: 800; line-height: 1.5; white-space: nowrap; }
/* a piece found: its set's or slot's icon before the words */
.endpanel .kv li.gear { align-items: center; gap: var(--sp-2); }
.rw-gear { flex: none; width: 2em; height: 2em; image-rendering: pixelated; }
#end-ok { justify-self: center; min-width: 10em; }
/* what the win paid, as a row of slots: icon, count in the corner, the word under it; a piece of gear in its quality's colour and word */
.endpanel .kv li.rw-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2); border-bottom: none; padding-bottom: var(--sp-2); }
.endpanel .kv .rw-slot { display: grid; justify-items: center; align-content: start; gap: 2px; width: 6.2em; text-align: center; --qc: var(--line); }
.endpanel .kv .rw-slot[data-q="common"] { --qc: var(--q-common, var(--ink)); }
.endpanel .kv .rw-slot[data-q="fine"] { --qc: var(--q-fine, var(--good)); }
.endpanel .kv .rw-slot[data-q="rare"] { --qc: var(--q-rare, var(--buff)); }
.endpanel .kv .rw-slot[data-q="heroic"] { --qc: var(--q-heroic, var(--gold)); }
.endpanel .kv .rw-slot-face { --slot: 3.2em; display: grid; }
.endpanel .kv .rw-slot-face .ico-sm { width: 60%; height: 60%; }
.endpanel .kv .rw-slot-face .rw-face { width: 72%; }
.endpanel .kv .rw-slot-face .rw-gear { width: 80%; height: 80%; }
.endpanel .kv .rw-slot-face .slot-badge { font-size: var(--fs-sm); font-weight: 900; }
.endpanel .kv .rw-cap { font-size: var(--fs-xs); line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; }
.endpanel .kv .rw-slot[data-q] .rw-cap { color: var(--qc); font-weight: 800; }
.endpanel .kv .rw-q { font-size: var(--fs-xs); color: var(--qc); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }
.endpanel .kv li.gear[data-q="fine"] { color: var(--q-fine, var(--good)); }
.endpanel .kv li.gear[data-q="rare"] { color: var(--q-rare, var(--buff)); }
.endpanel .kv li.gear[data-q="heroic"] { color: var(--q-heroic, var(--gold)); }
/* the Daily card between battles ("Battle 2 won") over the stage, and a replay: read only, so the battle controls step aside */
.dcard { position: absolute; inset: 18% max(8%, calc(50% - 13em)) auto; z-index: var(--z-modal); padding: var(--pad);
  display: grid; gap: var(--sp-2); justify-items: center; text-align: center; background: var(--panel); border: var(--bw) solid var(--gold);
  border-radius: var(--r); box-shadow: 0 0 0 100vmax var(--veil); }
.dcard h3 { margin: 0; color: var(--gold); font-size: var(--fs-xl); }
.dcard p { margin: 0; }
#abandon[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); box-shadow: inset 0 0 0 var(--bw) var(--bad); }
#battle[data-watch="1"] #auto, #battle[data-watch="1"] #retreat, #battle[data-watch="1"] #abandon { display: none; }
.endpanel .kv li.walled { flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* ---- phone: the stage stacks foes over heroes, each side one row ----------------------------------------------------------------- */
@media (max-width: 900px) {
  /* pills: one line, at most --pills of them (stage.js turns the rest into one "+N" pill), each cut short rather than wrapped */
  .stage { --pills: 3; }
  .sts { flex-wrap: nowrap; overflow: hidden; max-width: 100%; }
  .st { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; gap: 1px; }
  .st.buff, .st.debuff { --st: 18px; flex: none; overflow: hidden; padding: 0; }
  .st.more { flex: none; }
  /* HP now only: the bar under it shows the share of max, the unit's label and card say both numbers */
  .hp-max { display: none; }
  /* a name too long for its line breaks between syllables with a hyphen, never at any letter ("Mudlin g", audit 2026-11-19 #4) */
  .plate .uname { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: break-word;
    hyphens: auto; line-height: 1.15; }
  .side { gap: var(--sp-1); }
  .side.ally > .unit:nth-child(even), .side.enemy > .unit:nth-child(odd) { justify-self: center; }
  .track-k { display: none; }
  .track { min-height: 0; padding: var(--sp-1) var(--sp-2); }
  .order { min-height: 3em; gap: var(--sp-1); }
  .oc-face { width: 2.2em; }
  .oc.now { padding-right: var(--sp-3); margin-right: var(--sp-1); }
  .oc.now .oc-face { width: 2.8em; }
  .oc.now .oc-name { max-width: 6.5em; }
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); padding: var(--sp-1); }
  .stage .side.enemy { grid-row: 1; }
  .stage .side.ally { grid-row: 2; }
  .side, .side[data-rows="2"], .side[data-rows="3"] { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .side > *, .side[data-own] > * { grid-row: 1 !important; }
  .unit { padding: 0; grid-template-rows: minmax(0, 1fr) auto auto auto; }     /* the sides stand in rows of their own: no shared ground */
  .unit > .intent { max-height: none; }
  .unit > .plate { min-height: 0; }
  .plate { padding: 0 var(--sp-1); flex-wrap: wrap; }
  .plate .uname { flex: 1 1 100%; }
  /* a narrow foe: the icon and the hit number over the line, cut at two short lines, with no padding to spare the art's room */
  .intent { flex-wrap: wrap; justify-content: center; row-gap: 0; padding: 0 2px; text-align: center; }
  .intent-line { flex: 1 1 100%; -webkit-line-clamp: 2; line-clamp: 2; }
  .intent-n { display: inline; }
  /* the tip stands at the stage's foot, over the heroes' plates, so it never hides the foes it talks about */
  .btip, .btip.at-bar { top: auto; bottom: var(--sp-1); max-width: 92%; }
  /* the bar: the skills' faces in a row (each at least a tap wide), the names under them; the utilities on a line of their own */
  .skillbar { --face: max(var(--tap), 52px); padding: var(--sp-1); gap: var(--sp-1); }
  .skills { flex-basis: 100%; justify-content: space-evenly; }
  .skill { width: auto; flex: 1 1 0; max-width: calc(var(--face) * 2); }
  .utils { flex: 1 1 100%; justify-content: space-between; padding-left: 0; }
  .utils .key { display: none; }
  .utils { flex-wrap: nowrap; gap: 2px; }
  .utils .btn { padding: 0 var(--sp-2); min-width: var(--tap); }
  .utils .group { display: flex; gap: 2px; }
  /* the frames row: the four heroes' faces with their bars (no names: the plates on the stage carry them), the target at the right */
  .uframes { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-1); }
  .party { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .uf { column-gap: 3px; padding: 2px 3px 2px 2px; min-height: var(--tap); }
  .uf-face { width: 26px; border-width: 1px; }
  /* a hero's frame stands upright: the face, then the HP bar and the turn sliver the frame's width */
  .uf.pf .uf-name, .uf.pf .uf-hpt { display: none; }
  .uf.pf { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; justify-items: center; padding: 3px 3px 2px; border-radius: 1.2em 1.2em var(--r) var(--r); }
  .uf.pf .uf-face { grid-row: auto; }
  .uf.pf .uf-hp, .uf.pf .uf-tm { width: 100%; }
  .uf-bar { height: 8px; }
  .uf-lv { right: -6px; bottom: -6px; min-width: 1.4em; padding: 0 1px; }
  .uf.tf .uf-hp { font-size: var(--fs-xs); }
  .uf.tf .uf-bar { height: 1.35em; }
  .tf-intent, .tf-head .tf-key, .tf-sts { display: none; }
  .uf.tf { grid-template-rows: auto auto; }
  .uf.tf .uf-face { grid-row: 1 / span 2; }
  .inspect { width: auto; left: var(--sp-2); }
  .endpanel { inset: 10% 4% auto; }
  /* a titled battle (a mode, the Daily Levy) on a phone keeps the next four turns, so the title and the strip share one line */
  .track:has(.btitle:not([hidden])) .oc:nth-child(n+5) { display: none; }
  .track:has(.btitle:not([hidden])) .oc.now .oc-name { display: none; }
}
/* a foe about a hundred px wide shows its intent as the icon and hit number only (the words stay in its title, the fighter's label and
   the target frame): two lines of words under a foe a fifth of a phone wide pushed its figure off the top of the stage (audit
   2026-11-19 #4, /live at 360). The stage is the container, so the rule follows the stage's width, not the screen's. */
@container (max-width: 340px) { .side[data-count="3"] .intent-line { display: none; } .side[data-count="3"] .intent { flex-wrap: nowrap; } }
@container (max-width: 450px) { .side[data-count="4"] .intent-line { display: none; } .side[data-count="4"] .intent { flex-wrap: nowrap; } }
@container (max-width: 560px) { .side[data-count="5"] .intent-line { display: none; } .side[data-count="5"] .intent { flex-wrap: nowrap; }
  .side[data-count="5"] .plate { padding: 0 1px; } .side[data-count="5"] .plate .uname { letter-spacing: -0.02em; } }
/* a phone held upright with little height (360x640, 375x667; not 390x844, and not a tablet): the intent on the stage is its icon and hit number only, so the foes' heads
   keep their room; the target frame carries the words */
@media (max-width: 900px) and (min-aspect-ratio: 9/17) and (max-aspect-ratio: 2/3) {
  .uframes { grid-template-columns: minmax(0, 1fr); }
  .party { display: none; }
  .intent-line { display: none; }
  .st.buff, .st.debuff { --st: 14px; }
  .intent { flex-wrap: nowrap; padding: 0 var(--sp-1) 0 2px; }
  .tf-intent:not([hidden]) { display: block; }
  .uf.tf { grid-template-rows: auto auto auto; }
  .uf.tf .uf-face { grid-row: 1 / span 3; }
  .plate .uname { -webkit-line-clamp: 1; line-clamp: 1; }
}
/* short screens (landscape phones, 640x360): both sides of the battle in one row each, a slim strip */
@media (max-height: 500px) {
  .track-k { display: none; }
  #battle { gap: var(--sp-1); padding: var(--sp-1); }
  .track { min-height: 0; padding: 2px var(--sp-2); }
  .order { min-height: 0; padding: 2px 0; }
  .oc-face { width: 1.8em; }
  .oc.now .oc-face { width: 2.2em; }
  .oc-m { height: 3px; }
  .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .stage .side.enemy, .stage .side.ally { grid-row: 1; }
  .side, .side[data-rows="2"], .side[data-rows="3"] { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .side > *, .side[data-own] > * { grid-row: 1 !important; }
  .side[data-rows="1"] > .unit:nth-child(even) { order: 0; }
  .sts, .floats { min-height: 0; height: 1em; }
  /* both sides in one row again: one ground line, the intent's room one icon high */
  .unit { grid-template-rows: minmax(0, 1fr) var(--ih) auto auto; --ih: calc(max(20px, var(--fs-sm) * 1.2) + var(--bw) * 2 + var(--ring)); }
  .unit > .intent { max-height: calc(var(--ih) - var(--ring)); }
  /* a short stage has no height for a line of words under each foe: the intent is its icon and hit number (the words stay in its
     title), and the stage takes the whole width, so four or five foes keep their figures inside it (loop round 1, 844x390) */
  .intent-line { display: none; }
  .intent { flex-wrap: nowrap; }
  .stage { max-width: none; }
  .skillbar { --face: var(--tap); padding: 2px var(--sp-1); }
  .sk-name { display: none; }
  .skills { flex-basis: auto; flex: 1 1 0; }
  /* no room for a frames row on a short screen: the plates on the stage carry the names and HP */
  .uframes { display: none; }
  .utils { flex: none; }
  .plate { flex-wrap: wrap; }
  .plate .uname { flex: 1 1 100%; }
  /* the result card fits a landscape phone: a slimmer banner, small faces, the rows close together */
  .endpanel { inset: 2% max(4%, calc(50% - 16em)) auto; padding: var(--sp-1) var(--sp-3); gap: var(--sp-1); }
  .endpanel.victory h3 { font-size: var(--fs-xl); padding: 0 var(--sp-5); }
  .endpanel .kv { gap: 0; }
  .rw-face { width: 1.4em; }
}

/* ---- the field and its effects (feedback #355) -------------------------------------------------------------------------------- */
/* the area's backdrop (stage.js setBackdrop): a whole multiple of its pixels wide (--bd-w), from the foot; the sky's top and the
   field's foot are shaded so the name plates and the turn of the art read on any picture */
.stage[data-backdrop] {
  background:
    linear-gradient(to top, var(--bd-near), transparent) left 0 bottom 0 / 100% 14% no-repeat,
    linear-gradient(to bottom, var(--bd-shade), transparent 30%),
    var(--backdrop) 50% 100% / var(--bd-w, cover) auto no-repeat,
    var(--sky-low);
  --bd-shade: rgba(10, 8, 14, 0.35); }
.stage[data-backdrop]::before { display: none; }
:root[data-theme="light"] .stage[data-backdrop] { --bd-near: rgba(10, 8, 6, 0.35); --bd-shade: transparent; }
/* a hero's own attack or hit strip (stage.js heroAct) and an effect strip (playFx): one frame shown, --fr source pixels at the
   fighter's pixel multiple --m (stage.js writes both), centred on the art (--sh tall) */
.spr-anim, .fx-play { --fw: calc(var(--m, 1px) * var(--fr, 32)); }
/* an effect is never much bigger than the fighter it lands on (a 64 px slash at a big multiple would hide a 32 px foe) */
.fx-play { --fw: min(calc(var(--m, 1px) * var(--fr, 32)), calc(var(--sh, 48px) * 1.1)); }
.sprbox > .spr.off { visibility: hidden; }
.spr-anim { position: absolute; left: 0; bottom: calc((var(--sh, 48px) - var(--fw)) / 2); width: var(--fw); height: var(--fw); overflow: hidden;
  transform: translateX(-50%); pointer-events: none; }
.spr-strip { display: block; height: 100%; width: auto; max-width: none; image-rendering: pixelated;
  filter: drop-shadow(1px 0 0 var(--spr-edge)) drop-shadow(-1px 0 0 var(--spr-edge)) drop-shadow(0 -1px 0 var(--spr-edge)); }

/* an effect strip on a fighter (stage.js playFx): one frame, centred on the body */
.fx-play { position: absolute; left: 0; bottom: calc((var(--sh, 48px) - var(--fw)) / 2); width: var(--fw); height: var(--fw); overflow: hidden;
  transform: translateX(-50%); pointer-events: none; z-index: var(--z-label); line-height: 0; }
/* a heal, a shield or a level rises from the feet; a fall's dust settles at them */
.fx-play.fx-heal_glow, .fx-play.fx-level_up, .fx-play.fx-star_up, .fx-play.fx-death_puff { bottom: 0; }

/* fighters breathe: a one-pixel rise and fall at the battle's pixel size (--m), out of step with each other; a fighter down holds still */
.sprbox > .spr { animation: breathe 1.6s steps(1, end) infinite; }
.side > .unit:nth-child(2n) .sprbox > .spr { animation-delay: -0.5s; animation-duration: 1.9s; }
.side > .unit:nth-child(3n) .sprbox > .spr { animation-delay: -1.1s; }
.unit.down .sprbox > .spr { animation: none; }
@keyframes breathe { 0% { transform: translateX(-50%); } 50% { transform: translateX(-50%) translateY(calc(var(--m, 1px) * -1)); } }

/* what an effect does, on the fighter: a ring of its colour on the ground under a burning, poisoned, stunned or shielded fighter */
.unit[data-aura~="burn"] .sprbox::after, .unit[data-aura~="poison"] .sprbox::after, .unit[data-aura~="stun"] .sprbox::after,
.unit[data-aura~="shield"] .sprbox::after { content: ""; position: absolute; left: 0; bottom: 0; width: calc(var(--sw, 48px) * 0.9); height: calc(var(--sh, 48px) * 0.85);
  transform: translateX(-50%); border-radius: 45% 45% 20% 20%; pointer-events: none; mix-blend-mode: screen; opacity: 0.55;
  animation: aura 1.2s ease-in-out infinite alternate; }
.unit[data-aura~="burn"] .sprbox::after { background: radial-gradient(ellipse at 50% 100%, #ff7a2e, transparent 65%); }
.unit[data-aura~="poison"] .sprbox::after { background: radial-gradient(ellipse at 50% 100%, #7ee04a, transparent 65%); }
.unit[data-aura~="shield"] .sprbox::after { background: radial-gradient(ellipse at 50% 55%, transparent 45%, #8fc4ff 62%, transparent 72%); }
.unit[data-aura~="stun"] .sprbox::after { background: radial-gradient(ellipse at 50% 8%, #ffe066, transparent 30%); }
@keyframes aura { from { opacity: 0.35; } to { opacity: 0.7; } }
.float.level { color: var(--gold); font-size: max(var(--fs-xl), 4cqh); }

@media (prefers-reduced-motion: reduce) {
  .sprbox > .spr, .unit[data-aura] .sprbox::after { animation: none; }
}
