/* Touch / mobile HUD (js/mobile.js). Everything here is scoped to html.touch, which is set for coarse pointers
   (phones, tablets) or with ?mobile=1, so the desktop layout is untouched. Two layouts:
   html.touch.landscape: party tiles left, stick bottom-left, chat + camera bottom-centre, ball cluster + move column right
   html.touch.portrait:  quest card + party column top-left, minimap + quick row top-right; the left thumb steers, the right
                         thumb has every action in one cluster round the ball (see the end of this file) */

#m-ui { display: none; }

html.touch {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --ball: 76px;          /* Poké Ball button */
  --hbs: 46px;           /* hotbar / satellite button */
  --ring: 128px;         /* radius of the outer button ring around the ball (target button; layout spacing) */
  --mv-w: 116px;         /* landscape move column */
  --bx: calc(var(--sar) + 8px + var(--mv-w) + 22px + var(--ball) / 2);   /* ball centre, from the right edge */
  --by: calc(var(--sab) + 12px + var(--ball) / 2);                       /* ball centre, from the bottom edge */
  height: 100dvh;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html.touch body {
  height: 100dvh; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html.touch input, html.touch textarea, html.touch select { -webkit-user-select: text; user-select: text; font-size: 16px; } /* 16px: no iOS focus zoom */
html.touch #game, html.touch #game canvas { touch-action: none; }
html.touch button { touch-action: manipulation; }
html.touch .m-fast, html.touch #movebar .move, html.touch #ball-btn, html.touch #hotbar .hb, html.touch #m-stick-zone { touch-action: none; }
html.touch .pressed { filter: brightness(1.2); transform: scale(.92); transition: transform 60ms; }
html.touch button:active:not(:disabled) { filter: brightness(1.12); }

/* things a touch screen does not need */
html.touch #help-card, html.touch .move .key, html.touch .hb .key, html.touch #ball-btn .key { display: none !important; }
html.touch .tb:hover, html.touch .mi:hover, html.touch .move:hover, html.touch .pm:hover { border-color: var(--border-hi); }

/* ---------------------------------------------------------------- shared touch controls */
html.touch.m-ready #m-ui { display: block; }
html.touch body.battle-active #m-ui { display: none; }
#m-ui { pointer-events: none; }
#m-ui > * { position: fixed; z-index: 3; pointer-events: auto; }
.m-round, .m-act, #m-party-tg {
  display: grid; place-items: center; padding: 0; color: #fff; font: 900 20px Nunito, system-ui, sans-serif; cursor: pointer;
  border: 1px solid rgba(190, 210, 255, .35); background: radial-gradient(circle at 50% 30%, rgba(52, 84, 160, .95), rgba(14, 24, 54, .95));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.m-round .ic, .m-act .ic { width: 58%; height: 58%; }
.m-round { width: 48px; height: 48px; border-radius: 50%; }

/* joystick */
#m-stick-zone { left: 0; bottom: 0; width: 200px; height: 200px; touch-action: none; }
#m-stick {
  position: absolute; left: calc(var(--sal) + 20px); bottom: calc(var(--sab) + 16px); width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 32, 64, .25) 0 40%, rgba(16, 32, 64, .55) 70%);
  border: 2px solid rgba(111, 166, 255, .55); box-shadow: 0 0 0 2px rgba(10, 22, 48, .5), inset 0 0 18px rgba(0, 0, 0, .35);
  transition: border-color .15s;
}
#m-stick::before { /* direction ticks */
  content: ''; position: absolute; inset: 10px; border-radius: 50%;
  background: conic-gradient(from -4deg, rgba(255,255,255,.35) 0 8deg, transparent 8deg 90deg, rgba(255,255,255,.35) 90deg 98deg, transparent 98deg 180deg,
    rgba(255,255,255,.35) 180deg 188deg, transparent 188deg 270deg, rgba(255,255,255,.35) 270deg 278deg, transparent 278deg);
  -webkit-mask: radial-gradient(circle, transparent 0 82%, #000 83%); mask: radial-gradient(circle, transparent 0 82%, #000 83%);
}
#m-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #8fb9ff, #2c63c9 60%, #183c86); border: 2px solid #cfe0ff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45); transition: transform .08s ease-out;
}
#m-stick.on { border-color: #cfe0ff; }
#m-stick.on #m-knob { transition: none; }
#m-stick.run #m-knob { background: radial-gradient(circle at 40% 35%, #ffe9a8, #f3a51e 60%, #a8650a); border-color: #fff3c4; }

/* chat bubble + camera rotate */
#m-center { display: flex; gap: 10px; align-items: center; }
#m-chatbtn { position: relative; font-size: 20px; }
#m-chat-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ff3b3b;
  font: 900 11px/16px Nunito, sans-serif; font-style: normal; border: 2px solid #0a1630;
}
#m-chat-badge[hidden] { display: none; }
/* plain player chat while the chat is closed: a small quiet dot, no number (the red count is for @mentions and notices) */
#m-chat-badge.lo, .chat-unread.lo { min-width: 0; width: 11px; height: 11px; padding: 0; top: 0; right: 0; background: #8fb4ff; border-width: 2px; }
#m-scrim { inset: 0; z-index: 6; display: none; }
#m-scrim.on { display: block; background: rgba(4, 8, 22, .45); }

/* satellites around the ball: angle --a (0 = right, 90deg = up), radius --r, size --s (landscape; portrait places
   them on a grid, see the portrait section) */
#m-a, #m-jump, #m-target, #m-swap, #m-item, #m-mount, #m-fish {
  position: fixed; width: var(--s); height: var(--s); padding: 0;
  right: calc(var(--bx) - cos(var(--a)) * var(--r) - var(--s) / 2);
  bottom: calc(var(--by) + sin(var(--a)) * var(--r) - var(--s) / 2);
}
.m-act { border-radius: 50%; }
#m-a { --a: 135deg; --r: calc(var(--ball) / 2 + 38px); --s: 62px; flex-direction: column; gap: 0; line-height: 1;
  background: radial-gradient(circle at 50% 30%, #7fe89a, #1f8a44 72%); border-color: rgba(200, 255, 216, .7); }
#m-a b { font-size: 24px; }
#m-a small { font-size: 9px; font-weight: 900; letter-spacing: .3px; max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#m-a small:empty { display: none; }
#m-a.ready { box-shadow: 0 0 0 2px #0a1630, 0 0 14px 3px rgba(125, 255, 159, .65); }
#m-jump { --a: 90deg; --r: calc(var(--ball) / 2 + 30px); --s: 44px; font-size: 20px; }
#m-target { --a: 74deg; --r: var(--ring); --s: 46px; font-size: 22px; }
#m-swap { --a: 205deg; --r: calc(var(--ball) / 2 + 24px); --s: 38px; font-size: 16px; }
#m-item { --a: 180deg; --r: var(--ring); --s: 50px; }
#m-mount { --a: 104deg; --r: calc(var(--ring) + 4px); --s: 54px; }
#m-fish { --a: 158deg; --r: calc(var(--ring) + 34px); --s: 44px; animation: m-fish-in .2s ease-out; }
/* the utility buttons: the plain 3D object on a soft dark disc (no coloured plates); ≥48px hit areas */
#m-target, #m-swap, #m-item, #m-mount, #m-fish {
  background: rgba(10, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#m-target .ic, #m-swap .ic, #m-fish .ic { width: 60%; height: 60%; }
#m-swap::after, #m-jump::after, #m-target::after, #m-item::after, #m-mount::after, #m-fish::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
html.touch .m-hold { touch-action: none; -webkit-touch-callout: none; }
/* hold for more: a short arc on the rim (top right), on the two buttons that open a picker */
#m-item::before, #m-mount::before {
  content: ''; position: absolute; inset: 3px; border-radius: 50%; pointer-events: none;
  border: 2px solid transparent; border-top-color: rgba(255, 255, 255, .55); transform: rotate(30deg);
}
#m-item[aria-expanded="true"], #m-mount[aria-expanded="true"] { border-color: var(--gold, #f2b84b); }
/* quick item: icon and how many are left */
#m-item .mi-art { display: grid; place-items: center; width: 66%; height: 66%; pointer-events: none; }
#m-item .mi-art .item-art, #m-item .mi-art img, #m-item .mi-art svg { width: 100%; height: 100%; object-fit: contain; }
#m-item .mi-n { position: absolute; right: -5px; bottom: -3px; min-width: 20px; height: 18px; padding: 0 4px; border-radius: 9px; background: #0d1838;
  border: 1px solid rgba(255, 255, 255, .3); color: #fff; font: 900 10.5px Nunito, sans-serif; font-style: normal; display: grid; place-items: center; pointer-events: none; }
#m-item .mi-n:empty { display: none; }
#m-item.empty .mi-art { filter: saturate(.2) brightness(.8); }
/* Mount: the portrait of the mount you ride (gold rim) or the one a tap will call */
#m-mount .mm-art { display: grid; place-items: center; width: 100%; height: 100%; pointer-events: none; }
#m-mount .mm-art img { width: 86%; height: 86%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45)); }
#m-mount .mm-art .ic { width: 56%; height: 56%; }
#m-mount.riding { border-color: var(--gold, #f2b84b); box-shadow: 0 0 0 2px rgba(242, 184, 75, .35), 0 2px 8px rgba(0, 0, 0, .3); }
/* Fish: the 3D rod you cast; a turning ring while the line is out, gold with a "!" when a Pokémon bites (tap to hook) */
#m-fish .mf-art { display: grid; place-items: center; width: 88%; height: 88%; pointer-events: none; }
#m-fish .mf-art .item-art, #m-fish .mf-art img, #m-fish .mf-art svg { width: 100%; height: 100%; object-fit: contain; }
#m-fish .mf-art img { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); transform: scale(1.18); }   /* a long thin object: fill the disc */
#m-fish .mf-ring { position: absolute; inset: -3px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: conic-gradient(from 0deg, rgba(126, 210, 255, 0) 0 55%, rgba(126, 210, 255, .95) 100%);
  -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 3px), #000 calc(50% - 2.5px)); mask: radial-gradient(circle, transparent 0 calc(50% - 3px), #000 calc(50% - 2.5px)); }
