/* Path: static/mobile.css
   Purpose: the page on phones and tablets. While touch is in charge (html.bk-touch-ui, set by
   touch.js) the view fills the screen inside the safe area, the keyboard strip and the page below
   give way to the touch controls, and every panel fits a small screen with thumb-sized buttons.
   html.bk-page lets the page below be read normally; html.bk-portrait asks a phone to turn sideways. */

/* ---- the start screen, before touch.js has decided anything ---- */
.start { padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow-y: auto; }
.start-go { min-height: 48px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .start-go { padding: 14px 28px; font-size: 15px; }
  .start-alt, .start-join { min-height: 44px; }
}
@media (max-height: 420px) {
  .start-card { gap: 8px; }
  .start-card h1 { font-size: 34px; }
  .start-card p { font-size: 12px; }
  .start-go { margin-top: 2px; }
}
/* On a phone the start card's title is the short name, as on its Home Screen (owner, 10-16). */
@media (max-height: 500px), (max-width: 560px) {
  .start-maker { display: none; }
}
/* A phone on its side: the title beside the buttons, so the whole card fits the height without scrolling. */
@media (max-height: 500px) and (min-width: 560px) {
  .start-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; column-gap: 32px; width: min(760px, 100%); max-width: none; }
  .start-logo { width: 64px; height: 64px; }
  .start-card h1 { margin-top: 0; font-size: 34px; }
  /* How to play, What's new and Contact support stay on one line in the right column. */
  .start-news { padding: 0 8px; font-size: 12px; }
}

/* ---- the view fills the screen ---- */
html.bk-touch-ui:not(.bk-page), html.bk-touch-ui:not(.bk-page) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.bk-touch-ui:not(.bk-page) body { position: fixed; inset: 0; width: 100%; -webkit-text-size-adjust: 100%; user-select: none; -webkit-user-select: none; }
html.bk-touch-ui:not(.bk-page) #game { max-width: none; padding: 0; }
html.bk-touch-ui:not(.bk-page) .stage-wrap { position: fixed; inset: 0; }
html.bk-touch-ui:not(.bk-page) .stage-wrap .stage { width: 100%; height: 100%; aspect-ratio: auto; box-shadow: none; }
html.bk-touch-ui:not(.bk-page) .bar,
html.bk-touch-ui:not(.bk-page) .panels,
html.bk-touch-ui .keys-bar,
html.bk-touch-ui .bk-gear,
html.bk-touch-ui .look { display: none; }

/* The room name, small and centered at the top, between the buttons and the HUD corner. */
html.bk-touch-ui:not(.bk-page) .hud { position: fixed; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 46; padding: 0; pointer-events: none;
  max-width: 36vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; text-align: center; }
