/* Header global fixo e area segura para todas as janelas do jogo. */
:root {
  --nrmt-fixed-header-height: var(--bi-top, 58px);
  --nrmt-layer-header: 2147483000;
  --nrmt-layer-submenu: 2147483600;
}

body.nrmt-baiak-layout [class*="_topHud_"] {
  position: fixed !important;
  inset: 0 0 auto 0 !important;
  z-index: var(--nrmt-layer-header) !important;
  width: 100vw !important;
  height: var(--nrmt-fixed-header-height) !important;
  overflow: visible !important;
  isolation: isolate;
  transform: translateZ(0);
}

body.nrmt-baiak-layout [class*="_topHudNavigation_"],
body.nrmt-baiak-layout .nrmt-top-menu-grouped,
body.nrmt-baiak-layout .nrmt-menu-group.is-open {
  overflow: visible !important;
}

/* Abaixo de 1024px a barra precisa rolar na horizontal em vez de vazar —
   a regra acima existe pra grupo aberto (portado pro body de qualquer
   forma) nunca cortar, mas ela tambem bloqueava o scroll da propria barra. */
@media (max-width: 1024px) {
  body.nrmt-baiak-layout [class*="_topHudNavigation_"],
  body.nrmt-baiak-layout .nrmt-top-menu-grouped {
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }
}

/* O dropdown e movido para o body quando abre. Esta camada precisa superar
   lojas, inventario, admin e qualquer outra janela. */
body.nrmt-baiak-layout .nrmt-menu-group__dropdown,
body.nrmt-baiak-layout .nrmt-menu-group__dropdown.is-portal {
  z-index: var(--nrmt-layer-submenu) !important;
}

/* Overlays de interface usam somente a viewport abaixo do header. Efeitos de
   combate e telas de carregamento ficam fora desta lista de proposito.

   NOTA: esta lista reserva espaco para a barra fixa do topo, que virou o botao
   MENU flutuante na v181. Para as janelas ja padronizadas (Bencao do Rikudou,
   Tenten, Central de Invocacao, Orochimaru, Shizune, Depot, Ayame, Ibiki e
   Breeding) o offset so empurrava a janela ~58px para baixo sem nada ocupando
   aquele espaco -- por isso elas nao estao mais aqui. As demais seguem na
   lista ate serem conferidas uma a uma. */
body.nrmt-baiak-layout :is(
  .xp-overlay,
  .inventory-overlay,
  .equipment-overlay,
  .missions-overlay,
  .leaderboard-overlay,
  .shop-overlay,
  .crafting-overlay,
  .admin-overlay,
  .nrmt-admin-v2,
  .nrmt-hunts-overlay,
  .nrmt-ninja-collection,
  .nrmt-pvp,
  .nrmt-pvp-overlay,
  .nrmt-bi-rotation,
  .nrmt-team-select-overlay,
  .nrmt-game-overlay,
  .nrmt-market-overlay,
  .nrmt-referral-overlay,
  .nrmt-discord-overlay,
  .nrmt-hunt-analyzer-overlay,
  .nrmt-buffs-panel,
  .nrmt-copy-center-modal,
  .nrmt-modal-overlay,
  .nrmt-modal-backdrop,
  .nrmt-ranking-overlay,
  .nrmt-summon-modal,
  .nrmt-wiki-overlay,
  .nrmt-wiki,
  .nto-content-overlay,
  .nrmt-profile-overlay,
  .covil-prep-overlay,
  #nrmt-covil,
  #nrmt-bijuu-seal-choice,
  #nrmt-player-interaction,
  #nrmt-premium-shop,
  #nrmt-skins,
  #nrmt-tutorial,
  #nrmt-vip-store-v2
) {
  top: var(--nrmt-fixed-header-height) !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: auto !important;
  max-height: calc(100vh - var(--nrmt-fixed-header-height)) !important;
  box-sizing: border-box !important;
  padding-top: clamp(8px, 1.5vh, 18px) !important;
}