#m-fish.fishing .mf-ring { opacity: 1; animation: m-fish-spin 1.4s linear infinite; }
#m-fish .mf-bang { position: absolute; top: -8px; right: -6px; width: 22px; height: 22px; border-radius: 50%; display: none; place-items: center;
  background: #ffcf3f; color: #3a2400; border: 2px solid #fff; font: 900 15px/1 Nunito, sans-serif; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); pointer-events: none; }
#m-fish.hook { border-color: #ffd75e; box-shadow: 0 0 0 3px rgba(255, 207, 63, .55), 0 0 18px 4px rgba(255, 207, 63, .55); animation: m-fish-hook .32s ease-in-out infinite alternate; }
#m-fish.hook .mf-bang { display: grid; }
#m-fish.hook .mf-ring { background: conic-gradient(#ffd75e, #ffd75e); animation: none; }
@keyframes m-fish-spin { to { transform: rotate(360deg); } }
@keyframes m-fish-hook { to { transform: scale(1.12); } }
html.reduce-motion #m-fish .mf-ring, html.reduce-motion #m-fish.hook { animation: none; }
@media (prefers-reduced-motion: reduce) { #m-fish .mf-ring, #m-fish.hook { animation: none; } }
#m-mount[hidden], #m-fish[hidden], html:not(.touch) #m-fish, html:not(.touch) #m-item, html:not(.touch) #m-mount, html:not(.touch) .m-pick { display: none; }
@keyframes m-fish-in { from { transform: scale(.6); opacity: 0; } }

/* the pickers (hold Mount / the quick item): a small card just above the button that was held */
.m-pick { position: fixed; z-index: 30; width: min(300px, calc(100vw - 16px)); max-height: 52vh; overflow: auto; padding: 10px;
  border-radius: 18px; background: rgba(13, 21, 44, .96); border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: m-pick-in .16s ease-out; overscroll-behavior: contain; }
.m-pick[hidden] { display: none; }
@keyframes m-pick-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.m-pick .mp-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px; }
.m-pick .mp-head b { font-size: 12px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; color: var(--muted, #9fb0d9); }
.m-pick .mp-head small { color: var(--muted, #9fb0d9); font-weight: 700; font-size: 11.5px; }
.m-pick .mp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.m-pick .mp-it { position: relative; display: grid; justify-items: center; align-content: start; gap: 2px; min-height: 78px; padding: 6px 4px; border-radius: 14px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); color: #fff; font: 800 11px Nunito, sans-serif; text-align: center; }
.m-pick .mp-it.on { border-color: var(--gold, #f2b84b); background: rgba(242, 184, 75, .1); }
.m-pick .mp-pic { display: grid; place-items: center; width: 44px; height: 44px; }
.m-pick .mp-pic img, .m-pick .mp-pic .item-art { width: 100%; height: 100%; object-fit: contain; }
.m-pick .mp-pic .ic { width: 70%; height: 70%; }
.m-pick .mp-it span:not(.mp-pic) { line-height: 1.15; overflow-wrap: anywhere; }
.m-pick .mp-it i { position: absolute; top: 4px; right: 6px; font-style: normal; font-size: 10px; font-weight: 800; color: #ffe7a3; }
.m-pick .mp-empty { margin: 2px 2px 6px; color: var(--muted, #9fb0d9); font-weight: 700; font-size: 13px; }
.m-pick .mp-link { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; margin-top: 8px; border-radius: 12px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); color: #fff; font: 800 13px Nunito, sans-serif; }
.m-pick .mp-link .ic { width: 22px; height: 22px; }

/* ball */
html.touch #ball-btn {
  position: fixed; margin: 0; width: var(--ball); height: var(--ball);
  right: calc(var(--bx) - var(--ball) / 2); bottom: calc(var(--by) - var(--ball) / 2);
}
html.touch #ball-btn .ball { width: 70%; height: 70%; }
html.touch #ball-count { top: -6px; right: -6px; font-size: 12px; padding: 1px 6px; border-radius: 10px; background: var(--danger); border: 2px solid var(--ink); }
html.touch #ball-btn.m-catch { animation: ballpulse .7s ease-in-out infinite; }

html.touch #movebar { display: contents; }

/* the hotbar: Mount and the quick item stand in for it on touch screens (js/mobile.js) */
html.touch #hotbar { display: none !important; }

/* camera rotate buttons are optional (Settings → Controls); dragging the game always turns the camera */
html.touch:not(.cam-btns) #m-rotl, html.touch:not(.cam-btns) #m-rotr { display: none; }

/* joystick modes. float: a faint ghost at rest, the real stick appears under the thumb; off: tap to move only */
html.touch.stick-float #m-stick-zone, html.touch.stick-off #m-stick-zone { pointer-events: none; }
html.touch.stick-float #m-stick { transition: opacity .2s, border-color .15s; }
html.touch.stick-float #m-stick:not(.on) { opacity: .28; }
html.touch.stick-float #m-stick:not(.on) #m-knob { transform: scale(.8); }
html.touch.stick-off #m-stick { display: none; }

/* moves + target button only while a wild Pokémon is close (js/mobile.js .foes-near) */
html.touch .moves, html.touch #m-target { transition: opacity .2s, transform .25s var(--ease), visibility 0s; }
html.touch:not(.foes-near) .moves, html.touch:not(.foes-near) #m-target { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, transform .25s var(--ease), visibility 0s .25s; }
html.touch.landscape:not(.foes-near) .moves { transform: translateX(24px); }
html.touch.portrait:not(.foes-near) .moves { transform: translateY(16px); }

/* moves: name, PP and type icon; no panel behind them */
html.touch .moves { position: fixed; display: flex; flex-direction: row; padding: 0; background: none; border: 0; box-shadow: none; gap: 6px; }
html.touch .move { width: auto; height: 48px; padding: 0 8px 0 10px; gap: 6px; border-radius: 14px; box-shadow: 0 3px 10px rgba(0,0,0,.4); }
html.touch .mv-name { font-size: 13px; line-height: 1.1; min-width: 0; }
html.touch .mv-name small { font-size: 11px; }
html.touch .mv-type { width: 24px; height: 24px; flex: none; }

/* top: quest chip; tidy button row; compact minimap */
html.touch #quests { display: flex; transform: none; gap: 6px; right: auto; max-height: none; overflow: visible; }
html.touch .sq-head { padding: 6px 8px 6px 6px; gap: 8px; min-height: 44px; }
html.touch .sq-ic { width: 30px; height: 30px; }
html.touch .sq-title { font-size: 14px; }
html.touch .sq.collapsed .sq-act { display: none; }
html.touch .sq.collapsed .sq-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.touch .sq-body { padding: 0 10px 10px; }
/* while moving with the stick or fighting, the chip collapses and fades back */
html.touch.moving .sq-body, html.touch.in-fight .sq-body { display: none; }
html.touch.moving .sq-act, html.touch.in-fight .sq-act { display: none; }
html.touch.moving .sq-title, html.touch.in-fight .sq-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.touch #quests, html.touch #party, html.touch #m-center, html.touch #top-right, html.touch #m-party-tg { transition: opacity .25s; }
html.touch.moving #quests, html.touch.in-fight #quests { opacity: .55; }
html.touch.moving #m-center, html.touch.moving #top-right { opacity: .6; }
html.touch.moving #party { opacity: .75; }
/* tutorial: one line with the current step on phones */
html.touch .tut { padding: 6px 10px 7px; font-size: 12.5px; }
html.touch .tut .tut-step:not(.now), html.touch .tut .tut-reward, html.touch .tut .tut-badge { display: none; }
html.touch .tut-bar { margin: 4px 0 3px; }
html.touch.moving .tut .tut-step small, html.touch.in-fight .tut .tut-step small { display: none; }

html.touch #top-right { top: calc(var(--sat) + 6px); right: calc(var(--sar) + 8px); gap: 6px; }
html.touch .top-buttons { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: none; }
html.touch .tb, html.touch .mtb { width: 48px; height: 48px; border-radius: 14px; padding: 0; gap: 0; }
html.touch .tb-label { display: none; }
html.touch .tb-ic, html.touch .tb-ic .ic-tile, html.touch .mtb .ic-tile { width: 36px; height: 36px; }
.mtb { display: none; }
html.touch .mtb { position: relative; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
html.touch .mtb .tb-label { display: none; }
html.touch #m-menu[aria-expanded="true"] { border-color: var(--gold); }
html.touch #minimap { width: 120px; }
html.touch .mm-title { font-size: 10.5px; padding: 3px 4px; }
html.touch #minimap-view { height: 70px; }
html.touch .mm-footer { font-size: 11px; padding: 2px 6px; gap: 4px; }
html.touch #weather { display: none; }

/* ☰ menu: a bottom sheet of labelled icons, grouped */
html.touch #menu { position: fixed; inset: auto 0 0 0; z-index: 7; pointer-events: none; }
html.touch .mn-primary { display: none; }
html.touch .mn-more {
  display: block; position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: min(78dvh, 640px); overflow: auto; overscroll-behavior: contain;
  padding: 6px calc(var(--sar) + 14px) calc(var(--sab) + 14px) calc(var(--sal) + 14px); border-radius: 22px 22px 0 0; border-width: 1px 0 0;
  transform: translateY(105%); transition: transform 240ms var(--ease); animation: none; pointer-events: auto; visibility: hidden;
}
html.touch.menu-open .mn-more { transform: none; visibility: visible; }
html.touch .mn-more .sheet-grip { display: block; }
html.touch #menu .mn-more { display: block; }
/* grouped: a small heading per group, big icons with their names (no tile behind them), five to a row — every group is
   exactly one band of five (js/main.js MENU), so the rows are even. Sideways: two bands share a row (ten across). */
html.touch .mn-sec, html.touch .mn-sec-primary { display: block; }
html.touch .mn-sec h4 { display: block; margin: 2px 4px 2px; font-size: 10.5px; letter-spacing: .9px; }
html.touch .mn-sec + .mn-sec { margin-top: 4px; padding-top: 6px; }
html.touch .mn-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px 4px; }
html.touch .mn-grid .mi { min-width: 0; min-height: 80px; padding: 5px 1px 6px; gap: 3px; background: none; border-radius: 16px; transition: transform 120ms var(--ease), background 120ms; }
html.touch .mn-grid .mi:active { background: var(--surface-2); transform: scale(.9); }
html.touch .mn-grid .mi .ic-tile { width: 54px; height: 54px; }
html.touch .mn-grid .mi .dot { top: 2px; left: calc(50% + 14px); }
html.touch .mn-grid .mi-label { font-size: 11.5px; letter-spacing: -.2px; max-width: 100%; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
html.touch .mn-wallet { padding: 0 0 8px; margin-bottom: 4px; }
html.touch .mn-wallet .wl-pill { min-height: 44px; }
html.touch .mn-head-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 22px; }
html.touch .mn-head-btn span { display: none; }
html.touch .mn-head-btn .ic { width: 22px; height: 22px; }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .3); margin: 6px auto 10px; touch-action: none; }
html.touch.menu-open .mn-grid .mi { animation: mi-in 260ms var(--ease) both; animation-delay: calc(var(--i, 0) * 12ms); }
html.touch #m-menu.has-new .ic-bare { animation: new-glow 1.8s ease-in-out infinite; }
html.touch.reduce-motion #m-menu .ic-bare { animation: none; }
/* sideways phones: two bands per row, a little smaller, so all four fit the short screen */
html.touch.landscape #menu .mn-more.mn-bands { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; align-content: start; }
html.touch.landscape .mn-bands > .sheet-grip, html.touch.landscape .mn-bands > .mn-wallet { grid-column: 1 / -1; }
html.touch.landscape .mn-bands > .mn-sec { min-width: 0; margin-top: 0; }
html.touch.landscape .mn-bands > .mn-sec:nth-of-type(n+3) { margin-top: 4px; }
html.touch.landscape .mn-bands > .mn-sec + .mn-sec { border-top: 0; padding-top: 0; }
html.touch.landscape .mn-bands > .mn-sec:nth-of-type(n+3) { border-top: 1px solid var(--line); padding-top: 4px; }
html.touch.landscape .mn-more .sheet-grip { margin: 4px auto 6px; }
html.touch.landscape .mn-wallet { padding-bottom: 6px; }
html.touch.landscape .mn-grid .mi { min-height: 68px; padding: 3px 1px 4px; }
html.touch.landscape .mn-grid .mi .ic-tile { width: 46px; height: 46px; }
html.touch.landscape .mn-more { left: 50%; right: auto; width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 12px); transform: translate(-50%, 105%); }
html.touch.landscape.menu-open .mn-more { transform: translate(-50%, 0); }

/* chat (js/hud.js #chat[data-state]): the round chat button in #m-center is the bubble (unread badge while hidden);
   compact = a quiet ticker of the last lines in free space (tap it to open, x to hide); expanded = a sheet with
   channel pills, the log and the input row */
html.touch .chat-bubble { display: none !important; }
html.touch #chat { position: fixed; z-index: 3; transition: opacity .25s; }
html.touch #chat[data-state="compact"] .chat-card { background: rgba(8, 14, 34, .5); border: 0; border-radius: 12px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
html.touch #chat[data-state="compact"] #chat-size { display: none; }
html.touch #chat[data-state="compact"] .chat-head { opacity: 1; padding: 0; }
html.touch #chat[data-state="compact"] .chat-ibtn { width: 34px; height: 34px; color: rgba(255, 255, 255, .7); }
html.touch #chat[data-state="compact"] #chat-log {
  display: flex; flex-direction: column; justify-content: flex-end; max-height: calc(3 * 1.35em + 12px); min-height: 0;
  padding: 6px 9px; font-size: 12.5px; touch-action: manipulation;
}
html.touch #chat[data-state="compact"] .msg:first-child { padding-right: 28px; }
html.touch.moving #chat[data-state="compact"], html.touch.in-fight #chat[data-state="compact"] { opacity: .45; }
html.touch #chat[data-state="expanded"] {
  z-index: 7; left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 24px - var(--sal) - var(--sar)));
  bottom: calc(var(--sab) + 70px);
}
html.touch #chat[data-state="expanded"] .chat-card { background: rgba(13, 21, 44, .96); }
html.touch #chat[data-state="expanded"] .chat-head { padding: 6px 6px 6px 8px; }
html.touch #chat[data-state="expanded"] .chat-ibtn { width: 40px; height: 40px; background: var(--surface); }
/* one icon on the open sheet so all four channel pills fit: shrink to the ticker (x on the ticker hides it;
   the chat button / a tap outside closes back to whichever of the two it came from) */
html.touch #chat[data-state="expanded"] #chat-hide { display: none; }
html.touch #chat[data-state="expanded"] .chat-ibtn .ic { width: 20px; height: 20px; }
html.touch #chat[data-state="expanded"] #chat-log { height: min(32dvh, 220px); font-size: 14px; touch-action: pan-y; -webkit-user-select: text; user-select: text; }
html.touch .ct { min-height: 40px; padding: 4px 11px; font-size: 13.5px; }
html.touch #chat-input { min-height: 44px; }
html.touch #chat-form button { width: 44px; height: 44px; }
html.touch #chat-form button .ic { width: 22px; height: 22px; }
/* empty hotbar slots are noise on a phone (register items from the Bag) */
html.touch #hotbar .hb.empty { display: none; }
html.touch .hb .key { display: none; }

/* party tiles (landscape): portrait, level, HP */
html.touch .pm { grid-template-columns: 34px 1fr; gap: 5px; padding: 3px 6px 3px 3px; border-radius: 12px; }
html.touch .pm-icon { width: 34px; height: 34px; border-radius: 8px; }
html.touch .pm-top { font-size: 10px; }
html.touch .pm-top b { display: none; }
html.touch .pm-top span { font-size: 11px; }
html.touch .pm.egg .pm-top b { display: inline; font-size: 11px; }
html.touch .pm .exp, html.touch .pm .xp, html.touch .hp span { display: none; }
html.touch .hp { height: 7px; margin-top: 4px; border-radius: 4px; }
#m-party-tg { display: none; }

/* prompt, toast, tutorial */
html.touch #prompt { bottom: auto; top: calc(var(--sat) + 50px); font-size: 14px; white-space: normal; text-align: center; max-width: min(460px, calc(100vw - 32px)); }
/* landscape: under the quest widget (js/mobile.js --q-bot), which now sits where the prompt used to */
html.touch.landscape #prompt { top: calc(max(var(--q-bot, 0px), var(--sat) + 44px) + 6px); }

/* ---------------------------------------------------------------- landscape */
html.touch.landscape #m-stick-zone { width: 190px; height: 190px; }
html.touch.landscape #m-center {
  bottom: calc(var(--sab) + 12px);
  /* centred in the gap between the stick (~156px) and the hotbar ring */
  left: calc(var(--sal) + 156px + (100vw - var(--sal) - var(--sar) - 156px - 164px - (var(--bx) + var(--ring) + var(--hbs) / 2 + 6px - var(--sar))) / 2);
}
html.touch.landscape #party {
  top: calc(var(--sat) + 8px); left: calc(var(--sal) + 8px); width: auto;
  display: grid; grid-template-columns: repeat(2, 92px); gap: 5px;
}
html.touch.landscape #quests {
  top: calc(var(--sat) + 6px); left: calc(var(--sal) + 205px);
  width: min(320px, calc(100vw - var(--sal) - var(--sar) - 205px - 290px));
}
/* chat ticker: the free band between the stick and the hotbar ring, above the chat / camera buttons */
html.touch.landscape #chat:not([data-state="expanded"]) {
  left: calc(var(--sal) + 160px); right: calc(var(--bx) + var(--ring) + var(--hbs) / 2 + 10px); width: auto; max-width: 380px;
  bottom: calc(var(--sab) + 70px);
}
html.touch.landscape .moves { right: calc(var(--sar) + 8px); flex-direction: column; width: var(--mv-w); }
html.touch.landscape #moves-left { bottom: calc(var(--sab) + 10px + 2 * 46px + 12px); }
html.touch.landscape #moves-right { bottom: calc(var(--sab) + 10px); }
html.touch.landscape .move { width: var(--mv-w); }


