/* Orbis Battle — compact portrait layout preview, branch-only.
   Intentionally overrides Battle UI V5 after its layout stylesheet.
   No combat rules, target IDs or skill DOM nodes are changed. */
#battle-arena {
  --battle-compact-gap: 3px;
  /* Do not set display: game toggles arena inline between none/flex. */
  flex-direction: column !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  bottom: 0 !important;
  overflow: hidden !important;
  gap: 0 !important;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px) !important;
}

/* Top panel: two independent 2.5–3-row lists (allies/enemies).
   Only the lists scroll; the page and art scene do not. */
#battle-target-selector {
  /* V5 sets inline display block/none from live battle team state. */
  flex: 0 0 clamp(126px, 17dvh, 136px) !important;
  height: clamp(126px, 17dvh, 136px) !important;
  width: 100% !important;
  aspect-ratio: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 5px 7px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  background: linear-gradient(180deg,#301d12 0%,#1a100b 100%) !important;
  background-image: none !important;
  border: 0 !important;
  border-bottom: 1px solid #976b36 !important;
  border-radius: 0 !important;
  box-shadow: 0 2px 9px #0009 !important;
}
#battle-target-buttons {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important;
  column-gap: 6px !important;
}
#battle-target-buttons .battle-team-column {
  height: 100% !important;
  overflow: hidden !important;
  min-height: 0 !important;
}
#battle-target-buttons .battle-team-list {
  height: 100% !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  gap: 3px !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
#battle-target-buttons .battle-team-unit {
  flex: 0 0 43px !important;
  min-height: 43px !important;
  height: 43px !important;
  padding: 3px 4px !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-columns: 26px minmax(0,1fr) !important;
  grid-template-rows: 14px 10px 10px !important;
  gap: 1px 4px !important;
  background: linear-gradient(180deg,#e8d1a4,#c4a06b) !important;
  border-radius: 5px !important;
  box-shadow: inset 0 0 0 1px #f9e5b54d !important;
}
#battle-target-buttons .battle-unit-name-v5 {
  display: contents !important;
}
#battle-target-buttons .battle-unit-portrait-v5 {
  width: 25px !important;
  height: 25px !important;
  max-width: 25px !important;
  padding: 1px !important;
  grid-column: 1 !important;
  grid-row: 1 / 4 !important;
  background: linear-gradient(160deg,#6d4627,#20120b) !important;
  border: 1px solid #916934 !important;
  border-radius: 4px !important;
}
#battle-target-buttons .battle-unit-name-text-v5 {
  grid-column: 2 !important;
  grid-row: 1 !important;
  align-self: center !important;
  min-width: 0 !important;
  overflow: hidden !important;
  font-size: clamp(9px,2.55vw,11px) !important;
  line-height: 1.2 !important;
  text-overflow: ellipsis !important;
}
#battle-target-buttons .battle-resource-track-v5 {
  grid-column: 2 !important;
  height: 10px !important;
  min-height: 10px !important;
  margin: 0 !important;
  border-width: 0 !important;
  box-shadow: inset 0 0 2px #0007 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  align-self: center !important;
}
#battle-target-buttons .battle-resource-track-v5.hp {grid-row: 2 !important;}
#battle-target-buttons .battle-resource-track-v5.mp {
  grid-row: 3 !important;
  height: 10px !important;
}
#battle-target-buttons .battle-resource-label-v5 {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  padding: 0 2px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: clip !important;
  font-size: clamp(7px, 1.8vw, 9px) !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  text-align: center !important;
  pointer-events: none !important;
}
#battle-target-buttons .battle-unit-effects-v5 {display: none !important;}
#battle-target-buttons .battle-team-unit.is-selected,
#battle-target-buttons .battle-team-unit.is-ally-selected {
  border-color: #ffe8a0 !important;
  box-shadow: 0 0 0 1px #ffcc65, inset 0 0 3px #0005 !important;
}

/* Central stage reuses existing enemies' portraits; the large player figure
   previews the transparent paper-doll without altering combat logic. */
