/* Touch HUD uses the existing skill, item, quest and movement handlers. */
body.touch #hud {
  --pad: 10px;
  --self-w: 208px;
  --self-h: 64px;
  --map: 86px;
  --hud-cast-bottom: calc(94px + var(--safe-b));
}

body.touch #hud:not([data-hl-moved~=self]) #hud-self {
  width: var(--self-w);
  height: var(--self-h);
  transform: none;
}

body.touch #hud #hud-self {
  --self-meter-h: 11px;
  --self-meter-font: 10px;
  --self-meter-label-w: 20px;
  --self-name-h: 15px;
  --self-lane-inset: 9px;
  --self-lane-padding: 2px;
}

body.touch #hud-self .self-ava,
body.touch #hud-self #self-ring {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

body.touch #hud-self .self-main { min-width: 0; flex: 1; }
body.touch #hud-self #self-name { font-size: 12px; }
body.touch #hud-self .self-exp { width: 100%; }

body.touch #hud:not([data-hl-moved~=map]) #hud-map {
  transform: none;
  grid-template: "btns map" auto "bot bot" auto / 42px var(--map);
  gap: 6px;
}

body.touch #hud-map #mm-frame {
  border: 1px solid #fff3d7b3;
  border-radius: 15px;
  box-shadow: 0 2px 8px #102b3e55;
}

body.touch #hud-map #map-coords { font-size: 9px; bottom: 13px; }
body.touch #hud-map #map-name { font-size: 10px; padding: 1px 8px; }
body.touch #hud-map .mm-btns { gap: 5px; }
body.touch #hud-map #net-chip { font-size: 10px; min-height: 22px; }
body.touch #hud-map .ch-pill { min-height: 38px; width: 42px; }

body.touch #hud:not([data-hl-moved~=quick]) #hud-quick {
  top: calc(10px + var(--safe-t));
  right: calc(var(--hud-right) + var(--map) + 102px);
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

body.touch #hud #hud-quick .mbtn,
body.touch #hud #btn-menu {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 2px;
  border: 1px solid #fff3d794;
  border-radius: 13px;
  color: #fff6e4;
  background: #183c48ed;
  box-shadow: 0 2px 6px #10263844;
}

body.touch #hud #hud-quick .mbtn-ico { width: 23px; height: 23px; }
body.touch #hud #hud-quick .mbtn-ico .ico { width: 19px; height: 19px; }
body.touch #hud #hud-quick small { font-size: 9px; }

body.touch #hud:not([data-hl-moved~=menu]) #hud-menu {
  top: calc(10px + var(--safe-t));
  right: calc(var(--hud-right) + var(--map) + 52px);
  bottom: auto;
}

body.touch #hud #hud-menu .menu-items {
  margin-top: 7px;
  max-height: calc(100dvh - 78px - var(--safe-t) - var(--safe-b));
}

body.touch #hud .menu-items .mobile-menu-action {
  position: relative;
  inset: auto;
  transform: none;
  width: 100%;
  height: 62px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

body.touch #hud .menu-items .mobile-menu-action .ico { width: 23px; height: 23px; }
body.touch #hud .menu-items .mobile-menu-action .pk-badge,
body.touch #hud .menu-items .mobile-menu-action .pkl-count {
  right: 3px;
  bottom: auto;
  top: 2px;
  font-size: 9px;
}

body.touch #hud .menu-items #hud-evchips {
  position: static;
  grid-column: 1 / -1;
  width: 100%;
  pointer-events: auto;
  justify-content: flex-start;
  flex-wrap: wrap;
}

body.touch #hud .menu-items #hud-evchips button { min-height: 44px; }
body.touch #hud.game-open #hud-game {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
}

body.touch #hud:not([data-hl-moved~=auto]) #auto-dock {
  margin-top: 9px;
  width: 134px;
  gap: 5px;
}

body.touch #hud #btn-auto-combo,
body.touch #hud #btn-auto-go {
  position: relative;
  inset: auto;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-width: 1px;
  box-shadow: 0 2px 5px #122d3b50;
}

body.touch #hud #btn-auto { min-width: 44px; width: 44px; height: 40px; padding: 0 3px; border-width: 1px; }
body.touch #hud #btn-auto .auto-ico { display: none; }
body.touch #hud #btn-auto .auto-label { font-size: 10px; }

body.touch #hud:not([data-hl-moved~=target]) #hud-target {
  left: 50%;
  right: auto;
  top: calc(12px + var(--safe-t));
  max-width: min(200px, calc(100vw - 470px));
  transform: translateX(-50%);
  transform-origin: center top;
  padding: 4px 9px;
  border: 1px solid #fff2;
  background: #173340b8;
  border-radius: 12px;
  font-size: 12px;
}

body.touch #hud-target #target-ring { display: none; }
body.touch #hud-target #target-main { min-width: 0; width: 100%; }
body.touch #hud-target #target-name { font-size: 11px; }

