/* A single field instrument; the viewport already accounts for safe insets. */
#navigation-hud {
  position:absolute; inset:0; min-width:0; min-height:0;
  display:block; padding:0; border:0; pointer-events:none;
  background:none; box-shadow:none;
  font:400 12px/1.3 "Segoe UI",system-ui,sans-serif; letter-spacing:0; color:#c5c6b7;
}
#navigation-hud #compass {
  position:absolute; inset:18px auto auto 50%; transform:translateX(-50%); width:104px; height:104px; min-width:44px; min-height:44px;
  padding:0; border:1px solid #a18c5e; outline:0; border-radius:50%; overflow:hidden;
  background:radial-gradient(circle,#080f10 56%,#252c26 57%,#121b1a 70%);
  box-shadow:inset 0 1px 1px #ead6a277,inset 0 -2px 2px #000,0 0 0 2px #101817,0 0 0 3px #685c40,0 5px 12px #000b;
  pointer-events:auto; cursor:pointer;
}
#navigation-hud #compass::before {
  content:""; position:absolute; inset:4px; border-radius:50%; pointer-events:none;
  background:repeating-conic-gradient(#ab956777 0deg 1deg,transparent 1deg 15deg);
  mask-image:radial-gradient(circle,transparent 65%,#000 67% 72%,transparent 74%);
}
#navigation-hud #compass::after { content:""; position:absolute; inset:10px; border:1px solid #a18c5e77; border-radius:50%; pointer-events:none; box-shadow:inset 0 0 5px #000; }
#navigation-hud #minimap { width:80px; height:80px; border-radius:50%; box-shadow:none; image-rendering:auto; pointer-events:none; }
#navigation-hud .cardinal { display:grid; place-items:center; width:12px; height:12px; background:#111a18; border-radius:50%; color:#ead7af; font:700 11px/12px "Segoe UI",system-ui,sans-serif; text-shadow:0 1px 2px #000; z-index:2; }
#navigation-hud .cardinal.north { top:1px; color:#f1d8a2; }
#navigation-hud .cardinal.east { right:1px; }
#navigation-hud .cardinal.south { bottom:1px; }
#navigation-hud .cardinal.west { left:1px; }
.navigation-key { position:absolute; right:14px; bottom:14px; z-index:2; color:#b3a17b; font:9px/1 "Segoe UI",system-ui,sans-serif; pointer-events:none; }
#navigation-hud #compass:focus-visible { outline:2px solid #d2b57b; outline-offset:3px; }
#navigation-hud #floor-status {
  position:absolute; inset:18px 18px auto auto; transform:none; width:146px; min-width:0; padding:0 0 0 6px; border:0; border-left:1px solid #9c865b66; box-shadow:none;
  display:flex; flex-direction:column; align-items:stretch; justify-content:center; gap:2px;
  font:400 12px/1.3 "Segoe UI",system-ui,sans-serif; letter-spacing:0;
  background:linear-gradient(90deg,#0a1212ed,#0a1212b8 75%,#0a121200); text-shadow:0 1px 2px #000;
}
#navigation-hud #floor-label { color:#dfcfad; font:400 19px/1.15 Georgia,serif; }
#navigation-facing { color:#969e92; font-size:11px; margin-bottom:3px; }
#navigation-hud .hud-badge {
  min-width:0; min-height:44px; width:100%; padding:4px 0; justify-content:flex-start; gap:6px;
  border-top:1px solid #85734d26; border-radius:0; font:400 11px/1.2 "Segoe UI",system-ui,sans-serif; letter-spacing:0;
  box-shadow:none; outline:none; background:none; transform:none; pointer-events:auto;
}
#navigation-hud .hud-badge::after { display:none; }
#navigation-hud .hud-badge:focus-visible { outline:2px solid #c9ad75; outline-offset:0; }
#navigation-hud .hud-badge-text { white-space:normal; overflow-wrap:anywhere; }
#navigation-hud .hud-badge[aria-expanded="true"] :is(.navigation-badge-caption,.danger-label) { display:none; }
#navigation-hud .danger-label { font-size:10px; font-weight:400; }
#navigation-hud .danger-skulls { gap:1px; }
#navigation-hud .danger-skulls svg { width:10px; height:10px; }
#navigation-hud #miasma-status { color:#9da98c; text-shadow:none; }
#navigation-hud #danger-status { text-shadow:none; }
#navigation-hud #danger-status[data-tier="4"] { color:#c78d73; }
#navigation-hud #danger-status[data-tier="5"] { color:#dba08b; }
#navigation-hud #danger-status .danger-skulls svg { filter:none; }

#map-modal { width:min(1000px,calc(100vw - 48px - var(--edge-left) - var(--edge-right))); height:min(740px,calc(100dvh - 48px - var(--edge-top) - var(--edge-bottom))); max-height:none; display:flex; flex-direction:column; gap:16px; }
#map-modal .rpg-window-header { min-height:48px; padding-bottom:10px; }
#map-modal .rpg-window-header > div { min-width:0; }
#map-modal h2 { font-size:29px; }
.map-window-body { flex:1; min-height:0; display:grid; grid-template-columns:minmax(0,1fr) 158px; gap:20px; }
.map-chart { position:relative; min-width:0; min-height:0; border:1px solid #78664655; border-radius:4px; background:#091113; overflow:hidden; }
#expanded-map { width:100%; height:100%; image-rendering:auto; }
.map-cardinal { position:absolute; display:grid; place-items:center; width:16px; height:16px; border-radius:2px; background:#091113; color:#ead7af; font:700 12px/16px "Segoe UI",system-ui,sans-serif; pointer-events:none; }
.map-north { top:4px; left:50%; transform:translateX(-50%); }
.map-east { right:4px; top:50%; transform:translateY(-50%); }
.map-south { bottom:4px; left:50%; transform:translateX(-50%); }
.map-west { left:4px; top:50%; transform:translateY(-50%); }
.map-key { min-height:0; overflow:auto; padding-right:4px; scrollbar-width:thin; }
.map-key:focus-visible { outline:2px solid #b9a273; outline-offset:-2px; }
#map-modal .map-key h3 { margin:0 0 12px; font-size:18px; }
.map-key ul { display:flex; flex-direction:column; gap:12px; list-style:none; padding:0; margin:0; }
.map-key li { display:flex; align-items:center; gap:9px; margin:0; padding:0; background:none; border:0; font-size:12px; color:#c6c5b5; }
.map-key p { color:#929e90; font-size:11px; margin:18px 0 0; }
.map-symbol { width:12px; height:12px; flex:none; display:inline-block; position:relative; }
.map-symbol-you { background:#e4d6ae; clip-path:polygon(50% 0,100% 100%,50% 70%,0 100%); }
.map-symbol-stairs { border-left:2px solid #c4a170; border-right:2px solid #c4a170; background:repeating-linear-gradient(transparent 0 3px,#c4a170 3px 5px); }
.map-symbol-door { border:2px solid #a9895b; background:#3b2e21; }
.map-symbol-chest { height:9px; border:1px solid #dfc68c; background:linear-gradient(transparent 45%,#654826 45% 60%,transparent 60%),#bda16a; }
.map-symbol-shrine { width:10px; height:10px; border-radius:50%; border:2px solid #c0cebc; background:#748c7b; margin-inline:1px; }
.map-symbol-threat { width:9px; height:9px; transform:rotate(45deg); background:#bb7465; border:1px solid #e1ac93; margin-inline:1px 2px; }
.map-symbol-player { width:7px; height:7px; background:#78a9b4; margin-inline:2px 3px; }
.map-symbol-way-on { height:2px; margin-block:5px; background:repeating-linear-gradient(90deg,#8fd3c8 0 3px,transparent 3px 5px); }
.map-symbol-explored-out { border:2px solid #9a9273; background:repeating-linear-gradient(-45deg,#262d2a 0 2px,#5c635b 2px 3px); }
.map-symbol-route { height:2px; margin-block:5px; background:repeating-linear-gradient(90deg,#f0d58c 0 4px,transparent 4px 7px); }
.map-symbol-thread { height:3px; margin-block:4px; border-radius:2px; background:#c9a6ff; box-shadow:0 0 0 1px #1b1426; }
/* What a tap on the chart plotted, in the corner the cardinal marks leave free. */
.map-route-status { position:absolute; left:8px; bottom:8px; max-width:calc(50% - 22px); margin:0; padding:4px 7px; border-radius:3px; background:#091113e0; color:#e9d9b1; font:600 11px/1.3 "Segoe UI",system-ui,sans-serif; pointer-events:none; }
@media (hover:hover) and (pointer:fine) {
  #navigation-hud #compass:hover { border-color:#c4a46c; background:#141d1b; }
}
@media (hover:none), (pointer:coarse) { .navigation-key { display:none; } }
@media (orientation:landscape) {
  #dungeon-hud:has(#navigation-hud:not(.hidden)) #player-hud { max-width:calc(50% - 76px); min-width:0; }
}
@media (orientation:landscape) and (max-height:540px) {
  #dungeon-hud:has(#navigation-hud:not(.hidden)) #player-hud { left:12px; max-width:calc(50% - 68px); }
  #navigation-hud #compass { top:12px; width:88px; height:88px; }
  #navigation-hud #floor-status { top:12px; right:12px; width:112px; }
  #navigation-hud #minimap { width:64px; height:64px; }
  #navigation-hud #floor-label { font-size:17px; }
  #navigation-facing { font-size:10px; margin-bottom:1px; }
  #navigation-hud .hud-badge { gap:4px; font-size:11px; }
  #navigation-hud .danger-skulls svg { width:9px; height:9px; }
  #map-modal { gap:10px; padding:18px 22px; height:calc(100dvh - 24px - var(--edge-top) - var(--edge-bottom)); }
  #map-modal h2 { font-size:24px; }
  #map-modal .rpg-window-header { min-height:44px; padding-bottom:6px; }
  .map-window-body { gap:14px; grid-template-columns:minmax(0,1fr) 140px; }
  .map-key ul { gap:8px; }
  .map-key p { margin-top:12px; }
}
@media (orientation:portrait) and (max-width:600px) {
  #dungeon-hud:has(#navigation-hud:not(.hidden)) #player-hud { max-width:calc(100% - 112px); min-width:0; }
  #navigation-hud { top:140px; }
  #dungeon-hud:has(#player-hud.squad-mode) #navigation-hud { top:242px; }
  #navigation-hud #compass { top:0; width:88px; height:88px; }
  #navigation-hud #floor-status { top:0; right:12px; width:112px; }
  #navigation-hud #minimap { width:64px; height:64px; }
  #map-modal { padding:20px; gap:12px; }
  .map-window-body { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto; gap:12px; }
  .map-key { max-height:142px; }
  .map-key ul { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  #map-modal .map-key h3 { display:none; }
  .map-key p { margin-top:10px; }
}
/* Keep exact HP above its bar when the centred dial leaves a narrow party lane. */
@media (orientation:landscape) and (max-width:760px) and (max-height:540px) {
  #dungeon-hud:has(#navigation-hud:not(.hidden)) #player-hud.squad-mode .squad-row-body { grid-template-columns:1.8fr 1fr 1fr; column-gap:6px; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-meter-hp { display:grid; grid-template-columns:16px minmax(0,1fr); gap:2px 3px; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-meter-hp .squad-meter-label { grid-column:1; grid-row:1; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-meter-hp .squad-meter-value { grid-column:2; grid-row:1; font:600 10px/1.1 "Segoe UI",system-ui,sans-serif; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-meter-hp .squad-meter-track { grid-column:1 / -1; grid-row:2; width:100%; min-width:0; height:3px; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-resources .squad-meter-label { flex-basis:14px; }
  #dungeon-hud:has(#navigation-hud:not(.hidden)) .squad-resources .squad-meter-track { min-width:0; }
}