#battle-stage-preview {
  flex: 1 1 0 !important;
  min-height: 72px !important;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  align-items: end;
  gap: 4px;
  padding: 12px 10px 9px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 82%,#68472f6b,transparent 52%),
    linear-gradient(180deg,#1b130f,#30221a 65%,#130d09 100%);
  border-bottom: 1px solid #8f643d;
}
.battle-stage-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
  gap: 4px;
}
.battle-stage-art {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.battle-stage-art img {
  display: block;
  width: 100%;
  max-width: 200px;
  max-height: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 4px 6px #000b);
}
/* The large player-only preview uses a transparent 2:3 figure.
   The current hero display is 20% smaller than the former 1.23x preview:
   1.23 * 0.8 = 0.984; feet stay at the baseline, ratio is preserved.
   The ally art host must allow the enlarged sprite to exceed its own bounds. */
.battle-stage-figure[data-side="ally"] .battle-stage-art {
  overflow: visible;
}
.battle-stage-figure[data-side="ally"] .battle-stage-art img.battle-stage-player-avatar-v6 {
  display: block;
  width: 100%;
  max-width: min(48vw, 220px);
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  transform: scale(0.984);
  transform-origin: center bottom;
  background: transparent;
  border: 0;
  border-radius: 0;
  filter: drop-shadow(0 4px 5px #000a);
}
.battle-stage-fallback {
  display: grid;
  place-items: center;
  width: 62%;
  height: 62%;
  border: 1px dashed #9b76467a;
  border-radius: 8px;
  color: #ad967a;
  font: 12px Georgia,serif;
}
.battle-stage-name {
  flex: 0 0 auto;
  display: block;
  width: 100%;
  padding: 4px 2px;
  text-align: center;
  font: bold 11px/1.1 Georgia,serif;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: #f0deb4;
  text-shadow: 0 2px 3px #000;
}
#training-stats-panel {
  flex: 0 0 auto !important;
  margin: 1px 6px !important;
  max-height: 55px !important;
  overflow-y: auto !important;
  font-size: 10px !important;
}

/* Lower controls: approx 30–35% smaller than the old framed controls.
   Keep original skill nodes, event handlers, cooldowns and item art. */
#battle-action-panel {
  --battle-gap: 3px;
  --battle-item-size: clamp(29px,8.3vw,35px);
  --battle-scroll-width: clamp(79px,22vw,95px);
  flex: 0 0 auto !important;
  width: min(100%,430px) !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 3px 7px 2px !important;
  margin: 0 auto !important;
  gap: 3px !important;
  background: linear-gradient(180deg,#23160f,#140d08) !important;
}
#battle-action-panel .battle-toolbar-v5,
#battle-action-panel .battle-command-layout-v5 {
  width: 100% !important;
  grid-template-columns: 23% 75% !important;
  column-gap: 2% !important;
  justify-content: stretch !important;
  margin: 0 !important;
}
#battle-action-panel .battle-toolbar-v5 {
  height: 34px !important;
  align-items: center !important;
}
#battle-action-panel .battle-toolbar-v5 > .battle-consumables-v5 {
  grid-column: 2 !important;
  justify-self: end !important;
  align-self: center !important;
  grid-template-columns: var(--battle-item-size) var(--battle-item-size) var(--battle-scroll-width) !important;
  column-gap: 3px !important;
}
#battle-action-panel .battle-toolbar-v5 > #ba-auto-attack-toggle {
  width: 100% !important;
  height: 29px !important;
  aspect-ratio: auto !important;
  align-self: center !important;
  justify-self: stretch !important;
  transform: none !important;
  padding: 1px 3px !important;
  border: 1px solid #9b713c !important;
  border-radius: 6px !important;
  background: linear-gradient(180deg,#654527,#2b1a10) !important;
  background-image: none !important;
  font-size: 10px !important;
}
#battle-action-panel .battle-command-layout-v5 {
  align-items: stretch !important;
  height: auto !important;
}
#battle-action-panel .battle-command-layout-v5 > #ba-basic-attack-btn {
  width: 100% !important;
  height: clamp(68px,19.5vw,79px) !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  padding: 3px !important;
  border: 1px solid #bd8b40 !important;
  border-radius: 7px !important;
  background: linear-gradient(150deg,#634322,#29180f) !important;
  background-image: none !important;
  font-size: 12px !important;
}
#battle-action-panel .battle-skills-row {
  display: grid !important;
  grid-template-columns: repeat(4,minmax(0,1fr)) !important;
  grid-auto-rows: clamp(33px,9.4vw,39px) !important;
  gap: 3px !important;
  align-items: stretch !important;
}
#battle-action-panel .battle-skills-row > .action-slot.main-slot {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  border: 1px solid #91652d !important;
  border-radius: 6px !important;
  background: linear-gradient(150deg,#503822,#1e1510) !important;
  background-image: none !important;
  box-shadow: inset 0 1px 3px #0009 !important;
}
#battle-action-panel #ba-potion-hp,
#battle-action-panel #ba-potion-mp {
  height: var(--battle-item-size) !important;
  aspect-ratio: auto !important;
  border: 1px solid #926834 !important;
  border-radius: 6px !important;
  background: linear-gradient(150deg,#644529,#281a11) !important;
  background-image: none !important;
}
#battle-action-panel #ba-scroll-btn {
  height: var(--battle-item-size) !important;
  aspect-ratio: auto !important;
  padding: 0 4px !important;
  border: 1px solid #a57739 !important;
  border-radius: 6px !important;
  background: linear-gradient(150deg,#644529,#281a11) !important;
  background-image: none !important;
  font-size: 10px !important;
}
#battle-action-panel .arena-escape-row {
  flex: 0 0 auto !important;
  margin: 0 !important;
  padding: 0 !important;
}
#battle-action-panel .arena-escape-btn {
  width: min(48%,188px) !important;
  max-width: none !important;
  height: 24px !important;
  min-height: 24px !important;
  aspect-ratio: auto !important;
  padding: 0 6px !important;
  border: 1px solid #906b3e !important;
  border-radius: 6px !important;
  background: linear-gradient(180deg,#583820,#22150c) !important;
  background-image: none !important;
  font-size: 10px !important;
}
#battle-action-panel .cd-overlay {font-size: 10px !important;}