/* Janelas grandes respeitam a nova altura util mesmo quando uma folha antiga
   ainda usa 90vh/95vh, que antes fazia a moldura entrar sob o header. */
body.nrmt-baiak-layout :is(
  .xp-overlay,
  .inventory-overlay,
  .equipment-overlay,
  .missions-overlay,
  .leaderboard-overlay,
  .shop-overlay,
  .crafting-overlay,
  .admin-overlay,
  .nrmt-shop-overlay,
  .nrmt-inventory-overlay,
  .nrmt-hunts-overlay,
  .nrmt-craft-overlay,
  .nrmt-bi-helper,
  .nrmt-bi-rotation,
  .nrmt-team-select-overlay,
  .nrmt-breed-overlay,
  .nrmt-clinic-overlay,
  .nrmt-depot-overlay,
  .nrmt-edo-overlay,
  .nrmt-market-overlay,
  .nrmt-referral-overlay,
  .nrmt-discord-overlay,
  .nrmt-hunt-analyzer-overlay,
  .nrmt-buffs-panel,
  .nrmt-copy-center-modal,
  .nrmt-modal-overlay,
  .nrmt-ranking-overlay,
  .nrmt-smith-overlay,
  .nrmt-wiki-overlay,
  .nrmt-wiki,
  .nto-content-overlay,
  .nrmt-profile-overlay,
  #nrmt-covil,
  #nrmt-bijuu-seal-choice,
  #nrmt-player-interaction,
  #nrmt-player-trade,
  #nrmt-premium-shop,
  #nrmt-ramen-store,
  #nrmt-shop-v2,
  #nrmt-skins,
  #nrmt-vip-store-v2
) > :is(
  [class*="-window"],
  [class*="__window"],
  [class$="-modal"],
  [class$="-shell"]
) {
  max-height: calc(100% - 16px) !important;
  box-sizing: border-box !important;
}

body.nrmt-baiak-layout #nrmt-bijuu-seal-choice > .nrmt-bijuu-seal-card,
body.nrmt-baiak-layout .nrmt-buffs-panel > section {
  max-height: calc(100% - 16px) !important;
  box-sizing: border-box !important;
}

/* O HUD flutuante criado na V141 tambem nasce sempre abaixo do header. */
body.nrmt-baiak-layout #nrmt-bi-right.nrmt-bi-floating-layer {
  top: var(--nrmt-fixed-header-height) !important;
  height: calc(100vh - var(--nrmt-fixed-header-height)) !important;
}

@media (max-width: 680px) {
  body.nrmt-baiak-layout :is(
    .xp-overlay,
    .inventory-overlay,
    .equipment-overlay,
    .missions-overlay,
    .leaderboard-overlay,
    .shop-overlay,
    .crafting-overlay,
    .admin-overlay,
    .nrmt-shop-overlay,
    .nrmt-inventory-overlay,
    .nrmt-hunts-overlay,
    .nrmt-craft-overlay,
    .nrmt-bi-helper,
    .nrmt-bi-rotation,
    .nrmt-team-select-overlay,
    .nrmt-breed-overlay,
    .nrmt-market-overlay,
    .nrmt-referral-overlay,
    .nrmt-discord-overlay,
    .nrmt-hunt-analyzer-overlay,
    .nrmt-buffs-panel,
    .nrmt-copy-center-modal,
    .nrmt-modal-overlay,
    .nrmt-ranking-overlay,
    .nrmt-wiki-overlay,
    .nrmt-wiki,
    .nto-content-overlay,
    #nrmt-covil,
    #nrmt-bijuu-seal-choice,
    #nrmt-premium-shop,
    #nrmt-ramen-store,
    #nrmt-shop-v2,
    #nrmt-skins,
    #nrmt-vip-store-v2
  ) {
    padding: 5px !important;
    padding-top: 5px !important;
  }

  body.nrmt-baiak-layout .nrmt-menu-group__dropdown.is-portal {
    top: var(--nrmt-fixed-header-height) !important;
    max-height: calc(100vh - var(--nrmt-fixed-header-height) - 6px) !important;
    overflow-y: auto !important;
  }
}
