/* Mobile version (v0.63.0). Every rule here is scoped to body.mobile, so the full version is unaffected. */
html:has(body.mobile), body.mobile { overscroll-behavior: none; }
body.mobile { overflow: hidden; background-image: none; }
.mobile .m-app { position: fixed; inset: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }

/* top: outpost, bonds, orders, and the four resources with how full they are */
.mobile .m-top { flex: none; background: #111816; border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 6px) 8px 6px; }
.mobile .m-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; min-width: 0; }
.mobile .m-btn { position: relative; background: none; border: 0; color: var(--text); padding: 4px; min-width: 0; line-height: 0; }
.mobile .m-btn em, .mobile .m-nav em, .mobile .m-drawer a em { position: absolute; top: -2px; right: -4px; background: var(--bad); color: #fff; font-style: normal; font-size: 10px; line-height: 15px; min-width: 15px; text-align: center; border-radius: 8px; padding: 0 4px; font-family: var(--mono); }
.mobile .m-post { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; font-family: var(--stamp); letter-spacing: .05em; }
.mobile .m-chip { flex: none; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--warn); text-decoration: none; min-height: 0; font-family: var(--mono); text-transform: none; letter-spacing: 0; }
.mobile .m-res { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.mobile .m-r { display: flex; align-items: center; gap: 4px; min-width: 0; padding: 4px 5px; border-radius: 6px; background: var(--panel); border-left: 3px solid var(--c); color: var(--text); text-decoration: none; }
.mobile .m-r svg { flex: none; }
.mobile .m-rv { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile .m-rv b { font-size: 13px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mobile .m-rv small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.mobile .m-meter { display: block; height: 4px; margin-top: 3px; border-radius: 2px; background: #0a0e0d; overflow: hidden; }
.mobile .m-meter i { display: block; height: 100%; background: var(--good); transition: width .6s; }
.mobile .m-r.near .m-meter i { background: var(--warn); }
.mobile .m-r.full .m-meter i { background: var(--bad); }
.mobile .m-r.full { box-shadow: inset 0 0 0 1px var(--bad); }
.mobile .m-alert { flex: none; display: block; padding: 6px 10px; background: #4a1f1a; color: #ffd6cc; border-bottom: 1px solid var(--bad); text-decoration: none; font-size: 13px; }
.mobile .announce { flex: none; font-size: 12px; padding: 5px 10px; }

/* the page itself scrolls between the bars */
.mobile .m-main { flex: 1; min-height: 0; margin: 0; width: 100%; max-width: none; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 10px 10px 16px; }
.mobile .m-main h2 { font-size: 1.35rem; }
.mobile .m-main .grid2, .mobile .m-main .stat-cols, .mobile .m-main .viz-grid, .mobile .m-main .t10-grid { grid-template-columns: 1fr; }

/* bottom tabs */
.mobile .m-nav { flex: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: #111816; border-top: 1px solid var(--line); padding: 6px 2px calc(env(safe-area-inset-bottom) + 6px); }
.mobile .m-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-family: var(--stamp); font-size: 9.5px; letter-spacing: .02em; text-transform: uppercase; min-width: 0; }
.mobile .m-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile .m-nav a.on { color: var(--accent); }
.mobile .m-nav a.on::before { content: ''; position: absolute; top: -7px; left: 22%; right: 22%; height: 3px; border-radius: 2px; background: var(--accent); }
.mobile .m-nav em { right: 18%; }

/* side menus: left = pages and links (swipe right), right = orders (swipe left) */
.mobile .m-dim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .2s; }
.mobile .m-app.open-left .m-dim, .mobile .m-app.open-right .m-dim { opacity: 1; pointer-events: auto; }
.mobile .m-drawer { position: fixed; top: 0; bottom: 0; z-index: 41; width: min(320px, 86vw); background: #141b19; border: 1px solid var(--line); overflow-y: auto; padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; gap: 2px; transition: transform .22s ease; box-shadow: 0 0 30px #000c; }
.mobile .m-drawer.left { left: 0; border-left: 0; border-radius: 0 14px 14px 0; transform: translateX(-105%); }
.mobile .m-drawer.right { right: 0; border-right: 0; border-radius: 14px 0 0 14px; transform: translateX(105%); }
.mobile .m-app.open-left .m-drawer.left, .mobile .m-app.open-right .m-drawer.right { transform: none; }
.mobile .m-dhead { padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.mobile .m-cdr { display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; }
.mobile .m-cdr span { display: flex; flex-direction: column; }
.mobile .m-cdr .avatar { border-radius: 50%; }
.mobile .m-drawer a { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 6px; color: var(--text); text-decoration: none; font-family: var(--stamp); font-size: 13px; letter-spacing: .05em; text-transform: uppercase; }
.mobile .m-drawer a em { position: static; margin-left: auto; }
.mobile .m-drawer a.on { background: var(--panel); color: var(--accent); }
.mobile .m-drawer a.m-hero { background: var(--accent); color: var(--accent-ink); padding: 10px; margin: 2px 0 6px; }
.mobile .m-hero span { display: flex; flex-direction: column; min-width: 0; }
.mobile .m-hero small { font-family: var(--mono); text-transform: none; letter-spacing: 0; font-size: 11px; }
.mobile .m-dgroup { margin: 10px 6px 2px; color: var(--muted); font-family: var(--stamp); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.mobile .m-add { align-self: flex-start; background: none; border: 0; color: var(--accent); font-size: 12px; padding: 6px; min-height: 0; }
/* nothing in the menus may shrink: on a short screen the menu scrolls instead of overlapping */
.mobile .m-drawer > * { flex-shrink: 0; }
.mobile .m-dfoot > button { width: 100%; }
.mobile .m-dfoot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.mobile .m-dfoot a { padding: 2px 0; font-size: 12px; text-transform: none; letter-spacing: 0; font-family: var(--mono); color: var(--accent); }
.mobile .m-dfoot .row { gap: 6px; flex-wrap: wrap; }
.mobile #m-orders h2 { font-size: 1.2rem; }
.mobile #m-orders .order-grid { grid-template-columns: 1fr; }

/* Fields and Base maps, and the page of one building or field */
.mobile .m-mapwrap { margin: 0 -10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mobile .m-mapwrap svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.mobile .m-mapwrap .plot { cursor: pointer; }
.mobile .m-hint { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0 0; }
.mobile .build-strip { margin: 0 0 8px; flex-wrap: wrap; }
.mobile .m-backrow { margin: 0 0 6px; }
.mobile .m-back { font-family: var(--stamp); text-transform: uppercase; letter-spacing: .06em; text-decoration: none; }
.mobile .m-art { height: 180px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #26301f; margin-bottom: 8px; }
.mobile .m-art svg { width: 100%; height: 100%; display: block; }
.mobile .m-bp { position: static; max-height: none; overflow: visible; }
.mobile .m-bp .bp-photo { display: none; }

/* the map fills the width */
.mobile .page-map .warmap-layout { grid-template-columns: 1fr; }
.mobile .page-map .warmap { height: 56dvh; }

/* dialogs above the side menus */
.mobile .modal-back { z-index: 60; }
.mobile .m-mapwrap .base-svg { min-width: 0; width: 100%; }
.mobile #m-orders { text-align: left; }
.mobile #m-orders .order-head { flex-wrap: wrap; }
.mobile .m-hero .timer { color: inherit; font-weight: 700; }
.mobile .m-drawer a.nav-cmd small { text-transform: none; letter-spacing: 0; font-family: var(--mono); }
.mobile .m-drawer a.nav-cmd { padding: 8px; }
.mobile .cdr-tabs { flex-wrap: nowrap; }
.mobile .cdr-tabs button { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; font-size: 13px; }