/* Last 1–2 combat messages only. Expands on tap, never contains world chat. */
#battle-mini-log {
  flex: 0 0 39px;
  min-height: 39px;
  width: 100%;
  margin: 0;
  padding: 0;
  border-top: 1px solid #956f3c;
  background: linear-gradient(180deg,#281c13,#100b08);
  color: #e0c38f;
  font: 11px/1.35 Georgia,serif;
}
#battle-mini-log summary {
  display: block;
  height: 39px;
  padding: 3px 11px 4px;
  overflow: hidden;
  cursor: pointer;
  list-style: none;
  white-space: pre-line;
  color: #e6d1a8;
}
#battle-mini-log summary::-webkit-details-marker {display:none;}
#battle-mini-log summary::before {
  content: "БОЙОВИЙ ЛОГ  ▴";
  display: block;
  font-size: 9px;
  line-height: 11px;
  letter-spacing: .05em;
  color: #bd9450;
}
#battle-mini-log[open] {
  flex: 0 0 clamp(110px,23dvh,190px);
  overflow: hidden;
}
#battle-mini-log[open] summary {height: 31px;}
#battle-mini-log[open] summary::before {content: "БОЙОВИЙ ЛОГ  ▾";}
#battle-mini-log-history {
  height: calc(100% - 31px);
  padding: 4px 10px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 11px;
  line-height: 1.5;
}
.battle-mini-log-row {margin: 0 0 4px;}

@media (max-height: 660px) {
  #battle-target-selector {
    flex-basis: 124px !important;
    height: 124px !important;
  }
  #battle-target-buttons .battle-team-unit {
    flex-basis: 39px !important;
    height: 39px !important;
    min-height: 39px !important;
    grid-template-rows: 11px 9px 9px !important;
  }
  #battle-action-panel .battle-toolbar-v5 {height: 31px !important;}
  #battle-action-panel .battle-command-layout-v5 > #ba-basic-attack-btn {
    height: 66px !important;
  }
  #battle-action-panel .battle-skills-row {grid-auto-rows: 33px !important;}
  #battle-mini-log {flex-basis: 35px;min-height:35px;}
  #battle-mini-log summary {height:35px;}
}
@media (min-width: 600px) {
  #battle-action-panel {max-width: 480px !important;}
  #battle-target-buttons {max-width: 660px !important;margin:0 auto !important;}
}
@media (orientation: landscape) and (max-height: 480px) {
  #battle-arena {overflow-y:auto !important;}
  #battle-stage-preview {min-height: 100px !important;}
}


/* ── V6 refinement: existing V5 player buffs, unchanged icon/disclosure sizes ──
   Real .battle-unit-effects-v5 node is moved here after the V5 renderer.
   The original timed art (16–19px), 23px disclosure and detail rows remain intact. */
#battle-effects-strip {
  flex: 0 0 auto !important;
  width: 100% !important;
  min-height: 30px !important;
  max-height: min(24dvh, 136px) !important;
  box-sizing: border-box !important;
  padding: 3px 8px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #261b15, #160f0c) !important;
  border-bottom: 1px solid #90643b !important;
  color: #e6d2a6 !important;
}
#battle-effects-strip .battle-effects-anchor-v6 {
  width: 100% !important;
  min-height: 23px !important;
}
#battle-effects-strip .battle-unit-effects-v5 {
  display: flex !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 2px !important;
  flex-wrap: wrap !important;
  align-items: center !important;
}
#battle-effects-strip .orbis-buff-detail-panel {
  width: 100% !important;
  max-width: 100% !important;
}
#battle-effects-strip .battle-effects-empty-v6 {
  display: block;
  font: 10px/22px Georgia, "Times New Roman", serif;
  color: #907a5f;
}
/* Compact team rows still hide V5 effects there; icons appear in this strip. */

/* ── Bottom columns: LEFT Auto → Attack → Escape, RIGHT items → 8 skills ──
   Move the existing V5 controls without cloning their event handlers. */