/* ---------------------------------------------------------------- portrait */
html.touch.portrait {
  --ring: min(118px, 31vw);
  --hbs: min(44px, 11.4vw);
  --bx: calc(var(--sar) + 16px + var(--ball) / 2);
  --by: calc(var(--sab) + 20px + var(--ball) / 2);
}
html.touch.portrait #m-center .m-round { width: 46px; height: 46px; }

html.touch.portrait #top-right { flex-direction: column; align-items: flex-end; }
html.touch.portrait #minimap { width: 152px; order: -1; }
html.touch.portrait #minimap-view { height: 84px; }
html.touch.portrait #quests { top: calc(var(--sat) + 6px); left: calc(var(--sal) + 8px); width: calc(100vw - var(--sal) - var(--sar) - 176px); }

/* party: round portraits down the left edge, collapsible to the lead */
html.touch.portrait #m-party-tg {
  display: grid; left: calc(var(--sal) + 6px); top: calc(var(--sat) + 62px); width: 50px; height: 30px; border-radius: 15px;
}
html.touch.portrait #m-party-tg .ic { width: 22px; height: 22px; transform: rotate(-90deg); transition: transform .2s; }
html.touch.portrait.party-min #m-party-tg .ic { transform: rotate(90deg); }
html.touch.portrait #party { top: calc(var(--sat) + 100px); left: calc(var(--sal) + 6px); width: 50px; display: flex; flex-direction: column; gap: 8px; }
html.touch.portrait.party-min #party .pm:not(.lead) { display: none; }
html.touch.portrait .pm { width: 48px; height: 48px; padding: 0; display: block; border-radius: 50%; }
html.touch.portrait .pm-icon { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; }
/* the square portrait inset into the circle, so heads, tails and wings aren't clipped by it */
html.touch.portrait .pm-icon img { width: 80%; height: 80%; object-fit: contain; transform: translateY(-2px); filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
html.touch.portrait .pm-info { position: absolute; left: 4px; right: 4px; bottom: -4px; }
/* the level tag sits on the rim (top right), not over the Pokémon's face */
html.touch.portrait .pm-top { position: absolute; right: -16px; bottom: 42px; }
html.touch.portrait .pm-top span { font-size: 9px; background: #12264d; border: 1px solid var(--border-hi); border-radius: 6px; padding: 0 3px; color: var(--gold); }
html.touch.portrait .pm.egg .pm-top b { display: none; }
html.touch.portrait .hp { height: 6px; margin: 0; }
html.touch.portrait #party .bt-chip { top: auto; bottom: 30px; left: -6px; right: auto; }


/* tablets get a bit more room */
@media (min-width: 700px) and (min-height: 700px) {
  html.touch { --ball: 88px; --hbs: 52px; --ring: 150px; --mv-w: 150px; }
  html.touch .move { height: 54px; }
  html.touch.landscape #moves-left { bottom: calc(var(--sab) + 10px + 2 * 54px + 12px); }
  html.touch #minimap { width: 180px; }
  html.touch #minimap-view { height: 120px; }
  html.touch.landscape #party { grid-template-columns: repeat(2, 120px); }
  html.touch.landscape #quests { left: calc(var(--sal) + 265px); }
}

/* ---------------------------------------------------------------- panels: bottom sheets on touch screens */
html.touch #panel-root { place-items: end center; }
html.touch .modal {
  width: min(760px, 100vw); max-height: calc(100dvh - var(--sat) - 24px); border-radius: 24px 24px 0 0; border-width: 1px 1px 0;
  padding: 0 var(--sar) 0 var(--sal);
}
html.touch #panel-root.enter .modal { animation: sheet-in 240ms var(--ease); }
@keyframes sheet-in { from { transform: translateY(40%); opacity: 0; } }
html.touch .sheet-grip { display: block; margin: 8px auto 2px; cursor: grab; }
html.touch .modal-head { padding: 4px 10px 10px 14px; touch-action: none; }
html.touch .mh-title { font-size: 19px; }
html.touch .modal-x { width: 44px; height: 44px; }
html.touch .modal-body { flex: 1; padding: 12px 12px calc(var(--sab) + 16px); overscroll-behavior: contain; touch-action: pan-x pan-y; -webkit-user-select: text; user-select: text; }
html.touch .modal-body button { -webkit-user-select: none; user-select: none; }
html.touch .btn, html.touch .tab, html.touch .chip, html.touch .seg-b { min-height: 44px; }
html.touch .btn.sm { min-height: 40px; }
html.touch .btn.icon-only { width: 44px; }
html.touch .btn.sm.icon-only { width: 40px; }
/* tab strips: tap to switch (no swipe gestures); they fill the width when they fit, and scroll + snap when they don't */
html.touch .tabs.swipe:not(.set-nav) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; scroll-padding: 0 12px; }
html.touch .tabs.swipe::-webkit-scrollbar { display: none; }
html.touch .tabs.swipe .tab { flex: 1 0 auto; scroll-snap-align: start; justify-content: center; min-height: 40px; }
html.touch .bt-sheet { max-height: calc(100dvh - 24px); touch-action: pan-y; }
/* phones: sheets take the full height so lists have room */
@media (max-width: 760px), (max-height: 560px) {
  html.touch .modal { width: 100vw; height: calc(100dvh - var(--sat) - 8px); max-height: none; }
  html.touch .worldmap { height: calc(100dvh - var(--sat) - var(--sab) - 90px); }
}
html.touch.landscape .modal { width: min(900px, 100vw); }
@media (max-height: 560px) { html.touch .sheet-grip { margin: 5px auto 0; } html.touch .modal-head { padding-bottom: 6px; } }

/* turn-based battles: every layout (portrait / landscape / desktop) lives in battle.css */
html.touch .bt-btn, html.touch .bt-move, html.touch .bt-item, html.touch .bt-pcard, html.touch .bt-mv, html.touch .bt-pm, html.touch .bt-bag, html.touch .bt-run { touch-action: manipulation; }
/* the battle HUD owns the corners during a turn-based battle */
html.touch body.battle-active #top-right, html.touch body.battle-active #quests, html.touch body.battle-active #m-ui { display: none !important; }
/* short landscape screens: keep toasts above the player, under the prompt line */
html.touch.landscape #toast { top: calc(var(--sat) + 88px); max-width: min(420px, 60vw); text-align: center; }
/* landscape move column: the coloured edge carries the type, so the name gets the full width */
html.touch.landscape .mv-type { display: none; }
html.touch.landscape .move { padding: 0 8px 0 10px; }
html.touch.landscape.cb-types .mv-type { display: grid; width: 22px; height: 22px; }
/* the expanded story card and the tutorial never stack down over the player: one at a time */
html.touch .sq:not(.collapsed) ~ .tut { display: none; }
/* portrait: the tutorial is a two-line chip under the story chip; the party strip makes room for it */
html.touch.portrait .tut .tut-bar, html.touch.portrait .tut .tut-step small { display: none; }
html.touch.portrait .tut-head b { font-size: 12.5px; }
/* (the party column follows the card's real bottom edge: --q-bot, see the end of this file) */
html.touch.portrait.has-tut .sq:not(.collapsed) ~ .tut { display: none; }
/* keyboard letters mean nothing on a touch screen: battle menus too */
html.touch #battle-ui .k, html.touch .bt-btn .k, html.touch .bt-move .k { display: none; }

/* ---------------------------------------------------------------- short landscape screens (small phones sideways,
   browser bars showing): everything a size down so the game stays visible; under 340px tall, smaller still */
@media (orientation: landscape) and (max-height: 430px) {
  html.touch.landscape { --ball: 64px; --ring: 104px; --mv-w: 104px; }
  html.touch.landscape #m-a { --s: 52px; --r: calc(var(--ball) / 2 + 32px); }
  html.touch.landscape #m-a b { font-size: 20px; }
  html.touch.landscape #m-jump { --s: 38px; --r: calc(var(--ball) / 2 + 25px); }
  html.touch.landscape #m-swap { --s: 32px; --r: calc(var(--ball) / 2 + 20px); }
  html.touch.landscape #m-target { --s: 40px; }
  html.touch.landscape #m-stick { width: 104px; height: 104px; left: calc(var(--sal) + 14px); bottom: calc(var(--sab) + 10px); }
  html.touch.landscape #m-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  html.touch.landscape #m-center { left: calc(var(--sal) + 128px); bottom: calc(var(--sab) + 10px); gap: 8px; }
  html.touch.landscape .m-round { width: 42px; height: 42px; }
  html.touch.landscape .tb, html.touch.landscape .mtb { width: 40px; height: 40px; border-radius: 12px; }
  html.touch.landscape .tb-ic, html.touch.landscape .tb-ic .ic-tile, html.touch.landscape .mtb .ic-tile { width: 30px; height: 30px; }
  html.touch.landscape #minimap { width: 108px; }
  html.touch.landscape #minimap-view { height: 58px; }
  html.touch.landscape #party { grid-template-columns: repeat(2, 84px); gap: 4px; }
  html.touch.landscape .pm { grid-template-columns: 28px 1fr; padding: 2px 5px 2px 2px; }
  html.touch.landscape .pm-icon { width: 28px; height: 28px; }
  html.touch.landscape #quests { left: calc(var(--sal) + 186px); width: max(48px, min(300px, calc(100vw - var(--sal) - var(--sar) - 186px - 250px))); }
  html.touch.landscape .move { height: 40px; }
  html.touch.landscape #moves-left { bottom: calc(var(--sab) + 8px + 2 * 40px + 10px); }
  html.touch.landscape #moves-right { bottom: calc(var(--sab) + 8px); }
  html.touch.landscape .mv-name { font-size: 12px; }
  html.touch.landscape #chat[data-state="compact"] .msg:nth-last-child(n+3) { display: none; }   /* last two lines only */
  html.touch.landscape #chat:not([data-state="expanded"]) { left: calc(var(--sal) + 124px); bottom: calc(var(--sab) + 60px); max-width: 260px; }
}
/* the quest chip shrinks to its flag icon when there is no room for the title (tap it to read the quest) */
@media (orientation: landscape) and (max-width: 700px) {
  html.touch.landscape .sq.collapsed .sq-head > :not(.sq-ic) { display: none; }
  html.touch.landscape #quests:has(.sq.collapsed) { width: auto; }
  html.touch.landscape .sq.collapsed .sq-head { min-height: 40px; padding: 5px; }
  html.touch.landscape .sq:not(.collapsed) { width: min(320px, calc(100vw - var(--sal) - var(--sar) - 200px)); }
}
@media (orientation: landscape) and (max-height: 340px) {
  html.touch.landscape { --ball: 56px; --ring: 92px; }
  html.touch.landscape #m-a { --s: 46px; --r: calc(var(--ball) / 2 + 28px); }
  html.touch.landscape #m-jump { --s: 34px; }
  html.touch.landscape #m-swap { --s: 30px; }
  html.touch.landscape #m-stick { width: 92px; height: 92px; }
  html.touch.landscape #m-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  html.touch.landscape #m-center { left: calc(var(--sal) + 112px); }
  html.touch.landscape .m-round { width: 38px; height: 38px; }
  html.touch.landscape .tb, html.touch.landscape .mtb { width: 36px; height: 36px; }
  html.touch.landscape .tb-ic, html.touch.landscape .tb-ic .ic-tile, html.touch.landscape .mtb .ic-tile { width: 26px; height: 26px; }
  html.touch.landscape #minimap { width: 96px; }
  html.touch.landscape #minimap-view { height: 46px; }
  html.touch.landscape .cos-lure { font-size: 11px; padding: 1px 7px; }
}

/* ---------------------------------------------------------------- portrait polish: a lighter top, a quieter chat */
html.touch.portrait #minimap { width: 136px; }
html.touch.portrait #minimap-view { height: 70px; }
html.touch.portrait .mm-title { font-size: 10px; padding: 2px 4px; }
html.touch.portrait .mm-footer { font-size: 10.5px; padding: 1px 6px; }
html.touch.portrait .tb, html.touch.portrait .mtb { width: 42px; height: 42px; border-radius: 13px; }
html.touch.portrait .tb-ic, html.touch.portrait .tb-ic .ic-tile, html.touch.portrait .mtb .ic-tile { width: 32px; height: 32px; }
html.touch.portrait #quests { width: calc(100vw - var(--sal) - var(--sar) - 160px); }
html.touch.portrait #m-party-tg { width: 44px; height: 26px; border-radius: 13px; }
html.touch.portrait #m-party-tg .ic { width: 18px; height: 18px; }
html.touch.portrait #chat[data-state="compact"] #chat-log { font-size: 12px; padding: 5px 8px; }
html.touch.portrait #chat[data-state="compact"] .msg:nth-last-child(n+3) { display: none; }
html.touch #chat[data-state="compact"] .msg { padding-right: 30px; }   /* clear of the hide button */

/* ---------------------------------------------------------------- phone UX pass (390×844 portrait, 844×390 landscape) */
/* toasts and the action prompt are centred with left:50%, which capped their shrink-to-fit width at half the screen
   (three-line pills); size them to their text, then clamp to the screen */
#toast, html.touch #prompt { width: max-content; }
html.touch #prompt { max-width: min(460px, calc(100vw - 32px)); }
/* search fields: a long placeholder ends in … instead of being cut mid-word */
.search input, .mk-search, input[type=search] { text-overflow: ellipsis; }
/* party toggle: 26px tall pill, 44px hit area; nothing to toggle before the first Pokémon */
html.touch.portrait #m-party-tg::after { content: ''; position: absolute; inset: -9px -4px; }
html.touch.portrait:has(#party:empty) #m-party-tg { display: none; }
/* "A new update is ready": bigger tap targets, and it moves to the bottom while a sheet is open (it hid the title) */
html.touch #update-pill .btn { min-height: 36px; }
html.touch #update-pill .up-x { width: 36px; height: 36px; }
html.touch.portrait #update-pill { top: calc(max(var(--tr-bottom, 160px), var(--q-bot, 60px)) + 8px); }   /* under the quest card and the minimap row, not on them */
body.battle-active #update-pill { display: none; }   /* waits until the battle is over (it covered the battle sheets) */
body:has(.dlg.open) #update-pill { display: none; }   /* ...and until the conversation ends (it sat on the speech bubble) */
html.touch body:has(#panel-root.open) #update-pill { top: auto; bottom: calc(var(--sab) + 12px); }
/* links styled as buttons (Settings → Help → Guides) */
a.btn { text-decoration: none; }

@media (max-width: 760px) {
  /* Trainer Card: a full-width sheet like every other panel (its own width rule out-ranked the phone one) */
  html.touch .modal.tcx-panel { width: 100vw; }
  /* Pokédex: the search gets the room ("Name or numb…"), the type filter the rest */
  .dex-tools .search { flex: 1.4 1 0; }
  .dex-tools select { flex: 1 1 0; min-width: 0; }
}

@media (max-width: 480px) {
  /* Settings: a segmented control or slider no longer squeezes its label into a 4-line column; it wraps under it */
  .seg-row .row-text { flex: 1 1 150px; }
  .seg-row .seg { margin-left: auto; }
  .range-row { flex-wrap: wrap; row-gap: 2px; }
  .range-row .row-text { flex: 1 1 100%; }
  .range-row input[type=range] { max-width: none; }
  /* Help & Support topic cards: content top-aligned so the emoji / title / hint line up across a row */
  .sup-cat { align-content: start; }
  /* Mounts: the "Drag to rotate" hint sat on the platform ring; top of the stage like the Wardrobe */
  .mt-stage .stage-hint { top: 8px; bottom: auto; }
}

/* touch targets in battle sheets and small lists */
html.touch .bt-btn { min-height: 48px; }
html.touch .bt-back { min-height: 40px; font-size: 13px; }
html.touch .bt-x, html.touch .bt-tabs button { min-height: 40px; min-width: 40px; }
html.touch .bt-item { min-height: 48px; }
html.touch .pouch-item { min-height: 44px; }
html.touch .sup-back { min-height: 44px; padding: 6px 10px 6px 0; }
html.touch .ml-chip { min-height: 40px; }
html.touch .wm-zbtn { width: 44px; height: 44px; }
html.touch .wm-x { width: 44px; height: 44px; }
html.touch .wm-chip.wm-dd-btn { min-height: 40px; }
/* YES / NO and choice lists: a full-size thumb target (dialogue.css keeps the look) */
html.touch .dlg-yesno button, html.touch .dlg-choices button { min-height: 42px; }
/* Mail compose: the pencil read as a dot on the icon-only button */
.sp-compose .ic { width: 22px; height: 22px; }

/* ☰ menu, Pokémon and Bag under the minimap: one size, icon only (no tile plate behind them) */
html.touch .mtb { background: none; border: 0; box-shadow: none; }
html.touch .mtb .ic-tile { filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45)); }
html.touch .mtb:active .ic-tile { transform: scale(.92); }
html.touch #m-menu[aria-expanded="true"] .ic-tile { box-shadow: 0 0 0 2px var(--gold); border-radius: 12px; }

/* ---------------------------------------------------------------- calm HUD: fewer colours, fewer boxes, one quest card */
/* the side buttons (☰, Pokémon, Bag): the 3D object on a soft dark disc, no coloured tile */
html.touch .mtb { width: 44px; height: 44px; border-radius: 50%; background: rgba(10, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
html.touch .mtb .ic-tile.ic-bare { width: 34px; height: 34px; }
html.touch #m-menu[aria-expanded="true"] .ic-tile { box-shadow: none; }
html.touch #m-menu[aria-expanded="true"] { border-color: var(--gold); }
/* one quest card at a time: the beginner side quest stands in for the story card while it runs */
html.touch.has-tut .sq { display: none; }
/* party bubbles: smaller, no level tags (the Pokémon screen has the numbers); HP as a thin line under each */
html.touch.portrait #party { width: 44px; gap: 6px; }
html.touch.portrait .pm { width: 42px; height: 42px; background: rgba(10, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .14); }
html.touch.portrait .pm.lead { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242, 184, 75, .35); }
html.touch.portrait .pm-top { display: none; }
html.touch.portrait .hp { height: 4px; }

/* ---------------------------------------------------------------- portrait: quick row under the minimap
   No bottom dock on phones: Pokémon · Bag · Mall · More sit in one small row right under the minimap, as wide as it,
   plain 3D icons (no plate behind them). More opens the ☰ sheet, which holds everything else (Pokédex, Map, Mail …)
   and carries the badge total of what is inside it. The bottom edge is free, so the thumbs' controls sit on --sab. */
html.touch #m-mallbtn { display: none; }
html.touch.portrait #top-right { gap: 4px; }
html.touch.portrait .top-buttons {
  flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 0;
  width: 136px; padding: 0 2px; box-sizing: border-box;
}
html.touch.portrait .mtb, html.touch.portrait #m-mallbtn {
  display: grid; width: 32px; height: 32px; border-radius: 10px; background: none; border: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
html.touch.portrait .mtb::before { content: ''; position: absolute; inset: -6px -1px; }   /* ≥44px tall hit area, no gap in the row */
html.touch.portrait .mtb .ic-tile, html.touch.portrait .mtb .ic-tile.ic-bare { width: 30px; height: 30px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .55)); }
html.touch.portrait #m-teambtn { order: 1; }
html.touch.portrait #m-bagbtn { order: 2; }
html.touch.portrait #m-mallbtn { order: 3; }
html.touch.portrait #m-menu { order: 4; }
html.touch.portrait #cos-hud { order: 5; flex-basis: 100%; display: flex; justify-content: flex-end; }
html.touch.portrait #m-menu[aria-expanded="true"] { border: 0; }
html.touch.portrait #m-menu[aria-expanded="true"] .ic-tile { filter: drop-shadow(0 0 4px rgba(242, 184, 75, .9)); }
html.touch.portrait .mtb[data-badge]:not([data-badge=""])::after { top: -4px; right: -6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 3px; }

