/* =========================================================================
   Camada MOBILE do PokeIdle (celular, horizontal).
   -------------------------------------------------------------------------
   Este arquivo SÓ age em `html.pokeidle-mobile` (marcado em panels/mobile.js).
   Nenhuma regra daqui toca o desktop: o layout, os painéis e os eventos são os
   mesmos do cliente; aqui ficam apenas a moldura do HUD, os drawers e os
   ajustes de toque/rolagem.

   Regras de ouro:
   • o canvas ocupa a tela inteira;
   • o HUD é flutuante e não cobre o time/barra de skills por padrão;
   • topbar e sidebar viram drawers (mesmos botões, zero duplicação);
   • modais ocupam a tela com cabeçalho/rodapé compactos e conteúdo rolando;
   • tooltips de hover não aparecem no toque.
   ========================================================================= */

html.pokeidle-mobile {
  /* O grid do desktop não é mais usado: o palco vira fixed/fullscreen. */
  --sidebar-w: 0px;
  --topbar-h: 0px;
  --ui-zoom: 1;
  overscroll-behavior: none;
}

html.pokeidle-mobile body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* ── O jogo: só o canvas, de ponta a ponta ──────────────────────────────── */
/* IMPORTANTE: nada de `position: fixed` no #app. Um elemento fixed cria um
   stacking context e prendia os drawers (topbar/sidebar/chat/sessão) ABAIXO
   do backdrop do HUD. Com `relative` o topbar z3100 fica de fato acima do
   backdrop z2550, como o resto da UI mobile. */
html.pokeidle-mobile body.authed #app {
  position: relative;
  inset: auto;
  display: block;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  margin: 0;
  overflow: hidden;
}
html.pokeidle-mobile body.authed #main-stage {
  /* Absolute (não fixed): `fixed` criava um stacking context e prendia o chat
     e a sessão ABAIXO do backdrop do HUD. O #app já é 100dvh, então o palco
     continua ocupando a tela inteira. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #05070d;
}
html.pokeidle-mobile body.authed #log,
html.pokeidle-mobile body.authed #session {
  display: none !important;
}

/* ── HUD flutuante ──────────────────────────────────────────────────────── */
#mobile-hud {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2600;
  pointer-events: none;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
}
html.pokeidle-mobile body.authed #mobile-hud {
  display: block;
}
.mhud-group {
  position: absolute;
  display: flex;
  gap: 6px;
  pointer-events: none;
}
.mhud-tl {
  top: calc(6px + env(safe-area-inset-top, 0px));
  left: calc(6px + env(safe-area-inset-left, 0px));
}
.mhud-tr {
  top: calc(6px + env(safe-area-inset-top, 0px));
  right: calc(6px + env(safe-area-inset-right, 0px));
  align-items: center;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  max-width: calc(100vw - 110px);
}
.mhud-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(8, 13, 26, 0.86);
  color: #dbe7ff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mhud-btn:active {
  transform: scale(0.94);
}
.mhud-btn.on {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.7);
  color: #e0f6ff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}
.mhud-btn[hidden] {
  display: none !important;
}
.mhud-menu {
  width: auto;
  padding: 0 13px;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.mhud-ico {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}
.mhud-menu .mhud-ico {
  width: 18px;
  height: 18px;
}

/* O botão de instalar PWA só aparece dentro do drawer mobile; no desktop
   quem oferece a instalação é o próprio navegador (e a landing). */
html:not(.pokeidle-mobile) #install-app-btn {
  display: none !important;
}