#battle-action-panel .battle-compact-layout-v6 {
  display: grid !important;
  grid-template-columns: minmax(0, 23%) minmax(0, 75%) !important;
  gap: 2% !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  width: 100% !important;
  margin: 0 !important;
  min-width: 0 !important;
}
#battle-action-panel .battle-compact-left-v6 {
  min-width: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: 29px 75px 25px !important;
  gap: 3px !important;
  align-items: stretch !important;
}
#battle-action-panel .battle-compact-right-v6 {
  min-width: 0 !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: 34px 101px !important;
  gap: 3px !important;
  align-items: stretch !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle {
  grid-area: auto !important;
  width: 100% !important;
  min-width: 0 !important; /* Override legacy 132px minimum: match Attack column. */
  max-width: 100% !important;
  box-sizing: border-box !important;
  height: 29px !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  transform: none !important;
  padding: 1px 2px !important;
  gap: 2px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  border: 1px solid #9b713c !important;
  border-radius: 6px !important;
  background: linear-gradient(180deg,#654527,#2b1a10) !important;
  background-image: none !important;
  font-size: 10px !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-basic-attack-btn {
  grid-area: auto !important;
  width: 100% !important;
  height: 75px !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  padding: 3px !important;
  border: 1px solid #bd8b40 !important;
  border-radius: 7px !important;
  background: linear-gradient(150deg,#634322,#29180f) !important;
  background-image: none !important;
  font-size: 12px !important;
}
#battle-action-panel .battle-compact-left-v6 > .arena-escape-row {
  display: flex !important;
  justify-content: stretch !important;
  align-items: stretch !important;
  width: 100% !important;
  height: 25px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
#battle-action-panel .battle-compact-left-v6 .arena-escape-btn {
  width: 100% !important;
  max-width: none !important;
  height: 25px !important;
  min-height: 25px !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  padding: 0 2px !important;
  border: 1px solid #906b3e !important;
  border-radius: 6px !important;
  background: linear-gradient(180deg,#583820,#22150c) !important;
  background-image: none !important;
  font-size: 10px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
#battle-action-panel .battle-compact-right-v6 > .battle-consumables-v5 {
  grid-area: auto !important;
  justify-self: end !important;
  align-self: center !important;
  width: max-content !important;
  max-width: 100% !important;
  height: 34px !important;
  margin: 0 !important;
  display: grid !important;
  grid-template-columns: var(--battle-item-size) var(--battle-item-size) var(--battle-scroll-width) !important;
  column-gap: 3px !important;
  align-items: center !important;
}
#battle-action-panel .battle-compact-right-v6 > .battle-skills-row {
  grid-area: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 0 !important;
  height: 101px !important;
  max-height: 101px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(4,minmax(0,1fr)) !important;
  grid-auto-rows: 49px !important;
  grid-auto-flow: row !important;
  gap: 3px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  align-items: stretch !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot {
  width: 100% !important;
  height: 49px !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
}
/* V5 centered slots 6/7 in a six-slot layout and hid empty 8/9.
   For eight skills, clear those overrides and always reserve all eight cells. */
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > #skill-slot-6,
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > #skill-slot-7 {
  grid-column: auto !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > #skill-slot-8,
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > #skill-slot-9 {
  display: block !important;
  grid-column: auto !important;
}

/* Narrow / short phones: stay in two skill rows, reduce heights together. */
@media (max-height: 660px) {
  #battle-action-panel .battle-compact-left-v6 {
    grid-template-rows: 27px 66px 24px !important;
  }
  #battle-action-panel .battle-compact-right-v6 {
    grid-template-rows: 31px 92px !important;
  }
  #battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle {height:27px !important;}
  #battle-action-panel .battle-compact-left-v6 > #ba-basic-attack-btn {height:66px !important;}
  #battle-action-panel .battle-compact-left-v6 .arena-escape-btn {height:24px !important;min-height:24px !important;}
  #battle-action-panel .battle-compact-right-v6 > .battle-skills-row {
    height:92px !important;
    max-height:92px !important;
    grid-auto-rows:44px !important;
  }
  #battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot {
    height:44px !important;
  }
}
@media (max-width: 359px) {
  #battle-action-panel .battle-compact-left-v6 .arena-escape-btn {font-size:9px !important;}
}


/* Five equipped consumable types (stack counts summed by item ID).
   Replaces fixed HP/MP and separate scroll button; skill grid is unchanged. */
