/* Everything here is scoped to html.touch (a phone or tablet) or html.compact (a small screen), so the desktop game is untouched.
   public/js/mobile.js sets those classes, plus --app-h (the visible height, which follows the address bar and the keyboard). */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.touch { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
html.touch body.game { overscroll-behavior: none; }
html.touch body.game, html.touch body.game * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
html.touch body.game input, html.touch body.game textarea { -webkit-user-select: text; user-select: text; }
html.touch canvas { touch-action: none; }
html.touch button, html.touch a, html.touch select, html.touch summary, html.touch label, html.touch input { touch-action: manipulation; }

body.game { height: var(--app-h, 100vh); height: var(--app-h, 100dvh); }
html.touch body.game { box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: #101512; }
html.touch body.game #mapWrap { border-radius: 0; }

/* ---------- small icons made from one-colour masks, so they take the colour of their button ---------- */
.layers-glyph, .fs-glyph { display: block; width: 18px; height: 18px; background: currentColor; pointer-events: none; }
.layers-glyph { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3l7 4-7 4-7-4z'/%3E%3Cpath d='M3 11l7 4 7-4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3l7 4-7 4-7-4z'/%3E%3Cpath d='M3 11l7 4 7-4'/%3E%3C/svg%3E") center / contain no-repeat; }
.fs-glyph { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8V3h5M12 3h5v5M17 12v5h-5M8 17H3v-5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8V3h5M12 3h5v5M17 12v5h-5M8 17H3v-5'/%3E%3C/svg%3E") center / contain no-repeat; }
html.fullscreen .fs-glyph { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3v5H3M12 3v5h5M17 12h-5v5M3 12h5v5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3v5H3M12 3v5h5M17 12h-5v5M3 12h5v5'/%3E%3C/svg%3E"); }

.tools-toggle, .fs-btn { display: none; align-items: center; justify-content: center; width: 38px; min-height: 32px; padding: 0; background: var(--head); color: var(--head-text); border: 1px solid #6b7a5f; border-radius: 0; }
html.touch .fs-btn { display: inline-flex; }
html.compact .tools-toggle { display: inline-flex; }
.tools-toggle:hover, .fs-btn:hover { background: var(--bar-btn); color: var(--head-text); }
body.tools-open .tools-toggle { background: #4b5a40; }
/* on a computer: the same button, and the panel is open unless it was put away */
html:not(.touch):not(.compact) .tools-toggle { display: inline-flex; }
html:not(.touch):not(.compact) body:not(.tools-hidden) .tools-toggle { background: #4b5a40; }
html:not(.touch):not(.compact) body.tools-hidden #mapTools { display: none; }

/* ---------- turn your phone sideways ---------- */
.rotate-hint { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; padding: 24px; background: rgba(16, 22, 18, .97); color: #eef0e8; text-align: center; }
html.touch.portrait.phone body.game:not(.portrait-ok) .rotate-hint { display: flex; }
.rotate-card { max-width: 360px; }
.rotate-icon { position: relative; width: 52px; height: 88px; margin: 0 auto 20px; border: 3px solid #eef0e8; border-radius: 10px; animation: rotate-phone 2.6s ease-in-out infinite; }
.rotate-icon::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 3px; margin-left: -7px; border-radius: 2px; background: #eef0e8; }
@keyframes rotate-phone { 0%, 15% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.rotate-card h2 { margin: 0 0 10px; font-size: 22px; color: #fff; }
.rotate-card p { margin: 0 0 20px; font-size: 15px; line-height: 1.45; color: #cfd6c6; }
.rotate-actions { display: flex; flex-direction: column; gap: 10px; }
.rotate-actions button { min-height: 46px; font-size: 16px; }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; } }

.ios-tip { position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1500; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 20px); padding: 8px 12px; background: var(--head); color: var(--head-text); border: 1px solid #6b7a5f; font-size: 13.5px; }
.ios-tip[hidden] { display: none; }
html.portrait.phone body.game:not(.portrait-ok) .ios-tip { display: none; }

/* ---------- the map screen on a small screen ---------- */
html.touch #hover { display: none !important; }
html.compact #gameMenu { top: 6px; left: 6px; gap: 6px; max-width: calc(100% - 70px); z-index: 16; }
html.compact .menu-btn, html.compact .menu-chip, html.compact #gameMenu .badge-plain, html.compact #gameMenu .warn-text { min-height: 38px; padding: 4px 10px; font-size: 14px; display: inline-flex; align-items: center; }
html.compact #gameMenu .battle-btn { min-height: 38px; padding: 4px 12px; font-size: 14px; }
html.compact #gameMenu .warn-text:empty { display: none; }
html.compact .menu-panel { top: 44px; width: min(280px, 78vw); max-height: calc(var(--app-h, 100vh) - 60px); overflow-y: auto; }
html.compact #gameMenu .menu-panel { width: min(280px, 78vw); }
html.compact #gameMenu .menu-panel button, html.compact #gameMenu .menu-panel a.btn { min-height: 40px; }

html.compact #mapTools { display: none; top: 50px; left: 6px; z-index: 11; max-width: calc(100% - 12px); }
html.compact body.tools-open #mapTools { display: flex; }
html.compact #mapTools .seg button, html.compact #mapTools button { min-height: 36px; font-size: 13.5px; padding: 3px 11px; }

html.compact #sidebar { position: fixed; top: 0; right: 0; bottom: 0; width: min(84vw, 360px) !important; z-index: 30; box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0; box-shadow: -8px 0 24px rgba(0, 0, 0, .5); transition: transform .22s ease, visibility 0s; }
html.compact #sidebar > * { min-width: 0 !important; }
html.compact body.sidebar-closed #sidebar { width: min(84vw, 360px) !important; border-left-width: 1px; transform: translateX(110%); box-shadow: none; visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
html.compact .side-toggle { position: fixed; top: 50%; right: min(84vw, 360px); width: 30px; height: 78px; z-index: 31; transition: right .22s ease; }
html.compact body.sidebar-closed .side-toggle { right: env(safe-area-inset-right); }
html.compact .side-toggle .chev { width: 10px; height: 10px; }
html.compact #sideTabs button, html.compact .tabs button { height: 40px; font-size: 14px; }
html.compact #sidebar button { min-height: 36px; }
html.compact #sidebar .small { min-height: 34px; padding: 2px 10px; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { html.compact #sidebar, html.compact .side-toggle { transition: none; } }

html.compact #chat { left: 6px; bottom: 6px; width: min(62vw, 390px); height: min(var(--app-h, 100vh) - 70px, 230px); z-index: 14; }
html.compact #chatOpen { left: 6px; bottom: 6px; min-height: 40px; padding: 4px 14px; z-index: 13; }
html.compact .chat-tabs button { min-height: 38px; padding: 4px 12px; }
html.compact #chatForm input { min-height: 38px; font-size: 16px; }
html.compact #chatForm button { min-height: 38px; }

html.compact #callBar { bottom: 4px; }
html.compact #toast { bottom: 10px; max-width: calc(100% - 24px); }

/* the action bar for the selected hex: tap a hex, then move there or read about it */
.map-act { position: absolute; left: 50%; bottom: 8px; z-index: 12; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; max-width: calc(100% - 20px); padding: 6px 8px; background: rgba(231, 233, 226, .97); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.map-act[hidden] { display: none; }
.map-act-info { min-width: 0; max-width: 30vw; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-act button { min-height: 40px; padding: 4px 14px; font-size: 14px; white-space: nowrap; }
.map-act .map-act-close { min-width: 40px; padding: 0; font-size: 22px; line-height: 1; }
html.compact body:not(.sidebar-closed) .map-act { display: none; }
html.compact body.map-act-on #callBar { display: none; }

.press-ring { position: fixed; z-index: 40; width: 76px; height: 76px; margin: -38px 0 0 -38px; border: 4px solid rgba(255, 255, 255, .92); border-radius: 50%; background: rgba(77, 106, 45, .35); pointer-events: none; transform: scale(.35); opacity: 0; }
.press-ring[hidden] { display: none; }
.press-ring.go { animation: press-ring var(--press-ms, 480ms) linear forwards; }
@keyframes press-ring { from { transform: scale(.35); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.touch-tip { position: absolute; left: 50%; top: 52px; z-index: 9; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(560px, calc(100% - 140px)); padding: 8px 12px; background: rgba(61, 74, 52, .96); color: var(--head-text); border: 1px solid #6b7a5f; font-size: 13.5px; line-height: 1.35; }
.touch-tip button { flex: none; min-height: 36px; }
html.touch #touchTipBattle { top: 70px; }

/* ---------- the battle on a small screen ---------- */
.bv-touch-only { display: none; }
html.touch .bv-touch-only { display: inline-block; }
html.touch body.in-battle #touchTip, html.touch body.in-battle .map-act, html.touch body.in-battle .tools-toggle { display: none !important; }

html.compact #battleBar > .bar-group { padding: 2px 4px; gap: 4px; }
html.compact #battleBar .menu-btn, html.compact #battleBar .ui-toggle { min-height: 36px; font-size: 13px; padding: 3px 9px; }
html.compact #battleBar .menu-panel { top: 100%; width: min(250px, 70vw); }
html.compact #battleBar .menu-panel button { min-height: 38px; }

html.compact .phase { top: 4px; width: auto; max-width: 44vw; grid-template-columns: auto auto; gap: 0 10px; padding: 3px 10px 3px; }
html.compact .phase-title { font-size: 13px; white-space: nowrap; }
html.compact .phase-sub { display: none; }
html.compact .phase-time { grid-row: 1; grid-column: 2; font-size: 22px; min-width: 2.6ch; }
html.compact .phase-ready { grid-column: 1 / 3; font-size: 11.5px; }
html.compact .phase-bar { height: 4px; margin-top: 2px; }

html.compact #bvRight { top: 4px; right: 4px; gap: 3px; }
html.compact #bvSides { gap: 3px; }
html.compact .bv-chip { padding: 2px 7px; font-size: 11.5px; }
html.compact .bv-chip .swatch { width: 11px; height: 11px; margin-right: 5px; }
html.compact #bvLegend { display: none; }

html.compact #bvCommand { left: 6px; right: 6px; bottom: 6px; padding: 4px 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
html.compact .bv-selection { order: 1; flex: none; margin: 0; font-size: 12.5px; }
html.compact #bvCommand .bv-row { display: contents; }
html.compact .bv-units { order: 2; flex: 1 1 0; min-width: 0; flex-wrap: nowrap; overflow-x: auto; gap: 4px; -webkit-overflow-scrolling: touch; }
html.compact .bv-units > * { flex: none; }
html.compact .bv-buttons { order: 3; flex: 1 0 100%; flex-wrap: wrap; gap: 4px; }
html.compact .bv-buttons button { min-height: 38px; padding: 2px 12px; font-size: 13px; }
html.compact #bvCommand .bv-help { display: none; }

html.compact #bvModes { display: none; }
html.compact body.bv-orders-open #bvModes { display: flex; position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); margin: 0; padding: 6px 8px 8px; background: rgba(231, 233, 226, .98); border: 1px solid var(--line); justify-content: center; gap: 4px 14px; z-index: 6; }
html.touch .bv-ord { width: 38px; height: 38px; }
html.touch .bv-ord .oi { width: 22px; height: 22px; }
html.touch #bvOrderHint { max-width: min(340px, 70vw); }

html.compact .bv-dock { left: 6px; right: auto; transform: none; bottom: calc(var(--bv-command-h, 84px) + 14px); }
html.compact #bvControls { gap: 6px; }
html.compact .bv-dock button { min-width: 0; min-height: 44px; padding: 6px 14px; font-size: 13px; }
html.compact .bv-dock #bvReady { min-width: 104px; padding: 8px 18px; font-size: 15px; }

html.compact #bvMini { right: 6px; bottom: calc(var(--bv-command-h, 84px) + 14px); padding: 2px; }
html.compact #bvMini canvas { width: 128px; height: auto; }

html.compact body.in-battle #chatOpen { left: 6px; top: 46px; bottom: auto; min-height: 36px; padding: 3px 12px; }
html.compact body.in-battle #chat { bottom: calc(var(--bv-command-h, 84px) + 14px); height: min(46vh, 180px); }
html.compact #bvResult { max-width: min(92vw, 520px); max-height: calc(var(--app-h, 100vh) - 20px); overflow-y: auto; }
html.compact #bvResult button { min-height: 42px; }

/* very short screens (a small phone held sideways): give the battlefield every pixel we can */
@media (max-height: 380px) {
  html.compact #battleBar .menu-btn, html.compact #battleBar .ui-toggle { min-height: 32px; padding: 2px 8px; }
  html.compact .bv-buttons button { min-height: 34px; padding: 1px 10px; }
  html.compact .bv-dock button { min-height: 38px; padding: 4px 12px; }
  html.compact .bv-dock #bvReady { min-width: 96px; padding: 6px 14px; font-size: 14px; }
  html.compact #bvMini canvas { width: 104px; }
  html.compact #bvCommand { padding: 3px 5px; gap: 3px 8px; }
  html.compact .bv-units button, html.compact .bv-units > * { min-height: 30px; }
  html.compact .phase-time { font-size: 20px; }
  html.compact #gameMenu .menu-btn, html.compact .menu-chip, html.compact .tools-toggle, html.compact .fs-btn { min-height: 34px; }
  html.compact .menu-chip { padding: 2px 8px; }
}

/* the fallback: playing a phone game upright */
html.compact.portrait .bv-dock { right: 6px; }
html.compact.portrait #bvControls { flex-wrap: wrap; }
html.compact.portrait .bv-dock button { flex: 1 1 auto; }
html.compact.portrait .phase { max-width: 60vw; }
html.compact.portrait #bvRight { top: 48px; }
html.compact.portrait .map-act { flex-wrap: wrap; justify-content: center; }
html.compact.portrait .map-act-info { max-width: 100%; flex: 1 0 100%; text-align: center; }

/* ---------- every other page (lobby, history, settings, legal) on a narrow screen ---------- */
@media (max-width: 720px) {
  html, body { max-width: 100%; }
  .topbar { flex-wrap: wrap; gap: 6px 10px; padding: 6px 10px; }
  .topbar .brand .logo { height: 32px; padding: 2px 8px; }
  .topbar .grow { flex: 1 0 0; min-width: 0; }
  .topbar a.btn, .topbar button, .topbar .btn { min-height: 38px; padding-top: 3px; padding-bottom: 3px; display: inline-flex; align-items: center; }
  .topbar #who { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wrap { margin: 12px auto; padding: 0 10px; gap: 12px; grid-template-columns: minmax(0, 1fr) !important; }
  .wrap > *, .box, .box-body { min-width: 0; }
  .box-body { overflow-x: auto; }
  .box table { width: 100%; }
  input[type=text], input[type=password], input[type=email], input:not([type]), select, textarea { font-size: 16px; min-height: 40px; }
  button, .btn { min-height: 40px; }
  .play-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
html.touch button, html.touch .btn { -webkit-tap-highlight-color: transparent; }

/* ---------- the header menu on a narrow screen is a hamburger (public/js/mobile.js builds the button and the panel) ---------- */
.nav-toggle { display: none; }
.nav-panel { display: contents; }
.nav-bars { display: block; width: 22px; height: 22px; background: currentColor; pointer-events: none; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5h14M3 10h14M3 15h14'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5h14M3 10h14M3 15h14'/%3E%3C/svg%3E") center / contain no-repeat; }
html.nav-open .nav-bars { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 4l12 12M16 4L4 16'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 4l12 12M16 4L4 16'/%3E%3C/svg%3E"); }

html.narrow .topbar [hidden] { display: none !important; }
html.narrow .topbar.has-nav { position: relative; flex-wrap: nowrap; }
html.narrow .topbar.has-nav .nav-toggle { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; width: 46px; min-height: 42px; padding: 0; }
html.narrow .topbar.has-nav .nav-panel { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 50; flex-direction: column; align-items: stretch; gap: 0; padding: 0 0 8px; background: var(--head); border-top: 1px solid #5b6a50; box-shadow: 0 12px 24px rgba(0, 0, 0, .45); max-height: calc(var(--app-h, 100vh) - 56px); overflow-y: auto; }
html.narrow.nav-open .topbar.has-nav .nav-panel { display: flex; }
html.narrow .topbar.has-nav .nav-panel > * { margin: 0; }
html.narrow .topbar.has-nav .nav-panel > a.btn, html.narrow .topbar.has-nav .nav-panel > button { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 48px; padding: 8px 16px; font-size: 16px; text-align: left; border-width: 0 0 1px; border-radius: 0; }
html.narrow .topbar.has-nav .nav-panel > .grow { display: none; }
html.narrow .topbar.has-nav .nav-panel > #who { order: -1; display: block; max-width: none; padding: 12px 16px 10px; font-weight: 700; white-space: normal; background: none; border: 0; border-bottom: 1px solid #5b6a50; border-radius: 0; box-shadow: none; }
html.narrow .topbar.has-nav .nav-panel > #who:empty { display: none; }
html.narrow .topbar.has-nav .nav-panel { max-height: calc(var(--app-h, 100vh) - 58px); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* the sound settings live inside the hamburger menu, under their button, between Settings and Log out */
html.narrow .topbar.has-nav .nav-panel > .sound-btn { order: 5; }
html.narrow .topbar.has-nav .nav-panel > .sound-panel { order: 6; position: static; width: auto; margin: 0; padding: 6px 16px 12px; border: 0; border-top: 1px solid #6b7a5f; background: transparent; color: var(--head-text); }
html.narrow .topbar.has-nav .nav-panel > .sound-panel[hidden] { display: none; }
html.narrow .topbar.has-nav .nav-panel > .sound-panel label { margin: 10px 0 2px; font-size: 15px; }
html.narrow .topbar.has-nav .nav-panel > .sound-panel input[type=range] { height: 30px; }
html.narrow .topbar.has-nav .nav-panel > .sound-panel input[type=checkbox] { width: 24px; height: 24px; }
html.narrow .topbar.has-nav .nav-panel > .sound-panel .track { color: #c9d1bd; font-size: 13px; }
html.narrow .topbar.has-nav .nav-panel > #logout { order: 9; }

html.touch .gfx-seg button { min-height: 38px; padding: 4px 12px; }
html.compact #battleBar { z-index: 16; }
html.compact body.in-battle.bv-menu-open #chatOpen { visibility: hidden; }

/* ---------- the battalion designer on a small screen: three panes, and a footer that is always there ---------- */
.bb-panes, .bb-foot { display: none; }
html.compact .bb-overlay { padding: 0; align-items: stretch; }
html.compact .bb-modal { width: 100%; height: var(--app-h, 100vh); max-height: none; border: 0; border-radius: 0; box-sizing: border-box; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
html.compact .bb-head { min-height: 40px; padding: 2px 6px 2px 12px; }
html.compact .bb-head h2 { font-size: 14px; }
html.compact .bb-x { width: 40px; height: 40px; }
html.compact .bb-panes { display: flex; background: var(--panel-alt); border-bottom: 1px solid var(--line); }
html.compact .bb-pane { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 6px 4px; font: inherit; font-weight: 600; color: var(--text); background: var(--paper); border: 0; border-right: 1px solid var(--line); border-bottom: 3px solid transparent; border-radius: 0; }
html.compact .bb-pane:last-child { border-right: 0; }
html.compact .bb-pane.sel { color: var(--primary); background: var(--panel); border-bottom-color: var(--primary); }
html.compact .bb-body { display: block; position: relative; min-height: 0; overflow: hidden; }
html.compact .bb-body > .bb-left, html.compact .bb-body > .bb-mid, html.compact .bb-body > .bb-right { display: none; height: 100%; box-sizing: border-box; padding: 10px 12px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; border: 0; }
html.compact .bb-body[data-pane="mid"] > .bb-mid, html.compact .bb-body[data-pane="left"] > .bb-left, html.compact .bb-body[data-pane="right"] > .bb-right { display: block; }
html.compact .bb-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 10px; background: var(--panel-alt); border-top: 1px solid var(--line); }
html.compact .bb-foot:empty { display: none; }
html.compact .bb-foot .bb-qty { flex: none; margin: 0; gap: 6px; }
html.compact .bb-foot .bb-qty label { flex: none; }
html.compact .bb-foot .bb-qty button { min-width: 40px; min-height: 40px; }
html.compact .bb-foot .bb-qty input { width: 60px; min-height: 40px; font-size: 16px; }
html.compact .bb-foot .hint, html.compact .bb-foot #bbError { flex: 1 0 100%; margin: 0; font-size: 12.5px; line-height: 1.3; }
html.compact .bb-foot .bb-actions { display: flex; flex: 1 1 auto; flex-wrap: nowrap; gap: 6px; margin: 0; }
html.compact .bb-foot .bb-actions button { flex: 1 1 auto; min-height: 42px; padding: 4px 10px; font-size: 13.5px; white-space: nowrap; }
html.compact .bb-foot .bb-actions .primary { flex: 3 1 auto; grid-column: auto; padding: 4px 12px; font-size: 14px; }

html.compact .bb-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
html.compact .bb-tab { flex: none; min-height: 42px; }
html.compact .bb-blurb { margin: 8px 0; font-size: 13px; }
html.compact .bb-opts { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
html.compact .bb-opt { min-height: 48px; padding: 8px 10px; }
html.compact .bb-opt.sel { padding: 7px 9px; }
html.compact .bb-defaults { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
html.compact .bb-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
html.compact .bb-default, html.compact .bb-lib-load { min-height: 46px; }
html.compact .bb-lib-del { width: 44px; min-height: 46px; }
html.compact .bb-icons { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
html.compact .bb-icon { min-height: 46px; }
html.compact .bb-name input { min-height: 44px; font-size: 16px; }
html.compact .bb-name label { font-size: 13px; }
html.compact .bb-stats { font-size: 14px; }
html.compact.landscape .bb-right { display: none; }
html.compact.landscape .bb-body[data-pane="right"] > .bb-right { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-auto-rows: min-content; gap: 0 16px; align-content: start; }
html.compact.landscape .bb-right > .bb-name, html.compact.landscape .bb-right > h4, html.compact.landscape .bb-right > .bb-icons { grid-column: 1; }
html.compact.landscape .bb-right > .bb-summary { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; }
html.compact .bn-btns button { min-height: 38px; }
@media (max-height: 380px) {
  html.compact .bb-head { min-height: 34px; padding-top: 0; padding-bottom: 0; }
  html.compact .bb-x { width: 36px; height: 34px; }
  html.compact .bb-pane { min-height: 36px; padding: 3px 4px; }
  html.compact .bb-foot { padding: 4px 8px; }
  html.compact .bb-foot .bb-actions button, html.compact .bb-foot .bb-qty button, html.compact .bb-foot .bb-qty input { min-height: 38px; }
  html.compact .bb-body > .bb-left, html.compact .bb-body > .bb-mid, html.compact .bb-body > .bb-right { padding: 8px 10px; }
  html.compact .bb-tab { min-height: 38px; padding: 4px 12px; }
}
html.compact.portrait .bb-foot .bb-actions { flex-wrap: wrap; }
html.compact.portrait .bb-foot .bb-actions .primary { flex: 1 0 100%; }
html.compact.portrait .bb-foot .bb-qty { flex: 1 0 100%; justify-content: center; }
html.compact.portrait .bb-foot .bb-qty label { flex: 1; }
html.compact .bb-foot { box-sizing: border-box; max-width: 100%; }

html.compact .side-rail { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: calc(min(84vw, 360px) + 8px); z-index: 32; gap: 6px; transition: right .22s ease; }
html.compact body.sidebar-closed .side-rail { right: calc(env(safe-area-inset-right) + 8px); }
html.compact .side-rail button { width: 44px; height: 44px; }
html.compact .side-toggle { display: none; }
html.compact .side-head { padding-top: env(safe-area-inset-top); }
body:has(#menuPanel:not([hidden])) #mapTools { visibility: hidden; }   /* (the options panel is wider than the menu and would show beside it) */

html.compact #bvCommand > .bv-special { order: 3; flex: 1 0 100%; flex-direction: row; align-items: center; gap: 8px; padding: 0; border-left: 0; }
html.compact #bvCommand > .bv-special .bv-pair { gap: 6px; }
html.compact #bvCommand > .bv-special button { min-height: 38px; padding: 2px 12px; font-size: 13px; }