html.bk-touch-ui:not(.bk-page) .rname { font-size: 15px; text-shadow: 0 1px 3px #000; }
/* Code and coordinate share one line under the name; the HUD takes no touches here, so the sheet copies. */
html.bk-touch-ui:not(.bk-page) .rmeta { display: block; margin: 0; font-size: 10px; }
html.bk-touch-ui:not(.bk-page) :is(.rcode, .rcoord) { font-size: 10px; }
html.bk-touch-ui:not(.bk-page) .rcoord { margin-left: 8px; }
/* Ring and district share stay on that one line, cut short rather than wrapping onto the compass under it. */
/* Full strength with a tight dark edge, so the small line still reads over a brightly lit wall. */
html.bk-touch-ui:not(.bk-page) .rmeta { overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 2px #000, 0 1px 2px #000; }
html.bk-touch-ui:not(.bk-page) :is(.rcode, .rring, .rdist) { opacity: 1; }
html.bk-touch-ui:not(.bk-page) :is(.rring, .rdist) { margin-left: 6px; font-size: 10px; letter-spacing: 0; }
/* The first finder's name would be a third line over the compass; on a phone it is read on the map. */
html.bk-touch-ui:not(.bk-page) .rland { display: none; }
html.bk-touch-ui .compass { top: calc(max(6px, env(safe-area-inset-top)) + 40px); }
html.bk-touch-ui .version { top: auto; bottom: max(2px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }

/* The HUD corner, compact: two short rows instead of a tall column. */
html.bk-touch-ui .hud-corner { top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center;
  gap: 3px 10px; padding: 5px 8px; font-size: 10px; max-width: min(300px, 32vw); }
html.bk-touch-ui .hud-corner .meter { gap: 4px; }
html.bk-touch-ui .hud-corner .meter i { width: 40px; height: 5px; }
html.bk-touch-ui .hud-corner .fx { font-size: 10px; }
html.bk-touch-ui .hud-clock { font-size: 12px; }
html.bk-touch-ui .hud-corner .copyright { flex-basis: 100%; text-align: right; font-size: 10px; }
html.bk-touch-ui .hud-corner .fx span { padding: 1px 5px; }
html.bk-touch-ui .way { gap: 4px; }
/* The waypoint and supply drop chips take a row each at the corner's right edge, the drop under the waypoint. */
html.bk-touch-ui .hud-corner .way { flex-basis: 100%; justify-content: flex-end; }
/* Name and code are read here and worked from the menu (Your name, Copy return code): too small to tap. */
html.bk-touch-ui .hud-corner .code-tag, html.bk-touch-ui .hud-corner .linkish { font-size: 10px; pointer-events: none; }
@media (max-width: 700px) {
  html.bk-touch-ui .hud-corner .meter > span { display: none; }
}

/* Toasts and the hint sit above the middle, clear of both thumbs. */
html.bk-touch-ui .toast { bottom: auto; top: calc(max(6px, env(safe-area-inset-top)) + 100px); max-width: min(440px, 34vw); font-size: 13px; padding: 6px 10px; z-index: 46; }
html.bk-touch-ui .hint { max-width: 44vw; white-space: normal; text-align: center; font-size: 11px; }
/* Cards (static/notify.js) tighter on a phone, so one fits between the objective and the crosshair. */
html.bk-touch-ui .note-card:not(.toast) { padding: 6px 12px 7px !important; gap: 2px !important; line-height: 1.3 !important; max-width: min(340px, 44vw) !important; }
/* Quest and achievement cards (quests.js, achievements.js) in smaller type; the journal line is left out. */
html.bk-touch-ui .note-card .qc-did { font-size: 14px !important; }
html.bk-touch-ui .note-card :is(.qc-sub, .qc-next) { font-size: 10px !important; }
html.bk-touch-ui .note-card .qc-kept { display: none; }

/* ---- panels: thumb-sized, inside the screen, scrolling inside themselves ---- */
html.bk-touch-ui .ghost, html.bk-touch-ui .act, html.bk-touch-ui .tabs button { min-height: 44px; touch-action: manipulation; }
html.bk-touch-ui .field { height: 44px; font-size: 16px; }
/* Paint by thumb: bigger swatches, and the garment map beside the grid kept small. */
html.bk-touch-ui .paint-swatch { width: 40px; height: 40px; touch-action: manipulation; }
html.bk-touch-ui .paint-map { flex-basis: 96px; }
html.bk-touch-ui .tone-pick .ghost, html.bk-touch-ui .player-body li .ghost { min-height: 44px; }
/* A phone on its side: the grid fits the height left under the store's header. */
@media (max-height: 500px) {
  html.bk-touch-ui .paint-grid { max-width: max(150px, calc(100dvh - 150px)); }
}
html.bk-touch-ui .inv-panel, html.bk-touch-ui .sketch-panel, html.bk-touch-ui .writer, html.bk-touch-ui .fridge:not(.shop), html.bk-touch-ui .bk-settings, html.bk-touch-ui .gate form, html.bk-touch-ui .codecard {
  max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
html.bk-touch-ui .inv-panel { width: min(560px, calc(100% - 24px)); padding: 10px 12px; }
/* The Player panel as wide as the store, its other tab. Its figure keeps touch-action none (game.css), so a
   drag turns it and a pinch zooms it; the list beside it scrolls the panel. */
html.bk-touch-ui .player-panel { width: min(660px, calc(100% - 20px)); }
html.bk-touch-ui .pl-zoom { right: 4px; bottom: 4px; }
html.bk-touch-ui .pl-zoom .ghost { width: 44px; min-height: 44px; font-size: 20px; }
html.bk-touch-ui .pl-row { grid-template-columns: 44px minmax(0, 1fr); gap: 8px; }
html.bk-touch-ui .inv-panel header { margin-bottom: 8px; }
html.bk-touch-ui .inv-close, html.bk-touch-ui .inv-panel footer, html.bk-touch-ui .inv-grid li .key, html.bk-touch-ui .sketch-panel header span { display: none; }
html.bk-touch-ui .inv-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; margin-bottom: 8px; }
html.bk-touch-ui .inv-grid li { min-height: 64px; padding: 8px 4px 6px; gap: 4px; touch-action: manipulation; cursor: pointer; }
html.bk-touch-ui .inv-grid li svg { width: 56px; height: 20px; }
html.bk-touch-ui .inv-pockets li { min-height: 44px; touch-action: manipulation; }
/* A long press picks a slot up (game.js dragStart), so the browser's callout may not take it first. */
html.bk-touch-ui .inv-grid li, html.bk-touch-ui .inv-pockets li { -webkit-touch-callout: none; }
html.bk-touch-ui .inv-hand { min-height: 44px; touch-action: manipulation; }
.bk-invbar { display: none; }
html.bk-touch-ui .bk-invbar { display: flex; flex-wrap: wrap; gap: 6px; }
html.bk-touch-ui .bk-invbar .ghost { flex: 1 1 auto; }
.bk-close { display: none; }
html.bk-touch-ui .bk-close { display: inline-block; }
html.bk-touch-ui .sketch-panel { padding: 10px; gap: 8px; width: min(760px, calc(100% - 16px)); grid-template-columns: 1fr auto; align-items: start; }
html.bk-touch-ui .sketch-panel header { grid-column: 1 / -1; align-items: center; }
html.bk-touch-ui .sketch-panel canvas { max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); width: auto; height: calc(100dvh - 110px); justify-self: center; }
html.bk-touch-ui .sketch-tools { flex-direction: column; }
html.bk-touch-ui .terminal { inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
html.bk-touch-ui .terminal iframe { touch-action: none; }
/* The phone keyboard covers the bottom half: the writer sits at the top. */
html.bk-touch-ui .writer { top: max(8px, env(safe-area-inset-top)); transform: translateX(-50%); padding: 10px; gap: 8px; }
html.bk-touch-ui #pad { max-height: 46vh; max-height: 46dvh; width: auto; justify-self: center; }
html.bk-touch-ui .fridge:not(.shop) { padding: 14px; gap: 8px; }
/* The store keeps its centring transform: top to bottom inside the safe area, its list scrolling inside. */
html.bk-touch-ui .shop { top: max(6px, env(safe-area-inset-top)); bottom: max(6px, env(safe-area-inset-bottom)); transform: translateX(-50%); height: auto;
  width: min(660px, calc(100% - 20px)); padding: 10px 12px; gap: 8px; }
html.bk-touch-ui .shop .inv-tabs { margin-bottom: 0; }
/* The base line is drawn inside the strip: a tab hanging 1px over it would make the strip scroll up and down. */
html.bk-touch-ui .store-tabs { flex-wrap: nowrap; overflow: auto hidden; overscroll-behavior-x: contain; scrollbar-width: none;
  border-bottom: 0; box-shadow: inset 0 -1px var(--line); }
html.bk-touch-ui .store-tabs button { flex: none; height: 44px; margin-bottom: 0; }
html.bk-touch-ui .shop-code .field { height: 44px; }
html.bk-touch-ui .store-main { touch-action: pan-y; }
html.bk-touch-ui .restore .linkish { min-height: 44px; }
/* A pack's emote names each play on the preview, so each is a thumb target of its own. */
html.bk-touch-ui .store-body [data-try-emote] { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 6px; }
html.bk-touch-ui .store-body li.tryable { min-height: 44px; }
html.bk-touch-ui .cb-cell { height: 46px; }
/* Short screens: the two tabs share a row with the wallet and Close, and the list gets the rest. */
@media (max-height: 500px) {
  html.bk-touch-ui .shop-head h2, html.bk-touch-ui .shop > .shop-note { display: none; }
  html.bk-touch-ui .shop { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  html.bk-touch-ui .shop > * { grid-column: 1 / -1; }
  html.bk-touch-ui .shop > .inv-tabs { grid-column: 1; }
  html.bk-touch-ui .shop > .shop-head { grid-column: 2; justify-content: flex-end; }
  html.bk-touch-ui .store-preview { height: 150px; }
  /* The Player panel takes the whole height, and its figure all of it under the tabs, for room to zoom. */
  html.bk-touch-ui .player-panel { top: max(6px, env(safe-area-inset-top)); bottom: max(6px, env(safe-area-inset-bottom)); transform: translateX(-50%); height: auto; }
  html.bk-touch-ui .player-panel .store-preview { height: max(150px, calc(100dvh - 150px)); }
  /* Short screens: the support form's message box gives up height before anything else does. */
  html.bk-touch-ui dialog.support textarea.field { height: 72px; }
  html.bk-touch-ui .news.support { padding: 10px 14px; }
}
/* Centered by game.css (both axes); only wider here, so two columns of choices fit. */
html.bk-touch-ui #choices { width: min(520px, calc(100% - 32px)); }
html.bk-touch-ui #choicesList { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
/* With a panel up the room name steps aside; it sits outside the view and would print over the panel. The
   minimap's header showed through the Player panel, so it steps aside too, and on a phone the meters
   corner covered the store's Close button and the Radio chips showed through the preview. */
html.bk-blocked .hud, html.bk-blocked .track, html.bk-blocked .objective, html.bk-blocked .hint, html.bk-blocked .chat-log:not(.open), html.bk-blocked .note-card, html.bk-blocked .cross,
html.bk-blocked:has(.inv-panel:not([hidden]), .shop:not([hidden])) .minimap,
html.bk-touch-ui.bk-blocked:has(.inv-panel:not([hidden]), .shop:not([hidden])) :is(.hud-corner, .bk-chips) { visibility: hidden; }
html.bk-touch-ui .inv-grid li .inv-acts button, html.bk-touch-ui .inv-pockets li button { min-width: 44px; }
/* Eat or Drink sits beside Look and Drop: a thumb-sized target of its own, wrapping in a narrow slot. */
html.bk-touch-ui .inv-grid li .inv-acts [data-eat] { min-width: 44px; min-height: 44px; }
html.bk-touch-ui .inv-pack-head button { min-width: 44px; min-height: 44px; }
/* The corner would sit over the panel; the shop keeps it, since the return code to paste is shown there. */
html.bk-blocked:not(:has(#shop:not([hidden]))) .hud-corner { visibility: hidden; }
html.bk-touch-ui .gate { padding: 8px; }
html.bk-touch-ui .gate-part, html.bk-touch-ui .codecard { padding: 14px; gap: 8px; }

/* ---- the menu sheet: a top row with the way back, look speed, then four labeled groups ---- */
.bk-sheet { position: absolute; left: 50%; top: 50%; z-index: 50; transform: translate(-50%, -50%); display: grid; gap: 8px; width: min(760px, calc(100% - 24px));
  max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 10px; background: rgba(7,11,20,.96); border: 1px solid rgba(77,182,247,.35); color: #cfe6ff; font-size: 12px; }
.bk-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bk-sheet-title { margin: 0; font: 400 20px 'Special Elite', 'Courier New', monospace; color: #eaf4ff; }
.bk-resume { min-height: 44px; padding: 0 18px; }
.bk-sheet h3.bk-sheet-group-title { margin: 2px 0 -2px; font: 600 10px/1.2 'JetBrains Mono', monospace; letter-spacing: .14em; text-transform: uppercase; color: #7f9bb8; }
.bk-sheet-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 6px; }
.bk-sheet .ghost { min-height: 44px; padding: 4px 8px; font-size: 12px; line-height: 1.2; }
/* Look speed in the top row (touch.js): the slider takes the room between Paused and the way back. */
.bk-sheet-look { flex: 1; display: grid; grid-template-columns: auto 1fr 2.5em; align-items: center; gap: 10px; min-width: 0; font: 600 12px 'JetBrains Mono', monospace; color: #eaf4ff; }
.bk-sheet-look input { width: 100%; height: 44px; margin: 0; accent-color: #4DB6F7; touch-action: pan-x; }
.bk-sheet-look b { text-align: right; color: #4DB6F7; }
/* The Waypoint group (touch.js): where you are and the copy button, then the box with Set and Clear. */
.bk-sheet-way { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.bk-sheet-here { margin: 0; font: 600 12px 'JetBrains Mono', monospace; color: #eaf4ff; }
.bk-sheet-wayform { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
.bk-sheet-waymsg { grid-column: 1 / -1; margin: 0; color: #ffb3c8; }
.bk-sheet-waymsg:empty { display: none; }

/* ---- reading the page below the game ---- */
.bk-back { display: none; }
html.bk-page .bk-back { display: block; position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 60; min-height: 48px; }
html.bk-page .keys-bar { display: none; }

/* ---- turn sideways ---- */
.bk-rotate { display: none; }
html.bk-portrait .bk-rotate { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center;
  background: rgba(5,8,15,.72); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #eaf4ff; font: 400 20px/1.4 'Special Elite', 'Courier New', monospace; }
html.bk-portrait .bk-rotate p { margin: 0; max-width: 16em; }
/* Rotation lock found on (touch.js): said under the prompt in the warning color. */
html.bk-portrait .bk-rotate .bk-rotate-lock { max-width: 22em; font: 600 14px/1.4 'JetBrains Mono', monospace; color: #ffcf5a; }
html.bk-portrait .bk-rotate .bk-rotate-lock[hidden] { display: none; }
/* The way to full screen on an iPhone (touch.js HOME_STEPS), under the prompt. */
html.bk-portrait .bk-rotate .bk-rotate-go { min-height: 44px; padding: 0 22px; font: 600 14px 'JetBrains Mono', monospace; }
html.bk-portrait .bk-rotate .bk-rotate-home { max-width: 22em; font: 400 13px/1.5 'JetBrains Mono', monospace; color: #a9c4e0; }
html.bk-portrait .bk-rotate svg { color: #4DB6F7; }
html.bk-portrait .bk-rotate-phone { transform-origin: 60px 72px; animation: bk-turn 2.4s ease-in-out infinite; }
@keyframes bk-turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }
html.bk-portrait .stage > canvas:first-child { filter: blur(10px) brightness(.5) saturate(.6); }
html.bk-portrait .hud, html.bk-portrait .hud-corner, html.bk-portrait .hint, html.bk-portrait .cross { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { html.bk-portrait .bk-rotate-phone { animation: none; } }

/* Phones skip the film grain: a full-screen blended layer that animates costs fill rate a phone lacks. */
@media (pointer: coarse) { .grain { display: none; } }

/* ---- how to add the game to a phone or tablet Home Screen, asked until dismissed ---- */
.bk-home-tip { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 110;
  width: min(420px, calc(100% - 32px)); display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px;
  background: rgba(8,12,22,.94); color: #e8f3ff; font: 13px/1.4 'JetBrains Mono', monospace; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.bk-home-tip p { margin: 0; flex: 1; }
.bk-home-tip .act { min-height: 44px; flex: none; }
/* On the start screen it stands above the card in the same column (touch.js homeTip), not over the logo. */
.start .bk-home-tip { position: static; transform: none; width: min(440px, 100%); margin-bottom: 12px; }
@media (max-height: 500px) and (min-width: 560px) { .start .bk-home-tip { width: min(760px, 100%); } }

/* The objective and the quest tracker sit under the top row of buttons, clear of the stick below. */
html.bk-touch-ui .track { top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: max(10px, env(safe-area-inset-left)); max-width: min(300px, 38vw); }
/* Between the side button columns where there is room; on a narrow phone at least wide enough for a short line, at a smaller size. */
html.bk-touch-ui .objective:not(.fresh) { top: calc(max(8px, env(safe-area-inset-top)) + 52px); max-width: max(240px, calc(100% - 2 * min(300px, 38vw) - 40px)); }
@media (max-width: 700px) { html.bk-touch-ui .objective:not(.fresh) { font-size: 11px; padding: 4px 8px; } }
html.bk-touch-ui .quest-log .ql-close { min-height: 44px; }
/* The room chips (radio, bin) sit beside the minimap at its top (static/minimap.js sets --mm-top on the stage),
   never higher than the foot of a two-line objective. */
html.bk-touch-ui .bk-chips { bottom: auto; top: max(var(--mm-top, calc(max(8px, env(safe-area-inset-top)) + 150px)), calc(max(8px, env(safe-area-inset-top)) + 104px));
  left: calc(max(10px, env(safe-area-inset-left)) + min(190px, 26vw) + 8px); }
html.bk-touch-ui .bk-chip { min-height: 44px; padding: 6px 12px; }
/* The first-run guide (static/guide.css) in the minimap's place under the tracker's first line, and above the
   move stick at 844x390. The minimap steps aside and the room chips move past it while it shows; nothing
   else on a phone leaves room for it. */
html.bk-touch-ui .bk-guide { top: calc(max(8px, env(safe-area-inset-top)) + 76px); left: max(10px, env(safe-area-inset-left));
  width: min(190px, 26vw); padding: 6px 8px; gap: 3px; font-size: 11px; line-height: 1.3; }
html.bk-touch-ui:has(.bk-guide:not([hidden])) .minimap { visibility: hidden; }
html.bk-touch-ui:has(.bk-guide:not([hidden])) .bk-chips { left: calc(max(10px, env(safe-area-inset-left)) + min(190px, 26vw) + 8px); }
html.bk-touch-ui .bk-guide .guide-acts button { min-height: 44px; min-width: 64px; }
html.bk-touch-ui .bk-guide .guide-skip { padding: 0 6px; }
html.bk-touch-ui .bk-guide .guide-acts { gap: 4px 6px; flex-wrap: nowrap; }

/* Panels from social.js and photo mode: thumb-sized, inside the safe area. */
html.bk-touch-ui .bk-modal-back { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
html.bk-touch-ui .bk-panel { touch-action: pan-y; }
html.bk-touch-ui .bk-panel a { display: inline-flex; align-items: center; min-height: 44px; }
html.bk-touch-ui .bk-photobar { bottom: max(8px, env(safe-area-inset-bottom)); }
html.bk-touch-ui .bk-photobar button { min-height: 44px; padding: 6px 12px; }
/* The keypad pad in a list (game.js dialPad): a row of digit keys across the whole list. */
html.bk-touch-ui #choicesList .dial-pad { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }

/* The credits on a short screen: everything on one page without the logo, in smaller type. */
@media (max-height: 500px) {
  .credits { padding-block: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-bottom)); }
  .cr-card { width: min(720px, 100%); }
  .cr-logo { display: none; }
  .credits h2 { font-size: 22px; }
  .cr-list { margin-top: 8px; gap: 6px; }
  .cr-list dd { margin-top: 0; font-size: 16px; }
  .cr-list p { margin-top: 2px; font-size: 11px; line-height: 1.4; }
  .cr-copy { margin-top: 8px; font-size: 11px; }
  .credits .ghost { margin-top: 0; }
}
/* Settings (ui.js): rows and the graphics menu big enough for a thumb. */
html.bk-touch-ui .bk-settings .bk-check { min-height: 44px; }
html.bk-touch-ui .bk-settings .bk-select, html.bk-touch-ui .bk-settings .bk-btn { min-height: 44px; }
html.bk-touch-ui .bk-settings input[type="range"] { height: 44px; }
/* Key names mean nothing on a touch screen; the words beside them still say what a tap does, and a quest
   names the button instead (static/quests.js). Controls is the keyboard's own list. */
html.bk-touch-ui kbd:not(.controls-grid kbd), html.bk-touch-ui .inv-hand .key { display: none; }
/* The debug HUD's buttons at thumb size, and the console at the top, clear of the phone keyboard. */
html.bk-touch-ui .dbg-btn { min-height: 44px; padding: 0 12px; }
html.bk-touch-ui .dbg-con { top: max(8px, env(safe-area-inset-top)); bottom: auto; height: min(300px, 55%); width: min(760px, calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
html.bk-touch-ui .dbg-input { font-size: 16px; min-height: 36px; }
html.bk-touch-ui .dbg-logpanel { right: max(8px, env(safe-area-inset-right)); }
html.bk-touch-ui .dbg-check { min-height: 44px; }
/* The minimap: the thumb buttons hold the right, so it sits on the left between the quests and the
   move stick, at the height static/minimap.js measures there. */
html.bk-touch-ui .minimap, html.bk-touch-ui .minimap.wide { top: var(--mm-top); bottom: auto; right: auto; left: max(10px, env(safe-area-inset-left)); width: min(190px, 26vw); }
html.bk-touch-ui .minimap iframe, html.bk-touch-ui .minimap.wide iframe { height: var(--mm-h); }
html.bk-touch-ui .minimap.shut { width: auto; }
html.bk-touch-ui .minimap-head { height: 32px; }

/* ---- a phone on its side: the view first ----
   Under 500 px tall the corner keeps the clock, the counts and the meters; the name, the code and the
   copyright are in the menu sheet. The tracker shows the first quest (the rest are under Quests), and
   the minimap and the objective take less of the view. */
@media (max-height: 500px) {
  html.bk-touch-ui .hud-corner :is(.copyright, .code-tag, .linkish), html.bk-touch-ui .version { display: none; }
  html.bk-touch-ui .hud-corner { gap: 2px 8px; padding: 4px 7px; max-width: min(260px, 30vw); }
  html.bk-touch-ui .tracker { padding: 2px 6px; font-size: 10px; }
  html.bk-touch-ui .tracker li:nth-child(n+2) { display: none; }
  html.bk-touch-ui .minimap, html.bk-touch-ui .minimap.wide { width: min(160px, 21vw); }
  html.bk-touch-ui .bk-chips { left: calc(max(10px, env(safe-area-inset-left)) + min(160px, 21vw) + 8px); }
  html.bk-touch-ui .minimap-head { height: 28px; }
  html.bk-touch-ui .objective:not(.fresh) { font-size: 11px; padding: 4px 8px; max-width: min(320px, 36vw); }
  html.bk-touch-ui .rname { font-size: 13px; }
  html.bk-touch-ui .toast { top: calc(max(6px, env(safe-area-inset-top)) + 84px); font-size: 12px; }
}
.bk-sheet-copy { margin: 0; font-size: 10px; color: #7f93ad; text-align: center; }
/* The gun's rounds sit left of the dot on a phone, clear of the thumb buttons on the right. */
html.bk-touch-ui .ammo { left: auto; right: calc(50% + 18px); font-size: 11px; }
/* A new objective glides in from the middle; on a phone at a smaller size. */
html.bk-touch-ui .objective.fresh { padding: 7px 14px; font-size: 14px; max-width: min(420px, 60vw); }
