/* v416 — estabilidade, acessibilidade móvel e painéis personalizáveis */
#shiny-global-next,
#legacy-quick-rail {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#shiny-global-next.dragging-panel,
#legacy-quick-rail.dragging-panel {
  cursor: grabbing;
  filter: brightness(1.12);
}

.sg-next {
  position: fixed;
  z-index: 34;
  left: 10px;
  top: 140px;
  display: grid;
  grid-template-columns: 34px minmax(108px, 1fr);
  align-items: center;
  gap: 8px;
  width: 178px;
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid #3e7770;
  border-radius: 12px;
  background: linear-gradient(145deg, #0b2528f2, #07171df2);
  box-shadow: 0 8px 24px #000a;
  color: #e8fffa;
  cursor: grab;
}

.sg-next.hidden {
  display: none;
}

.sg-next > i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #5f938a;
  border-radius: 8px;
  background: #163d3b;
  color: #ffe17b;
  font-style: normal;
}

.sg-next > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  text-align: left;
}

.sg-next small {
  overflow: hidden;
  color: #62e0c8;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-next b {
  color: #fff0a8;
  font: 900 16px/1.1 Georgia, serif;
}

.sg-next em {
  overflow: hidden;
  color: #95aaa9;
  font-size: 7px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-next.active {
  border-color: #ffcf68;
  box-shadow: 0 8px 24px #000a, 0 0 20px #ffc84b38;
}

.legacy-quick-rail {
  cursor: grab;
}

.house-pokemon-window {
  height: min(720px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
}

#house-pokemon-content {
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.house-pokemon-window > footer {
  position: sticky;
  z-index: 3;
  bottom: 0;
  flex: 0 0 auto;
  padding-bottom: max(13px, env(safe-area-inset-bottom));
  box-shadow: 0 -10px 22px #07121ab8;
}

.guild-window {
  height: min(760px, calc(100dvh - 20px));
}

.guild-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.guild-content .guild-grid {
  align-items: start;
}

.guild-content .guild-grid > .guild-card {
  max-height: min(390px, 48dvh);
  overflow: auto;
  scrollbar-gutter: stable;
}

.guild-content > .guild-card:last-child {
  max-height: 245px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.guild-content .guild-row {
  gap: 10px;
}

@media (max-width: 780px), (hover: none) and (pointer: coarse) {
  html,
  body {
    width: 100%;
    min-width: 0;
    overscroll-behavior: none;
  }

  .game-shell,
  .game-main,
  #stage {
    max-width: 100vw;
    min-width: 0;
  }

  .client-top-actions {
    right: 4px;
    bottom: max(4px, env(safe-area-inset-bottom));
    left: 4px;
    max-width: none;
    transform: none;
    scrollbar-width: none;
  }

  .client-top-actions::-webkit-scrollbar {
    display: none;
  }

  .client-top-actions button {
    flex: 0 0 34px;
    width: 34px;
    height: 32px;
  }

  .client-top-actions img {
    width: 25px;
    height: 25px;
  }

  .panel.client-open {
    max-width: calc(100vw - 8px);
    max-height: calc(100dvh - 58px);
  }

  .inventory-panel.client-open,
  .trainer-panel.client-open,
  .market-panel.client-open,
  .depot-panel.client-open,
  .player-market-panel.client-open,
  .npc-directory-panel.client-open {
    right: 4px !important;
    left: 4px !important;
    width: auto !important;
    max-width: none;
    overflow: auto;
  }

  .system-window,
  .system-window-wide {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
  }

  .system-window > header,
  .friends-window > header {
    height: 52px;
    padding: 0 12px;
  }

  .system-window h2 {
    font-size: 17px;
  }

  .house-pokemon-window {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .house-pokemon-window > header {
    padding: 11px 13px;
  }

  #house-pokemon-content {
    padding: 0 9px 9px;
  }

  .house-pokemon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .house-pokemon-card {
    min-height: 60px;
    padding: 3px 24px 3px 2px;
  }

  .house-pokemon-card canvas {
    width: 46px;
    height: 46px;
  }

  .house-pokemon-window > footer {
    padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  }

  .house-pokemon-window > footer button {
    min-height: 43px;
    padding: 0 12px;
  }

  .guild-content {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .guild-content .guild-grid {
    grid-template-columns: 1fr;
  }

  .guild-content .guild-grid > .guild-card,
  .guild-content > .guild-card:last-child {
    max-height: 42dvh;
  }

  .guild-content .guild-bonuses {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .guild-content .guild-row {
    align-items: flex-start;
    font-size: 10px;
  }

  .legacy-quick-rail {
    display: grid !important;
    grid-template-columns: repeat(5, 29px);
    gap: 3px;
    width: max-content;
  }

  .legacy-quick-rail button {
    grid-template-columns: 23px;
    width: 29px;
    height: 29px;
    padding: 2px;
  }

  .legacy-quick-rail i {
    width: 22px;
    height: 22px;
  }

  .legacy-quick-rail span {
    display: none;
  }

  .sg-next {
    grid-template-columns: 27px minmax(85px, 1fr);
    gap: 5px;
    width: 132px;
    min-height: 44px;
    padding: 4px 6px;
    border-radius: 9px;
  }

  .sg-next > i {
    width: 26px;
    height: 26px;
  }

  .sg-next b {
    font-size: 12px;
  }

  .sg-next em {
    display: none;
  }

  .sg-dock,
  .sg-ranking {
    right: 5px;
    max-width: calc(100vw - 10px);
  }

  .sg-ranking {
    width: min(240px, calc(100vw - 10px));
    max-height: 45dvh;
  }

  .modal {
    overscroll-behavior: contain;
  }
}

@media (max-width: 430px) {
  .house-pokemon-card b {
    font-size: 9px;
  }

  .house-pokemon-card small {
    font-size: 8px;
  }

  .guild-content .guild-bonuses small {
    font-size: 7px;
  }
}