/* ── Backdrop dos drawers ───────────────────────────────────────────────── */
#mobile-backdrop {
  position: fixed;
  inset: 0;
  /* Abaixo do HUD (2600) e dos drawers (3100); acima do canvas, do time
     (2100), da barra de skills (2400) e do botão de Hunts (2500). */
  z-index: 2550;
  background: rgba(2, 6, 17, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
#mobile-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Cabeçalho comum dos drawers ────────────────────────────────────────── */
.mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  padding: 2px 2px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
/* A sidebar/topbar/sessão rolam por inteiro; o cabeçalho (e o X) fica preso
   no topo para nunca "sumir" no fim da rolagem. */
html.pokeidle-mobile #topbar > .mobile-drawer-head,
html.pokeidle-mobile #sidebar-right > .mobile-drawer-head,
html.pokeidle-mobile #session-side-root > .mobile-drawer-head {
  position: sticky;
  top: 0;
  z-index: 7;
  margin: 0 0 4px;
  padding: 4px 2px 8px;
  background: linear-gradient(180deg, rgba(13, 21, 40, 0.99), rgba(13, 21, 40, 0.94));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mobile-drawer-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #7dd3fc;
}
.mobile-drawer-close {
  width: 38px;
  height: 38px;
  min-width: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #c7d7f4;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mobile-drawer-close:active {
  background: rgba(255, 77, 103, 0.24);
  border-color: rgba(255, 77, 103, 0.55);
}

/* ── TOPBAR = drawer esquerdo (os mesmos botões do desktop) ─────────────── */
html.pokeidle-mobile body.authed #topbar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(340px, 88vw);
  height: 100dvh;
  min-height: 0;
  z-index: 3100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px
    calc(12px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(13, 21, 40, 0.98), rgba(6, 10, 22, 0.99));
  box-shadow: 30px 0 70px rgba(0, 0, 0, 0.55);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0.22s;
  container-type: normal;
  zoom: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.pokeidle-mobile body.mobile-menu-open #topbar {
  transform: none;
  visibility: visible;
}
html.pokeidle-mobile #topbar .pk-brand {
  margin-bottom: 2px;
}
html.pokeidle-mobile #topbar .pk-top-divider {
  display: none;
}
html.pokeidle-mobile #topbar .top-icon-btn {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: 42px !important;
  min-height: 42px;
  /* Grid de duas colunas (ícone | rótulo): o texto é um nó solto dentro do
     botão, e o flex do tema centralizava o conjunto. O grid alinha à
     esquerda de forma estável. */
  display: grid !important;
  flex-direction: row !important;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  column-gap: 10px;
  padding: 0 12px !important;
  font-size: 13px !important;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: left;
  border-radius: 11px !important;
}
html.pokeidle-mobile #topbar .top-icon-btn > svg,
html.pokeidle-mobile #topbar .top-icon-btn > img {
  margin: 0 !important;
  flex: 0 0 auto;
}
html.pokeidle-mobile #topbar .top-icon-btn .top-ico {
  width: 20px;
  height: 20px;
}
html.pokeidle-mobile #topbar .messages-badge {
  position: absolute;
  top: 4px;
  right: 7px;
  margin: 0;
  animation: none;
}
html.pokeidle-mobile #topbar .topbar-gold,
html.pokeidle-mobile #topbar .topbar-diamonds {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  padding: 0 12px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
}
html.pokeidle-mobile #topbar .topbar-gold b,
html.pokeidle-mobile #topbar .topbar-diamonds b {
  margin-left: auto;
}
html.pokeidle-mobile #topbar .top-store-inline {
  justify-content: flex-start !important;
  font-size: 12px !important;
  letter-spacing: 0.04em;
}

/* ── TOPBAR V3 dentro do drawer ─────────────────────────────────────────── */
/* No celular o drawer mostra tudo de uma vez: abas, atalhos e o "Mais" já
   aberto (não existe hover nem espaço para popover flutuante). */