#battle-action-panel .battle-compact-right-v6 > .battle-consumables-v5 {
  display:block !important;
  grid-area:auto !important;
  align-self:stretch !important;
  justify-self:stretch !important;
  width:100% !important;
  max-width:100% !important;
  height:34px !important;
  min-height:0 !important;
  margin:0 !important;
  padding:0 !important;
}
#battle-quickbar-slots {
  display:grid !important;
  grid-template-columns:repeat(5,minmax(0,1fr)) !important;
  gap:4px !important;
  width:100% !important;
  height:100% !important;
  margin:0 !important;
  padding:0 !important;
  align-items:center !important;
}
#battle-quickbar-slots .orbis-quick-slot {
  height:34px !important;
  aspect-ratio:auto !important;
  min-width:0 !important;
  width:100% !important;
  padding:1px !important;
  background-image:none !important;
  border-radius:5px !important;
}
#battle-quickbar-slots .orbis-quick-slot:disabled {opacity:.55;cursor:default;}
#battle-quickbar-slots .orbis-quick-slot:active:not(:disabled) {filter:brightness(1.2);}
#battle-quickbar-slots .orbis-quick-slot-art {
  width:100%;
  height:100%;
  object-fit:contain;
}
#battle-quickbar-slots .orbis-quick-slot-count {
  font-size:10px;
  right:1px;
  bottom:1px;
}
@media (max-height:660px) {
  #battle-action-panel .battle-compact-right-v6 > .battle-consumables-v5 {height:31px !important;}
  #battle-quickbar-slots .orbis-quick-slot {height:31px !important;}
}


/* === V6 battle visual polish: ember & sapphire, test branch only === */
/* Presentation only. Do not alter the existing compact grid tracks,
   touch targets, skill IDs, cooldown timers, quickbar data or game actions. */