/* ---------------------------------------------------------------- portrait: two thumbs
   Left thumb = movement only: a big, empty stick zone (nothing else on that side to hit by mistake).
   Right thumb = every action, one cluster round the Poké Ball in the bottom-right corner, nearest = most used:
                              [chat]       the chat bubble (and camera buttons, if on) over the item
     top row      [fish] [target] [item]      target / fish only when they apply; the item sits over the ball column
     moves        [ 1 ] [ 2 ]                  a 2 × 2 block, only near wild Pokémon, right above the ball row:
                  [ 3 ] [ 4 ]                  the thumb rocks between moves and the ball while the left thumb steers
     bottom row   [mount] [A] [BALL]           ball in the corner; A beside it; Mount at the inner end, a sideways
                          (swap)               sweep away (used while walking, out of the path ball → moves)
   No button overlaps another or the stick zone; every hit area is ≥ 48px. */
html.touch.portrait {
  --ball: min(76px, 20vw);
  --as: 58px;            /* A */
  --ms: 52px;            /* Mount */
  --us: 50px;            /* quick item (top row) */
  --mvh: 48px;           /* move button height */
  --bx: calc(var(--sar) + 12px + var(--ball) / 2);
  --by: calc(var(--sab) + 28px + var(--ball) / 2);
  --cw: calc(var(--ball) + 8px + var(--as) + 8px + var(--ms));      /* width of the bottom row */
  --band: calc(var(--by) + var(--ball) / 2 + 10px);                /* bottom of the lower move row */
  --top: calc(var(--band) + 2 * var(--mvh) + 6px + 8px);           /* bottom of the top row */
  --ctop: calc(var(--top) + var(--us));                            /* top of the action buttons */
  --chat: calc(var(--ctop) + 10px + 46px);                         /* top of the chat bubble above them */
}
html.touch.portrait #m-a { --s: var(--as); right: calc(var(--sar) + 12px + var(--ball) + 8px); bottom: calc(var(--by) - var(--as) / 2); }
html.touch.portrait #m-mount { --s: var(--ms); right: calc(var(--sar) + 12px + var(--ball) + 8px + var(--as) + 8px); bottom: calc(var(--by) - var(--ms) / 2); }
/* swap-ball: a small disc tucked under the gap between A and the ball */
html.touch.portrait #m-swap { --s: 36px; right: calc(var(--bx) + var(--ball) / 2 - 17px); bottom: calc(var(--sab) + 6px); }
html.touch.portrait #m-swap::after { inset: -6px -6px 0; }
html.touch.portrait #m-item { --s: var(--us); right: calc(var(--sar) + 12px + (var(--ball) - var(--us)) / 2); bottom: var(--top); }
html.touch.portrait #m-target { --s: 46px; right: calc(var(--sar) + 12px + (var(--ball) + var(--us)) / 2 + 12px); bottom: calc(var(--top) + 2px); }
html.touch.portrait #m-fish { --s: 46px; right: calc(var(--sar) + 12px + (var(--ball) + var(--us)) / 2 + 12px + 46px + 12px); bottom: calc(var(--top) + 2px); }
/* moves: 1 2 over 3 4, as wide as the bottom row */
html.touch.portrait .moves { left: auto; right: calc(var(--sar) + 8px); width: calc(var(--cw) + 4px); gap: 6px; }
html.touch.portrait #moves-left { bottom: calc(var(--band) + var(--mvh) + 6px); }
html.touch.portrait #moves-right { bottom: var(--band); }
html.touch.portrait .move { flex: 1 1 0; min-width: 0; height: var(--mvh); padding: 2px 6px 2px 9px; border-radius: 13px; }
html.touch.portrait .mv-name { font-size: 12px; letter-spacing: -.2px; line-height: 1.1; overflow: hidden; overflow-wrap: normal; hyphens: auto; -webkit-hyphens: auto; }
html.touch.portrait .mv-name small { font-size: 10px; }
/* the type as a small dot beside the PP (bottom right): the name gets the full width */
html.touch.portrait .mv-type { position: absolute; right: 6px; bottom: 6px; width: 14px; height: 14px; }
html.touch.portrait .mv-type i { display: none; }
/* left thumb: a big stick zone on the bottom-left, clear of everything else (the floating stick appears where the
   thumb lands); the chat bubble lives in the right cluster, over the item button */