html.pokeidle-mobile #topbar {
  gap: 6px;
}
html.pokeidle-mobile #topbar .pk-spacer {
  display: none;
}
html.pokeidle-mobile #topbar .pk-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}
html.pokeidle-mobile #topbar .pk-tab {
  width: 100%;
  height: 42px;
  justify-content: flex-start;
  padding: 0 12px;
  border-color: rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: left;
  border-radius: 11px;
}
html.pokeidle-mobile #topbar .pk-tab span {
  display: inline;
}
html.pokeidle-mobile #topbar .pk-tab .pk-i {
  width: 20px;
  height: 20px;
}
html.pokeidle-mobile #topbar .pk-shortcuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}
html.pokeidle-mobile #topbar .pk-icon-btn {
  width: 100%;
  height: 42px;
  border-color: rgba(148, 163, 184, 0.14);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 11px;
}
html.pokeidle-mobile #topbar #discord-btn {
  display: flex;
}
html.pokeidle-mobile #topbar .pk-more-btn {
  display: none;
}
html.pokeidle-mobile #topbar .pk-more-wrap {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  height: auto;
}
html.pokeidle-mobile #topbar .pk-more-panel,
html.pokeidle-mobile #topbar .pk-more-panel[hidden] {
  position: static;
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: none;
}
html.pokeidle-mobile #topbar .pk-more-panel::before {
  display: none;
}
html.pokeidle-mobile #topbar .pk-more-head {
  padding: 4px 2px 8px;
}
html.pokeidle-mobile #topbar .pk-more-grid {
  gap: 6px;
}
html.pokeidle-mobile #topbar .pk-menu-item {
  min-height: 42px;
  padding: 6px 8px;
  border-color: rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12.5px;
}
html.pokeidle-mobile #topbar .pk-more-admin {
  width: 30px;
  height: 30px;
}
html.pokeidle-mobile #topbar .pk-more-foot {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 9px 2px 2px;
}
html.pokeidle-mobile #topbar .pk-foot-btn {
  flex: 1 1 auto;
  min-height: 38px;
  justify-content: flex-start;
  padding: 6px 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}
html.pokeidle-mobile #topbar .pk-foot-danger {
  margin-left: 0;
}
html.pokeidle-mobile #topbar .pk-online,
html.pokeidle-mobile #topbar .pk-coin {
  display: flex;
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
}
html.pokeidle-mobile #topbar .pk-online span {
  display: inline;
}
html.pokeidle-mobile #topbar .pk-coin b {
  margin-left: auto;
}
html.pokeidle-mobile #topbar .pk-coin-gem {
  padding-right: 12px;
}
/* A conta já está no rodapé do "Mais" no mobile. */
html.pokeidle-mobile #topbar #account-btn {
  display: none;
}

/* ── SIDEBAR = drawer direito (treinador + inventário) ──────────────────── */
html.pokeidle-mobile body.authed #sidebar-right {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(330px, 88vw);
  height: 100dvh;
  z-index: 3100;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 8px calc(8px + env(safe-area-inset-right, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px)) 8px;
  border: 0;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(13, 21, 40, 0.98), rgba(6, 10, 22, 0.99));
  box-shadow: -30px 0 70px rgba(0, 0, 0, 0.55);
  transform: translateX(104%);
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0.22s;
  zoom: 1;
  /* A sidebar INTEIRA rola: o card do treinador pode ocupar a altura toda em
     paisagem e, sem isso, o inventário ficava inalcançável. */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.pokeidle-mobile body.mobile-bag-open #sidebar-right {
  transform: none;
  visibility: visible;
}
html.pokeidle-mobile #sidebar-right > .mobile-drawer-head {
  padding: 2px 2px 8px;
}
html.pokeidle-mobile #sidebar-right > #trainer-card {
  margin: 8px 4px 0 !important;
  flex: 0 0 auto;
}
html.pokeidle-mobile #sidebar-right > #inventory {
  /* Quem rola é a sidebar inteira (ver acima); o inventário entra no fluxo
     com a altura natural para não criar uma segunda barra de rolagem. */
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
}
html.pokeidle-mobile #sidebar-right #inventory > #inv-grid,
html.pokeidle-mobile #sidebar-right #inventory > #inv-grid.poke-grid {
  height: auto !important;
  max-height: none !important;
  grid-auto-rows: 46px !important;
  overflow: visible;
  touch-action: pan-y;
}
html.pokeidle-mobile #sidebar-right .inv-cell {
  min-height: 46px;
}

/* ── SESSÃO = drawer esquerdo (só existe dentro da hunt) ────────────────── */
html.pokeidle-mobile body.authed #session-side-root {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: min(340px, 88vw) !important;
  height: 100dvh !important;
  max-height: none !important;
  z-index: 3100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 !important;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px
    calc(12px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(13, 21, 40, 0.98), rgba(6, 10, 22, 0.99));
  box-shadow: 30px 0 70px rgba(0, 0, 0, 0.55);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0.22s;
  zoom: 1;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.pokeidle-mobile body.mobile-session-open #session-side-root {
  transform: none;
  visibility: visible;
}
html.pokeidle-mobile #session-side-root[hidden] {
  display: none !important;
}
html.pokeidle-mobile #session-side-root .session-side {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ── CHAT = bottom sheet ────────────────────────────────────────────────── */
html.pokeidle-mobile body.authed #chat {
  position: fixed !important;
  left: calc(8px + env(safe-area-inset-left, 0px)) !important;
  right: calc(8px + env(safe-area-inset-right, 0px)) !important;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: min(60dvh, 380px) !important;
  z-index: 3100;
  transform: translateY(calc(100% + 28px));
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1), visibility 0.22s;
  border-radius: 16px !important;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.mobile-chat-open #chat {
  transform: none;
  visibility: visible;
}
html.pokeidle-mobile #chat .mobile-drawer-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 17px;
}