#battle-action-panel {
  background:
    radial-gradient(ellipse at 50% -25%, #b9772938 0%, transparent 73%),
    linear-gradient(90deg, #6b431f50, transparent 16%, transparent 84%, #6b431f50),
    linear-gradient(180deg, #553219 0%, #301c11 14%, #1d120e 64%, #322015 100%) !important;
  box-shadow:
    0 -4px 16px #000a,
    inset 0 2px 0 #c9974b,
    inset 0 4px 0 #f3d49035,
    inset 0 -1px 0 #a07137,
    inset 0 -4px 9px #090503aa !important;
  box-sizing: border-box !important;
}
#battle-action-panel .battle-compact-layout-v6 {
  position: relative;
}
#battle-action-panel .battle-compact-layout-v6::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 23.95%;
  width: 1px;
  background: linear-gradient(180deg, transparent, #d5a15a9c 20%, #e1b365 50%, #d5a15a9c 80%, transparent);
  box-shadow: 0 0 4px #d49b4580;
  pointer-events: none;
}
#battle-action-panel .battle-compact-left-v6,
#battle-action-panel .battle-compact-right-v6 {
  border-radius: 6px;
  background:
    linear-gradient(145deg, #e6a64f12 0%, transparent 42%),
    linear-gradient(180deg, #2f1b1296, #170e0ba3);
  box-shadow: inset 0 0 0 1px #c5964a40, inset 0 1px 7px #0805038a;
}

/* The three combat commands have distinct roles, not grey identical tiles. */
#battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle {
  color: #e3f4ff !important;
  border-color: #548ab5 !important;
  background: linear-gradient(180deg, #356c93 0%, #174061 48%, #10273d 100%) !important;
  background-image: linear-gradient(180deg, #356c93, #174061 48%, #10273d) !important;
  box-shadow: inset 0 1px 0 #b5e9ff66, inset 0 -4px 6px #050f21a8, 0 0 0 1px #0c2730 !important;
  text-shadow: 0 1px 2px #000e, 0 0 5px #7ebdff66 !important;
  font-weight: 800 !important;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
#battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle::before {
  width: 8px !important;
  height: 8px !important;
  flex: 0 0 8px !important;
  border: 1px solid #b5cbe1 !important;
  background: #162b3b !important;
  box-shadow: inset 0 1px 2px #000c, 0 0 0 1px #07131f !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle.is-on {
  border-color: #9ccde9 !important;
  background: linear-gradient(180deg, #328ea9, #155c83 58%, #0d354e) !important;
  box-shadow: inset 0 1px 0 #d7fcff85, 0 0 8px #59bde277, inset 0 -3px 6px #061a36b8 !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle.is-on::before {
  background: radial-gradient(circle, #a6faff 0 38%, #329fdf 49% 100%) !important;
  border-color: #d7fcff !important;
  box-shadow: 0 0 7px #72d9ffbb !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-basic-attack-btn {
  color: #ffedc9 !important;
  border-color: #d49a4f !important;
  background: 
    radial-gradient(ellipse at 50% 18%, #cc622dba, transparent 73%),
    linear-gradient(165deg, #863518, #562016 58%, #29130f) !important;
  background-image:
    radial-gradient(ellipse at 50% 18%, #cc622dba, transparent 73%),
    linear-gradient(165deg, #863518, #562016 58%, #29130f) !important;
  box-shadow:
    inset 0 1px 0 #ffe0a080,
    inset 0 -8px 13px #190702ab,
    0 0 0 1px #442315,
    0 0 9px #b6442629 !important;
  text-shadow: 0 2px 2px #160504, 0 0 7px #f78b4380 !important;
  font-weight: 900 !important;
}
#battle-action-panel .battle-compact-left-v6 > #ba-basic-attack-btn:active:not(:disabled) {
  border-color: #ffcf76 !important;
  box-shadow: inset 0 0 12px #ffa85b8f, 0 0 9px #ef7a3899 !important;
}
#battle-action-panel .battle-compact-left-v6 .arena-escape-btn {
  color: #ffdfd8 !important;
  border-color: #9e5557 !important;
  background: linear-gradient(180deg, #713439, #431e27 61%, #251217) !important;
  background-image: linear-gradient(180deg, #713439, #431e27 61%, #251217) !important;
  box-shadow: inset 0 1px 0 #ffbcbf3b, inset 0 -4px 6px #0b0609b3, 0 0 0 1px #2a1117 !important;
  text-shadow: 0 1px 2px #090406 !important;
}
#battle-action-panel .battle-compact-left-v6 .arena-escape-btn:active:not(:disabled) {
  border-color: #da8e8b !important;
  background: linear-gradient(180deg, #964249, #54232e 65%, #291317) !important;
}

/* The five-slot band is a single bronze item belt. Slot area is unchanged. */
#battle-action-panel .battle-compact-right-v6 > .battle-consumables-v5 {
  border-radius: 5px !important;
  background:
    linear-gradient(180deg, #8a562a44, #170f0ab0 50%, #6d45264d) !important;
  box-shadow: inset 0 0 0 1px #c0934f7a, inset 0 1px 3px #000b !important;
}
#battle-quickbar-slots .orbis-quick-slot {
  border: 1px solid #be965b !important;
  border-radius: 5px !important;
  background: radial-gradient(ellipse at 50% 12%, #7b552f9e, transparent 77%), linear-gradient(160deg, #4c321e, #170f0b) !important;
  box-shadow: inset 0 1px 0 #f5cf7d4d, inset 0 -3px 7px #0c0705bb, 0 0 0 1px #120b0873 !important;
}
#battle-quickbar-slots .orbis-quick-slot[data-consumable-type="potion"] {
  border-color: #d48869 !important;
  background: radial-gradient(ellipse at 50% 12%, #a64a3388, transparent 76%), linear-gradient(160deg, #563020, #1a1110) !important;
}
/* Existing item-family metadata distinguishes red HP and blue MP potions. */
#battle-quickbar-slots .orbis-quick-slot[data-consumable-affinity="hp"] {
  border-color: #df8466 !important;
  background: radial-gradient(ellipse at 50% 12%, #c341368a, transparent 76%), linear-gradient(160deg, #5b2820, #1c1010) !important;
  box-shadow: inset 0 1px 0 #ffd8a455, inset 0 -3px 7px #120705c9, 0 0 3px #df583d65 !important;
}
#battle-quickbar-slots .orbis-quick-slot[data-consumable-affinity="mp"] {
  border-color: #64a4de !important;
  background: radial-gradient(ellipse at 50% 12%, #267fc8a3, transparent 76%), linear-gradient(160deg, #173959, #0d151f) !important;
  box-shadow: inset 0 1px 0 #b1e4ff77, inset 0 -3px 7px #06101bcc, 0 0 3px #328fd687 !important;
}
#battle-quickbar-slots .orbis-quick-slot[data-consumable-type="elixir"] {
  border-color: #6ca7c1 !important;
  background: radial-gradient(ellipse at 50% 12%, #267caa87, transparent 76%), linear-gradient(160deg, #213e53, #10181e) !important;
}
#battle-quickbar-slots .orbis-quick-slot[data-consumable-type="scroll"] {
  border-color: #c7a16a !important;
  background: radial-gradient(ellipse at 50% 12%, #91643f99, transparent 76%), linear-gradient(160deg, #4c3522, #1b1510) !important;
}
#battle-quickbar-slots .orbis-quick-slot.is-empty:disabled {
  opacity: .87 !important;
  border-color: #71563b !important;
  background: linear-gradient(145deg, #38291c, #160f0b) !important;
  box-shadow: inset 0 0 7px #0009, inset 0 0 0 1px #ae7b3440 !important;
}
#battle-quickbar-slots .orbis-quick-slot.is-filled:active:not(:disabled) {
  filter: brightness(1.16);
  box-shadow: inset 0 0 6px #f7c77994, 0 0 7px #edbd667a !important;
}
#battle-quickbar-slots .orbis-quick-slot-count {
  right: 1px !important;
  bottom: 1px !important;
  padding: 1px 2px !important;
  border-radius: 3px;
  color: #fff5cf !important;
  background: #180e0bcd;
  box-shadow: 0 0 0 1px #a16c385c;
  text-shadow: 0 1px 2px #000, 0 0 2px #000 !important;
}
#battle-quickbar-slots .orbis-quick-slot-placeholder {
  color: #ad8655 !important;
  opacity: .72 !important;
}

/* 8-slot skill board: warm gold around the original artwork.
   The actual skill icons and cooldown overlays remain untouched. */
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot {
  border-color: #a87b45 !important;
  border-radius: 6px !important;
  background: linear-gradient(155deg, #4c301a, #1d130e 63%, #372212) !important;
  box-shadow: inset 0 1px 0 #f7da9666, inset 0 0 0 1px #3b2110, inset 0 -4px 7px #08050499 !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot:not(.empty):not(.on-cooldown) {
  border-color: #d9ad68 !important;
  box-shadow: inset 0 1px 0 #fbe9be8a, inset 0 0 0 1px #70431f, 0 0 5px #f3ae5455 !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot.empty {
  opacity: .86 !important;
  border-color: #765632 !important;
  background: linear-gradient(150deg, #36271b, #120e0b 65%, #261b12) !important;
  box-shadow: inset 0 0 7px #000b, inset 0 1px 0 #976b403b !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot.on-cooldown {
  border-color: #91714d !important;
  box-shadow: inset 0 0 8px #000b, 0 0 0 1px #3e2819 !important;
}
#battle-action-panel .battle-compact-right-v6 .battle-skills-row .cd-overlay {
  border: 1px solid #bc905f7a !important;
  border-radius: 5px !important;
  background: linear-gradient(180deg, #160f0bde, #261b17c7) !important;
  color: #ffe9ba !important;
  text-shadow: 0 1px 3px #000 !important;
  font-weight: 900 !important;
}

/* Combat-only journal: gilded header and ink-like dark parchment.
   Summary height, expandable history and two-message preview stay intact. */
#battle-mini-log {
  border-top: 1px solid #cb974d !important;
  background:
    linear-gradient(90deg, #9360322e, transparent 18%, transparent 82%, #9360322e),
    linear-gradient(180deg, #3d281a, #221811 40%, #150f0c) !important;
  box-shadow: inset 0 2px 0 #f1ce8445, 0 -2px 7px #0009 !important;
  color: #f1d9b0 !important;
}
#battle-mini-log summary {
  color: #f5dfb7 !important;
  text-shadow: 0 1px 2px #000 !important;
}
#battle-mini-log summary::before {
  color: #f3bc65 !important;
  text-shadow: 0 0 5px #b97c3580, 0 1px 1px #000 !important;
}
#battle-mini-log[open] {
  background: linear-gradient(180deg, #332115, #1d1510) !important;
}
#battle-mini-log-history {
  border-top: 1px solid #a3743e69 !important;
  color: #ecd4aa !important;
}
#battle-mini-log .battle-mini-log-row {
  padding: 2px 0 3px;
  border-bottom: 1px solid #8c603329;
}
@media (prefers-reduced-motion: reduce) {
  #battle-action-panel .battle-compact-left-v6 > #ba-auto-attack-toggle {
    transition: none !important;
  }
}


/* R1 leather paper-doll: alpha layers share the original 1024x1536 pose.
   Legacy (currently unused) paperdoll overlay retains its own original 1.23x alignment.
   Enemy and target portraits are not changed. */
.battle-stage-figure[data-side="ally"] .battle-stage-art {
    position: relative;
}
.battle-stage-figure[data-side="ally"] .battle-stage-art img.orbis-paperdoll-battle-layer {
    display: block;
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 100%;
    max-width: min(48vw, 220px);
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center bottom;
    transform: translateX(-50%) scale(1.23);
    transform-origin: center bottom;
    background: transparent;
    border: 0;
    border-radius: 0;
    filter: none;
    z-index: 2;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}


/* Region battle backdrops: single painted image selected at battle start.
   Top cards, status icons, skill UI, target art and player sprites unchanged.
   Only stage receives a background, never the whole arena. */
#battle-stage-preview.orbis-region-background {
  background-image:
    linear-gradient(180deg,rgba(15,11,7,.09) 0%,rgba(15,11,7,.05) 58%,rgba(15,10,7,.38) 100%),
    var(--orbis-region-stage-url) !important;
  background-size: 100% 100%, cover !important;
  background-position: center center, center center !important;
  background-repeat: no-repeat !important;
}


/* V6: override the V5 wood-texture background behind the top cards and
   battle scene. Use the same smooth brown gradients as the lower HUD. */
#battle-arena {
  background: linear-gradient(180deg,#3b271b 0%,#2e1e15 17%,#20150f 45%,#1b120d 68%,#332115 100%) !important;
  background-image: linear-gradient(180deg,#3b271b 0%,#2e1e15 17%,#20150f 45%,#1b120d 68%,#332115 100%) !important;
  background-repeat: no-repeat !important;
}

/* The illustrated region panorama covers the central stage only.
   Each image URL is absolute and set once per fight. */
#battle-stage-preview.orbis-region-background {
  background-color: #221710 !important;
  background-image:
    linear-gradient(180deg,rgba(13,9,6,.07),rgba(13,9,6,.04) 55%,rgba(13,9,6,.43)),
    var(--orbis-region-stage-url) !important;
  background-size: 100% 100%, cover !important;
  background-position: center, center !important;
  background-repeat: no-repeat !important;
}

/* Plain dark-brown tiles, no old image textures. */
#battle-action-panel .battle-compact-right-v6 .battle-skills-row > .action-slot.main-slot.empty {
  background: linear-gradient(165deg,#3c291c,#20160f 55%,#130e0b) !important;
  background-image: linear-gradient(165deg,#3c291c,#20160f 55%,#130e0b) !important;
}


/* Approved battle-stage separation: soften scenery, preserve its details.
   All overlays are behind the two real characters and never cover controls. */
#battle-stage-preview {
  position: relative;
  isolation: isolate;
}
#battle-stage-preview.orbis-region-background::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 48% 72% at 25% 68%, rgba(31,23,17,.19), transparent 90%),
    radial-gradient(ellipse 48% 72% at 75% 68%, rgba(28,20,15,.23), transparent 90%),
    linear-gradient(180deg, rgba(23,17,13,.05) 0%, rgba(20,14,11,.13) 57%, rgba(17,11,8,.28) 100%);
}
#battle-stage-preview .battle-stage-figure {
  position: relative;
  z-index: 1;
  min-width: 0;
}
#battle-stage-preview .battle-stage-art {
  position: relative;
  isolation: isolate;
}
#battle-stage-preview .battle-stage-art::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 72%;
  height: clamp(10px, 2.1dvh, 20px);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(13,9,7,.62) 0%, rgba(13,9,7,.28) 43%, transparent 73%);
  pointer-events: none;
}
#battle-stage-preview .battle-stage-figure[data-side="enemy"] .battle-stage-art {
  overflow: hidden;
}
#battle-stage-preview .battle-stage-figure[data-side="ally"] .battle-stage-art > img.battle-stage-player-avatar-v6,
#battle-stage-preview .battle-stage-figure[data-side="enemy"] .battle-stage-art > img {
  position: relative;
  z-index: 1;
}
#battle-stage-preview .battle-stage-figure[data-side="ally"] .battle-stage-art > img.battle-stage-player-avatar-v6 {
  filter: drop-shadow(0 1px 1px rgba(239,215,169,.25))
          drop-shadow(1px 7px 8px rgba(9,6,4,.82)) contrast(1.055) !important;
}
#battle-stage-preview .battle-stage-figure[data-side="enemy"] .battle-stage-art > img {
  filter: drop-shadow(0 1px 1px rgba(244,215,174,.48))
          drop-shadow(1px 7px 8px rgba(10,6,4,.88)) contrast(1.085) brightness(1.04) !important;
}
/* Silhouette-measured square images can be wider than their visible subject.
   Their visible alpha footprint, not the square canvas, is width-capped.
   The enemy host clips its own half so no mob can cover the player. */
