/* Phone composition owns the dock. Feature modules keep their actions/art. */
.phone-shortcut,
.topbar #navbar-commerce-slot {
  display: none;
}
#game-shell .phone-shortcut[hidden] {
  display: none;
}
#game-shell .topbar #navbar-commerce-slot:empty {
  display: none;
}
/* Touch surfaces keep their existing fills without creating backdrop-filter
   layers over the moving world or underneath native dialogs. */
@media (pointer: coarse) {
  .game-panel,
  .drawer-backdrop,
  .modal-backdrop,
  .hunt-map-overlay,
  .capture-rules-dialog::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (max-width: 650px) {
  :root {
    --mobile-dock-height: 64px;
    --mobile-dock-space: calc(
      var(--mobile-dock-height) + env(safe-area-inset-bottom, 0px)
    );
    --mobile-safe-top: env(safe-area-inset-top, 0px);
  }
  #game-shell header.topbar[data-navbar-layout="compact"] {
    --ui-navigation-top-inset: env(safe-area-inset-top, 0px);
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: var(--mobile-dock-space);
    min-height: var(--mobile-dock-space);
    padding: 3px max(4px, env(safe-area-inset-right, 0px))
      calc(3px + env(safe-area-inset-bottom, 0px))
      max(4px, env(safe-area-inset-left, 0px));
    gap: 0;
    border-width: 1px 0 0;
    border-radius: 0;
    background: var(--ui-color-surface);
    box-shadow: 0 -4px 16px #0005;
    z-index: 18;
  }
  /* Keep the top HUD controls reachable while a long dock menu scrolls. */
  :root[data-hud-layout="single"] #game-shell header.topbar[data-navbar-layout="compact"] {
    --ui-navigation-top-inset: var(--hud-panel-top, env(safe-area-inset-top, 0px));
  }
  #game-shell .topbar[data-navbar-layout="compact"] nav.top-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 0;
    flex: 1;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    .top-actions
    > :is(
      .navbar-group--primary,
      .navbar-hunt-group,
      #navbar-commerce-slot,
      #nav-shop,
      #nav-menu
    ) {
    grid-column: auto;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    height: 56px;
    margin: 0;
    justify-self: stretch;
    justify-content: center;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    :is(#nav-pokemon, #nav-hunt, #nav-commerce, #nav-shop, #nav-menu) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 56px;
    min-height: 44px;
    padding: 0 1px;
    margin: 0;
    gap: 0;
    font: 600 10px/14px var(--ui-font-body);
    color: var(--ui-color-text-muted);
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    :is(#nav-pokemon, #nav-hunt, #nav-commerce, #nav-shop, #nav-menu)
    .nav-label {
    display: block;
    flex-shrink: 0;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    font: 600 10px/14px var(--ui-font-body);
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #nav-pokemon
    .navbar-chevron {
    display: none;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #nav-hunt {
    flex: 1;
    width: calc(100% - 18px);
  }
  #game-shell .topbar[data-navbar-layout="compact"] #navbar-commerce-slot {
    display: flex;
    align-items: center;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #navbar-commerce-slot > .navbar-group {
    width: 100%;
    height: 100%;
    min-width: 0;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #nav-commerce .navbar-chevron {
    position: absolute;
    right: 3px;
    bottom: 5px;
    width: 8px;
    height: 8px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    .top-actions
    .navbar-hunt-toggle {
    flex: 0 0 18px;
    width: 18px;
    min-width: 18px;
    height: 56px;
    padding: 0;
  }
  /* Rubis uses the same compact icon/label rhythm as the other destinations. */
  #game-shell .topbar[data-navbar-layout="compact"] #nav-shop {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    transform: none;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #nav-shop > .nav-icon {
    grid-row: auto;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #nav-shop
    .navbar-ruby-sale {
    position: absolute;
    right: 1px;
    top: 0;
    font-size: 11px;
    line-height: 12px;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #nav-menu > .ui-pixel-icon {
    margin-block: 6px;
  }
  #game-shell .topbar[data-navbar-layout="compact"] .top-actions > #nav-menu {
    flex-direction: column;
  }
  #game-shell .topbar[data-navbar-layout="compact"] .navbar-view-controls {
    display: none;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #navbar-live-slot {
    display: none;
  }
  #game-shell .topbar[data-navbar-layout="compact"] .navbar-compact-menu {
    --ui-navigation-width: 320px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #navbar-menu-panel
    > #navbar-view-panel {
    position: static;
    width: auto !important;
    max-height: none !important;
    margin-top: 4px;
    border: 0;
    border-top: 1px solid var(--ui-color-border);
    padding: 4px 0 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #navbar-secondary
    #nav-live {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #navbar-secondary
    #nav-live
    .nav-label {
    font-size: 12px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    #navbar-secondary
    #nav-live
    .live-nav-caption {
    gap: 6px;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #navbar-secondary #nav-battle-pass {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    height: 44px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 4px 8px;
    font: 600 12px/1.2 var(--ui-font-body);
  }
  #game-shell .topbar[data-navbar-layout="compact"] #navbar-secondary #nav-battle-pass .nav-label {
    font-size: 12px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    :is(
      #nav-menu,
      #nav-pokemon,
      #nav-commerce,
      #nav-shop
    )[aria-expanded="true"],
  #game-shell
    .topbar[data-navbar-layout="compact"]
    :is(#nav-hunt, #nav-commerce, #nav-shop).active {
    color: var(--ui-color-text);
    border-color: var(--ui-color-primary);
    background: color-mix(in srgb, var(--ui-color-primary) 12%, transparent);
  }
  #game-shell .topbar [data-navbar-notification] {
    top: 0;
    right: 4px;
  }
  #game-shell .phone-shortcut {
    position: fixed;
    z-index: 10;
    top: var(--hud-game-pass-top, calc(env(safe-area-inset-top, 0px) + 6px));
    left: var(--hud-game-pass-left, calc(100vw - 50px));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-color: var(--ui-color-border);
    background: var(--ui-color-surface);
    color: var(--ui-color-text);
  }
  #game-shell .phone-shortcut .nav-icon.ui-pixel-icon {
    width: 36px;
    height: 36px;
  }
  #game-shell .phone-shortcut.active {
    border-color: var(--ui-color-primary);
  }
  #game-shell .bottom-tools {
    bottom: calc(var(--mobile-dock-space) + 4px);
    left: 10px;
    right: 10px;
    transform: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }
  #game-shell .bottom-tools .skills {
    width: 100%;
    max-width: 100%;
    padding: 3px 0 7px;
  }
  #game-shell .bottom-tools .skill-group-identity strong {
    font-size: 10px;
  }
  #game-shell .bottom-tools .skill-group-identity small {
    font-size: 8px;
  }
  #game-shell .bottom-tools .skill-group-edit {
    gap: 0;
    padding: 3px 2px;
    font-size: 0;
  }
  #game-shell .bottom-tools .skill-group-edit > span:first-child {
    font-size: 11px;
  }
  #game-shell .global-boost-events {
    top: auto;
    bottom: var(--hud-bonuses-bottom, calc(var(--mobile-dock-space) + 8px));
    left: 50%;
    max-width: calc(100vw - 20px);
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #game-shell .global-boost-events-list {
    height: auto;
    min-height: 24px;
    align-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #game-shell .global-boost-events-list .active-boost.global-boost-event {
    min-height: 24px;
  }
  :root[data-hud-layout="single"] .hud-panel-switch {
    right: 6px;
    width: max-content;
    max-width: var(--hud-switch-max-width, calc(100vw - 12px));
    padding: 0;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  :root[data-hud-layout][data-hud-gift-dock="tabs"] .hud-panel-switch {
    max-width: var(--hud-switch-max-width, calc(100vw - 68px));
  }
  :root[data-hud-layout="single"] .hud-panel-switch button {
    flex-shrink: 0;
    min-width: 52px;
    min-height: 40px;
    padding: 3px 10px;
  }
  :root[data-hud-layout="single"] :is(.party, .ha-analyzer) {
    max-height: var(--hud-panel-height);
  }
  #game-shell #game-chat[data-picker-open="true"] {
    bottom: var(--hud-chat-bottom, calc(var(--mobile-dock-space) + 6px));
    max-height: calc(
      100dvh - var(--hud-chat-bottom, 72px) - var(--hud-panel-top, 54px) - 8px
    );
  }
}
@media (max-width: 299px) {
  #game-shell
    .topbar[data-navbar-layout="compact"]
    :is(#nav-pokemon, #nav-hunt, #nav-commerce, #nav-shop, #nav-menu)
    .nav-label {
    font-size: 9px;
  }
  #game-shell
    .topbar[data-navbar-layout="compact"]
    .top-actions
    .navbar-hunt-toggle {
    display: none;
  }
  #game-shell .topbar[data-navbar-layout="compact"] #nav-hunt {
    width: 100%;
  }
}
