/* Native mobile menu and five editable shortcuts. Desktop remains untouched. */
html.mobile-hud #world-hud {
  --mobile-rail-surface:rgb(14 13 11 / .85);
  --mobile-rail-edge:#e5ceb13b;
  --mobile-nav-safe-left:max(8px,env(safe-area-inset-left));
  --mobile-nav-safe-right:max(8px,env(safe-area-inset-right));
}
@media (orientation:landscape) {
  html.mobile-hud #world-hud {
    --hud-left:var(--mobile-nav-safe-left);
    --hud-right:var(--mobile-nav-safe-right);
  }
  html.mobile-hud #world-hud .hud-status-stack:has(#player-hud-grip) {
    --player-hud-left:var(--hud-left);
  }
}
html.mobile-hud #world-hud #mobile-navigation {
  position:fixed;
  inset:0;
  z-index:8;
  pointer-events:none;
  margin:0;
  padding:0;
  border:0;
  background:none;
  box-shadow:none;
  color:#ece7dc;
  font:400 12px/1.2 "Segoe UI",Arial,sans-serif;
  --mobile-nav-safe-top:max(4px,env(safe-area-inset-top));
  --mobile-nav-safe-bottom:max(8px,env(safe-area-inset-bottom));
  --mobile-nav-rail-step:clamp(32px,calc((100dvh - var(--mobile-nav-safe-top) - var(--mobile-nav-safe-bottom)) / 7),44px);
}
html:not(.mobile-hud) #mobile-navigation,
html.mobile-hud #world-hud #mobile-navigation[hidden],
html.mobile-hud #world-hud #mobile-navigation [hidden] {display:none!important}
html.mobile-hud #world-hud #mobile-navigation * {box-sizing:border-box}
html.mobile-hud #world-hud #mobile-navigation button {
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:none;
  box-shadow:none;
  color:inherit;
  font:inherit;
  text-shadow:none;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
