/* Phones (mobile-nav.mjs): a bar at the bottom, the sidebar as the More panel over it, and the page at full
   width. Loaded last so it wins over layout.css. Wider screens never see any of it. */
.phone-bar,.phone-top,.phone-scrim,.sidebar-tile.phone-only,.phone-text{display:none}
.install-help{width:min(440px,calc(100vw - 32px));padding:22px 24px;border:1px solid var(--border-strong);border-radius:12px;background:var(--panel);color:var(--text)}
.install-help::backdrop{background:#050805c7}.install-help h2{margin:0 0 12px;font-size:18px}.install-help ul{margin:0 0 12px;padding-left:18px;line-height:1.6}.install-help .primary{margin-top:6px}
/* Phones and tablets (body.mobile-device, mobile-nav.mjs) cannot run the Windows app or read the game's folder:
   Settings says what the app does for them instead of offering it. */
body:not(.mobile-device) #profilePanel-settings .settings-row.device-note,body.mobile-device #profilePanel-settings .app-settings .settings-row.helper-row{display:none}

@media(max-width:760px){
  :root{--sidebar-width:0px;--phone-bar:58px;--phone-bar-total:calc(var(--phone-bar) + env(safe-area-inset-bottom,0px))}
  body main.app-main{margin-left:0;width:100%;padding:0 12px calc(var(--phone-bar-total) + 20px)}

  /* The bar. */
  .phone-bar{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));position:fixed;left:0;right:0;bottom:0;z-index:85;height:var(--phone-bar-total);padding-bottom:env(safe-area-inset-bottom,0px);background:#121812f7;border-top:1px solid var(--border);backdrop-filter:blur(8px)}
  .phone-tab{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;padding:6px 2px;border:0;border-radius:0;background:transparent;color:var(--muted);font-size:10.5px;line-height:1.1}
  .phone-tab-icon{font-size:19px;line-height:1}.phone-tab-label{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .phone-tab:is(:hover,:focus,:active){background:transparent;border-color:transparent}.phone-tab:focus-visible{outline:2px solid var(--accent);outline-offset:-4px}
  .phone-tab.active{color:var(--accent)}.phone-tab.active::before{content:'';position:absolute;top:0;left:22%;right:22%;height:2px;border-radius:0 0 2px 2px;background:var(--accent)}
  .phone-tab .nav-badge{position:absolute;top:4px;left:calc(50% + 6px);min-width:16px;margin:0;padding:0 4px;font-size:10px}
  .phone-more.has-news::after{content:'';position:absolute;top:8px;left:calc(50% + 8px);width:8px;height:8px;border-radius:50%;background:#e7c778}
  .phone-tab.guest-locked{opacity:.4}

  /* The strip over the page: the logo, the character; the EN | CZ switch keeps its corner. */
  /* Above the pages' own scenery, which some (Raid) draw up past their top edge. */
  .phone-top{position:relative;z-index:3;display:flex;align-items:center;gap:10px;min-height:48px;padding:6px 92px 6px 0}
  .phone-brand{display:flex;align-items:center;gap:7px;color:var(--text);text-decoration:none}.phone-brand img{flex:none}.phone-brand strong{font-size:15px;letter-spacing:2px}
  .phone-character{min-width:0;padding:5px 10px;border:1px solid var(--border);border-radius:999px;background:#1d241c;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .language-switch{top:12px;right:12px}

  /* The sidebar becomes the More panel, sliding up over the bar. */
  .app-sidebar{inset:auto 0 var(--phone-bar-total) 0;width:auto;max-height:calc(100dvh - var(--phone-bar-total) - 40px);z-index:80;padding:16px 14px 12px;border:0;border-top:1px solid var(--border-strong,#3a483b);border-radius:16px 16px 0 0;box-shadow:0 -18px 50px #000c;transform:translateY(calc(100% + var(--phone-bar-total)));visibility:hidden;transition:transform .22s ease,visibility 0s .22s}
  body.more-open .app-sidebar{transform:none;visibility:visible;transition:transform .22s ease}
  body.account-menu-open>.app-sidebar{z-index:80}
  body.more-open{overflow:hidden}
  .phone-scrim{position:fixed;inset:0 0 var(--phone-bar-total) 0;z-index:79;background:#050805a8}
  body.more-open .phone-scrim{display:block}
  .app-sidebar .sidebar-brand{display:none}
  .app-sidebar .main-nav{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .app-sidebar .main-nav :is(#nav-home,#nav-raid,#nav-tasks,#nav-phone),.app-sidebar .nav-submenu{display:none!important}
  /* A guest's bar has Maps and Trade instead; the panel lists what the bar does not. */
  body.phone-guest .app-sidebar .main-nav :is(#nav-tasks,#nav-phone){display:flex!important}body.phone-guest .app-sidebar .main-nav :is(#nav-maps,#nav-market){display:none!important}
  .app-sidebar .main-nav button,.sidebar-tile.phone-only,.app-sidebar .sidebar-guide{flex-direction:column;justify-content:center;gap:6px;min-height:64px;padding:10px 4px;font-size:12px;text-align:center;white-space:normal;border:1px solid var(--border);border-radius:10px;background:#192019}
  .app-sidebar .main-nav button.active{box-shadow:inset 0 -3px var(--accent)}
  .app-sidebar .nav-icon{width:auto;font-size:20px}
  .sidebar-bottom{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:8px;padding-top:0}
  .sidebar-bottom>:not(.sidebar-guide):not(.sidebar-tile){grid-column:1/-1}
  .sidebar-tile.phone-only{display:flex;align-items:center;color:var(--text)}.sidebar-tile.phone-only[hidden]{display:none}
  .app-sidebar .sidebar-guide .nav-icon{width:22px;height:22px;font-size:13px}
  .app-sidebar .character-chip{padding:10px 12px;font-size:12px}
  .account-menu{left:12px;right:12px;width:auto;max-width:none;bottom:calc(var(--phone-bar-total) + 12px);max-height:calc(100dvh - var(--phone-bar-total) - 40px);z-index:95}

  /* Trade's three pages: tabs over the page, as the sidebar's drop-down is in the closed panel. */
  body:has(#lootPage:not([hidden]),#itemsPage:not([hidden]),#profitPage:not([hidden])) #marketTabs[hidden]{display:flex!important;margin:0 0 14px}

  /* Friends opens from More as a panel over the bar; closed, it takes no room. */
  .friends-dock{left:8px;right:8px;bottom:calc(var(--phone-bar-total) + 8px)}
  .friends-dock[data-open=false]{display:none}

  /* Full-window views end at the bar, so it stays in reach. */
  #raidMapDrawer.raid-map-drawer{bottom:var(--phone-bar-total);height:auto}
  .phone-page:not([hidden]){bottom:var(--phone-bar-total)}
  .tb-window{inset:8px 8px calc(var(--phone-bar-total) + 8px) 8px}
  .poll-popup{bottom:calc(var(--phone-bar-total) + 12px)}
  /* The walkthrough sits over the bar it points into. */
  .tutorial:not(.tutorial-top){left:12px;right:12px;width:auto;bottom:calc(var(--phone-bar-total) + 12px);max-height:calc(62vh - var(--phone-bar-total))}
  .phone-tab.tutorial-target{outline-offset:-4px}
  .tutorial.tutorial-top{top:56px}
  /* Maps are map-first: one row of controls that scrolls sideways, the map in the rest of the screen, and the
     marker filters (closed to begin with, maps.mjs) rolling out over it. */
  .local-map-controls{flex-wrap:nowrap;gap:6px;margin:0 -12px 8px;padding:0 12px 4px;overflow-x:auto;scrollbar-width:none}
  .local-map-controls::-webkit-scrollbar{display:none}
  .local-map-controls>*,.local-map-controls .locator>*{flex:none}
  .local-map-controls label{display:flex;align-items:center;font-size:0}.local-map-controls select{margin:0;font-size:13px;min-height:40px}
  .local-map-controls button{min-height:40px;padding:7px 11px;font-size:13px;white-space:nowrap}
  .local-map-controls .locator{display:flex;flex-wrap:nowrap;gap:6px;margin:0;padding:0;border:0}
  .local-map-controls :is(.locator-caption,.locator-unsupported){display:none}
  .local-map-controls .map-loot-run{margin-left:0}
  .map-drawer-toggle{padding:14px 9px}
  .local-map-stage .leaflet-left .leaflet-control-zoom{margin-left:46px}
  #mapsPage:has(#mapExplorerViewer:not([hidden])) .companion-heading{display:none}
  #mapExplorerTitle{margin:4px 0 8px;font-size:18px}
  #mapExplorerViewer .local-map-canvas{height:calc(100dvh - var(--phone-bar-total) - 172px);min-height:300px}
  /* The Raid map: its title, then its buttons in one row; the task list lies over the map from its edge. */
  #raidMapDrawer.raid-map-drawer{padding:8px 10px}
  #raidMapDrawer .raid-map-drawer-heading{flex-wrap:wrap;gap:6px;margin-bottom:8px;padding-right:0}
  #raidMapDrawer .raid-map-drawer-heading h2{flex-basis:100%;order:-2;margin:0;padding:0 92px 0 0;min-height:44px;line-height:44px;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #raidMapDrawer .raid-map-drawer-heading button{min-height:40px;padding:6px 10px;font-size:12.5px}
  #raidCloseMap{order:-1}
  .raid-map-full-workspace{position:relative;grid-template-columns:30px minmax(0,1fr);gap:6px}
  #raidMapTasksHost{position:absolute;z-index:600;top:0;bottom:0;left:36px;width:min(340px,calc(100% - 44px));padding:10px;border:1px solid var(--border-strong,#3a483b);border-radius:10px;background:#101710f7;box-shadow:12px 0 40px #000c}
  #raidMapDrawer .local-map-controls{max-height:none;overflow-y:hidden}
  /* Page headings: shorter, with their buttons on a row under the words rather than squeezed beside them. */
  .app-main :is(.companion-heading,.page-heading,.gs-heading){flex-direction:column;align-items:stretch;gap:10px;margin:2px 0 16px}
  .app-main :is(.companion-heading,.page-heading,.gs-heading) h1{margin:2px 0 4px;font-size:25px;line-height:1.15}
  .app-main :is(.companion-heading,.page-heading) p{margin:0;font-size:13.5px}
  .app-main :is(.companion-heading,.page-heading,.gs-heading)>button{align-self:flex-start}
  .app-main .page-heading br{display:none}
  /* The Loot run page: Back and the settings on one row, the title over the whole width under them. */
  .loot-run-page-head{flex-wrap:wrap;gap:8px 10px}.loot-run-page-head>div{flex-basis:100%;order:1}.loot-run-page-head h1{font-size:22px}
  .loot-run-page-head>button:last-child{margin-left:auto}
  /* Its map's one row of controls scrolls; it must not widen the column. */
  .loot-run-page-grid{grid-template-columns:minmax(0,1fr)}
  /* The scenery behind a page stays scenery: at full strength it reads through the words on a narrow screen. */
  .page-art::before{opacity:.4}
  /* Settings: the words above their controls when both do not fit on one line. */
  .companion-page .settings-row{flex-wrap:wrap;gap:10px 16px}:is(#profilePanel-settings,.companion-page) .settings-row>.settings-words{flex:1 1 210px}
  .settings-row>select,.settings-row>input[type=number]{flex:1 1 200px;width:auto}
  /* Wide tables scroll sideways under a fixed first column. */
  .ammo-table :is(th,td):first-child{position:sticky;left:0;z-index:1;background:var(--panel);box-shadow:1px 0 var(--border)}
  .ammo-table th:first-child{z-index:2}
  /* What a phone can do: choose a screenshot, not paste one. */
  .desk-text{display:none}.phone-text{display:block}
  /* Fingers, not a mouse pointer: buttons, chips and fields are 40 pixels high (inline links stay text). */
  main.app-main :is(button,select,input:is([type=text],[type=search],[type=number],[type=email],[type=password],[type=url])):not(.item-link,.phone-tab,[class*=-link],[class*=-name],.hideout-item-picture){min-height:40px}
  .language-switch button{min-width:40px;min-height:34px}.phone-character{min-height:34px}
  /* Windows with a lot to read take the whole screen, as a phone's own screens do; short notes stay small. */
  dialog:is(.item-popup,.changelog-window,.dev-chat-window,.guide-dialog,.wide-dialog,.friend-profile,.loot-keys-window,.history-dialog)[open]{inset:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0}
  /* The walkthrough's phone pictures are tall: a part of the panel, not all of it. */
  .tutorial-image.phone-picture{width:auto;max-width:100%;max-height:30vh;margin:0 auto 10px}
  .guide-dialog .guide-figure img{max-height:62vh}
  /* Games, the character picker and setup fill the screen on their own. */
  body:has(.games-workspace:not([hidden]),.character-select:not([hidden]),.character-setup:not([hidden])) :is(.phone-bar,.phone-scrim){display:none}
  .account-loading .phone-bar{display:none}
}