body.touch #hud:not([data-hl-moved~=quest]) #quest-tracker {
  left: var(--hud-left);
  right: auto;
  top: calc(98px + var(--safe-t));
  width: 204px;
  max-height: 108px;
  border: 1px solid #fff3d74d;
  border-radius: 12px;
  background: #173340b8;
  box-shadow: 0 2px 8px #10263822;
  font-size: 12px;
}

body.touch #hud #quest-tracker .qt-head { min-height: 36px; height: 36px; padding-left: 10px; }
body.touch #hud #quest-tracker .qt-toggle { width: 44px; height: 36px; }
body.touch #hud #quest-tracker .qt-name { font-size: 12px; }
body.touch #hud #quest-tracker .qt-obj { font-size: 11px; }
body.touch #hud #quest-tracker .qt-list { padding: 0 8px 7px; }
body.touch #hud #quest-tracker .qt-route { width: 44px; min-height: 44px; }
body.touch #hud:not([data-hl-moved~=quest]) #quest-tracker.collapsed { width: 44px; height: 44px; }
body.touch #hud #quest-tracker.collapsed .qt-head { height: 44px; }

body.touch #hud:not([data-hl-moved~=buffs]) #buffbar {
  top: calc(76px + var(--safe-t));
  left: var(--hud-left);
  max-width: 208px;
}

body.touch #hud:not([data-hl-moved~=joy]) #joy-zone { width: 34vw; height: 42vh; --joy-d: 84px; }
body.touch #hud:not([data-hl-moved~=joy]) #joy-base {
  left: calc(80px + var(--safe-l));
  top: calc(100% - 74px - var(--safe-b));
  border: 1px solid #fff9;
  background: radial-gradient(circle, #a1c8c126 45%, #17334066 47%);
  box-shadow: 0 2px 8px #10263833;
}
body.touch #hud #joy-knob { width: 36px; height: 36px; border-width: 2px; }

body.touch #hud:not([data-hl-moved~=chat]):not(.chat-expanded):not(.chatting) #hud-chat {
  left: var(--hud-left);
  right: auto;
  bottom: calc(126px + var(--safe-b));
  width: min(240px, 36vw);
  max-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: 7px;
  background: #17334045;
  transform: none;
  overflow: hidden;
}

body.touch #hud:not(.chat-expanded):not(.chatting) #hud-chat .chat-head,
body.touch #hud:not(.chat-expanded):not(.chatting) #chat-form,
body.touch #hud:not(.chat-expanded):not(.chatting) #chat-filters { display: none; }
body.touch #hud:not(.chat-expanded):not(.chatting) #chat-log { max-height: 40px; height: 40px; font-size: 11px; padding: 0; }

body.touch #hud:not([data-hl-moved~=chatBtn]) #btn-chat {
  left: calc(var(--hud-left) + 144px);
  bottom: calc(14px + var(--safe-b));
  width: 44px;
  height: 44px;
  border: 1px solid #fff5;
  background: #173340c9;
  color: #fff5dd;
  box-shadow: none;
}

body.touch #hud:not(.hl-edit):not([data-hl-moved~=hotNum]) #hotbar-1 { display: none; }
body.touch #hud:not([data-hl-moved~=hotF]) #hotbars {
  left: calc(50% - 40px);
  right: auto;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%) !important;
  transform-origin: center bottom;
}

body.touch #hud:not([data-hl-moved~=hotF]) #hotbar-2 {
  gap: 5px;
  padding: 5px;
  background: #173340b8;
  border: 1px solid #fff3d75c;
  border-radius: 12px;
}

body.touch #hud:not([data-hl-moved~=hotF]) #hotbar-2 .hot {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  background: #fff7e8e8;
  box-shadow: inset 0 0 0 1px #fff8;
}

body.touch #hud:not([data-hl-moved~=hotF]) #hotbar-2:before { pointer-events: none; }

body.touch #hud:not(.hl-edit):not([data-hl-moved~=hotF]) #hotbar-2[data-mobile-page="0"] > .hot:nth-of-type(n+6),
body.touch #hud:not(.hl-edit):not([data-hl-moved~=hotF]) #hotbar-2[data-mobile-page="1"] > .hot:nth-of-type(-n+5) { display: none; }

#btn-mobile-itempage {
  order: 1;
  position: relative;
  width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid #fff3d77d;
  border-radius: 9px;
  background: #244b57;
  color: #fff6df;
  font-size: 12px;
  pointer-events: auto;
}

body.touch #hud[data-hl-moved~=hotF] #btn-mobile-itempage { display: none; }
#btn-mobile-items { display: none; }

body.touch #hud:not([data-hl-moved~=actions]) #mobile-actions {
  --ma-s: 1;
  width: 218px;
  height: 188px;
  right: calc(12px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
  transform: none;
}

body.touch #hud #mobile-skills,
body.touch #hud #btn-hotpage { display: block !important; }
body.touch #hud #btn-potion:not([hidden]) { display: block !important; }

body.touch #hud #mobile-skills .mskill,
body.touch #hud #btn-potion {
  width: 56px;
  height: 56px;
  border: 1px solid #fff3d7b3;
  background: #1733409e;
  box-shadow: 0 2px 7px #10263855;
}

