/* SPI-51 follow-up (1 Dec 2026): in-battle chrome, frameless Chaos art,
   and alignment. Loaded just before fight_fit.css. Hide-during-battle rules
   are also in fight_fit.css so they win over blaze_hud_skin.css.
   No button scaling (SPI-53 owns low-res Android shrinking). */

/* ---- Lobby controls: SFX, music, fullscreen (and the HUD picker) live
   in the pre-battle menu, not over the fight. ---- */
#pvpLobbyControls.pvp-lobby-controls{
  display:flex;flex-wrap:wrap;justify-content:center;align-items:center;
  gap:8px;margin:8px auto 10px;padding:0 10px;max-width:520px;
  box-sizing:border-box;
}
#pvpLobbyControls[hidden],
html body:has(#battle:not(.hide)) #pvpLobbyControls,
html body:has(#result:not(.hide)) #pvpLobbyControls{
  display:none!important;
}
#pvpLobbyControls #pvpFullscreen,
#pvpLobbyControls #dexaSfxBtn,
#pvpLobbyControls #dexaGlobalMusicBtn,
#pvpLobbyControls #hudLaunch{
  position:static!important;top:auto!important;right:auto!important;left:auto!important;
  bottom:auto!important;transform:none!important;z-index:auto!important;
  width:auto!important;height:auto!important;min-height:40px!important;
  margin:0!important;padding:8px 12px!important;
  border-radius:999px!important;
  font:800 11px/1.2 system-ui,sans-serif!important;
}

/* ---- Frameless Chaos cards: keep the inner picture size, drop the frame. ---- */
html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile{
  --chaos-art-w:42px; /* was a 50px framed tile (3px pad + 1px border each side) */
  width:var(--chaos-art-w)!important;
  min-width:var(--chaos-art-w)!important;
  max-width:var(--chaos-art-w)!important;
  padding:0!important;
  border:0!important;
  border-radius:0!important;
  background:none!important;
  box-shadow:none!important;
  backdrop-filter:none!important;
  gap:2px!important;
}
html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile > img,
html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile > span[aria-hidden]{
  width:100%!important;
  border-radius:4px!important;
  box-shadow:0 1px 4px rgba(0,0,0,.45)!important;
}
html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile .battle-chaos-name{
  min-height:0!important;
  font:700 7px/1.1 system-ui,sans-serif!important;
  letter-spacing:.01em!important;
  text-align:center!important;
}
@media (max-width:379px){
  html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile{--chaos-art-w:34px}
}
@media (max-height:520px) and (min-width:521px){
  html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile{--chaos-art-w:32px}
}
@media (max-height:520px) and (min-width:560px) and (orientation:landscape){
  html[data-hudpack] body #battle#battle .battle-chaos-strip .battle-chaos-tile{--chaos-art-w:34px}
}
@media (min-width:1020px){
  html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile{--chaos-art-w:86px}
}
@media (min-width:1020px) and (max-height:700px){
  html[data-hudpack] body #battle .battle-chaos-strip .battle-chaos-tile{--chaos-art-w:62px}
}

/* ---- Portrait button grid: centred, even gaps; history stays on screen.
   Labels and cost sit in the baked art; contain+center so they stay in frame
   without shrinking the button. ---- */
html body:has(#battle:not(.hide)) main #battle#battle:not(.hide) > .moves:has(#strike){
  width:100%!important;
  max-width:100%!important;
  margin-left:auto!important;
  margin-right:auto!important;
  padding-left:12px!important;
  padding-right:12px!important;
  box-sizing:border-box!important;
  justify-items:center!important;
  justify-content:center!important;
  column-gap:8px!important;
  row-gap:8px!important;
}
html body:has(#battle:not(.hide)) main #battle#battle:not(.hide) > .moves:has(#strike) > :is(#strike,#lightPower,#ability,#guard,#regen,#siphon){
  background-position:50% 50%!important;
  justify-self:center!important;
  margin-left:auto!important;
  margin-right:auto!important;
}
@media (orientation:portrait){
  html body:has(#battle:not(.hide)) main #battle#battle:not(.hide) > .moves:has(#strike) > :is(#strike,#lightPower,#ability,#guard,#regen,#siphon){
    background-size:contain!important;
    background-position:50% 50%!important;
  }
}
html body:has(#battle:not(.hide)) main #battle#battle:not(.hide) > .battle-history{
  flex:0 0 auto!important;
  margin:6px 12px max(12px, env(safe-area-inset-bottom, 0px))!important;
  max-width:calc(100% - 24px)!important;
  box-sizing:border-box!important;
}

