/* Celular. Este arquivo só é carregado em telas de celular (veja o media do <link> em index.html):
   em pé (largura até 520 px) ou deitado (tela de toque com altura até 560 px). Nada aqui muda o computador.
   Motivo: a tela do jogo era montada para caber exatamente na altura da janela; em celulares baixos isso escondia botões
   (por exemplo, "Abrir roleta") e espremia painéis. Agora a tela tem uma altura mínima e a página rola quando a janela é menor. */

/* =================== comum (em pé e deitado) =================== */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
body:has(.compact-shell) {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* tela de resultado (vitória/derrota): se o conteúdo passar da altura, a página rola em vez de cortar */
html:has(.site-theme .outcome),
body:has(.site-theme .outcome) {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
}

/* alvos de toque: nada abaixo de ~32 px */
.compact-shell .mp-btn {
  min-width: 30px;
  min-height: 28px;
}
.compact-shell .music-toggle {
  min-width: 32px;
  min-height: 30px;
}
.compact-shell .run-nav .sfx-toggle {
  min-width: 30px;
  min-height: 28px;
}
.compact-shell .speed-chip {
  min-width: 34px !important;
  min-height: 30px !important;
  font-size: var(--text-md) !important;
}
.compact-shell .encounter-help {
  min-width: 30px !important;
  min-height: 30px !important;
}
.compact-shell .dock-manage {
  min-width: 32px;
  min-height: 32px;
}
.compact-shell .shop-stop {
  position: relative;
}
.compact-shell .shop-stop::before {
  content: '';
  position: absolute;
  inset: -6px;
} /* área de toque maior, sem mudar o desenho */
.compact-shell .btn.ghost[data-action='skip-battle'] {
  min-height: 30px;
  padding: 6px 10px;
}

/* formulários: 16 px evita o zoom automático do iPhone ao tocar num campo */
input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='submit']):not([type='button']),
select,
textarea {
  font-size: 16px !important;
}
.home-back {
  min-height: 36px;
}
.pass-toggle {
  min-height: 32px;
  min-width: 44px;
}
.home-recovery {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 10px;
}

/* janelas (modais): a janela inteira rola, em vez de cada painel ficar minúsculo */
.site-theme .modal {
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
}
.capture-modal .modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.capture-modal .upgrader-layout {
  height: auto;
  min-height: 0;
  grid-auto-rows: auto;
  align-content: start;
}
.capture-modal .upgrade-side {
  min-height: 230px;
  max-height: none;
}
.capture-modal .upgrade-center {
  overflow: visible;
}
.capture-modal .upgrade-center .wheel-wrap {
  width: 178px;
  height: 178px;
  margin: 6px auto 12px;
} /* a roleta volta ao tamanho legível */
.capture-modal .wheel-center strong {
  font-size: 36px;
}
.capture-modal .wheel-center span {
  display: block;
  font-size: var(--text-2xs);
  letter-spacing: 0.4px;
}
.capture-modal .wheel-center small {
  font-size: var(--text-2xs);
  letter-spacing: 0.3px;
}

