/* Shared command interface for the browser and Android WebView. */
:root {
  --hud-cyan: #79dfff;
  --hud-line: #448ca7;
  --hud-text: #d2effa;
  --hud-muted: #85a9b9;
  --hud-surface: linear-gradient(135deg, #102b39f5, #04111bf2 70%);
  --hud-shadow: inset 0 0 0 3px #041019, inset 0 0 18px #2cbaf016, 0 6px 24px #0008;
  --hud-edge: max(16px, env(safe-area-inset-left));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
body { color: var(--hud-text); }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid #a3eaff !important; outline-offset: 4px; }
#brand, body #artStatus { display: none; }
#commandNav {
  position: fixed; left: var(--hud-edge); top: max(16px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 0; z-index: 9; padding: 5px 8px;
  border: 1px solid var(--hud-cyan); border-radius: 3px 10px 3px 10px;
  background: var(--hud-surface); box-shadow: var(--hud-shadow);
}
body #commandNav #btnMenu, #commandNav button {
  position: static; padding: 8px 14px; min-height: 40px; margin: 0;
  background: transparent; border: 0; color: #b6e3f7; font: 600 15px "Segoe UI", sans-serif;
  cursor: pointer; letter-spacing: .3px;
}
#commandNav button + button { border-left: 1px solid #4e879044; }
body #commandNav #btnMenu::before { content: '☰'; font-size: 22px; margin-right: 14px; vertical-align: -1px; color: #90dcf8; }
#commandNav button:hover { color: white; background: #61cfff12; }
body #btnFullscreen, body:not(.admin-mode) #btnFullscreen {
  top: max(81px, calc(env(safe-area-inset-top) + 65px)); left: var(--hud-edge);
  color: var(--hud-muted); border: 1px solid #38677d; background: #051722de;
  padding: 8px 12px; font-size: 11px; border-radius: 2px; z-index: 8;
}
body #btnAtlas { top: 122px; left: var(--hud-edge); }
body #hud { top: 85px; right: 280px; left: 350px; bottom: auto; max-height: 25vh; gap: 5px; overflow: visible; }
body #hud .panel { background: var(--hud-surface); border-color: #38677d; border-radius: 2px; }
body #hud .panel.gold {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 50%; right: auto; bottom: auto;
  transform: translateX(-50%); display: flex; align-items: center; gap: 12px; min-height: 52px;
  padding: 8px 22px; color: #afd9eb; font-size: 16px; white-space: nowrap;
  border: 1px solid var(--hud-cyan); border-radius: 3px 9px 3px 9px; box-shadow: var(--hud-shadow); z-index: 8;
}
body #hud .gold::before { content: '◆'; color: #f5d591; font-size: 25px; text-shadow: 4px 3px #8a6539; margin-right: 4px; }
body #hud .gold b { font-size: 23px; color: #ffdb93; margin: 0; font-weight: 700; }
body #fpsBadge {
  top: var(--tactical-fps-top, 224px) !important; right: max(16px, env(safe-area-inset-right)) !important; bottom: auto !important;
  min-width: 90px; padding: 9px 14px; color: #b8e8fa; font-size: 12px;
  border: 1px solid #5da4bf; border-radius: 2px 7px 2px 7px; background: var(--hud-surface); box-shadow: var(--hud-shadow); z-index: 8;
}
#fpsBadge::before { content: '▥'; margin-right: 12px; color: #84d9f7; }
/* Leave the battlefield visible until a commander opens the construction deck. */
body #buildToggle, body #frameToggle {
  position: fixed;
  min-height: 56px; min-width: 150px; padding: 12px 24px; font: 600 16px "Segoe UI", sans-serif;
  color: #c0ecff; background: var(--hud-surface); border: 1px solid #80dfff;
  border-radius: 3px 10px 3px 10px; box-shadow: var(--hud-shadow); cursor: pointer;
}
body #buildToggle { position: fixed; left: var(--hud-edge) !important; bottom: max(16px, env(safe-area-inset-bottom)) !important; top: auto !important; z-index: 9; }
#buildToggle::before { content: '▥'; font-size: 25px; margin-right: 18px; vertical-align: -2px; }
body #frameToggle { right: max(16px, env(safe-area-inset-right)) !important; bottom: max(16px, env(safe-area-inset-bottom)) !important; z-index: 9; }
#frameToggle::before { content: '□'; display: inline-block; margin-right: 14px; border: 1px dashed #8bdcff; width: 20px; height: 20px; color: transparent; }
body #frameToggle[aria-pressed="true"] { background: #16475b; color: white; border-color: #b1f0ff; }
body #buildbar {
  left: var(--hud-edge); bottom: max(82px, calc(env(safe-area-inset-bottom) + 66px)); padding: 31px 10px 10px; gap: 8px;
  max-width: calc(100vw - 32px); border: 1px solid #69c6e7; border-radius: 3px 10px 3px 10px;
  background: var(--hud-surface); box-shadow: var(--hud-shadow);
}
#buildbar.hud-collapsed { display: none; }
body #buildbar::before { content: 'BASISBAU / GEBÄUDE'; top: 11px; left: 13px; color: #83d5f1; letter-spacing: 2px; font-size: 9px; }
body #buildbar button.build-card, body #ctxmenu button.production-card {
  border: 1px solid #376c82; border-bottom: 2px solid #58b9dc; border-radius: 2px; background: #0b222e; color: #d2edfa;
}
body #buildbar button.build-card { width: 136px; }
body .build-portrait, body #ctxmenu .production-card canvas {
  background: linear-gradient(#68cef008 1px, transparent 1px), linear-gradient(90deg,#68cef008 1px,transparent 1px), radial-gradient(ellipse at 50% 80%,#244654,#071720 75%);
  background-size: 16px 16px,16px 16px,auto;
}
body .build-name { color: #d0ecf8; }
body .build-detail { color: #84a8b8; }
body .build-cost { color: #f0cd89; }
body .build-cost small { color: #819ba6; }
body #buildbar button.build-card:hover:not(:disabled), body #ctxmenu .production-card:hover:not(:disabled) {
  background: #163d4e; border-color: #9be9ff; box-shadow: inset 0 0 16px #68d9ff18;
}
body #buildbar button.build-card:disabled, body #ctxmenu .production-card:disabled {
  background: #0c1b24; border-color: #284553; color: #6c8792;
}
body #ctxmenu, body #touchControls {
  background: var(--hud-surface); border: 1px solid #5cabc8; border-radius: 3px 9px 3px 9px;
  box-shadow: var(--hud-shadow); color: var(--hud-text);
}
body #ctxmenu .ctx-title { color: #83d5f1; border-color: #315b6d; padding: 5px 4px 9px; }
body #ctxmenu .queue-badge { background: #0e2e3c; border-color: #72c9e3; color: #cff3ff; }
body .touch-status { color: #92c9dc; letter-spacing: .7px; }
body .touch-actions button, body #ctxmenu button[data-action] {
  border: 1px solid #3d768c; border-bottom: 2px solid #5cb5d3; background: linear-gradient(#173948,#0b202c); color: #c5e8f7;
}
body .touch-actions button:hover:not(:disabled), body .touch-actions button[aria-pressed="true"] {
  background: #205367; color: #e7fbff; border-color: #8ee5ff;
}
body .touch-actions button:disabled { background: #10202a; border-color: #2c4956; color: #698390; }
body #touchControls { bottom: var(--touch-deck-bottom, 82px) !important; z-index: 9; }
/* Main menu and pause panels share the same luminous frame. */
body #overlay {
  z-index: 20; padding: 24px; overflow: auto; backdrop-filter: none;
  background: linear-gradient(90deg,#020b14ed 0%,#04111ccb 43%,#04111c26 100%),url(menu-background.png) center/cover no-repeat;
}
body #overlay .card {
  position: relative; width: min(580px,calc(100vw - 48px)); max-width: none; min-width: 0; max-height: calc(100dvh - 48px);
  overflow: auto; padding: 42px; text-align: left;
  border: 1px solid #64bad5; border-radius: 3px 20px 3px 20px;
  background: linear-gradient(130deg,#102a38ed,#040f1aeb);
  box-shadow: inset 0 0 0 5px #03111b, inset 0 0 70px #33bbef08,0 24px 80px #000a;
}
body #overlay .card::before { content: 'FRESHFX  /  TAKTISCHE EINSATZZENTRALE'; color: #8ed8f0; letter-spacing: 2.2px; font-size: 9px; margin-bottom: 24px; }
body #overlay .card h1 { font-size: clamp(30px,4vw,48px); font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: #e4f7ff; margin-bottom: 16px; text-shadow: 0 0 28px #64cffa30; }
body #overlay .card p { font-size: 14px; line-height: 1.7; color: #9fbcca; }
body #overlay .diff-row { justify-content: flex-start; gap: 8px; margin-top: 25px; }
body #overlay .diff-label { flex-basis: 100%; color: #80adbf; font-size: 10px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 4px; }
body #overlay .diff-btn { flex: 1; min-height: 42px; color: #9ac1d1; background: #091e2c; border: 1px solid #2c546a; font-size: 12px; }
body #overlay .diff-btn.active { color: #e3f7ff; border-color: #7ad9f7; background: linear-gradient(135deg,#22546a,#102c40); box-shadow: inset 0 -2px #71dcff; }
body #loadingPanel { margin: 24px 0; border-color: #2a5265; background-color: #061622; padding: 15px; }
body #loadingPanel::before { background: #77d9f6; }
body #loadingPanel[data-state=ready]::before { background: #8ed9bd; }
body #loadingTitle { color: #b9d9e7; }
body #loadingPercent { color: #85ddfa; }
body #loadingProgress { height: 5px; border: 0; }
body #loadingProgress::-webkit-progress-value { background: linear-gradient(90deg,#237eaa,#8be6ff); }
body #loadingDetail { min-height: 0; font-size: 10px !important; color: #7f9ead !important; }
body .start-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 0; }
body .start-actions #ovBtn { min-height: 52px; font-size: 15px; letter-spacing: 1px; background: linear-gradient(115deg,#286786,#10374e); color: #e5f8ff; border: 1px solid #88def8; box-shadow: inset 0 0 20px #58ceff18; }
body .start-actions #ovBtn:hover:not(:disabled) { background: #2e7592; }
body .start-actions #ovLoadBtn { min-height: 44px; font-size: 13px; color: #a5cadb; border: 1px solid #426f83; background: #0a202e; }
body .start-actions #ovLoadBtn:disabled { color: #587480; border-color: #28414e; background: #091720; opacity: .8; }
body #ovInfoBtn { padding: 9px 0; min-height: 40px; color: #8db9cd; border: 0; background: transparent; margin-top: 12px; font-size: 12px; }
body #gameMenu, body #artGallery, body #quitScreen .card {
  background: var(--hud-surface); border: 1px solid #70c7e4; border-radius: 3px 14px 3px 14px; box-shadow: var(--hud-shadow),0 24px 100px #000b;
}
body #gameMenu { max-height: calc(100dvh - 32px); }
body .menu-head { padding-top: 24px; }
body .menu-head h2 { color: #d4f2ff; font-size: 24px; }
body .menu-tabs { border-bottom: 1px solid #2d5365; padding-bottom: 16px; }
body .menu-tabs button, body .menu-actions button, body .gfx-preset, body .gfx-fps, body .gfx-res, body #menuClose {
  min-height: 40px; background: #0d2938; border-color: #396a80; color: #b1d8e9;
}
body .menu-tabs button.active, body .gfx-preset.active, body .gfx-fps.active, body .gfx-res.active { border-color: #83d7f3; background: #1f4e63; color: #e7f8ff; }
body .menu-actions button.danger { background: #43272b; border-color: #965a58; color: #f4b6ab; }
body .menu-stats .stat { border-color: #254756; background: #071923; }
body #tipbox { border: 1px solid #5794ae; background: #071823f5; border-radius: 3px; }
body.hud-start #commandNav, body.hud-start #hud, body.hud-start #btnFullscreen,
body.hud-start #btnAtlas, body.hud-start #buildbar, body.hud-start #buildToggle,
body.hud-start #frameToggle, body.hud-start #touchControls, body.hud-start #fpsBadge { display: none !important; }
@media(min-width:1000px) { body #overlay { justify-items: center; padding: 24px; } }
@media(max-width:1000px) {
  body #commandNav #btnMenu,#commandNav button { font-size: 12px; padding: 7px 10px; }
  #commandNav { padding: 3px 5px; }
  body #hud .panel.gold { min-height: 48px; padding: 7px 14px; font-size: 13px; gap: 9px; }
  body #hud .gold b { font-size: 20px; }
  body #buildToggle,body #frameToggle { min-height: 48px; min-width: 116px; padding: 8px 17px; font-size: 13px; }
  body #buildbar { bottom: 76px; }
}
@media(max-width:650px) {
  :root { --hud-edge: max(10px,env(safe-area-inset-left)); }
  #commandNav { top: max(10px,env(safe-area-inset-top)); }
  body #commandNav #btnMenu { padding: 6px 10px; }
  body #commandNav #btnMenu::before { margin-right: 8px; }
  #commandNav .hud-nav-link { display: none; }
  body #hud .panel.gold { top: max(10px,env(safe-area-inset-top)); left: auto; right: 10px; transform: none; min-height: 48px; }
  body #hud .gold::before { font-size: 20px; }
  body #btnFullscreen, body:not(.admin-mode) #btnFullscreen { top: 70px; }
  body #hud { top: 118px; left: 10px; right: 170px; }
  body #overlay { padding: 12px; }
  body #overlay .card { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 28px 24px; }
  body #overlay .card::before { font-size: 8px; letter-spacing: 1.4px; margin-bottom: 20px; }
  body #overlay .card h1 { font-size: clamp(25px,7.8vw,42px); }
  body #buildbar { gap: 5px; padding: 28px 7px 7px; max-width: calc(100vw - 20px); width: calc(100vw - 20px); overflow-x: auto; }
  body #buildbar button.build-card { flex: 1 0 72px; width: auto; }
  body .build-detail { font-size: 8px; }
  body #touchControls { left: 10px; right: 10px; max-width: calc(100vw - 20px); }
  body #ctxmenu .production-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  body #ctxmenu .production-card canvas { height: 50px; }
  body #ctxmenu .build-name { font-size: 10px; padding: 5px; }
  body #ctxmenu .build-cost { font-size: 11px; padding: 0 5px 5px; }
}
@media(max-height:540px) and (min-width:651px) {
  body #overlay { padding: 12px; }
  body #overlay .card { width: min(700px,calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 16px 28px; }
  body #overlay .card::before { margin-bottom: 8px; }
  body #overlay .card h1 { font-size: 28px; margin-bottom: 6px; }
  body #overlay .card p { font-size: 12px; }
  body #overlay .diff-row { margin-top: 8px; }
  body #loadingPanel { margin: 10px 0; padding: 10px 14px; }
  body .start-actions { grid-template-columns: 1fr 1fr; }
  body .start-actions #ovBtn { min-height: 44px; }
  body #ovInfoBtn { margin-top: 2px; padding: 5px 0; }
  body #buildbar .build-portrait { height: 48px; }
  body #buildbar .build-detail { min-height: 24px; }
  body #buildbar button.build-card { width: 120px; }
  body #ctxmenu { max-height: calc(100dvh - 100px); }
}

/* Reference HUD: cut metal edges, a double illuminated rim and actual pictograms. */
:root {
  --hud-surface:
    radial-gradient(ellipse at 50% 0%, #29729830, transparent 62%),
    linear-gradient(115deg, #061924ed, #031019f2 68%, #092534ed);
  --hud-cut: polygon(10px 0,calc(100% - 10px) 0,100% 10px,100% calc(100% - 10px),calc(100% - 10px) 100%,10px 100%,0 calc(100% - 10px),0 10px);
}
#commandNav, body #hud .panel.gold, body #buildToggle, body #frameToggle,
body #fpsBadge, body #buildbar, body #touchControls, body #ctxmenu,
body #overlay .card, body #gameMenu, body #artGallery {
  border: 0; border-radius: 0; clip-path: var(--hud-cut);
  background: var(--hud-surface);
  box-shadow: inset 0 0 22px #40bfff19, inset 0 1px #c2f4ff5c;
}
#commandNav::after, body #hud .panel.gold::after, body #buildToggle::after,
body #frameToggle::after, body #fpsBadge::after, body #buildbar::after,
body #touchControls::after, body #ctxmenu::after, body #overlay .card::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  border: 16px solid transparent; border-image: url(hud-frame.svg) 16 fill stretch;
}
/* A pseudo-frame on a scrolling dialog would move with its contents. */
body #gameMenu, body #artGallery { border: 2px solid #71c8e5; }
#commandNav { padding: 7px 14px; }
body #commandNav #btnMenu, #commandNav button {
  font-family: "Bahnschrift", "Arial Narrow", "sans-serif-condensed", sans-serif;
  font-weight: 400; font-size: 18px; letter-spacing: .2px; padding: 6px 14px;
}
body #commandNav #btnMenu { display: flex; align-items: center; gap: 22px; }
body #commandNav #btnMenu::before {
  content: ''; width: 28px; height: 28px; margin: 0; flex: 0 0 28px;
  background: url(hud-menu.svg) center/contain no-repeat;
}
#commandNav button + button { border: 0; }
#commandNav .hud-nav-link { position: relative; padding-left: 20px; }
#commandNav .hud-nav-link::before { content: '·'; position: absolute; left: 1px; color: #81bdd2; }
body #hud .panel.gold {
  padding: 9px 22px; gap: 12px; min-height: 56px; font-size: 18px;
  font-family: "Bahnschrift", "Arial Narrow", "sans-serif-condensed", sans-serif;
}
body #hud .gold::before {
  content: ''; display: inline-block; width: 32px; height: 32px; margin: 0 5px 0 0;
  background: url(hud-gold.svg) center/contain no-repeat; filter: drop-shadow(0 1px 2px #0008);
}
body #hud .gold b { font-size: 25px; color: #ffdb94; }
body #buildToggle, body #frameToggle {
  min-width: 176px; min-height: 68px; padding: 12px 24px;
  font-family: "Bahnschrift", "Arial Narrow", "sans-serif-condensed", sans-serif;
  font-size: 19px; font-weight: 400; letter-spacing: .3px;
}
body #buildToggle::before, body #frameToggle::before {
  content: ''; display: inline-block; width: 36px; height: 36px; border: 0;
  margin: 0 20px 0 0; vertical-align: middle; background: url(hud-factory.svg) center/contain no-repeat;
  filter: drop-shadow(0 0 4px #5acbff55);
}
body #frameToggle::before { background-image: url(hud-selection.svg); }
body #fpsBadge {
  min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 6px 18px; font: 16px "Bahnschrift","Arial Narrow","sans-serif-condensed",sans-serif;
}
body #fpsBadge.hidden { display: none; }
body #fpsBadge::before {
  content: ''; width: 25px; height: 25px; margin: 0;
  background: url(hud-signal.svg) center/contain no-repeat;
}
body #buildbar { bottom: max(94px,calc(env(safe-area-inset-bottom) + 78px)); }
body #overlay .card {
  background: radial-gradient(ellipse at 50% 0,#1d526342,transparent 60%),linear-gradient(135deg,#071b28f5,#030d17f5);
  text-align: center;
}
body #overlay .diff-row { justify-content: center; }
body #overlay .card::before { color: #9bddf2; }
body #overlay { background: linear-gradient(#030d16a1,#020b15c9),url(menu-background.png) center/cover no-repeat; }
body .start-actions #ovBtn { background: linear-gradient(110deg,#163e53,#256583 50%,#13364a); }
body .touch-actions button {
  position: relative; border: 1px solid #3c7f98; border-bottom: 2px solid #83c7dd;
  background: linear-gradient(150deg,#103044d9,#061923ed); font-weight: 500;
}
body .touch-actions button[aria-pressed="true"] { background: linear-gradient(#235a72,#10374b); box-shadow: inset 0 0 16px #79ddff30; }
body #touchControls { padding: 12px 12px 11px; gap: 8px; }
body .touch-status { font-size: 10px; font-weight: 500; letter-spacing: 1px; color: #acdff1; }
/* The selection deck replaces the lower shortcuts, leaving no unused row. */
body.hud-command-active #buildToggle, body.hud-command-active #frameToggle { display: none !important; }
body.hud-build-open #frameToggle { display: none !important; }
body.hud-command-active #touchControls {
  bottom: max(6px,env(safe-area-inset-bottom)) !important;
  left: max(10px,env(safe-area-inset-left)); right: auto;
}
@media(max-width:1000px) {
  #commandNav { padding: 6px 9px; }
  body #commandNav #btnMenu,#commandNav button { font-size: 14px; padding: 5px 10px; min-height: 38px; }
  body #commandNav #btnMenu { gap: 13px; }
  body #commandNav #btnMenu::before { width: 24px; height: 24px; flex-basis: 24px; }
  #commandNav .hud-nav-link { padding-left: 15px; }
  body #hud .panel.gold { min-height: 50px; font-size: 15px; padding: 7px 15px; gap: 10px; }
  body #hud .gold::before { width: 27px; height: 27px; margin-right: 2px; }
  body #hud .gold b { font-size: 22px; }
  body #buildToggle,body #frameToggle { min-width: 130px; min-height: 54px; font-size: 15px; padding: 10px 17px; }
  body #buildToggle::before,body #frameToggle::before { width: 28px; height: 28px; margin-right: 14px; }
  body #fpsBadge { min-height: 34px; font-size: 13px; padding: 5px 13px; }
  body #fpsBadge::before { width: 20px; height: 20px; }
  body #buildbar { bottom: max(80px,calc(env(safe-area-inset-bottom) + 64px)); }
}
@media(max-width:650px) {
  body #commandNav #btnMenu { gap: 10px; }
  body #commandNav #btnMenu::before { margin: 0; }
  body #hud .gold::before { width: 27px; height: 27px; }
  body #overlay .card { padding: 28px 24px; }
  body.hud-command-active #touchControls { right: max(10px,env(safe-area-inset-right)); max-width: none; }
  body #touchControls { padding: 10px 9px 9px; }
  body .touch-status { font-size: 9px; letter-spacing: .6px; }
}
@media(max-height:540px) and (min-width:651px) {
  body #overlay .card { padding: 16px 28px; }
}

/* Persistent frame switch: no instruction deck while dragging a selection. */

body.hud-box-active #touchControls { display: none !important; }
body.hud-box-active #frameToggle { display: block !important; }
body.hud-box-active #frameToggle[aria-pressed="true"] {
  background: radial-gradient(ellipse at center,#387e9b85,#082737 76%);
  color: #e2f9ff; text-shadow: 0 0 8px #72dfff70;
}
body.hud-start #frameToggle { display: none !important; }

/* Compact phone HUD: preserve usable touch targets while reducing the chrome. */
@media (max-width:1000px), (pointer:coarse) {
  :root { --hud-edge: max(8px,env(safe-area-inset-left)); }
  #commandNav { top:max(8px,env(safe-area-inset-top)); padding:2px 6px; }
  body #commandNav #btnMenu,#commandNav button { min-height:36px; font-size:12px; padding:4px 8px; }
  body #commandNav #btnMenu { gap:8px; }
  body #commandNav #btnMenu::before { width:20px; height:20px; flex-basis:20px; }
  #commandNav .hud-nav-link { padding-left:12px; }
  body #hud .panel.gold { top:max(8px,env(safe-area-inset-top)); min-height:40px; padding:5px 12px; gap:7px; font-size:12px; }
  body #hud .gold::before { width:23px; height:23px; margin-right:1px; }
  body #hud .gold b { font-size:18px; }
  body #buildToggle,body #frameToggle { min-width:100px; min-height:42px; font-size:12px; padding:8px 12px; bottom:max(8px,env(safe-area-inset-bottom)) !important; }
  body #frameToggle { right:max(8px,env(safe-area-inset-right)) !important; }
  body #buildToggle::before,body #frameToggle::before { width:22px; height:22px; margin-right:9px; }
  body #fpsBadge { right:max(8px,env(safe-area-inset-right)) !important; min-width:70px; min-height:28px; font-size:11px; padding:4px 10px; gap:7px; }
  body #fpsBadge::before { width:16px; height:16px; }
  body #buildbar { bottom:max(58px,calc(env(safe-area-inset-bottom) + 50px)); padding:23px 7px 7px; gap:5px; }
  body #buildbar::before { top:8px; font-size:8px; letter-spacing:1.4px; }
  body #buildbar button.build-card { width:100px; }
  body #buildbar .build-portrait { height:40px; }
  body #buildbar .build-name { font-size:9px; padding:4px 5px 2px; }
  body #buildbar .build-detail { font-size:8px; min-height:22px; padding:0 5px 4px; }
  body #ctxmenu { width:min(230px,calc(100vw - 16px)); padding:6px; gap:5px; }
  body #ctxmenu .production-card canvas { height:40px; }
  body #touchControls { padding:8px; gap:5px; }
  body .touch-actions button { min-height:40px; font-size:11px; padding:6px 9px; }
  body .touch-status { font-size:9px; letter-spacing:.4px; }
  body #btnFullscreen,body:not(.admin-mode) #btnFullscreen { top:56px; font-size:10px; padding:6px 9px; }
}
@media(max-width:650px) {
  body #buildbar button.build-card { flex:1 0 65px; width:auto; }
}

/* A single compact action to clear the entire current unit selection. */
body #clearSelection {
  position:fixed; z-index:9; display:grid; place-items:center;
  right:calc(max(16px,env(safe-area-inset-right)) + var(--hud-frame-width,200px) + 8px);
  bottom:max(16px,env(safe-area-inset-bottom));
  width:48px; height:48px; min-width:0; min-height:0; padding:0; margin:0;
  color:var(--hud-text); background:var(--hud-surface);
  border:1px solid var(--hud-cyan); border-radius:3px 10px 3px 10px;
  box-shadow:var(--hud-shadow); font:30px/1 "Segoe UI",sans-serif; cursor:pointer;
}
body #clearSelection[hidden] { display:none !important; }
body #clearSelection:hover { color:white; border-color:white; }
body #clearSelection:active { background:#16475b; }
@media (max-width:1000px), (pointer:coarse) {
  body #clearSelection {
    right:calc(max(8px,env(safe-area-inset-right)) + var(--hud-frame-width,110px) + 8px);
    bottom:max(8px,env(safe-area-inset-bottom)); width:42px; height:42px; font-size:27px;
  }
}

/* Keep the FPS reading, remove only its decorative signal icon. */
body #fpsBadge::before { content:none !important; display:none !important; }
body #fpsBadge { gap:0; }
/* Keep Info reachable inside short Android landscape windows. */
body.android #overlay .card { box-sizing:border-box; }
@media (max-height:540px) {
 body.android #overlay .card { display:grid;grid-template-columns:1fr 1fr;gap:8px 18px;padding:14px 20px !important;max-height:calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
 body.android #overlay .card::before,body.android #ovTitle,body.android #ovText { grid-column:1/-1; }
 body.android #overlay .card::before { margin:0; }
 body.android #ovTitle { font-size:24px;margin:0; }
 body.android #ovText { margin:0;font-size:11px;line-height:1.4; }
 body.android #overlay .diff-row { margin:0;align-content:center;gap:5px; }
 body.android #overlay .diff-label { margin:0;font-size:9px; }
 body.android #overlay .diff-btn { min-height:36px;padding:6px;font-size:11px; }
 body.android #loadingPanel { margin:0;padding:8px; }
 body.android .start-actions { grid-column:1/-1;grid-template-columns:1fr 1fr;gap:8px; }
 body.android .start-actions #ovBtn,body.android .start-actions #ovLoadBtn { min-height:40px;padding:7px;font-size:12px; }
 body.android #ovInfoBtn { grid-column:1/-1;position:relative;z-index:1;margin:0;min-height:36px;padding:6px; }
}

body.android #ovInfo { grid-column:1/-1; }

/* Keep debug statistics and the animation launcher off the battlefield in every mode. */
body #hud .panel:not(.gold),body.admin-mode #hud .panel:not(.gold),body #btnAtlas,body.admin-mode #btnAtlas,body #cmdHelp{display:none!important}
/* A scrolling menu must own its border; a positioned decoration scrolls over cards. */
body #ctxmenu{border:2px solid #71c8e5;border-radius:8px;clip-path:none;box-sizing:border-box;overflow:auto;overscroll-behavior:contain;max-height:calc(100dvh - 100px)}
body #ctxmenu::after{content:none!important;display:none!important}