html.mobile-hud #world-hud #mobile-navigation button:focus-visible {outline:2px solid #ead8b1;outline-offset:-2px}
html.mobile-hud #world-hud #mobile-navigation button:disabled {opacity:.45;cursor:default}
html.mobile-hud #world-hud #mobile-navigation svg {display:block;flex:none;width:20px;height:20px;pointer-events:none}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-native {
  --native-size:27px;
  display:block;
  flex:none;
  width:var(--native-size);
  height:var(--native-size);
  background:transparent url('samurai-pc-menu.png') no-repeat;
  background-size:calc(8 * var(--native-size)) calc(4 * var(--native-size));
  background-position:calc(-1 * var(--native-col) * var(--native-size)) calc(-1 * var(--native-row) * var(--native-size));
  pointer-events:none;
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail {
  position:fixed;
  z-index:2;
  top:var(--mobile-nav-safe-top);
  right:var(--mobile-nav-safe-right);
  display:grid;
  grid-template-columns:44px;
  pointer-events:auto;
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-slots {display:grid;grid-template-rows:repeat(5,var(--mobile-nav-rail-step));height:calc(5 * var(--mobile-nav-rail-step));overflow:visible}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button {
  position:relative;
  isolation:isolate;
  display:grid;
  place-items:center;
  width:44px;
  min-width:44px;
  height:var(--mobile-nav-rail-step);
  min-height:var(--mobile-nav-rail-step);
  color:#ead8b1;
  pointer-events:auto;
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button::before {
  position:absolute;
  z-index:-1;
  inset:4px;
  border:1px solid var(--mobile-rail-edge);
  border-radius:5px;
  background:var(--mobile-rail-surface);
  content:"";
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button:active::before,
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button[aria-expanded=true]::before {border-color:#e6c88e;background:#3c301af5}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-fixed-chat {color:#17120c}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-fixed-chat::before {border-color:#ffe3a4;background:#e9c486}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-fixed-chat:is(:active,[aria-expanded=true])::before {background:#ffdc9c}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-empty {height:var(--mobile-nav-rail-step);pointer-events:none}
html.mobile-hud #world-hud #mobile-navigation[data-editing=true] .mobile-nav-empty {margin:8px;border:1px dashed #e5ceb13b;border-radius:4px}
html.mobile-hud #world-hud #mobile-navigation[data-editing=true] .mobile-nav-slots .mobile-nav-rail-button {touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none}
html.mobile-hud #world-hud #mobile-navigation[data-editing=true] .mobile-nav-slots .mobile-nav-rail-button::after {
  position:absolute;right:5px;top:16px;width:4px;height:12px;
  background:radial-gradient(circle,#ebcc957d .75px,transparent 1px) 0 0/4px 4px;pointer-events:none;content:"";
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-slots[data-dragging] .mobile-nav-rail-button {transform:translateY(var(--mobile-nav-offset,0px));transition:transform 90ms ease}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button[data-lifted] {z-index:3;cursor:grabbing;transition:none!important}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button[data-lifted]::before {border-color:#edca8c;background:#65491e}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-rail-button[data-outside] {opacity:.6}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-backdrop {
  position:fixed;
  inset:0;
  display:grid;
  place-items:center;
  padding:calc(var(--mobile-nav-safe-top) + 4px) calc(var(--mobile-nav-safe-right) + 52px) var(--mobile-nav-safe-bottom) var(--mobile-nav-safe-left);
  background:rgb(0 0 0 / .4);
  pointer-events:auto;
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-panel {
  display:grid;
  grid-template-rows:44px 44px auto minmax(0,1fr) 44px;
  width:min(424px,100%);
  height:min(306px,100%);
  min-height:0;
  overflow:hidden;
  border-radius:6px;
  background:#1b1b1a;
  box-shadow:0 0 0 1px #ede0bf32;
}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-header {grid-row:1;display:flex;align-items:center;gap:3px;min-width:0;padding:0 5px 0 12px;border-bottom:1px solid #ffffff15}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-header h2 {margin:0;color:#ead8b1;font:600 14px/1 "Segoe UI",Arial,sans-serif}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit {display:flex;align-items:center;gap:4px;margin-left:auto;min-height:44px;padding:0 5px;color:#ead8b1;font-size:11px;white-space:nowrap}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit svg {width:14px;height:14px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit[aria-pressed=true] {color:#ffdf9e}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-close {display:grid;place-items:center;flex:none;width:44px;height:44px;color:#ead8b1}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tabs {grid-row:2;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));min-width:0;border-bottom:1px solid #ffffff20}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tab {min-width:0;min-height:44px;color:#d7cfc1;font-size:11px;font-weight:600}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tab[aria-selected=true] {box-shadow:inset 0 -2px #dfbc80;background:#e2b97012;color:#ffe4af}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit-hint {grid-row:3;display:flex;align-items:baseline;gap:8px;margin:0;padding:4px 9px;background:#e9ba7910;color:#e6d4b5;font-size:11px;line-height:1.25}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit-count {flex:none;color:#ffe4af;font-variant-numeric:tabular-nums}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-body {grid-row:4;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#4f4c44 transparent;padding:6px 8px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-grid {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;align-content:start}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile {position:relative;display:grid;justify-items:center;align-content:center;gap:2px;min-width:0;min-height:46px;padding:3px;border-radius:4px;background:#ffffff07;font-size:11px;line-height:1.12;text-align:center;overflow-wrap:anywhere}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile .mobile-nav-native {--native-size:25px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile:active {background:#514025}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile small {color:#d1b78e;font-size:9px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile[aria-pressed=true] {background:#e2b97019;box-shadow:inset 0 0 0 1px #dfbc8080}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-pin {position:absolute;top:2px;right:3px;display:grid;place-items:center;width:16px;height:16px;border-radius:50%;background:#0b0b0bd0;color:#ded5c5;font-size:11px;pointer-events:none}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-pin svg {width:12px;height:12px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tile[aria-pressed=true] .mobile-nav-pin {color:#ffdf9e}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-footer {grid-row:5;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border-top:1px solid #ffffff20;background:#161616}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session {display:flex;align-items:center;justify-content:center;gap:7px;min-width:0;min-height:44px;padding:0 3px;color:#f0d4aa;text-align:left}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session[data-mobile-nav-session=logout] {border-left:1px solid #ffffff20;color:#f5c8b9}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session:active {background:#544333}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session svg {width:17px;height:17px}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session > span {display:grid;font-weight:600}
html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session small {color:#d7cfc1;font-size:10px;font-weight:400}
/* Replace obsolete launchers only while the new navigation is actually active. */
html.mobile-hud main.in-world:not(.ui-open) #world-hud:has(#mobile-navigation[data-active=true]) .mobile-rail,
html.mobile-hud main.in-world:not(.ui-open):has(#mobile-navigation[data-active=true]) #world-ui-toggle {display:none!important}
/* The existing teleport handler and radar remain intact; this is a map-width row below it. */
html.mobile-hud #world-hud #hud-radar :is(#radar-record,#hunt-radar) {display:none}
html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]) #hud-radar {
  right:calc(var(--mobile-nav-safe-right) + 51px);
}
html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]) #hud-radar #mobile-teleport {
  --teleport-plate-height:26px;
  position:absolute;inset:calc(100% + 5px) -1px auto;isolation:isolate;
  display:flex;align-items:center;justify-content:center;gap:2px;
  width:auto;min-width:0;height:44px;min-height:44px;margin:0;padding:0 2px calc(44px - var(--teleport-plate-height));
  border:0;border-radius:4px;background:none;color:#eaf4fc;box-shadow:none;
  font:600 10px/1 "Segoe UI",Arial,sans-serif;white-space:nowrap;
}
html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]) #hud-radar #mobile-teleport::before {
  content:"";display:block;flex:none;width:13px;height:13px;
  /* The native 64px texture puts the visible icon in its upper-left quarter. */
  background:var(--teleport-icon) -2px -1.75px/27px 27px no-repeat;
}
html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]) #hud-radar #mobile-teleport::after {
  content:"";position:absolute;z-index:-1;inset:0 0 auto;height:var(--teleport-plate-height);box-sizing:border-box;
  border:1px solid #8bb8d075;border-radius:4px;background:rgb(27 56 80 / .95);pointer-events:none;
}
/* The right-handed Auto control clears the fixed rail. Preserve mirrored control positions. */
@media (orientation:landscape) {
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) #action-bar .hunt-shortcut {translate:-48px 0}
}
/* Put Attack between the center dock and the rail when their heights overlap. */
@media (orientation:landscape) and (min-width:520px) and (max-height:430px) {
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) #action-bar [data-basic-action=attack] {
    --mobile-nav-attack-size:clamp(44px,calc((100vw - var(--mobile-skill-dock-width,280px)) / 2 - var(--mobile-nav-safe-right) - 53px),calc(1.55 * var(--touch-slot)));
    position:fixed;inset:auto calc(var(--mobile-nav-safe-right) + 49px) calc(var(--hud-bottom) + 52px) auto;
    width:var(--mobile-nav-attack-size);height:var(--mobile-nav-attack-size);
  }
}
/* Clear the straight rail without covering the center skill dock on short screens. */
@media (orientation:landscape) and (min-width:520px) and (max-height:366px) {
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) {
    --mobile-nav-combat-edge:calc(var(--mobile-nav-safe-right) + 49px);
    --mobile-nav-target-end:var(--mobile-nav-combat-edge);
  }
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) #action-bar [data-basic-action=target] {
    position:fixed;inset:auto var(--mobile-nav-target-end) var(--hud-bottom) auto;
    width:clamp(44px,calc((100vw - var(--mobile-skill-dock-width,280px)) / 2 - var(--mobile-nav-target-end) - 4px),78px);
    height:44px;min-height:44px;
  }
}
@media (orientation:landscape) and (min-width:650px) and (min-height:285px) and (max-height:366px) {
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) {
    --mobile-nav-target-end:calc(var(--mobile-nav-combat-edge) + 76px);
  }
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) #action-bar [data-modifier] {
    position:fixed;inset:auto calc(var(--mobile-nav-combat-edge) + 38px) var(--hud-bottom) auto;
    width:34px;height:44px;min-height:44px;
  }
  html.mobile-hud #world-hud:has(#mobile-navigation[data-active=true]):not([data-bar-side=left]) #action-bar [data-modifier=shift] {
    right:var(--mobile-nav-combat-edge);
  }
}
@media (min-width:520px) {
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-grid[data-category=main] {grid-template-columns:repeat(5,minmax(0,1fr))}
}
@media (max-width:419px) {
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-grid {grid-template-columns:repeat(2,minmax(0,1fr))}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-header {padding-left:8px}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit {font-size:10px}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-edit svg {display:none}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-tab {font-size:10px}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session {gap:4px}
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-session small {font-size:9px}
}
@media (prefers-reduced-motion:reduce) {
  html.mobile-hud #world-hud #mobile-navigation .mobile-nav-slots[data-dragging] .mobile-nav-rail-button {transition:none}
}