/* tela inicial: a página rola (sem painel com rolagem própria) e o aviso de convidado quebra em linhas */
.site-theme.home-screen,
.home-screen {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
  justify-content: flex-start;
  padding-top: max(7px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.site-theme .home-window,
.home-window {
  max-height: none;
  overflow: visible;
}
.site-theme .account-bar .ab-text,
.account-bar.guest .ab-text {
  display: block;
  min-width: 0;
  flex: 1 1 0;
  width: 100%;
}
.account-bar.guest .ab-text b {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-size: var(--text-md);
  line-height: 1.35;
  text-align: center;
}
.site-theme .home-audio .mp-btn {
  min-width: 34px;
  min-height: 34px;
}
.site-theme .home-audio .music-toggle {
  min-width: 38px;
  min-height: 38px;
}
.site-theme .home-audio .sfx-toggle,
.site-theme .home-audio .lang-btn {
  min-height: 38px;
}
.site-theme .home-tagline,
.site-theme .home-version,
.site-theme .home-credit,
.home-tagline,
.home-version,
.home-credit {
  font-size: var(--text-xs);
}
.lucky-face small,
.lucky-face em {
  font-size: var(--text-xs);
}

/* telas de menu (Pokédex, Hall da Fama, trocas, cartão): a página inteira rola */
.site-theme.menu-page:not(:has(.starter-grid)):not(:has(.outcome)) {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
}
.site-theme.menu-page:not(:has(.starter-grid)):not(:has(.outcome)) .main {
  flex: 0 0 auto;
  height: auto;
  overflow: visible;
}
.menu-page .menu-header-actions .mp-btn {
  min-width: 34px;
  min-height: 34px;
}
.menu-page .menu-header-actions .music-toggle {
  min-width: 38px;
  min-height: 36px;
}
.menu-page .menu-header-actions .lang-btn,
.menu-page .menu-header-actions .sfx-toggle {
  min-height: 36px;
}
.menu-page .menu-header-actions > .btn {
  min-height: 36px;
}
.pkt-next {
  flex: none;
  min-height: 34px;
}

/* =================== celular em pé =================== */
@media (max-width: 520px) {
  /* a tela do jogo tem pelo menos a altura do layout de 760 px; se a janela for menor, a página rola */
  .slots-shell.compact-shell {
    height: max(calc(100vh - 14px), 760px);
    height: max(calc(100dvh - 14px), 760px);
    max-height: none;
    margin-bottom: max(7px, env(safe-area-inset-bottom));
  }

  /* cabeçalho: logo, música e botões não se sobrepõem */
  .compact-shell .game-topbar {
    height: 76px;
    padding: 5px 8px;
    grid-template-rows: 31px 28px;
    gap: 4px 6px;
  }
  .compact-shell .expedition-brand {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    min-width: 0;
    line-height: 1;
  }
  .compact-shell .expedition-brand strong {
    display: block;
    font-size: 23px;
    line-height: 31px;
    white-space: nowrap;
  }
  .compact-shell .expedition-id {
    grid-column: 1/-1;
    min-width: 0;
    overflow: hidden;
  }
  .compact-shell .game-top-actions {
    grid-column: 2;
    grid-row: 1;
  }
  .compact-shell .expedition-id .music-player.bar {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  .compact-shell .expedition-id .mp-info {
    min-width: 0;
    flex: 1 1 0;
    overflow: hidden;
  }
  .compact-shell .expedition-id .mp-title,
  .compact-shell .expedition-id .mp-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .compact-shell .run-nav button.danger {
    width: 34px;
    min-width: 34px;
    padding: 4px 0;
    font-size: 0;
    text-align: center;
  }
  .compact-shell .run-nav button.danger::first-letter {
    font-size: 15px;
  } /* só a bandeira de "⚑ ABANDONAR PARTIDA" fica visível */

  /* textos pequenos demais para ler no celular (7-8 px) sobem para 9-10 px */
  .compact-shell .run-nav > button:not(.danger):not(.sfx-toggle):not(.lang-btn) {
    font-size: var(--text-sm);
  }
  .compact-shell .track-caption strong,
  .compact-shell .track-caption span {
    font-size: var(--text-xs);
  }
  .compact-shell .machine-title small {
    font-size: var(--text-xs);
  }
  .compact-shell .reel-number {
    font-size: var(--text-xs);
  }
  .compact-shell .reel-details span,
  .compact-shell .reel-battle,
  .compact-shell .reel-battle:disabled {
    font-size: 8.5px;
  }
  .compact-shell .encounter-spin small {
    font-size: var(--text-xs);
  }
  .compact-shell .expedition-dock .member-health > strong {
    font-size: var(--text-xs);
  }
  .compact-shell .expedition-dock .member.empty small {
    font-size: var(--text-xs);
  }
  .compact-shell .progress-copy small,
  .compact-shell .dock-tips small {
    font-size: var(--text-xs);
  }

  /* telas de menu: cabeçalho em duas linhas */
  .site-theme.menu-page .menu-top,
  .site-theme.menu-page:has(.starter-grid) .menu-top {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 6px 8px;
  }
  .menu-page .menu-header-actions {
    flex: 1 1 100%;
    justify-content: space-between;
    gap: 6px;
  }

  /* escolha do inicial: desafio e dicas do Professor Oak em coluna única (em duas colunas estouravam a largura) */
  .pk-extra {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .pk-tips > header {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* celulares muito estreitos (320 px) */
@media (max-width: 350px) {
  .compact-shell .encounter-spin {
    font-size: var(--text-xl);
  }
  .compact-shell .encounter-spin small {
    letter-spacing: 0;
  }
}

/* =================== celular deitado (tela de toque, altura até 560 px) =================== */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  .slots-shell.compact-shell {
    height: max(calc(100vh - 12px), 560px);
    height: max(calc(100dvh - 12px), 560px);
    max-height: none;
  }
}

/* nível, filtros do Hall e painel de jogadores no celular */
@media (max-width: 520px) {
  .hall-tools .dex-find,
  .players-tools .dex-find {
    flex: 1 1 100%;
  }
  .hall-stats {
    flex-wrap: wrap;
  }
  .hall-stats span {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
  .hall-head {
    align-items: stretch;
  }
  .hall-title > div {
    min-width: 0;
  }
  .hall-team-name-input {
    width: 100%;
  }
  .hall-rename {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  .players-totals {
    width: 100%;
  }
  .players-totals span {
    flex: 1;
    min-width: 0;
    padding: 7px 6px;
  }
  .player-card {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'photo id' 'side side' 'stats stats' 'ban ban';
    gap: 10px;
  }
  .pc-photo {
    width: 42px;
    height: 42px;
  }
  .pc-photo img {
    width: 34px;
    height: 34px;
  }
  .pc-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .pc-side .btn {
    height: 34px;
    padding-left: 18px;
    padding-right: 18px;
  }
  .pc-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .pc-stats .lv {
    grid-column: 1/-1;
    grid-auto-flow: column;
    justify-content: center;
    gap: 8px;
    align-items: baseline;
  }
  .pc-stats .lv dt {
    order: 0;
  }
  .pc-stats .lv dd {
    order: 1;
    font-size: 16px;
  }
  .pc-stats .lv small {
    order: 2;
  }
  .pc-stats dd {
    font-size: 16px;
  }
  .players-pager .btn {
    min-height: 40px;
  }
  .ban-actions .btn {
    flex: 1 1 130px;
    min-height: 42px;
  }
  .ban-presets .dex-chip {
    min-height: 36px;
  }
  .oc-xp {
    margin: 0 12px 10px;
  }
  .ab-xp {
    max-width: none;
  }
}
@media (max-width: 520px) {
  .credits-link {
    min-height: 32px;
    font-size: var(--text-xs);
  }
  .account-bar:not(.guest) .ab-photo {
    width: 52px;
    height: 52px;
  }
  .account-bar:not(.guest) .ab-photo img {
    width: 44px;
    height: 44px;
  }
  .site-theme .home-audio .notif-toggle {
    width: 32px;
  }
  .credits-sheet {
    max-height: 60dvh;
  }
}

/* skins no celular */
@media (max-width: 520px) {
  .skin-use .btn {
    min-height: 36px;
  }
  .skins-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }
  .adm-skin {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .adm-actions {
    grid-column: 1/-1;
    justify-content: flex-start;
  }
  .adm-actions .btn {
    height: 36px;
  }
  .adm-preview {
    flex-wrap: wrap;
  }
  .prev-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .skin-pick {
    flex-wrap: wrap;
  }
}

/* v8 · tela inicial no celular: botões de admin em duas colunas, trio (Skins/PvP/Minigames) em três, player de música em linha própria */
@media (max-width: 520px) {
  .site-theme .home-actions .admin-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .site-theme .home-actions .admin-row.player-trio {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .site-theme .home-actions .admin-row .home-menu-card {
    min-height: 54px;
  }
  .site-theme .home-window:not(.auth-active) .home-actions .admin-row.player-trio .home-menu-card {
    padding: 8px 8px 8px 11px;
  }
  .site-theme .home-window:not(.auth-active) .home-actions .admin-row.player-trio .home-menu-copy small {
    font-size: var(--text-xs);
    line-height: 1.3;
  }
  .site-theme .home-audio {
    flex-wrap: wrap;
    justify-content: center;
  }
  .site-theme .home-audio .music-player {
    flex: 1 1 100%;
    min-width: 0;
  }
  .site-theme .home-audio .music-player .mp-info {
    flex: 1;
    min-width: 0;
  }
}

/* v8 · botão ORGANIZAR no celular: o ícone ⇄ ficava escondido atrás da "face" do botão pixelado (que usa o ::after) */
@media (max-width: 520px) {
  .compact-shell .dock-manage {
    font-size: 0 !important;
    width: 34px;
    padding: 0;
    display: inline-grid;
    place-items: center;
  }
  .compact-shell .dock-manage:after {
    content: '' !important;
  }
  .compact-shell .dock-manage .dm-label {
    display: none;
  }
  .compact-shell .dock-manage .dm-icon {
    position: relative;
    z-index: 1;
    font-size: 17px;
    line-height: 1;
  }
}

/* v8 · modais no celular: o corpo do modal (ex.: Upgrader) tinha rolagem desligada e escondia a parte de baixo (listas de oferta e destino) */
.overlay .modal-body {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.overlay .modal {
  max-height: 100dvh;
}

/* tela de espera do chefe (lendários e míticos): no celular o conteúdo passava da altura do quadro e o botão
   "SEGUIR PARA O SANTUÁRIO" ficava escondido. Agora o quadro rola e o botão fica sempre visível no rodapé. */
.compact-shell .raid-wait {
  overflow-x: hidden;
  overflow-y: auto;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 10px 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.compact-shell .raid-wait::-webkit-scrollbar {
  display: none;
}
.compact-shell .raid-wait > * {
  flex-shrink: 0;
}
.compact-shell .raid-wait header h1 {
  font-size: 21px;
  letter-spacing: 2px;
}
.compact-shell .raid-wait header p {
  font-size: 10.5px;
}
.compact-shell .raid-silhouettes {
  gap: 8px;
}
.compact-shell .raid-team {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.compact-shell .raid-rules {
  grid-template-columns: 1fr;
  gap: 5px;
}
.compact-shell .raid-wait .raid-go-wrap {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: block;
  width: calc(100% + 20px);
  max-width: none;
  margin: 2px -10px 0;
  padding: 10px 10px 12px;
  background: linear-gradient(#0000, #070b1ae6 35%, #070b1a);
  text-align: center;
}
.compact-shell .raid-wait .btn.raid-go {
  width: auto;
  min-width: 0;
  min-height: 36px;
  padding: 7px 14px;
  font-size: 12.5px;
  letter-spacing: 1.4px;
}
@media (max-width: 520px) {
  .site-theme .home-audio .jira-toggle {
    width: 32px;
  }
}
/* mesa de cartas com a oferta da chave: o rodapé de itens sai para caber tudo, e o quadro rola se ainda faltar altura */
.compact-shell .card-table:has(.key-offer) {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.compact-shell .card-table:has(.key-offer) > footer {
  display: none;
}
.compact-shell .card-actions .key-offer {
  padding: 6px 10px;
  margin-bottom: 4px;
}

/* Mobile site layout. Keep these overrides in this last, media-gated sheet. */
@media (max-width: 520px) {
  .site-theme.home-screen,
  .site-theme.menu-page {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .site-theme .home-window,
  .site-theme.menu-page > .main,
  .site-theme.menu-page > .menu-top {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  .site-theme .home-window {
    padding: 12px;
  }
  .site-theme .home-window:not(.auth-active) .home-actions {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    gap: 10px;
  }
  .site-theme .home-window:not(.auth-active) .home-actions .home-menu-card {
    min-height: 64px;
    padding: 10px 12px;
  }
  .site-theme .home-menu-copy {
    min-width: 0;
  }
  .site-theme .home-menu-copy strong {
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
  .site-theme .home-menu-copy small {
    font-size: 11px;
    line-height: 1.4;
  }
  .site-theme .home-actions .admin-row.player-trio {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .site-theme .home-actions .admin-row.player-trio > :last-child {
    grid-column: 1 / -1;
  }
  .site-theme .home-window:not(.auth-active) .home-actions .admin-row.player-trio .home-menu-copy small {
    font-size: 11px;
  }
  .site-theme .home-audio {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .site-theme .home-audio .music-player {
    flex-basis: 100%;
  }
  .site-theme .account-bar:not(.guest) {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 8px;
    padding: 10px;
  }
  .site-theme .account-bar:not(.guest) .ab-photo {
    width: 52px;
    height: 52px;
  }
  .site-theme .account-bar:not(.guest) .ab-text > small {
    font-size: 9px;
  }
  .site-theme .account-bar:not(.guest) .ab-name > b {
    font-size: 17px;
  }
  .site-theme .account-bar:not(.guest) .ab-name {
    flex-wrap: wrap;
  }
  .site-theme .account-bar:not(.guest) .ab-xp {
    height: 10px;
    max-width: none;
  }
  .site-theme .account-bar:not(.guest) .ab-wallet,
  .site-theme .account-bar:not(.guest) .ab-actions {
    width: 100%;
    justify-self: stretch;
  }
  .site-theme .account-bar:not(.guest) .ab-wallet > span {
    height: auto;
    min-height: 42px;
    min-width: 0;
    padding: 5px 6px;
    grid-template-rows: 10px 18px;
  }
  .site-theme .account-bar:not(.guest) .ab-wallet small {
    display: block;
    font-size: 8px;
    line-height: 10px;
  }
  .site-theme .account-bar:not(.guest) .ab-wallet b {
    font-size: 15px;
    line-height: 18px;
  }
  .site-theme .account-bar:not(.guest) .ab-actions .ab-btn {
    width: 100%;
    height: auto;
    min-height: 34px;
    padding: 6px 4px;
    font-size: 9px;
    gap: 4px;
  }
  .site-theme .account-bar:not(.guest) .ab-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .site-theme .account-bar:not(.guest) .ab-actions .ab-btn span {
    display: inline;
  }
  .site-theme .home-premise,
  .guest-progress-note {
    margin-left: 0;
    margin-right: 0;
  }

  /* Navigation and forms wrap instead of creating a sideways page. */
  .site-theme.menu-page > .main {
    padding: 14px 10px;
  }
  .menu-page .menu-header-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
  .menu-page .menu-header-actions > *,
  .menu-page .menu-header-actions .music-player {
    min-width: 0;
  }
  .site-theme .btn,
  .shop-tabs .shop-tab,
  .dex-chip,
  .trades-tabs button {
    min-height: 34px;
  }
  .site-theme .btn {
    max-width: 100%;
    padding: 7px 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .account-notice {
    flex-direction: column;
    align-items: stretch;
  }
  .account-notice .btn {
    width: 100%;
  }

  /* Region and starter cards keep all descriptions visible. */
  .rg-card.kanto,
  .rg-card.johto {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
    padding: 16px 12px;
  }
  .rg-card .rg-name {
    flex: none;
    width: 100%;
  }
  .rg-card .rg-name small {
    font-size: 11px;
    line-height: 1.4;
  }
  .rg-card.kanto .rg-bosses,
  .rg-card.johto .rg-bosses {
    width: 100%;
    justify-content: center;
    gap: 3px;
  }
  .rg-card.kanto .rg-bosses > i,
  .rg-card.johto .rg-bosses > i {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: 48px;
  }
  .rg-card.kanto .rg-boss,
  .rg-card.johto .rg-boss {
    width: 100%;
    max-width: 46px;
    height: 46px;
  }
  .pk-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .pk-card {
    width: 100%;
    min-width: 0;
  }
  .pk-card .pk-portrait {
    min-height: 100px;
  }
  .pk-card .pk-top,
  .pk-card .pk-stats small {
    font-size: 10px;
  }

  /* Shop: one readable offer per row, with centered sprite comparison. */
  .shop-hd,
  .shop-wallet {
    flex-wrap: wrap;
    gap: 8px;
  }
  .shop-wallet {
    width: 100%;
  }
  .shop-wallet .shop-bal {
    flex: 1 1 0;
    min-width: 0;
  }
  .shop-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
  }
  .shop-tabs .shop-tab {
    min-width: 0;
    padding: 8px 4px;
    font-size: 10px;
    white-space: normal;
  }
  .shopx .sx-grid,
  .shopx .sx-grid.n1 {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .shopx .sx-card {
    grid-template-rows: 150px auto auto;
    min-height: 0;
    padding: 12px;
  }
  .shopx .sx-card .sx-art {
    height: 150px;
    grid-template-columns: minmax(0, 128px) minmax(0, 64px);
    gap: 12px;
  }
  .shopx .sx-card .sx-skin {
    height: 128px;
  }
  .shopx .sx-card .sx-btn {
    min-height: 36px;
    font-size: 12px;
  }
  .sx-title {
    font-size: clamp(22px, 7vw, 32px);
    overflow-wrap: anywhere;
  }
  .sx-sub {
    letter-spacing: 1px;
  }
  .sx-offers-head {
    flex-wrap: wrap;
    letter-spacing: 1px;
  }
  .shop-packs .pack-list {
    grid-template-columns: minmax(0, 1fr);
  }

  /* PvP: preserve player on the left and opponent on the right. */
  .pvp-team-hd {
    flex-wrap: wrap;
    gap: 10px;
  }
  .pvp-team-hd > .btn {
    width: 100%;
  }
  .pvp-team-details,
  .pvp-selected-team .hall-team {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pvp-invite-form {
    grid-template-columns: minmax(0, 1fr);
  }
  .pvp-invite-form input,
  .pvp-invite-form .btn {
    grid-column: 1;
    width: 100%;
    min-width: 0;
  }
  .menu-page.site-theme .pvp-lobby .pvp-panel.pvp-history-panel {
    padding: 12px 8px 8px;
  }
  .pvp-history-matchup {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
    gap: 4px;
  }
  .pvp-history-team {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pvp-history-side > .pvp-trainer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .pvp-history-member .hall-name,
  .pvp-history-item {
    overflow-wrap: anywhere;
  }

  .overlay {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }
  .overlay .modal,
  .overlay .pvp-result-modal {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
  }
  .overlay .modal-body {
    padding: 12px;
  }
  .capture-modal .target-roster .target-card,
  .capture-modal .target-roster .target-card.single {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .capture-modal .target-roster .target-card .target-portrait .pixel {
    width: 44px;
    height: 44px;
    object-fit: contain;
  }
  .evc-card.capture .evc-art.evc-foes.n3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 180px;
    align-content: center;
  }
  .evc-card .evc-art-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
  }
  .compact-shell .run-main:has(> .evc-card) {
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .compact-shell .run-main > .evc-card {
    flex: none;
  }
  .pw-intro .pw-intro-wheel {
    width: 140px;
  }
  .pw-intro .evc-art {
    min-height: 190px;
  }
  .pw button[aria-label] {
    min-width: 30px;
    min-height: 30px;
  }
  .site-theme .pw .btn.pw-spin {
    width: auto;
    min-width: 0;
    min-height: 36px;
    padding: 8px 16px;
    font-size: 12px;
  }
  .site-theme .pvp-battle-page .card-battle .btn.battle-log-more {
    height: 30px;
    min-height: 30px;
    padding: 4px 8px;
  }
  .evolution-fx > .btn.full {
    width: auto;
    justify-self: center;
    padding-left: 16px;
    padding-right: 16px;
  }
  .evc-foes.n3 .evc-foe {
    min-width: 0;
  }
  .evc-foes.n3 .evc-foe .evc-foe-img {
    width: 76px !important;
    height: 76px !important;
  }
  .evc-foes.n3 .evc-foe figcaption {
    max-width: 100%;
    padding: 2px 4px;
  }
  .evc-foes.n3 .evc-foe figcaption strong {
    font-size: 11px;
    overflow-wrap: anywhere;
  }
  .evc-foes.n3 .evc-foe figcaption small {
    font-size: 9px;
  }
  .site-theme .sim-page,
  .site-theme .sim-head,
  .site-theme .sim-list {
    min-width: 0;
  }
  .site-theme .sim-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .site-theme .sim-head input,
  .site-theme .sim-tabs > button {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .site-theme .sim-tabs > button {
    white-space: normal;
  }
  .pko-reveal {
    width: 100%;
    min-width: 0;
    padding: 0 12px;
    box-sizing: border-box;
  }
  .pko-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .pvp-history-team {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .site-theme .dex-page,
  .site-theme .dex-page .dex-head,
  .site-theme .dex-page .dex-tools,
  .site-theme .dex-page .dex-grid {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .site-theme .dex-page .dex-head > div:first-child {
    min-width: 0;
  }
  .site-theme .dex-page .dex-regions {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .slots-shell.compact-shell:has(.encounter-upgraded) {
    height: auto;
    min-height: max(calc(100dvh - 64px), 980px);
  }
  .compact-shell .game-stage:has(.encounter-upgraded),
  .compact-shell .game-main:has(.encounter-upgraded),
  .compact-shell .run-layout:has(.encounter-upgraded),
  .compact-shell .run-main:has(> .encounter-upgraded),
  .compact-shell .encounter-upgraded {
    flex: none;
    height: auto;
    min-height: 0;
  }
  .compact-shell .encounter-upgraded {
    overflow: hidden;
  }
}

@media (max-width: 350px) {
  .site-theme .home-window:not(.auth-active) .home-actions,
  .site-theme .home-actions .visitor-options,
  .site-theme .home-actions .admin-row.player-trio {
    grid-template-columns: minmax(0, 1fr);
  }
  .site-theme .home-actions > *,
  .site-theme .home-actions .admin-row.player-trio > * {
    grid-column: 1;
  }
}