html.touch.portrait #m-stick-zone { bottom: calc(var(--sab) + 6px); width: min(190px, calc(100vw - var(--sar) - 8px - var(--cw) - 4px - 10px)); height: 220px; }   /* ends 10px before the moves / Mount */
html.touch.portrait #m-stick { width: 112px; height: 112px; left: calc(var(--sal) + 16px); bottom: 16px; }
html.touch.portrait #m-center { left: auto; right: calc(var(--sar) + 12px + (var(--ball) - 46px) / 2); bottom: calc(var(--ctop) + 10px); gap: 8px; flex-direction: row-reverse; }
html.touch.portrait #m-center .m-round { width: 46px; height: 46px; }
/* chat: the open sheet hangs from the top (stays clear of the soft keyboard) */
html.touch.portrait #chat[data-state="expanded"] {
  /* a bottom sheet like a messaging app: full width, the input on the bottom edge, riding on top of the soft keyboard
     (--kb: js/mobile.js measures how much of the screen the keyboard covers) */
  top: auto; left: 0; right: 0; transform: none; width: 100%; bottom: var(--kb, 0px);
}
html.touch.portrait #chat[data-state="expanded"] .chat-card { border-radius: 18px 18px 0 0; padding-bottom: calc(var(--sab) * (1 - var(--kbon, 0)) + 6px); box-shadow: 0 -12px 30px rgba(0, 0, 0, .45); }
html.touch.portrait #chat[data-state="expanded"] #chat-log { height: min(38dvh, 300px); }
html.touch.portrait.kb-open #chat[data-state="expanded"] #chat-log { height: min(26dvh, 200px); }
html.touch.portrait #chat:not([data-state="expanded"]) { transition: opacity .25s; }
/* the chat ticker and the action prompt sit above the cluster, so they never move with the moves */
html.touch.portrait #chat:not([data-state="expanded"]) { left: calc(var(--sal) + 8px); width: min(320px, calc(100vw - 16px - var(--sal) - var(--sar))); bottom: calc(var(--chat) + 10px); }
html.touch.portrait #prompt { top: auto; bottom: calc(var(--chat) + 10px); }
html.touch.portrait:has(#chat[data-state="compact"]) #prompt { bottom: calc(var(--chat) + 10px + 64px); }
@media (min-width: 700px) and (min-height: 700px) {
  html.touch.portrait { --ball: 88px; --as: 64px; --ms: 58px; --us: 54px; --mvh: 54px; }
  html.touch.portrait .mv-name { font-size: 13.5px; }
}

/* landscape: Mount up-left of the ball, the quick item left of it (polar positions above); short screens a size down */
@media (orientation: landscape) and (max-height: 430px) {
  html.touch.landscape #m-mount { --s: 46px; }
  html.touch.landscape #m-stick-zone { width: 122px; }   /* clear of the chat bubble beside the stick */
  html.touch.landscape #m-item { --s: 44px; }
}

/* ---------------------------------------------------------------- portrait: quest card + party column, smaller type
   The quest card opens and shuts with a height animation (its details capped at a third of the screen, scrolling
   inside); the party column (toggle + bubbles) hangs a fixed gap under the card's real bottom edge (--q-bot, published
   by js/mobile.js), so the two never overlap whichever state the card is in. */
html.touch .sq .sq-body {
  display: block; max-height: 34dvh; overflow: hidden auto; overscroll-behavior: contain; opacity: 1;
  transition: max-height .24s var(--ease, ease), opacity .18s, padding .24s var(--ease, ease);
}
html.touch .sq.collapsed .sq-body, html.touch.moving .sq-body, html.touch.in-fight .sq-body {
  display: block; max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; pointer-events: none;
}
/* js/questhelper.js redraws the card when it opens, so the opening is a keyframe; the party column glides after it */
html.touch:not(.moving):not(.in-fight) .sq:not(.collapsed) .sq-body { animation: sq-open .24s var(--ease, ease); }
@keyframes sq-open { from { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; } }
@media (prefers-reduced-motion: reduce) { html.touch .sq .sq-body { animation: none !important; transition: none; } }
html.touch .sq-head { min-height: 38px; padding: 5px 8px 5px 6px; gap: 7px; }
html.touch .sq-ic { width: 26px; height: 26px; padding: 5px; border-radius: 8px; }
html.touch .sq-title { font-size: 12.5px; line-height: 1.2; }
html.touch .sq-act { font-size: 11px; letter-spacing: .3px; }
html.touch .sq-count { font-size: 11px; }
html.touch .sq-chev { width: 18px; height: 18px; }
html.touch .sq-desc { font-size: 12px; line-height: 1.35; }
html.touch .sq-reward, html.touch .sq-side, html.touch .sq-where { font-size: 11px; }
html.touch .sq-foot { flex-wrap: wrap; gap: 6px; margin-top: 6px; }
html.touch .sq-where { flex: 1 1 100%; align-items: flex-start; line-height: 1.3; }
html.touch .sq-where svg { width: 13px; height: 13px; margin-top: 1px; }
html.touch .sq-log { font-size: 11px; min-height: 32px; padding: 4px 10px; }
html.touch.portrait .sq-body { padding: 0 9px 9px 39px; }   /* under the title, not under the flag */
html.touch .tut { padding: 5px 9px 6px; font-size: 11.5px; }
html.touch.portrait .tut-head b { font-size: 12px; }

html.touch.portrait #m-party-tg { top: calc(var(--q-bot, 50px) + 8px); transition: opacity .25s, top .22s var(--ease, ease); }
html.touch.portrait #party { top: calc(var(--q-bot, 50px) + 8px + 26px + 10px); transition: opacity .25s, top .22s var(--ease, ease); }
html.touch.portrait:has(#party:empty) #party { top: calc(var(--q-bot, 50px) + 8px); }
html.touch.portrait.q-grow #m-party-tg, html.touch.portrait.q-grow #party { transition: opacity .25s; }

/* smaller type across the phone HUD (nothing under 11px) */
html.touch.portrait .mm-title { font-size: 11px; padding: 2px 4px; line-height: 1.2; }
html.touch.portrait .mm-footer { font-size: 11px; }
html.touch.portrait #chat[data-state="compact"] #chat-log { font-size: 11.5px; }
html.touch.portrait #prompt { font-size: 12.5px; padding: 7px 14px; }
html.touch.portrait #toast { font-size: 12.5px; padding: 8px 16px; }
html.touch.portrait .mv-name small { font-size: 10.5px; }

/* ---------------------------------------------------------------- profile chip + compact quest widget (js/profilehud.js)
   Top-left: the trainer chip, the quest lines under it; the party column follows #quests' bottom edge (--q-bot).
   The Battle Basics card is one of the widget's lines on phones (the Quest log has its steps). */
html.touch #quests .tut { display: none; }
html.touch .phud { gap: 5px; }
html.touch .pf-chip { height: 40px; padding: 3px 9px 3px 3px; gap: 7px; border-radius: 20px; }
html.touch .pf-ava { width: 32px; height: 32px; }
html.touch .pf-name { font-size: 12.5px; }
html.touch .pf-sub { font-size: 11px; gap: 7px; }
html.touch .pf-bdg { display: none; }   /* phones: picture, name and level only */
html.touch .qw { padding: 2px; border-radius: 12px; }
html.touch .qw-row { min-height: 30px; padding: 4px 8px; gap: 7px; font-size: 12px; border-radius: 10px; }   /* comfortable to tap */
html.touch .qw-row + .qw-row { margin-top: 1px; }
html.touch .qw-ic { width: 14px; height: 14px; }
html.touch .qw-n { font-size: 11px; }
/* in a fight: just the current objective */
html.touch.in-fight .qw-row:not(:first-child) { display: none; }
html.touch .pf-panel .modal-head { gap: 8px; }
html.touch .pf-switch .seg-b { min-height: 34px; padding: 4px 12px; font-size: 13px; }
/* Quest log: the four tabs share the width (no sideways scroll on a phone) */
html.touch .tabs.swipe.ql-tabs .tab { flex: 1 1 0; min-width: 0; padding: 6px 6px; gap: 4px; font-size: 12.5px; }
html.touch .ql-tabs .tab .ic { width: 15px; height: 15px; }
html.touch .ql-tabs .tab em { padding: 0 5px; }
/* short landscape: the story objective and the daily line only (the next-step preview waits for the Quest log) */
@media (orientation: landscape) and (max-height: 430px) {
  html.touch.landscape .qw-row.next { display: none; }
}
html.touch .pf-row { gap: 5px; }
html.touch .pf-cur { height: 19px; }
/* phones: money over diamonds, small. Long names and big amounts are capped (name 66px, pills 76px) so the chip and
   the wallet end before the minimap even at 360px wide */
html.touch .pf-wallet { flex-direction: column; gap: 3px; min-width: 0; max-width: 76px; }
html.touch .pf-name { max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
html.touch .pf-cur { height: 18px; gap: 3px; padding: 0 2px; font-size: 10.5px; }
html.touch .pf-cur.money { padding-right: 6px; }
html.touch .pf-cur b { padding: 0 1px; max-width: 50px; }
html.touch .pf-row { gap: 5px; }
html.touch .pf-cur .wl-cur, html.touch .pf-cur .dia { width: 12px; height: 12px; }
html.touch .pf-plus { width: 13px; height: 13px; font-size: 11px; }

/* ---------------------------------------------------------------- portrait: quick buttons down the right edge
   The mirror of the party on the left: the same 42 px bubbles in the party's glass, 6 px apart, a 3D object filling
   90 % of each (no labels), and the same 44 x 26 pill above them that folds the column to just the
   Menu (html.tools-min, js/mobile.js). */
#m-tools-tg { display: none; }
html.touch.portrait .top-buttons {
  flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: center; gap: 6px;
  width: 44px; padding: 0; margin-top: 4px;
}
html.touch.portrait #m-tools-tg {
  display: grid; place-items: center; order: 0; width: 44px; height: 26px; padding: 0; border-radius: 13px; position: relative; cursor: pointer; color: #fff;
  border: 1px solid rgba(190, 210, 255, .35); background: radial-gradient(circle at 50% 30%, rgba(52, 84, 160, .95), rgba(14, 24, 54, .95));
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
}
html.touch.portrait #m-tools-tg::after { content: ''; position: absolute; inset: -9px -4px; }
html.touch.portrait #m-tools-tg .ic { width: 18px; height: 18px; transform: rotate(-90deg); transition: transform .2s; }
html.touch.portrait.tools-min #m-tools-tg .ic { transform: rotate(90deg); }
html.touch.portrait .top-buttons .mtb, html.touch.portrait .top-buttons #m-mallbtn {
  width: 42px; height: 42px; border-radius: 50%; place-items: center; padding: 0;
  background: rgba(10, 18, 40, .55); border: 1px solid rgba(255, 255, 255, .14); box-shadow: none;
}
html.touch.portrait .top-buttons .mtb::before { inset: -2px; }
/* the 3D object fills 90 % of the bubble and sits in its centre (the render is 41/48 of the icon box, drawn from its top
   edge: 44 px box = a 38 px object, moved down 3 px to centre it), with the party portraits' soft shadow */
html.touch.portrait .top-buttons .mtb .ic-tile, html.touch.portrait .top-buttons .mtb .ic-tile.ic-bare {
  width: 44px; height: 44px; margin: -1px; transform: translate(-1px, 2px); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .45));
}
html.touch.portrait .top-buttons .mtb:active { transform: scale(.93); }
/* the Menu's four tiles make a square: drawn a little smaller so its corners stay inside the round bubble */
html.touch.portrait .top-buttons #m-menu .ic-tile { width: 37px; height: 37px; margin: 0; transform: translate(0, 3px); }
html.touch.portrait #m-menu[aria-expanded="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242, 184, 75, .35); }
html.touch.portrait #m-menu { order: 1; }
html.touch.portrait #m-teambtn { order: 2; }
html.touch.portrait #m-bagbtn { order: 3; }
html.touch.portrait #m-mallbtn { order: 4; }
html.touch.portrait #cos-hud { order: 6; flex-basis: auto; }
html.touch.portrait.tools-min .top-buttons .mtb-quick, html.touch.portrait.tools-min .top-buttons #m-mallbtn { display: none; }
html.touch.portrait .top-buttons .mtb[data-badge]:not([data-badge=""])::after { top: -3px; right: -4px; }