/* ── Time: coluna vertical, arrastável e rolável ────────────────────────── */
html.pokeidle-mobile body.authed #party-squares-root {
  position: fixed !important;
  top: calc(58px + env(safe-area-inset-top, 0px)) !important;
  right: calc(8px + env(safe-area-inset-right, 0px)) !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 2100;
  max-height: calc(100dvh - 66px - env(safe-area-inset-bottom, 0px));
}
html.pokeidle-mobile .party-squares {
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 4px !important;
}
html.pokeidle-mobile .party-cards {
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 4px !important;
  max-height: calc(100dvh - 112px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 1px 2px 3px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile .party-ctrl-strip {
  flex-direction: row !important;
  align-self: flex-end;
  padding-top: 0 !important;
  gap: 4px !important;
}
html.pokeidle-mobile .party-ctrl {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px;
  font-size: 15px;
}
html.pokeidle-mobile .party-mobile-drag {
  cursor: grab;
  touch-action: none;
}
html.pokeidle-mobile .party-square {
  width: 58px !important;
  padding: 8px 8px 14px !important;
  border-radius: 8px !important;
  touch-action: manipulation;
}
html.pokeidle-mobile .party-square.active {
  transform: none;
}
html.pokeidle-mobile .party-square .ps-bar {
  left: 5px !important;
  right: 5px !important;
  bottom: 7px !important;
  height: 3px !important;
}
html.pokeidle-mobile .party-square .ps-hp {
  bottom: 1px !important;
  font-size: 7px !important;
}
html.pokeidle-mobile .party-square .ps-types {
  left: -6px !important;
  bottom: -4px !important;
}
html.pokeidle-mobile .party-square .ps-types img {
  width: 12px !important;
  height: 12px !important;
}
html.pokeidle-mobile .party-square .ps-boost {
  font-size: 9px !important;
  padding: 0 3px !important;
}
html.pokeidle-mobile body.mobile-team-hidden #party-squares-root {
  display: none !important;
}

/* ── Barra de skills: encaixa no rodapé e não invade o botão das Hunts ──── */
html.pokeidle-mobile body.authed #floating-skill-bar {
  z-index: 2400;
  /* Centraliza no espaço ENTRE o botão de Hunts (esquerda) e o time (direita).
     Assim a barra nunca cobre nenhum dos dois em telas estreitas. */
  left: calc(130px + env(safe-area-inset-left, 0px));
  right: calc(120px + env(safe-area-inset-right, 0px));
  bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  margin-inline: auto;
  max-width: calc(100vw - 250px);
  max-height: calc(100dvh - 58px);
  padding: 20px 6px 6px;
  touch-action: none;
}
html.pokeidle-mobile #floating-skill-bar.horizontal {
  padding: 18px 8px 6px 6px;
}
html.pokeidle-mobile .skillbar-toolbar {
  top: 2px;
  right: 2px;
  gap: 6px;
}
html.pokeidle-mobile .skillbar-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  font-size: 15px;
  border-radius: 7px;
}
html.pokeidle-mobile .skillbar-grip {
  width: 24px;
  height: 24px;
  touch-action: none;
}
html.pokeidle-mobile .skill-slot {
  min-width: 54px;
  min-height: 54px;
}

/* ── Hunts: botão sempre acima de tudo (o time cobria no mobile) ────────── */
html.pokeidle-mobile body.authed .dock {
  left: calc(8px + env(safe-area-inset-left, 0px)) !important;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 2500 !important;
  width: auto !important;
  gap: 6px;
}
html.pokeidle-mobile body.authed #hunt-btn {
  min-height: 42px;
  padding: 0 16px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
  letter-spacing: 0.06em;
  touch-action: manipulation;
}
html.pokeidle-mobile body.authed #hunt-btn::before {
  width: 13px;
  height: 13px;
}