/* ---- HUD readouts stay inside the panel; the portrait ring is centred on the face. ---- */
html body:has(#battle:not(.hide)) #battle .arena-hud .hud-v2-panel > b,
html body:has(#battle:not(.hide)) #battle .arena-hud #an,
html body:has(#battle:not(.hide)) #battle .arena-hud #bn,
html body:has(#battle:not(.hide)) #battle .arena-hud .hp-readout,
html body:has(#battle:not(.hide)) #battle .arena-hud .resource-label{
  max-width:100%!important;
  overflow:hidden!important;
  text-overflow:ellipsis!important;
}


/* ---- In-fight Chaos: small archetype symbols under each HUD plate. Menu art stays as-is. ---- */
html[data-hudpack] body:has(#battle:not(.hide)) #battle#battle #arena#arena > #battleChaosStrip.battle-chaos-strip,
html body:has(#battle:not(.hide)) #battle #battleChaosStrip.battle-chaos-strip{
  position:absolute!important;
  left:0!important;right:0!important;top:0!important;bottom:auto!important;
  width:100%!important;height:0!important;min-height:0!important;
  margin:0!important;padding:0!important;
  overflow:visible!important;pointer-events:none!important;z-index:8!important;
  align-items:flex-start!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-side,
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-side.right{
  position:absolute!important;
  display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;
  align-items:center!important;justify-content:center!important;
  gap:6px!important;
  height:28px!important;min-height:28px!important;
  pointer-events:none!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-side{justify-content:flex-start!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-side.right{justify-content:flex-end!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile{
  --chaos-art-w:22px;
  width:22px!important;height:22px!important;min-width:22px!important;max-width:22px!important;
  padding:0!important;margin:0!important;gap:0!important;
  border:0!important;border-radius:50%!important;
  background:rgba(6,10,16,.55)!important;
  box-shadow:0 0 0 1px rgba(255,255,255,.18),0 1px 3px rgba(0,0,0,.45)!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile > img,
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile .battle-chaos-art,
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile .battle-chaos-name{
  display:none!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-symbol{
  display:block!important;width:14px!important;height:14px!important;
  color:#fff6c8!important;line-height:0!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-symbol svg{
  display:block!important;width:100%!important;height:100%!important;
}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="BLAZE"] .battle-chaos-symbol{color:#FF1E1E!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="FROST"] .battle-chaos-symbol{color:#8FD4FF!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="VOLT"] .battle-chaos-symbol{color:#FFE033!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="STORM"] .battle-chaos-symbol{color:#FFFFFF!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="POWER"] .battle-chaos-symbol{color:#22D46A!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="SHADOW"] .battle-chaos-symbol{color:#A855F7!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="TOXIC"] .battle-chaos-symbol{color:#3DDC6A!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="TITAN"] .battle-chaos-symbol{color:#8B929A!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="PULSE"] .battle-chaos-symbol{color:#FF1E1E!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="ROCKET"] .battle-chaos-symbol{color:#FF1E1E!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="CRYSTAL"] .battle-chaos-symbol{color:#12C56C!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="GEAR"] .battle-chaos-symbol{color:#C8872E!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="PHANTOM"] .battle-chaos-symbol{color:#5EC8FF!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="TERRA"] .battle-chaos-symbol{color:#FF8A14!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="NOVA"] .battle-chaos-symbol{color:#FFD000!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="MYSTIC"] .battle-chaos-symbol{color:#FF5AA8!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile[data-fighter="DEXATRON"] .battle-chaos-symbol{color:#B8FF1A!important}
html body:has(#battle:not(.hide)) #battle #battleChaosStrip .battle-chaos-tile.countered{
  opacity:.42!important;filter:grayscale(.35)!important;
}

/* SPI-91: brief icon flash of the activated Chaos card — small, centred,
   pointer-events none, does not cover the fight. The large full-card pop is gone. */
#chaosCardPop.chaos-card-pop{
  position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;
  pointer-events:none;background:transparent;
}
#chaosCardPop.chaos-card-pop[hidden]{display:none!important}
#chaosCardPop.chaos-card-pop img{
  width:min(16vw, 64px);height:auto;aspect-ratio:3/4;object-fit:contain;
  border-radius:6px;box-shadow:0 4px 16px rgba(0,0,0,.4);
  transform:scale(.4);opacity:0;
}
#chaosCardPop.chaos-card-pop.is-in img{animation:spi51-chaos-icon-flash-in .12s ease-out forwards}
#chaosCardPop.chaos-card-pop.is-out img{animation:spi51-chaos-icon-flash-out .12s ease-in forwards}
@keyframes spi51-chaos-icon-flash-in{from{transform:scale(.4);opacity:0}to{transform:scale(1);opacity:1}}
@keyframes spi51-chaos-icon-flash-out{from{transform:scale(1);opacity:1}to{transform:scale(.6);opacity:0}}

/* SPI-91: in portrait only, drop the top fight HUD by 10% of the viewport
   height plus the notch / status-bar inset so the top of the plate is visible.
   Landscape is unchanged. */
@media (orientation:portrait){
  html body:has(#battle:not(.hide)) #battle#battle:not(.hide) #arena#arena > .arena-hud,
  html[data-hudpack] body:has(#battle:not(.hide)) main[data-hud] #battle#battle #arena#arena > .arena-hud.fight,
  html[data-hudpack] body:has(#battle:not(.hide)) main[data-hud] #battle .pve-parity-arena > .arena-hud,
  html:not([data-hudpack]) body:has(#battle:not(.hide)) main[data-hud] #battle #arena.pve-parity-arena > .fight.arena-hud{
    margin-top:calc(10vh + env(safe-area-inset-top, 0px))!important;
  }
}

/* LIGHT POWER / LIFE SIPHON: keep baked label and cost plaque in-frame.
   A second CSS cost pill on pack buttons was sitting on the label. */
html body:has(#battle:not(.hide)) main #battle#battle:not(.hide) > .moves:has(#strike) > :is(#lightPower,#siphon){
  background-size:contain!important;
  background-position:50% 50%!important;
  background-repeat:no-repeat!important;
  overflow:visible!important;
}
html body:has(#battle:not(.hide)) main[data-hud] #battle#battle:not(.hide) > .moves:has(#strike) > :is(#lightPower,#siphon)::after{
  display:none!important;
  content:none!important;
}