/* ---------------------------------------------------------------- tablets (iPad size, docs/ux-tablet-review) */
@media (min-width: 700px) and (min-height: 700px) {
  /* full 44px touch targets where phones keep slimmer ones: the Profile tabs in panel headers, the calendar filters,
     the ranked tabs and formats, the Mall's "See all", the money / diamond pills in panel headers, the battle speed pill */
  html.touch .pf-switch .seg-b, html.touch .cal-f, html.touch .rk-tabs button, html.touch .rk-fmt button, html.touch .ml-see { min-height: 44px; }
  html.touch .modal-head .wl-pill { min-height: 40px; }
  html.touch .bt-speed { height: 40px; padding: 0 14px; }
  /* portrait: the quest card stays a card (it spanned 80% of the top of the screen, over the world) */
  html.touch.portrait #quests { width: min(440px, calc(100vw - var(--sal) - var(--sar) - 160px)); }
  /* portrait sheets: lists get the height (a 720px sheet left a third of the screen dimmed and unused) */
  html.touch.portrait .modal.size-lg, html.touch.portrait .modal.tall { height: min(900px, calc(100dvh - var(--sat) - 96px)); }
}
html.touch .bt-speed::after { content: ''; position: absolute; inset: -7px -4px; }

/* ---------------------------------------------------------------- the gold Mall bubble (owner, 24 Nov 2026)
   Always in view: first in the quick row (portrait), in the column (landscape), and it stays when the row is folded
   away. Bigger than the other bubbles, gold, a light sweeping across it now and then, a gentle breath, and a "Mall"
   ribbon under it. */
