/**
 * MobileKernel chrome — HP / portrait must NEVER cover the board.
 * Loaded after champion-chrome.css. body.mobile-kernel is set by MobileKernel.js.
 *
 * Law: BoardKernel owns squares. MobileKernel owns shell chrome slots.
 */

/* ── Claim wins over desktop fixed left dock ── */
html body.mobile-kernel.chess-page.world-champion-chrome .chess-hero-portrait,
html body.mobile-kernel.chess-page.world-champion-chrome #chess-hero-portrait,
html body.mobile-kernel.world-champion-chrome .chess-hero-portrait,
html body.mobile-kernel.world-champion-chrome #chess-hero-portrait,
html body.m-body-chess.world-champion-chrome .chess-hero-portrait,
html body.m-body-chess.world-champion-chrome #chess-hero-portrait,
html body.m-body-battle.world-champion-chrome .chess-hero-portrait,
html body.m-body-battle.world-champion-chrome #chess-hero-portrait {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 2 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  backdrop-filter: none !important;
  pointer-events: none !important;
}

/*
 * Practice + battle: hide full desktop portrait dock entirely.
 * Vitals live in m-play-vitals / clocks / MobileKernel strip — not over squares.
 */
html body.mobile-kernel.m-body-chess .chess-hero-portrait,
html body.mobile-kernel.m-body-chess #chess-hero-portrait,
html body.mobile-kernel.m-body-battle .chess-hero-portrait,
html body.mobile-kernel.m-body-battle #chess-hero-portrait,
html body.m-body-chess .m-chess-board-host .chess-hero-portrait,
html body.m-body-battle .m-chess-board-host .chess-hero-portrait,
html body.m-body-battle .chess-hero-portrait,
html body.mobile-kernel #chess-hero-portrait[data-mobile-hidden='1'] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  z-index: -1 !important;
}

/* Rails inside portrait must not float either */
html body.mobile-kernel #live-hp-rail,
html body.mobile-kernel #live-xp-rail,
html body.m-body-chess #live-hp-rail,
html body.m-body-chess #live-xp-rail,
html body.m-body-battle #live-hp-rail,
html body.m-body-battle #live-xp-rail {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 1 !important;
}

/* Board host always above any stray chrome */
html body.mobile-kernel .m-chess-board-host,
html body.mobile-kernel .m-battle-host,
html body.mobile-kernel #board-wrapper,
html body.m-body-chess #board-wrapper,
html body.m-body-battle #board-wrapper {
  position: relative !important;
  z-index: 5 !important;
}

/* Slim optional vitals host (when present in forge dock) */
#m-mobile-vitals,
.mobile-kernel-vitals-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 6;
}

/* Narrow desktop chess without m-body: bottom strip, never mid-board */
@media (max-width: 700px) {
  html body.mobile-kernel.chess-page:not(.m-body-chess):not(.m-body-battle)
    .chess-hero-portrait,
  html body.mobile-kernel.chess-page:not(.m-body-chess):not(.m-body-battle)
    #chess-hero-portrait {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: max(4.5rem, env(safe-area-inset-bottom, 0px)) !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    flex-direction: row !important;
    z-index: 30 !important;
    max-height: 4.5rem !important;
    overflow: hidden !important;
  }
  /* Board stays clear of bottom strip */
  html body.mobile-kernel.chess-page:not(.m-body-chess):not(.m-body-battle)
    #board-wrapper {
    margin-bottom: 0.5rem !important;
  }
}