#battle-stage-preview .battle-stage-figure[data-side="enemy"] .battle-stage-art > img.battle-stage-measured-enemy-v6 {
  position: absolute !important;
  z-index: 1;
  left: var(--battle-enemy-left) !important;
  bottom: var(--battle-enemy-bottom) !important;
  top: auto !important;
  width: var(--battle-enemy-width) !important;
  height: var(--battle-enemy-height) !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
  transform: none !important;
}
/* Fallback for file:// restrictions: unmeasured cutouts stay contained. */

/* Boss presence, only when the selected enemy has runtime difficulty=boss.
   The right-side sprite may extend across the centre, never over the hero. */
#battle-stage-preview.battle-stage-boss-active .battle-stage-figure[data-side="enemy"] {
  z-index: 2;
}
#battle-stage-preview.battle-stage-boss-active .battle-stage-figure[data-side="enemy"] .battle-stage-art {
  overflow: visible !important;
}
#battle-stage-preview.battle-stage-boss-active .battle-stage-figure[data-side="enemy"] .battle-stage-art > img {
  filter:
    drop-shadow(0 0 2px rgba(155,40,57,.94))
    drop-shadow(0 0 6px rgba(103,29,102,.83))
    drop-shadow(0 0 11px rgba(61,21,88,.57))
    drop-shadow(2px 8px 8px rgba(15,5,13,.85))
    contrast(1.075) !important;
}
/* The little enemy portrait gets only the aura, not a size change. */
#battle-target-buttons .battle-team-unit[data-battle-difficulty="boss"] .battle-unit-portrait-v5 {
  filter: drop-shadow(0 0 3px rgba(139,31,66,.85))
          drop-shadow(0 0 5px rgba(91,29,119,.7)) !important;
}


/* The normal ancient sentry can use the centre gap (not the boss 65% zone).
   Its measured visible pixels stay clear of the hero and viewport. */
#battle-stage-preview.battle-stage-sentry-tall .battle-stage-figure[data-side="enemy"] .battle-stage-art {
  overflow: visible !important;
}