html.touch.portrait #m-mallbtn { order: 1; }
html.touch.portrait #m-menu { order: 2; }
html.touch.portrait #m-teambtn { order: 3; }
html.touch.portrait #m-bagbtn { order: 4; }
html.touch.portrait .top-buttons #m-mallbtn, html.touch.landscape #m-mallbtn {
  position: relative; width: 52px; height: 52px; border-radius: 50%; border: 2px solid #fff2a8; overflow: visible;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .85) 50%, transparent 62%) no-repeat -120% 0 / 60% 100%,
    radial-gradient(circle at 50% 35%, #fff1a0, #ffc22e 62%, #f29b12);
  box-shadow: 0 3px 0 #b86f0c, 0 0 16px 4px rgba(255, 196, 46, .75);
  animation: m-mall-shine 3.6s ease-in-out infinite, m-mall-breathe 3.6s ease-in-out infinite; }
@keyframes m-mall-shine { 0%, 55% { background-position: -120% 0, 0 0; } 85%, 100% { background-position: 240% 0, 0 0; } }
@keyframes m-mall-breathe { 0%, 100% { transform: none; } 50% { transform: scale(1.06); } }
html.touch.portrait .top-buttons #m-mallbtn .ic-tile, html.touch.landscape #m-mallbtn .ic-tile { width: 44px; height: 44px; margin: 0; transform: translate(0, -1px); }
html.touch #m-mallbtn .tb-label, html.touch.portrait #m-menu .tb-label { display: block; position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); padding: 1px 8px 2px; border-radius: 999px;
  background: rgba(10, 18, 40, .72); color: #fff; font: 700 10.5px/1.25 Nunito, system-ui, sans-serif; letter-spacing: .5px; white-space: nowrap;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); pointer-events: none; }