/* ── Sem tooltips de hover no toque ─────────────────────────────────────── */
html.pokeidle-mobile .party-tip,
html.pokeidle-mobile .summon-tip,
html.pokeidle-mobile .inv-tip {
  display: none !important;
}

/* ── Modais: tela cheia, cabeçalho/rodapé finos e conteúdo rolável ───────── */
/* Toda modal do jogo fica ACIMA do HUD (2600) e dos drawers (3100). Era por
   isso que a engrenagem/Config abria "atrás" dos botões do HUD e não dava
   para fechar. */
html.pokeidle-mobile body.authed .idle-modal-overlay,
html.pokeidle-mobile body.authed .idle-hunt-modal,
html.pokeidle-mobile body.authed .msg-overlay,
html.pokeidle-mobile body.authed .wiki-modal,
html.pokeidle-mobile body.authed .duel-overlay,
html.pokeidle-mobile body.authed .prc-overlay,
html.pokeidle-mobile body.authed .sbx-overlay,
html.pokeidle-mobile body.authed .nm-modal,
html.pokeidle-mobile body.authed .boost-modal,
html.pokeidle-mobile body.authed .dvx-overlay,
html.pokeidle-mobile body.authed .dvx-rw-overlay,
html.pokeidle-mobile body.authed .egx-overlay,
html.pokeidle-mobile body.authed .egx-pool-overlay,
html.pokeidle-mobile body.authed .vipr-overlay,
html.pokeidle-mobile body.authed .pwarn-overlay,
html.pokeidle-mobile body.authed #collections-overlay,
html.pokeidle-mobile body.authed #pokedex-overlay,
html.pokeidle-mobile body.authed #capture-mgmt-overlay {
  z-index: 5000 !important;
}
/* Confirmações abertas POR CIMA de outra modal. */
html.pokeidle-mobile body.authed .boost-confirm-overlay,
html.pokeidle-mobile body.authed .pc-modal,
html.pokeidle-mobile body.authed .tv-modal-backdrop,
html.pokeidle-mobile body.authed .col-picker-overlay {
  z-index: 5100 !important;
}
/* Menus de contexto/itens sempre na frente de tudo que está aberto. */
html.pokeidle-mobile body.authed .game-context-menu,
html.pokeidle-mobile body.authed .inv-menu {
  z-index: 5200 !important;
}

