/* The TAB latch stays beside the radar while its menu opens below it. */
body.visor #hud:has(#minimap:not([hidden])) #menubar,
body.visor #hud:has(#minimap:not([hidden])) #menubar:not(.folded),
body.visor.pad-mode #hud:has(#minimap:not([hidden])) #menubar:not(.folded) {
  display: block; width: 44px; height: 44px; padding: 0; max-height: none;
  top: calc(var(--hud-edge) + var(--st)); overflow: visible;
  border: 0 !important; border-image: none !important; background: none !important;
  border-radius: 0 !important; box-shadow: none !important;
}
body.visor #hud #menubar::before, body.visor #hud #menubar::after { content: none !important; }
body.visor #hud:has(#minimap:not([hidden])) #menubar .menu-fold,
body.visor #hud:has(#minimap:not([hidden])) #menubar.folded .menu-fold,
body.visor #hud:has(#minimap:not([hidden])) #menubar:not(.folded) .menu-fold,
body.visor.pad-mode #hud:has(#minimap:not([hidden])) #menubar:not(.folded) .menu-fold {
  position: absolute; inset: 0; width: 44px; height: 44px; padding: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid #bb904e; border-radius: 8px; color: #f4d49a;
  background: linear-gradient(180deg, #68482b, #322015);
  box-shadow: inset 0 1px 0 #d6b16c66, 0 3px 8px #160b0799; filter: none;
}
body.visor #hud #menubar .menu-fold::before { content: none; }
body.visor #hud #menubar .menu-fold::after { inset: 0; }
body.visor #hud #menubar .menu-fold svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; }
body.visor #hud #menubar .menu-fold span { font: 700 8px/1 var(--f-num); letter-spacing: .1em; color: inherit; text-shadow: none; }
body.visor #hud #menubar.folded .menu-close-icon,
body.visor #hud #menubar:not(.folded) .menu-open-icon { display: none; }
body.visor #hud #menubar:not(.folded) .menu-fold { color: #39200e; background: linear-gradient(180deg, #f6db9a, #c39146); }
body.visor #hud #menubar .menu-panel {
  position: absolute; top: 52px; right: 0; width: 218px; padding: 10px;
  max-height: calc(100dvh - var(--st) - var(--sb) - var(--hud-edge) - 62px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #ad8144 #302116;
  border: 1px solid #b68d53; border-radius: 10px;
  background: linear-gradient(160deg, #483423f7, #211810fa);
  box-shadow: inset 0 1px 0 #edcd9440, 0 10px 26px #0c080999;
  animation: menu-unfold 140ms ease-out; transform-origin: top right;
}
body.visor #hud #menubar.folded .menu-panel { display: none; }
body.visor #hud #menubar .menu-heading { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; font: 600 11px/1.4 var(--f-body); color: #edcf99; text-shadow: none; }
body.visor #hud #menubar .menu-heading::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, #b68d5377, transparent); }
body.visor #hud #menubar .menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
body.visor #hud #menubar .menu-grid > button {
  position: relative; width: 100%; height: 56px; min-width: 0; padding: 5px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid #b68d533b; border-image: none; border-radius: 6px;
  color: #e6c58b; background: linear-gradient(180deg, #76543733, #b48a5110); box-shadow: none; filter: none;
}
body.visor #hud #menubar .menu-grid > button svg { width: 22px; height: 22px; }
body.visor #hud #menubar .menu-grid > button span { color: #f1e1c3; font: 500 10px/1.2 var(--f-body); text-shadow: none; }
body.visor #hud #menubar .menu-grid > button small { display: block; position: absolute; top: 3px; right: 4px; font: 500 8px/1 var(--f-num); color: #c3a475; }
body.visor #hud #menubar .menu-grid > button:hover,
body.visor #hud #menubar .menu-grid > button:focus-visible { background: #ae824133; border-color: #ddbc79; outline: 2px solid #ddbc79; outline-offset: -2px; }
body.visor #hud #menubar .menu-grid > button.on { background: linear-gradient(180deg, #f5d99a, #c59249); color: #39200e; border-color: #f5d99a; }
body.visor #hud #menubar .menu-grid > button.on span,
body.visor #hud #menubar .menu-grid > button.on small { color: #39200e !important; }
@keyframes menu-unfold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (pointer: coarse) { body.visor #hud #menubar .menu-grid > button small { display: none; } }
@media (orientation: landscape) and (max-height: 520px) {
  body.visor #hud #menubar .menu-panel { width: 208px; padding: 8px; }
  body.visor #hud #menubar .menu-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  body.visor #hud #menubar .menu-grid > button { height: 48px; }
  body.visor #hud #menubar .menu-grid > button svg { width: 19px; height: 19px; }
  body.visor #hud #menubar .menu-grid > button span { font-size: 9px; }
}
@media (orientation: portrait) and (max-width: 760px) {
  body.visor #hud #menubar .menu-panel {
    top: calc(var(--hud-map-width) + 64px); right: calc(-1 * (var(--hud-map-width) + 28px));
    width: min(280px, calc(100vw - var(--sl) - var(--sr) - 16px));
    max-height: calc(100dvh - var(--st) - var(--sb) - var(--hud-map-width) - 88px);
  }
}
@media (prefers-reduced-motion: reduce) { body.visor #hud #menubar .menu-panel { animation: none; } }
