/* Compact diagonal overlays on wide arenas; narrow screens get their own layout.
   Actor sizes and the arena camera remain unchanged at every breakpoint. */
.battle-board { display:grid; grid-template-columns:minmax(0,1fr); min-width:0; position:relative; }
.combat-huds { display:contents; }
.battle-board .combat-huds > .hud {
  --camp-color:#388a7b;
  position:relative; inset:auto; width:auto; min-width:0;
  padding:6px 12px; display:grid; gap:4px;
  color:#283f48; background:linear-gradient(135deg,#fffdf2f5,#eee9d9f2);
  border:1px solid #d3bf96; border-left:3px solid var(--camp-color);
  border-radius:3px 12px 3px 3px; box-shadow:0 3px 9px #132b3b22;
  font:12px/1.25 'Segoe UI',system-ui,sans-serif; z-index:5;
}
.battle-board .combat-huds > .enemy-hud { --camp-color:#a3684b; grid-row:1; }
.battle-board .combat-huds > .player-hud { grid-row:3; }
.combat-huds .hud-heading { display:flex; flex-wrap:nowrap; align-items:center; gap:6px; justify-content:space-between; margin:0; min-width:0; }
.combat-huds .hud-identity { min-width:0; }
.combat-huds .hud-camp { display:none; }
.combat-huds .hud-name { gap:5px; min-width:0; }
.combat-huds .hud-name > strong { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font:400 20px/1 Georgia,serif; }
.combat-huds .hud .discipline-marks { gap:3px; flex-shrink:0; }
.combat-huds .hud .discipline-marks .game-logo { width:16px; height:16px; font-size:15px; }
.combat-huds .hud-affinities { display:flex; align-items:center; gap:5px; flex-shrink:0; }
.combat-huds .hud .hud-detail { padding:0; min-width:24px; min-height:24px; }
.combat-huds .hud .hud-detail .element-badge > .game-logo { width:22px; height:22px; }
.combat-huds .hud .aura-status { display:flex; align-items:center; gap:3px; border:1px dashed #828d99; padding:2px 4px; min-height:24px; border-radius:4px; background:transparent; color:#465967; }
.combat-huds .hud .aura-status > small { display:inline; font:9px/1 'Segoe UI',sans-serif; margin:0; letter-spacing:0; }
.combat-huds .hud .aura-status .game-logo { width:14px; height:14px; }
.combat-huds .hud-vitals { display:grid; gap:5px; min-width:0; }
.combat-huds .hud-health,.combat-huds .hud-mana { display:block; position:relative; margin:0; min-width:0; }
.combat-huds .resource-caption { display:flex; align-items:baseline; justify-content:space-between; gap:4px; margin:0 0 3px; font-size:9px; line-height:1; }
.combat-huds .resource-caption > b { font-variant-numeric:tabular-nums; white-space:nowrap; }
.combat-huds .hud-health .resource-caption { position:absolute; inset:0 6px; z-index:1; align-items:center; margin:0; color:#163c31; }
.combat-huds .hud-health .resource-caption > b { font-size:13px; font-weight:750; text-shadow:0 1px 2px #ffffffc9; }
.combat-huds .hud-mana .resource-caption { color:#596886; }
.combat-huds .hud-mana .game-logo { width:10px; height:10px; }
.combat-huds .hud-mana .resource-caption > b { font-size:10px; font-weight:600; }
.combat-huds .hud .hud-vitals progress { appearance:none; display:block; width:100%; min-width:0; margin:0; padding:0; border:0; overflow:hidden; border-radius:3px; background:#d5ddce; }
.combat-huds .hud .hud-vitals .health-bar { height:18px; accent-color:#78be9a; }
.combat-huds .hud .hud-vitals .mana-bar { height:4px; accent-color:#778fb7; background:#d2d8e2; }
.combat-huds .health-bar::-webkit-progress-bar { background:#d5ddce; }
.combat-huds .health-bar::-webkit-progress-value { background:linear-gradient(90deg,#68b69b,#acd8a4); }
.combat-huds .health-bar::-moz-progress-bar { background:linear-gradient(90deg,#68b69b,#acd8a4); }
.combat-huds .hud .hud-mana .mana-bar::-webkit-progress-bar { background:#d2d8e2; }
.combat-huds .hud .hud-mana .mana-bar::-webkit-progress-value { background:#778fb7; }
.combat-huds .hud .hud-mana .mana-bar::-moz-progress-bar { background:#778fb7; }
/* Only populated groups are rendered. A single group takes the available space. */
.combat-huds .hud .hud-effects { display:flex; flex-wrap:nowrap; align-items:center; gap:0; padding:2px 0; margin:0; min-width:0; }
.combat-huds .hud-state { display:flex; align-items:center; gap:6px; min-width:0; }
.combat-huds .hud-state > .aura-status { flex-shrink:0; }
.combat-huds .hud-state > .hud-effects { flex:1; }
.combat-huds .hud .effect-group { display:flex; flex:var(--effect-weight,1) 1 0; flex-wrap:wrap; align-items:center; gap:3px; min-width:0; }
.combat-huds .effect-group + .effect-group { border-left:1px solid #b9ada16b; padding-left:7px; margin-left:7px; }
.combat-huds .effect-token { animation:hud-effect-float 3s ease-in-out infinite; }
.combat-huds .hud .status-chip { font:600 10px/1.2 'Segoe UI',sans-serif; min-height:22px; padding:2px 3px; margin:0; white-space:nowrap; border:0; border-radius:3px; background:transparent; }
.combat-huds .effect-buffs .status-chip { color:#22684e; background:#409c7810; }
.combat-huds .effect-debuffs .status-chip { color:#934c49; background:#a8545410; }
.combat-huds .effect-token.is-expiring { animation:hud-effect-float 3s ease-in-out infinite,hud-effect-expiring 2.6s ease-in-out infinite; }
.combat-huds .effect-token:hover,.combat-huds .effect-token:focus-visible { animation-play-state:paused; }
@keyframes hud-effect-float { 0%,100%{transform:translateY(1px)}50%{transform:translateY(-2px)} }
@keyframes hud-effect-expiring { 0%,100%{opacity:1}50%{opacity:.68} }
.combat-huds .hud-roster { display:flex; align-items:center; justify-content:space-between; gap:6px; padding-top:5px; border-top:1px solid #baaa8770; min-width:0; }
.combat-huds .roster-caption { display:flex; align-items:center; gap:6px; color:#6f6756; font-size:9px; line-height:1; white-space:nowrap; }
.combat-huds .roster-caption > b { color:#554f42; font-size:10px; font-variant-numeric:tabular-nums; }
.combat-huds .team-portraits { display:flex; gap:4px; flex-shrink:0; }
.combat-huds .team-portrait { width:21px; height:24px; min-width:0; padding:0; margin:0; cursor:help; }
.combat-huds .team-portrait:hover,.combat-huds .team-portrait:focus-visible { outline:2px solid #388a7b; outline-offset:2px; }
.combat-tip.reserve-preview { width:270px; max-width:calc(100vw - 24px); padding:14px; background:linear-gradient(145deg,#fffbed,#e8e5d7); color:#283f48; border:1px solid #bda575; box-shadow:0 12px 35px #12253355; }
.combat-tip.reserve-preview > strong { color:#4e4839; }
.reserve-preview-content { display:grid; gap:8px; }
.reserve-preview-content > .portrait { width:100%; height:190px; min-height:0; background:radial-gradient(ellipse at bottom,#8ca9a148,transparent 70%); }
.reserve-preview-content > .portrait img { width:100%; height:100%; object-fit:contain; }
.reserve-preview-content p { margin:0; font-size:12px; line-height:1.45; }
.combat-huds .team-state { font-size:6px; }
#battle .battle-board .stage { grid-row:2; height:auto; min-width:0; aspect-ratio:16/9; overflow:hidden; isolation:isolate; container-type:inline-size; }
#battle .battle-board .stage .player-actor { left:4%; right:auto; top:auto; bottom:12%; width:38%; height:62%; }
#battle .battle-board .stage .enemy-actor { left:61%; right:auto; top:auto; bottom:44%; width:32%; height:49%; }
#battle .battle-board .stage .actor > .portrait { width:100%; height:100%; max-width:100%; max-height:100%; }
#battle .battle-board .stage .actor > .portrait > img { width:100%; height:100%; object-fit:contain; object-position:center bottom; }
#battle .battle-board .stage .actor > .actor-name { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* Narrow screens: one compact opponent frame, the intact arena, then your frame.
   Keeping frames within this single board avoids miniaturizing either character. */
@media(max-width:1199px) {
  .battle-board { border:1px solid #d3bf9680; border-radius:8px; overflow:hidden; background:#eee9d9; }
  .battle-board .combat-huds > .hud { border:0; border-radius:0; padding:8px 10px; grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr); column-gap:10px; box-shadow:none; }
  .combat-huds .hud-heading { grid-column:1; grid-row:1; flex-wrap:wrap; gap:3px; align-content:center; }
  .combat-huds .hud-name > strong { font-size:17px; }
  .combat-huds .hud-vitals { grid-column:2; grid-row:1; align-self:center; }
  .combat-huds .hud-state { grid-column:1/-1; }
  .combat-huds .hud .effect-group { flex-wrap:wrap; }
  .combat-huds .hud-roster { grid-column:1/-1; }
  .combat-huds .hud .status-chip { font-size:10px; min-height:24px; }
  #battle .battle-board .stage { border:0; border-radius:0; }
}
/* On a wide arena, reuse the original two opposite corners, not an outside band.
   The corner slots have space for both status groups without entering fighter boxes. */
@media(min-width:1200px) {
  .battle-board { display:block; }
  .combat-huds { display:block; position:absolute; inset:0; pointer-events:none; z-index:5; }
  .battle-board .combat-huds > .hud { position:absolute; width:36%; max-width:430px; pointer-events:auto; }
  .battle-board .combat-huds > .enemy-hud { top:2%; left:3%; bottom:auto; right:auto; }
  .battle-board .combat-huds > .player-hud { bottom:3%; right:3%; top:auto; left:auto; }
}
@media(prefers-reduced-motion:reduce) { .combat-huds .effect-token,.combat-huds .effect-token.is-expiring { animation:none; transform:none; opacity:1; } }
html[data-reduced-motion=true] .combat-huds .effect-token { animation:none; transform:none; opacity:1; }

/* The playable game owns its viewport. Art comparison pages never set this
   screen attribute, so their original camera and document layout stay intact. */
html:has(body[data-screen="battle"]) { height:100%; overflow:hidden; }
html[data-art] body[data-screen="battle"] { height:100dvh; min-height:0; overflow:hidden; background:#142b36; padding:0; }
body[data-screen="battle"]::before,body[data-screen="battle"]::after,
body[data-screen="battle"] > header,body[data-screen="battle"] > footer { display:none; }
body[data-screen="battle"] > main {
  width:100%; max-width:none; height:100dvh; min-height:0; margin:0; padding:0;
  padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);
  overflow:hidden;
}
body[data-screen="battle"] #message:not([hidden]) {
  position:fixed; z-index:70; top:12px; left:50%; transform:translateX(-50%);
  width:max-content; max-width:calc(100% - 110px); margin:0; padding:9px 14px;
  box-shadow:0 4px 20px #0005;
}
body[data-screen="battle"] #battle {
  --console-size:202px; --feedback-size:36px; --hud-slot:172px;
  position:relative; display:grid; width:100%; height:100%; min-width:0; min-height:0;
  grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) var(--feedback-size) var(--console-size);
  overflow:hidden; isolation:isolate; animation:none;
}
body[data-screen="battle"] #battle:has(#combat-feedback[hidden]) { --feedback-size:0px; }
body[data-screen="battle"] #battle > .battle-top,
body[data-screen="battle"] #battle > .arena-name { display:none; }
body[data-screen="battle"] #battle .battle-board {
  display:block; grid-column:1; grid-row:1; width:100%; height:100%; min-height:0;
  border:0; border-radius:0; background:#244254; overflow:hidden;
}
body[data-screen="battle"] #battle .battle-board .stage {
  position:absolute; inset:0; width:100%; height:100%; min-height:0; aspect-ratio:auto;
  border:0; border-radius:0; box-shadow:none;
}
/* Reframe the same artwork without stretching it. Fighter feet stay on the
   floor and safety slots reserve real space for either opponent's HUD. */
/* Only the artwork turns toward its opponent. The image flag is also cloned
   into manifestation cards, while names, frames and movement stay upright. */
.actor img[data-battle-mirrored="true"] { transform:scaleX(-1); }
/* Native v4 characters use fixed, whole multiples of 128 x 192 at rest.
   Slots and motion keep their existing geometry; only the raster is fitted.
   JS snaps the raster's position within the stage to whole CSS pixels. */
body[data-screen="battle"] #battle .stage .actor[data-native-sprite="true"] > .portrait {
  position:absolute; aspect-ratio:auto; width:var(--sprite-width,128px); height:var(--sprite-height,192px);
  min-width:0; min-height:0; max-width:none; max-height:none;
  left:var(--sprite-left,0px); top:var(--sprite-top,0px); bottom:auto;
}
body[data-screen="battle"] #battle .stage .actor[data-native-sprite="true"] > .portrait > img {
  width:100%; height:100%; max-width:none; max-height:none;
}
body[data-screen="battle"] #battle .stage .actor[data-native-sprite="true"] > .actor-name {
  left:calc(var(--sprite-left,0px) + var(--sprite-width,128px)/2);
  top:calc(var(--sprite-top,0px) + var(--sprite-height,192px) + 1px); bottom:auto;
}
body[data-screen="battle"] #battle .stage::before { background-size:cover; background-position:center 75%; }
body[data-screen="battle"] #battle .stage::after { background:linear-gradient(180deg,#10243720,transparent 25%,transparent 75%,#10243718); }
body[data-screen="battle"] #battle .combat-huds { display:block; position:absolute; inset:0; z-index:5; pointer-events:none; }
body[data-screen="battle"] #battle .combat-huds > .hud {
  position:absolute; width:34%; max-width:450px; padding:9px 13px; gap:5px;
  display:grid; grid-template-columns:minmax(0,1fr); pointer-events:auto;
  max-height:var(--hud-slot); overflow:auto; scrollbar-width:thin;
}
body[data-screen="battle"] #battle .combat-huds > .enemy-hud { left:2%; top:12px; right:auto; bottom:auto; }
body[data-screen="battle"] #battle .combat-huds > .player-hud { right:2%; bottom:14px; left:auto; top:auto; }
body[data-screen="battle"] #battle .hud :is(.hud-heading,.hud-vitals,.hud-state,.hud-roster) { grid-column:auto; grid-row:auto; }
body[data-screen="battle"] #battle .hud-heading { flex-wrap:nowrap; }
body[data-screen="battle"] #battle .hud .hud-state { min-width:0; }
body[data-screen="battle"] #battle .hud .hud-effects { max-height:54px; overflow:auto; scrollbar-width:thin; }
body[data-screen="battle"] #battle .hud .effect-group { align-content:center; }
body[data-screen="battle"] #battle .hud .health-bar { height:21px; }
body[data-screen="battle"] #battle .team-portrait { width:25px; height:30px; }
body[data-screen="battle"] #battle .battle-board .stage .player-actor {
  left:4%; right:auto; top:auto; bottom:12%; width:38%;
  height:min(62%,calc(88% - var(--hud-slot) - 28px));
}
body[data-screen="battle"] #battle .battle-board .stage .enemy-actor {
  left:61%; right:auto; top:auto; bottom:max(44%,calc(var(--hud-slot) + 28px)); width:32%;
  height:min(49%,calc(100% - max(44%,calc(var(--hud-slot) + 28px)) - 16px));
}
body[data-screen="battle"] #battle .actor-name { margin-top:1px; padding:1px 7px; font:10px/12px 'Segoe UI',sans-serif; }
body[data-screen="battle"] #combat-feedback {
  grid-column:1; grid-row:2; min-height:0; margin:0; border:0;
  grid-template-columns:repeat(2,minmax(0,1fr)); overflow:hidden;
}
body[data-screen="battle"] #combat-feedback .impact-recap { min-width:0; min-height:0; height:100%; padding:3px 12px; gap:8px; }
body[data-screen="battle"] #combat-feedback .impact-identity > img { width:20px; height:27px; }
body[data-screen="battle"] #combat-feedback .impact-amount { font-size:20px; }
body[data-screen="battle"] #combat-feedback .compact-symbols { flex-wrap:nowrap; min-width:0; overflow:hidden; }
body[data-screen="battle"] #battle-console {
  grid-column:1; grid-row:3; display:grid; grid-template-columns:minmax(200px,.65fr) minmax(0,2.35fr);
  width:100%; height:100%; min-height:0; max-height:100%; overflow:hidden;
  border:0; border-top:2px solid #c9ae7c; border-radius:0; box-shadow:none;
  background:#f2ead6; color:#263e4c;
}
body[data-screen="battle"] #battle-console::after { display:none; }
body[data-screen="battle"] #battle-console .narration {
  display:flex; flex-direction:column; justify-content:center; align-items:flex-start;
  min-width:0; min-height:0; padding:18px 24px; gap:9px; border:0; border-right:1px solid #b9a575;
  background:linear-gradient(110deg,#e4d8b8,#eee5ce);
}
body[data-screen="battle"] #battle-console .narration::before,
body[data-screen="battle"] #battle-console .narration::after { display:none; }
body[data-screen="battle"] #battle-console .narration > p {
  min-height:0; margin:0; font:clamp(19px,1.65vw,27px)/1.2 Georgia,serif;
}
body[data-screen="battle"] #battle-console .narration .eyebrow { font-size:9px; letter-spacing:1.6px; }
body[data-screen="battle"] #battle-console .support-status { font:11px/1.25 'Segoe UI',sans-serif; padding-top:7px; }
body[data-screen="battle"] #battle-console .commands {
  display:grid; grid-template-rows:35px minmax(0,1fr); min-width:0; min-height:0;
  padding:9px 16px 12px; gap:7px; overflow:hidden;
}
body[data-screen="battle"] #battle-console .commands[hidden] { display:none; }
body[data-screen="battle"] #command-tabs {
  display:flex; flex-wrap:nowrap; gap:7px; margin:0; padding:0; min-width:0; min-height:0; border:0;
}
body[data-screen="battle"] #command-tabs button { min-height:33px; padding:6px 10px; font-size:12px; }
body[data-screen="battle"] #battle-actions {
  display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); grid-auto-rows:minmax(0,1fr);
  gap:10px; min-width:0; min-height:0; align-items:stretch;
}
body[data-screen="battle"] #battle-actions[hidden],body[data-screen="battle"] #command-tabs[hidden] { display:none; }
body[data-screen="battle"] #battle-actions .battle-ability-choice { min-height:0; display:grid; grid-template-rows:minmax(0,1fr) 30px; }
body[data-screen="battle"] #battle-actions .battle-ability {
  min-width:0; min-height:0; height:100%; padding:9px 10px;
  grid-template-columns:30px minmax(0,1fr); grid-template-rows:auto auto auto; gap:3px 8px;
  align-content:center; box-shadow:none;
}
body[data-screen="battle"] #battle-actions .battle-ability > .ability-emblem { width:29px; height:38px; grid-column:1; grid-row:1/4; }
body[data-screen="battle"] #battle-actions .ability-emblem .game-logo { width:26px; height:30px; font-size:24px; }
body[data-screen="battle"] #battle-actions .battle-ability > .ability-meta { grid-column:2; grid-row:1; font-size:9px; }
body[data-screen="battle"] #battle-actions .battle-ability > strong { grid-column:2; grid-row:2; font:clamp(15px,1.35vw,21px)/1.12 Georgia,serif; }
body[data-screen="battle"] #battle-actions .battle-ability > b { grid-column:2; grid-row:3; font-size:10px; }
body[data-screen="battle"] #battle-actions .ability-info { min-width:0; min-height:0; height:30px; padding:3px 7px; font-size:10px; }
body[data-screen="battle"] #battle-actions .ability-info .compact-symbols { min-width:0; flex-wrap:nowrap; overflow:hidden; }
body[data-screen="battle"] #battle-actions .ability-info .effect-symbols { font-size:9px; }
body[data-screen="battle"] #battle-actions:has(.reserve-choice) { grid-template-columns:repeat(2,minmax(0,1fr)); }
body[data-screen="battle"] #battle-actions:has(.assist-card) { grid-template-rows:20px minmax(0,1fr); }
body[data-screen="battle"] #battle-actions .assist-help { min-height:0; height:20px; padding:0; line-height:20px; }
body[data-screen="battle"] #battle-actions .assist-card { min-height:0; display:grid; grid-template-rows:minmax(0,1fr) 26px; }
body[data-screen="battle"] #battle-actions .assist-card .ability-info { height:26px; }
body[data-screen="battle"] #battle-actions .reserve-choice {
  display:grid; grid-template-columns:55px minmax(0,1fr); grid-template-rows:repeat(4,auto);
  align-content:center; text-align:left; min-height:0; padding:7px 12px; gap:2px 9px; overflow:hidden;
}
body[data-screen="battle"] #battle-actions .reserve-choice > .portrait { grid-column:1; grid-row:1/5; width:55px; height:90px; }
body[data-screen="battle"] #battle-actions .reserve-choice > strong { font-size:20px; grid-column:2; }
body[data-screen="battle"] #battle-actions .reserve-choice > :is(.element-badge,span,small) { grid-column:2; justify-content:flex-start; }
body[data-screen="battle"] #battle-actions .reserve-choice > small { font-size:10px; }
body[data-screen="battle"] #battle-console:has(#result:not([hidden])) .commands { display:block; }
body[data-screen="battle"] #battle-console #result { height:100%; padding:5px; display:flex; align-items:center; flex-wrap:wrap; gap:10px 16px; }
body[data-screen="battle"] #battle-console #result[hidden] { display:none; }
body[data-screen="battle"] #battle-console #result h2 { margin:0; font-size:30px; color:#75532d; }
body[data-screen="battle"] #battle-console #result p { margin:0; color:#53616b; font-size:12px; }
body[data-screen="battle"] #battle-console.resolving { grid-template-columns:minmax(0,1fr); min-height:0; }
body[data-screen="battle"] #battle-console.resolving .narration { min-height:0; padding:18px 30px; border:0; align-items:center; text-align:center; }
body[data-screen="battle"] #battle-console.resolving .narration > p { margin:0; min-height:0; max-width:920px; font-size:clamp(21px,2.5vw,32px); }
body[data-screen="battle"] .battle-settings-button {
  position:absolute; z-index:30; top:12px; right:12px; width:44px; height:44px;
  display:grid; place-items:center; padding:0; background:#183a4cde; color:#fff7dd;
  border:1px solid #e0c995; border-radius:50%; font-size:24px; box-shadow:0 3px 12px #09202f44;
}
body[data-screen="battle"] .battle-settings-button:hover { background:#315770; transform:none; }
.battle-settings-dialog { max-width:530px; }
.battle-settings-dialog .motion-option { margin:15px 0; display:flex; align-items:center; gap:10px; }
.battle-settings-dialog .motion-option input { width:18px; height:18px; }
.battle-settings-dialog .element-guide,.battle-settings-dialog .journal { color:#405968; border-color:#a49a8270; margin:18px 0; }
.battle-settings-dialog summary { color:#294b5c; min-height:40px; display:list-item; padding-top:9px; }
.battle-settings-dialog #leave { width:100%; min-height:44px; border:1px solid #9e404e; background:#9e404e; color:#fff3e2; margin-top:18px; padding:10px; }
.battle-settings-dialog #leave:hover:not(:disabled) { background:#813440; color:#fff3e2; }
.battle-settings-dialog .sound-toggle { width:100%; justify-content:center; min-height:44px; }

/* Laptops keep the two corner frames but use their horizontal compact format. */
@media (max-width:1199px),(max-height:720px) {
  body[data-screen="battle"] #battle { --console-size:174px; --hud-slot:132px; --feedback-size:32px; }
  body[data-screen="battle"] #battle .combat-huds > .hud { width:40%; max-width:450px; padding:6px 9px; gap:4px; grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr); }
  body[data-screen="battle"] #battle .hud .hud-heading { grid-column:1; grid-row:1; }
  body[data-screen="battle"] #battle .hud .hud-vitals { grid-column:2; grid-row:1; }
  body[data-screen="battle"] #battle .hud .hud-state,body[data-screen="battle"] #battle .hud .hud-roster { grid-column:1/-1; }
  body[data-screen="battle"] #battle .hud-name > strong { font-size:17px; }
  body[data-screen="battle"] #battle .hud-heading { gap:3px; }
  body[data-screen="battle"] #battle .hud .hud-detail { min-width:22px; }
  body[data-screen="battle"] #battle .team-portrait { width:22px; height:27px; }
  body[data-screen="battle"] #battle-console { grid-template-columns:minmax(160px,.55fr) minmax(0,2.45fr); }
  body[data-screen="battle"] #battle-console .narration { padding:13px 16px; }
  body[data-screen="battle"] #battle-console .commands { padding:6px 10px 9px; grid-template-rows:32px minmax(0,1fr); gap:4px; }
  body[data-screen="battle"] #battle-actions { gap:7px; }
  body[data-screen="battle"] #battle-actions .battle-ability { padding:6px 7px; grid-template-columns:23px minmax(0,1fr); gap:3px 5px; }
  body[data-screen="battle"] #battle-actions .battle-ability > .ability-emblem { width:23px; height:32px; }
  body[data-screen="battle"] #battle-actions .ability-emblem .game-logo { width:21px; height:25px; font-size:20px; }
  body[data-screen="battle"] #battle-actions .battle-ability > strong { font-size:16px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > .portrait { height:70px; }
}

/* A phone uses two safe, in-board status bands, not overlapping corner cards.
   The stage keeps all remaining height; action targets stay comfortably tappable. */
@media (max-width:700px) and (orientation:portrait) {
  body[data-screen="battle"] #battle { --console-size:282px; --feedback-size:32px; }
  body[data-screen="battle"] #battle .battle-board { display:grid; grid-template-rows:auto minmax(0,1fr) auto; }
  body[data-screen="battle"] #battle .combat-huds { display:contents; }
  body[data-screen="battle"] #battle .combat-huds > .hud { position:relative; inset:auto; width:100%; max-width:none; max-height:none; border:0; border-radius:0; padding:6px 10px; gap:4px; grid-template-columns:minmax(0,1fr) minmax(0,1.15fr); box-shadow:none; }
  body[data-screen="battle"] #battle .combat-huds > .enemy-hud { grid-row:1; padding-right:58px; border-bottom:1px solid #af998070; }
  body[data-screen="battle"] #battle .combat-huds > .player-hud { grid-row:3; border-top:1px solid #af998070; }
  body[data-screen="battle"] #battle .hud-heading { flex-wrap:wrap; gap:1px; }
  body[data-screen="battle"] #battle .hud-name > strong { font-size:17px; }
  body[data-screen="battle"] #battle .hud .hud-detail { min-height:20px; min-width:20px; }
  body[data-screen="battle"] #battle .hud-roster { padding-top:3px; }
  body[data-screen="battle"] #battle .team-portrait { width:23px; height:27px; }
  body[data-screen="battle"] #battle .battle-board .stage { position:relative; inset:auto; grid-row:2; min-height:0; }
  body[data-screen="battle"] #battle .stage::before { background-position:center 78%; }
  body[data-screen="battle"] #battle .battle-board .stage .player-actor { left:0; width:51%; height:66%; bottom:9%; }
  body[data-screen="battle"] #battle .battle-board .stage .enemy-actor { left:54%; width:43%; height:52%; bottom:40%; }
  body[data-screen="battle"] #battle .actor-name { font-size:8px; }
  body[data-screen="battle"] #battle-console { grid-template-columns:minmax(0,1fr); grid-template-rows:47px minmax(0,1fr); }
  body[data-screen="battle"] #battle-console .narration { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:2px 8px; padding:5px 10px; border-right:0; border-bottom:1px solid #b9a57570; }
  body[data-screen="battle"] #battle-console .narration .eyebrow { font-size:8px; letter-spacing:1px; }
  body[data-screen="battle"] #battle-console .narration > p { grid-column:1; grid-row:2; font-size:17px; white-space:nowrap; text-overflow:ellipsis; overflow:hidden; }
  body[data-screen="battle"] #battle-console .support-status { grid-column:2; grid-row:1/3; font-size:9px; max-width:115px; padding:0; border:0; }
  body[data-screen="battle"] #battle-console .commands { padding:4px 7px 7px; grid-template-rows:35px minmax(0,1fr); gap:4px; }
  body[data-screen="battle"] #command-tabs { gap:0; justify-content:space-between; }
  body[data-screen="battle"] #command-tabs button { padding:5px 6px; min-height:35px; font-size:10px; }
  body[data-screen="battle"] #command-tabs #pass { margin-left:0; }
  body[data-screen="battle"] #battle-actions { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(0,1fr)); gap:5px; }
  body[data-screen="battle"] #battle-actions .battle-ability-choice { grid-template-rows:minmax(0,1fr) 25px; }
  body[data-screen="battle"] #battle-actions .battle-ability { padding:4px 5px; gap:1px 4px; grid-template-columns:24px minmax(0,1fr); }
  body[data-screen="battle"] #battle-actions .battle-ability > strong { font-size:15px; }
  body[data-screen="battle"] #battle-actions .battle-ability > .ability-meta { font-size:8px; }
  body[data-screen="battle"] #battle-actions .battle-ability > b { font-size:9px; }
  body[data-screen="battle"] #battle-actions .ability-info { height:25px; padding:2px 5px; }
  body[data-screen="battle"] #battle-actions:has(.reserve-choice) { grid-template-rows:minmax(0,1fr); }
  body[data-screen="battle"] #battle-actions:has(.assist-card) { grid-template-rows:20px minmax(0,1fr); }
  body[data-screen="battle"] #battle-actions .reserve-choice { padding:6px; grid-template-columns:40px minmax(0,1fr); gap:3px 5px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > .portrait { width:40px; height:88px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > strong { font-size:17px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > small { font-size:9px; }
  body[data-screen="battle"] #combat-feedback .impact-recap { padding:2px 5px; gap:4px; }
  body[data-screen="battle"] #combat-feedback .impact-identity > small { display:none; }
  body[data-screen="battle"] #combat-feedback .impact-amount { font-size:17px; }
  body[data-screen="battle"] #combat-feedback .effect-symbols { font-size:9px; gap:1px; padding:2px; }
  body[data-screen="battle"] #combat-feedback .effect-symbols .game-logo { width:14px; height:14px; }
  body[data-screen="battle"] #battle-console.resolving { grid-template-rows:minmax(0,1fr); }
  body[data-screen="battle"] #battle-console.resolving .narration { display:flex; padding:15px; }
  body[data-screen="battle"] #battle-console.resolving .narration > p { white-space:normal; font-size:23px; }
  body[data-screen="battle"] .battle-settings-button { top:8px; right:8px; width:40px; height:40px; font-size:22px; }
}

/* Landscape phones use a side command rail, so neither the arena nor the four
   actions collapse into an unusable strip on a short display. */
@media (max-height:500px) and (orientation:landscape) {
  body[data-screen="battle"] #battle { --feedback-size:32px; grid-template-columns:minmax(0,1fr) clamp(300px,38vw,370px); grid-template-rows:minmax(0,1fr) var(--feedback-size); }
  body[data-screen="battle"] #battle .battle-board { grid-column:1; grid-row:1/-1; display:grid; grid-template-rows:auto minmax(0,1fr) auto; }
  body[data-screen="battle"] #battle .combat-huds { display:contents; }
  body[data-screen="battle"] #battle .combat-huds > .hud { position:relative; inset:auto; width:100%; max-width:none; max-height:none; border:0; border-radius:0; padding:5px 10px; gap:3px; grid-template-columns:minmax(0,1fr) minmax(0,1.25fr); box-shadow:none; }
  body[data-screen="battle"] #battle .combat-huds > .enemy-hud { grid-row:1; }
  body[data-screen="battle"] #battle .combat-huds > .player-hud { grid-row:3; }
  body[data-screen="battle"] #battle .combat-huds > .hud { padding:4px 10px; gap:2px 10px; }
  body[data-screen="battle"] #battle .hud .hud-heading { grid-column:1; grid-row:1; min-height:20px; }
  body[data-screen="battle"] #battle .hud .hud-vitals { grid-column:2; grid-row:1/3; }
  body[data-screen="battle"] #battle .hud .hud-state { grid-column:1; grid-row:2; gap:4px; min-height:0; }
  body[data-screen="battle"] #battle .hud .hud-roster { grid-column:1/-1; grid-row:3; padding-top:3px; }
  body[data-screen="battle"] #battle .hud:not(:has(.hud-state)) .hud-vitals { grid-row:1; }
  body[data-screen="battle"] #battle .hud:not(:has(.hud-state)) .hud-roster { grid-row:2; }
  body[data-screen="battle"] #battle .hud .hud-name > strong { font-size:16px; }
  body[data-screen="battle"] #battle .hud .hud-detail { min-height:20px; }
  body[data-screen="battle"] #battle .hud .hud-detail .element-badge > .game-logo { width:19px; height:19px; }
  body[data-screen="battle"] #battle .hud .hud-effects { padding:0; max-height:21px; }
  body[data-screen="battle"] #battle .hud .status-chip { min-height:19px; padding:1px 3px; font-size:9px; }
  body[data-screen="battle"] #battle .hud .aura-status { min-height:19px; padding:1px 3px; }
  body[data-screen="battle"] #battle .team-portrait { width:21px; height:22px; }
  body[data-screen="battle"] #battle .battle-board .stage { position:relative; inset:auto; grid-row:2; }
  body[data-screen="battle"] #battle .battle-board .stage .player-actor { left:3%; width:43%; height:68%; bottom:max(9%,20px); }
  body[data-screen="battle"] #battle .battle-board .stage .enemy-actor { left:59%; width:36%; height:52%; bottom:40%; }
  body[data-screen="battle"] #battle-console { grid-column:2; grid-row:1; grid-template-columns:minmax(0,1fr); grid-template-rows:48px minmax(0,1fr); border-top:0; border-left:1px solid #c9ae7c; }
  body[data-screen="battle"] #battle-console .narration { padding:6px 56px 5px 12px; gap:4px; border:0; }
  body[data-screen="battle"] #battle-console .narration > p { margin:0; font-size:17px; }
  body[data-screen="battle"] #battle-console .narration .eyebrow { font-size:8px; }
  body[data-screen="battle"] #battle-console .support-status { display:none; }
  body[data-screen="battle"] #battle-console .commands { padding:3px 7px 7px; grid-template-rows:32px minmax(0,1fr); gap:4px; }
  body[data-screen="battle"] #command-tabs { gap:0; }
  body[data-screen="battle"] #command-tabs button { padding:4px 5px; font-size:10px; }
  body[data-screen="battle"] #battle-actions { grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:repeat(2,minmax(0,1fr)); gap:5px; }
  body[data-screen="battle"] #battle-actions .battle-ability { padding:5px 6px; grid-template-columns:22px minmax(0,1fr); gap:2px 4px; }
  body[data-screen="battle"] #battle-actions .battle-ability > strong { font-size:15px; }
  body[data-screen="battle"] #battle-actions .battle-ability > .ability-meta { font-size:8px; }
  body[data-screen="battle"] #battle-actions .ability-info { padding:2px 4px; }
  body[data-screen="battle"] #battle-actions:has(.reserve-choice) { grid-template-rows:minmax(0,1fr); }
  body[data-screen="battle"] #battle-actions:has(.assist-card) { grid-template-rows:20px minmax(0,1fr); }
  body[data-screen="battle"] #battle-actions .reserve-choice { padding:7px; grid-template-columns:minmax(0,1fr); text-align:center; justify-items:center; gap:4px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > .portrait { grid-row:auto; grid-column:1; width:100%; height:100px; }
  body[data-screen="battle"] #battle-actions .reserve-choice > :is(strong,.element-badge,span,small) { grid-column:1; text-align:center; justify-content:center; }
  body[data-screen="battle"] #battle-console.resolving { grid-template-rows:minmax(0,1fr); }
  body[data-screen="battle"] #battle-console.resolving .narration { padding:45px 16px 15px; }
  body[data-screen="battle"] #battle-console.resolving .narration > p { font-size:24px; }
  body[data-screen="battle"] #combat-feedback { grid-column:2; grid-row:2; }
  body[data-screen="battle"] #combat-feedback .impact-recap { padding:2px 4px; gap:4px; }
  body[data-screen="battle"] #combat-feedback .impact-identity > small { display:none; }
  body[data-screen="battle"] #combat-feedback .impact-amount { font-size:16px; }
  body[data-screen="battle"] #combat-feedback .effect-symbols { font-size:8px; padding:1px; gap:1px; }
  body[data-screen="battle"] #combat-feedback .effect-symbols .game-logo { width:13px; height:13px; }
  body[data-screen="battle"] .battle-settings-button { top:7px; right:8px; width:36px; height:36px; font-size:20px; }
}