body.touch #hud #mobile-skills .mskill:not(:has(.icon)) { opacity: .65; }
body.touch #hud #mobile-skills .mskill:first-child { right: 90px; bottom: 0; }
body.touch #hud #mobile-skills .mskill:nth-child(2) { right: 152px; bottom: 0; }
body.touch #hud #mobile-skills .mskill:nth-child(3) { right: 152px; bottom: 64px; }
body.touch #hud #mobile-skills .mskill:nth-child(4) { right: 90px; bottom: 64px; }
body.touch #hud #mobile-skills .mskill:nth-child(5) { right: 24px; bottom: 104px; }

body.touch #hud #btn-attack {
  width: 78px;
  height: 78px;
  border: 2px solid #fff0ca;
  background: linear-gradient(145deg, #3a8a89, #22566b);
  box-shadow: 0 0 0 3px #21454b80, 0 4px 9px #10263866;
}
body.touch #hud #btn-attack .ico { width: 34px; height: 34px; filter: none; }
body.touch #hud #btn-attack:active { transform: scale(.94); }

body.touch #hud #btn-hotpage {
  right: 218px;
  bottom: 62px;
  width: 46px;
  height: 44px;
  padding: 10px 0 0;
  border: 1px solid #fff3d794;
  border-radius: 11px;
  background: #244b57d9;
  box-shadow: none;
}

body.touch #hud #btn-potion {
  right: 218px;
  bottom: 0;
  width: 48px;
  height: 48px;
  border-color: #f4bbcf;
}

body.touch:is(.sk-dragging, .bag-dragging, .hot-dragging) #hud.win-open #mobile-actions { visibility: visible; z-index: 30; }
body.touch #hud.win-open #btn-mobile-items,
body.touch #hud.chat-expanded #btn-mobile-items,
body.touch #hud.chatting #btn-mobile-items { visibility: hidden; }

@media (max-width: 800px) {
  body.touch #hud { --self-w: 184px; --map: 78px; }
  body.touch #hud:not([data-hl-moved~=quest]) #quest-tracker { width: 184px; }
  body.touch #hud:not([data-hl-moved~=target]) #hud-target { top: calc(78px + var(--safe-t)); max-width: 170px; }
  body.touch #hud:not(.hl-edit):not([data-hl-moved~=hotF]):not(.mobile-items-open) #hotbar-2 { display: none; }
  body.touch #hud:not([data-hl-moved~=hotF]) #hotbars {
    left: calc(var(--hud-left) + 154px);
    bottom: calc(68px + var(--safe-b));
    transform: none !important;
    align-items: flex-start;
  }
  body.touch #hud:not([data-hl-moved~=hotF]) #hotbar-2 { flex-wrap: wrap; width: 162px; justify-content: center; }
  body.touch #hud #btn-mobile-items {
    position: absolute;
    z-index: 5;
    display: block;
    pointer-events: auto;
    left: calc(var(--hud-left) + 196px);
    bottom: calc(14px + var(--safe-b));
    width: 52px;
    height: 44px;
    padding: 0;
    border: 1px solid #fff3d77d;
    border-radius: 12px;
    background: #244b57d9;
    color: #fff6df;
    font-size: 11px;
  }
  body.touch #hud:is([data-hl-moved~=hotF], [data-hl-hidden~=hotF]) #btn-mobile-items { display: none; }
}

@media (max-height: 360px) and (orientation: landscape) {
  body.touch #hud { --map: 70px; }
  body.touch #hud:not([data-hl-moved~=quest]) #quest-tracker {
    top: calc(86px + var(--safe-t));
    max-height: 90px;
  }
  body.touch #hud:not(.chat-expanded):not(.chatting) #hud-chat { display: none; }
}

@media (orientation: portrait) and (max-width: 600px) {
  body.touch #hud { --self-w: 180px; --map: 76px; }
  body.touch #hud:not([data-hl-moved~=quick]) #hud-quick {
    top: calc(158px + var(--safe-t));
    right: calc(var(--hud-right) + 52px);
  }
  body.touch #hud:not([data-hl-moved~=menu]) #hud-menu {
    top: calc(158px + var(--safe-t));
    right: var(--hud-right);
  }
  body.touch #hud:not([data-hl-moved~=target]) #hud-target {
    left: var(--hud-left);
    top: calc(224px + var(--safe-t));
    max-width: 180px;
    transform: none;
  }
  body.touch #hud #btn-hotpage { right: 152px; bottom: 192px; }
  body.touch #hud #btn-potion { right: 218px; bottom: 144px; }
  body.touch #hud:not([data-hl-moved~=joy]) #joy-base { top: calc(100% - 104px - var(--safe-b)); }
  body.touch #hud:not([data-hl-moved~=chatBtn]) #btn-chat { left: var(--hud-left); }
  body.touch #hud #btn-mobile-items { left: calc(var(--hud-left) + 60px); }
}