html.pokeidle-mobile body.authed .idle-modal-overlay {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center !important;
}
html.pokeidle-mobile body.authed .idle-modal-overlay > .idle-modal,
html.pokeidle-mobile body.authed section.dex.dex-modal > .idle-modal {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding-left: max(12px, env(safe-area-inset-left, 0px)) !important;
  padding-right: max(12px, env(safe-area-inset-right, 0px)) !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* O perfil/ranking/guilda/amigos/config/evolução usam .idle-hunt-box. */
html.pokeidle-mobile body.authed .idle-hunt-modal {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center !important;
}
html.pokeidle-mobile body.authed .idle-hunt-box {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding: calc(8px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px)) !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* O CONFIG usa o shell novo (.pk-modal): ocupa a tela toda no celular. */
html.pokeidle-mobile body.authed .pk-modal-overlay {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center !important;
}
html.pokeidle-mobile body.authed .pk-modal {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border: 0 !important;
  border-radius: 0 !important;
}
html.pokeidle-mobile body.authed .pk-modal-side {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  border-right: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
html.pokeidle-mobile body.authed .pk-modal-brand {
  flex: 0 0 auto;
  padding: 0 10px 0 0;
}
html.pokeidle-mobile body.authed .pk-modal-brand .pk-i {
  width: 20px;
  height: 20px;
}
html.pokeidle-mobile body.authed .pk-modal-side-foot {
  display: none;
}
html.pokeidle-mobile body.authed .pk-side-tab {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 12px;
}
html.pokeidle-mobile body.authed .pk-modal-main {
  flex: 1 1 auto;
  min-height: 0;
}
html.pokeidle-mobile body.authed .pk-modal-head {
  flex: 0 0 auto;
  padding: 10px 12px;
}
html.pokeidle-mobile body.authed .pk-modal-head h2 {
  font-size: 20px;
}
html.pokeidle-mobile body.authed .pk-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 12px 8px;
}
html.pokeidle-mobile body.authed .pk-modal-foot {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
}
html.pokeidle-mobile body.authed .pk-modal-row {
  gap: 10px;
  padding: 9px 2px;
}
html.pokeidle-mobile body.authed .pk-modal-row-txt small {
  font-size: 10px;
}
html.pokeidle-mobile body.authed .pk-quality {
  flex-wrap: wrap;
  justify-content: flex-end;
}

html.pokeidle-mobile body.authed .idle-modal-head,
html.pokeidle-mobile body.authed .mobile-modal-head {
  position: sticky;
  top: 0;
  z-index: 8;
  flex: 0 0 auto;
  min-height: 44px;
  margin: 0 0 6px !important;
  padding: 4px 6px 6px !important;
  border-radius: 0;
  background: rgba(10, 17, 32, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
html.pokeidle-mobile body.authed .idle-modal-title {
  font-size: 14px !important;
  letter-spacing: 0.08em !important;
  line-height: 1.1 !important;
}
html.pokeidle-mobile body.authed .idle-modal-gear {
  font-size: 15px !important;
}
html.pokeidle-mobile body.authed .idle-modal-x {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  font-size: 18px !important;
}
html.pokeidle-mobile body.authed .idle-modal-foot {
  position: sticky;
  bottom: 0;
  z-index: 8;
  flex: 0 0 auto;
  min-height: 48px;
  margin: 6px 0 0 !important;
  padding: 5px 6px 6px !important;
  border-radius: 0;
  background: rgba(10, 17, 32, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
html.pokeidle-mobile body.authed .idle-modal-foot button,
html.pokeidle-mobile body.authed .idle-modal-foot .idle-config-btn {
  min-height: 38px;
  padding: 4px 18px !important;
  font-size: 12px !important;
}

/* Mercado: corpo rola; tabela pode rolar no eixo X em telas estreitas. */
html.pokeidle-mobile body.authed .mkt {
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  overflow: hidden !important;
}
html.pokeidle-mobile body.authed .mkt-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.pokeidle-mobile body.authed .mkt-tabs-row {
  padding: 0 2px 6px;
}
html.pokeidle-mobile body.authed .mkt-foot {
  flex: 0 0 auto;
  gap: 6px;
  padding-top: 6px;
  margin-top: 4px;
}
html.pokeidle-mobile body.authed .mkt-table {
  overflow-x: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
html.pokeidle-mobile body.authed .mkt-thead,
html.pokeidle-mobile body.authed .mkt-row {
  min-width: 720px;
  grid-template-columns: 30px 34px minmax(110px, 1fr) 66px 72px 100px 96px;
  gap: 5px;
  padding: 6px 8px;
}
html.pokeidle-mobile body.authed .mkt-thead {
  white-space: nowrap;
  font-size: 9px;
}
html.pokeidle-mobile body.authed .mkt-filters {
  gap: 6px;
}
html.pokeidle-mobile body.authed .mkt-search {
  font-size: 16px;
}

/* Capturas: a lista ocupa o resto e rola; o card do outfit encolhe. */
html.pokeidle-mobile body.authed .capture-list {
  max-height: none !important;
}
html.pokeidle-mobile body.authed .dex-modal .idle-modal > .capture-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.authed .capture-outfit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 8px;
  margin-bottom: 6px;
}
html.pokeidle-mobile body.authed .capture-outfit-preview {
  display: none !important;
}
html.pokeidle-mobile body.authed .capture-outfit-progress {
  flex: 1 1 100%;
  height: 4px;
}
html.pokeidle-mobile body.authed .capture-outfit-hint {
  margin: 0;
  font-size: 10px;
}
html.pokeidle-mobile body.authed .capture-tools {
  margin-bottom: 6px;
}
html.pokeidle-mobile body.authed .capture-search {
  font-size: 16px;
}

/* Loja de Diamantes: categorias viram uma faixa horizontal; cards rolam. */
html.pokeidle-mobile body.authed .coin-shop {
  width: 100% !important;
  flex: 1 1 auto;
  min-height: 0;
}
html.pokeidle-mobile body.authed .coin-shop-layout {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  flex: 1 1 auto;
}
html.pokeidle-mobile body.authed .coin-shop-side {
  min-height: 0;
  max-height: none;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}
html.pokeidle-mobile body.authed .coin-shop-side-title {
  display: none;
}
html.pokeidle-mobile body.authed .coin-shop-tabs {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
  touch-action: pan-x;
}
html.pokeidle-mobile body.authed .coin-shop-tab {
  width: auto;
  min-height: 30px;
  flex: 0 0 auto;
  padding: 4px 12px;
  white-space: nowrap;
}
html.pokeidle-mobile body.authed .coin-shop-main {
  min-height: 0;
  flex: 1 1 auto;
}
html.pokeidle-mobile body.authed .coin-shop-top {
  gap: 6px;
  flex: 0 0 auto;
}
html.pokeidle-mobile body.authed .coin-shop-balances {
  gap: 4px;
  flex-wrap: wrap;
}
html.pokeidle-mobile body.authed .coin-shop-balance {
  min-height: 34px;
  padding: 2px 10px;
}
html.pokeidle-mobile body.authed .coin-shop-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 7px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.authed .coin-shop-card {
  padding: 8px;
  gap: 8px;
}
html.pokeidle-mobile body.authed .coin-shop-art {
  width: 54px;
  height: 54px;
}
html.pokeidle-mobile body.authed .coin-shop-buy {
  min-height: 36px;
}

/* Hunts: a modal já era a única superfície; aqui ela ganha a tela toda. */
html.pokeidle-mobile body.authed #hunts .hunts-overlay {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center !important;
}
html.pokeidle-mobile body.authed #hunts .hunts-overlay .hunts-modal,
html.pokeidle-mobile body.authed #hunts.dex-modal .idle-modal {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
html.pokeidle-mobile body.authed .hunts-modal .hunts-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Dex: mantém a duas colunas, mas a lista/detalhe roláveis. */
html.pokeidle-mobile body.authed .dex2 {
  flex: 1 1 auto;
  min-height: 0;
}
html.pokeidle-mobile body.authed .dex2-left {
  flex-basis: min(40vw, 230px);
}
html.pokeidle-mobile body.authed .dex2-list,
html.pokeidle-mobile body.authed .dex2-right {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.authed .dex2-search {
  font-size: 16px;
}

/* Mensagens: duas colunas em paisagem; a lista rola. */
html.pokeidle-mobile body.authed .msg-overlay {
  padding: 0 !important;
}
html.pokeidle-mobile body.authed .msg-box {
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
}
html.pokeidle-mobile body.authed .msg-head {
  min-height: 44px;
  padding: 4px 8px !important;
}
html.pokeidle-mobile body.authed .msg-title {
  font-size: 13px;
  letter-spacing: 0.14em;
}
html.pokeidle-mobile body.authed .msg-bar {
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 8px !important;
}
html.pokeidle-mobile body.authed .msg-layout {
  grid-template-columns: minmax(176px, 35%) minmax(0, 1fr);
  min-height: 0;
}
html.pokeidle-mobile body.authed .msg-list {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.authed .msg-input {
  font-size: 16px;
}

/* Poképedia: tela cheia; painel e listas com rolagem própria. */
html.pokeidle-mobile body.authed .wiki-modal {
  padding: 0 !important;
}
html.pokeidle-mobile body.authed .wiki-panel {
  width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
}
html.pokeidle-mobile body.authed .wiki-panel .items-list,
html.pokeidle-mobile body.authed .wiki-panel .details-list,
html.pokeidle-mobile body.authed .wiki-panel .details-body {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Modais avulsos (pagamento, boost, fusão, coleções, recompensas...). */
html.pokeidle-mobile body.authed .prc-overlay,
html.pokeidle-mobile body.authed .sbx-overlay,
html.pokeidle-mobile body.authed .nm-modal,
html.pokeidle-mobile body.authed .boost-modal,
html.pokeidle-mobile body.authed .dvx-overlay,
html.pokeidle-mobile body.authed .dvx-rw-overlay,
html.pokeidle-mobile body.authed .egx-overlay,
html.pokeidle-mobile body.authed .egx-pool-overlay,
html.pokeidle-mobile body.authed .vipr-overlay,
html.pokeidle-mobile body.authed .pwarn-overlay,
html.pokeidle-mobile body.authed #collections-overlay,
html.pokeidle-mobile body.authed #pokedex-overlay {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: center !important;
}
html.pokeidle-mobile body.authed .prc-content,
html.pokeidle-mobile body.authed .sbx-modal,
html.pokeidle-mobile body.authed .nm-panel,
html.pokeidle-mobile body.authed .boost-panel,
html.pokeidle-mobile body.authed .dvx-panel,
html.pokeidle-mobile body.authed .dvx-rw-panel,
html.pokeidle-mobile body.authed .egx-panel,
html.pokeidle-mobile body.authed .egx-pool-panel,
html.pokeidle-mobile body.authed .vipr-panel,
html.pokeidle-mobile body.authed .pwarn-panel,
html.pokeidle-mobile body.authed .collections-window,
html.pokeidle-mobile body.authed .pokedex-window {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.pokeidle-mobile body.authed .duel-overlay,
html.pokeidle-mobile body.authed .personal-picker {
  padding: 8px !important;
}
html.pokeidle-mobile body.authed .duel-modal,
html.pokeidle-mobile body.authed .personal-picker-panel {
  max-height: 100dvh !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
html.pokeidle-mobile body.authed .personal-picker-list {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* Inputs a 16px: evita o zoom automático do iOS ao focar. */
html.pokeidle-mobile body.authed input[type='search'],
html.pokeidle-mobile body.authed input[type='text'],
html.pokeidle-mobile body.authed input[type='email'],
html.pokeidle-mobile body.authed input[type='password'],
html.pokeidle-mobile body.authed input[type='number'],
html.pokeidle-mobile body.authed textarea,
html.pokeidle-mobile body.authed select {
  font-size: 16px;
}

/* ── Overlay de orientação (só mobile, logado, em retrato) ──────────────── */
#mobile-rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(56, 189, 248, 0.16), transparent 55%),
    #060a16;
  color: #e8ecf5;
  text-align: center;
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
}
html.pokeidle-mobile body.authed #mobile-rotate {
  display: flex;
}
@media (orientation: landscape) {
  html.pokeidle-mobile #mobile-rotate {
    display: none !important;
  }
}
.mobile-rotate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(360px, 88vw);
  padding: 26px 22px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.mobile-rotate-icon {
  width: 74px;
  height: 74px;
  color: #38bdf8;
  animation: mobile-rotate-hint 1.8s ease-in-out infinite;
}
@keyframes mobile-rotate-hint {
  0%,
  100% {
    transform: rotate(0deg);
  }
  45% {
    transform: rotate(-90deg);
  }
  70% {
    transform: rotate(-90deg);
  }
}
.mobile-rotate-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.mobile-rotate-text {
  margin: 0;
  color: #9fb0cc;
  font-size: 13px;
  line-height: 1.45;
}
.mobile-rotate-btn {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #38bdf8, #4f8ef7 60%, #8b5cf6);
  color: #04121f;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Em retrato o jogo não deve responder a toque por baixo do aviso. */
@media (orientation: portrait) {
  html.pokeidle-mobile body.authed #mobile-hud,
  html.pokeidle-mobile body.authed #party-squares-root,
  html.pokeidle-mobile body.authed #floating-skill-bar,
  html.pokeidle-mobile body.authed .dock {
    visibility: hidden;
  }
}

/* Mesmo motivo do desktop (pokemon-theme-modern.css): o blur sobre o canvas
   animado custa um re-blur por frame. No celular, que tem menos GPU, o ganho
   é ainda maior. */
html.pokeidle-mobile .mhud-btn,
html.pokeidle-mobile #topbar > .mobile-drawer-head,
html.pokeidle-mobile #sidebar-right > .mobile-drawer-head,
html.pokeidle-mobile body.authed .idle-modal-head,
html.pokeidle-mobile body.authed .mobile-modal-head,
html.pokeidle-mobile body.authed .idle-modal-foot {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