html.touch.portrait.tools-min .top-buttons #m-mallbtn { display: grid; }
/* portrait: beside the fold arrow, under the minimap's left half (owner, 24 Nov 2026), bigger, out of the column */
html.touch.portrait .top-buttons { position: relative; }
/* no fold arrow (owner, 24 Nov 2026): the Menu leads the column and the Mall sits beside it */
html.touch #m-tools-tg { display: none !important; }
html.touch.portrait .top-buttons #m-menu { margin-bottom: 12px; }   /* room for its "Hub" label */
/* only Mall and Hub up here (owner, 24 Nov 2026): Pokémon and Bag are in the Hub sheet's first row (and the party
   portraits open your team) */
html.touch.portrait #m-teambtn { display: none !important; }
/* one row under the minimap: Mall · Bag · Hub (owner, 24 Nov 2026) */
html.touch.portrait .top-buttons #m-mallbtn { right: calc(100% + 51px) !important; }
html.touch.portrait .top-buttons #m-bagbtn { position: absolute; top: 0; right: calc(100% + 5px); margin: 0; }
html.touch.portrait #m-bagbtn .tb-label { display: block; position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); padding: 1px 8px 2px; border-radius: 999px;
  background: rgba(10, 18, 40, .72); color: #fff; font: 700 10.5px/1.25 Nunito, system-ui, sans-serif; letter-spacing: .5px; white-space: nowrap; pointer-events: none; }
html.touch.portrait .top-buttons #m-mallbtn { position: absolute; top: 0; right: calc(100% + 8px); width: 42px; height: 42px; margin: 0; z-index: 2; border-width: 1px; box-sizing: border-box; }
html.touch.portrait .top-buttons #m-mallbtn .ic-tile { width: 46px; height: 46px; margin: -2px; transform: translate(0, -1px); }
html.touch.landscape #m-mallbtn { margin-bottom: 8px; }
html.touch.landscape #m-mallbtn { display: grid; place-items: center; }
html.reduce-motion #m-mallbtn { animation: none !important; }
@media (prefers-reduced-motion: reduce) { html.touch #m-mallbtn { animation: none !important; } }

/* the quest tracker folds on phones too (js/hudextras.js builds the header for both; remembered): a small arrow inside
   the card, at the right end of its first line (owner, 30 Nov 2026), the list down to its first line when folded */
html.touch .qw-wrap { position: relative; }
html.touch .qw-head {
  position: absolute; top: 3px; right: 3px; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; margin: 0; padding: 0;
  border: 0; border-radius: 9px; cursor: pointer; color: rgba(221, 229, 255, .85); background: rgba(255, 255, 255, .07); box-shadow: none;
}
html.touch .qw-head:active { background: rgba(255, 255, 255, .16); }
html.touch .qw-wrap .qw .qw-row:first-child { padding-right: 36px; }   /* the first line's text and count stay clear of the arrow */
html.touch .qw-head > span { display: none; }
html.touch .qw-head .ic { width: 16px; height: 16px; transform: rotate(180deg); transition: transform .2s; }
html.touch .phud.qw-min .qw-head .ic { transform: rotate(0deg); }
html.touch .phud.qw-min .qw .qw-row:nth-child(n+2) { display: none; }
html.touch .phud:has(.qw:empty) .qw-head { display: none; }
html.touch .qw-head::before { content: ''; position: absolute; inset: -10px -6px; }   /* finger-sized tap area */
