body.touch-layout #gameplay-root #hud .hint,
body.touch-layout #gameplay-root #hud .hud-signature {
  display: none;
}

body.touch-layout #gameplay-root #hud {
  top: max(10px, env(safe-area-inset-top) + 8px);
  left: max(10px, env(safe-area-inset-left) + 8px);
  gap: 6px;
  padding: 10px 12px;
  max-width: min(72vw, 320px);
}

body.touch-layout #gameplay-root #hud .hud-topline {
  margin-bottom: 0;
  gap: 10px;
}

body.touch-layout #gameplay-root #hud .title {
  font-size: 14px;
}

body.touch-layout #gameplay-root .time-display {
  font-size: 11px;
}

body.touch-layout #gameplay-root .hud-status-row {
  gap: 6px;
}

body.touch-layout #gameplay-root .coords-display {
  font-size: 10px;
}

body.touch-layout #gameplay-root #inventory {
  left: 50%;
  bottom: max(0px, env(safe-area-inset-bottom));
  width: auto;
  max-width: calc(100vw - 24px);
  justify-content: center;
  z-index: 15;
}

body.touch-layout #gameplay-root .inventory-bar {
  gap: 4px;
}

body.touch-layout #gameplay-root .inventory-slot {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  min-height: 46px;
  padding: 5px 3px;
  border-radius: 12px;
}

body.touch-layout #gameplay-root .inventory-overflow-button {
  width: 42px;
  min-width: 42px;
  min-height: 46px;
  padding: 5px 3px;
  border-radius: 12px;
  font-size: 18px;
}

body.touch-layout.phone-layout #gameplay-root #inventory {
  bottom: max(0px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 16px);
}

body.touch-layout.phone-layout #gameplay-root .inventory-slot {
  flex-basis: 39px;
  width: 39px;
  min-width: 39px;
  min-height: 44px;
  padding: 4px 2px;
}

body.touch-layout.phone-layout #gameplay-root .inventory-overflow-button {
  width: 39px;
  min-width: 39px;
  min-height: 44px;
  padding: 4px 2px;
}

body.touch-layout #gameplay-root .inventory-label {
  font-size: 9px;
}

body.touch-layout #gameplay-root .inventory-count {
  display: none;
}

body.touch-layout #gameplay-root .interaction-prompt {
  bottom: max(56px, env(safe-area-inset-bottom) + 48px);
  font-size: 11px;
  padding: 7px 12px;
  z-index: 15;
}

body.touch-layout #gameplay-root .dialogue-card {
  padding: 18px;
  border-radius: 18px 18px 14px 14px;
}

body.touch-layout #gameplay-root .dialogue-choices {
  flex-direction: column;
}

body.touch-layout #gameplay-root .dialogue-choice,
body.touch-layout #gameplay-root .dialogue-close {
  min-height: 48px;
}

body.touch-layout #gameplay-root .inventory-modal {
  padding: 10px;
  z-index: 17;
}

body.touch-layout #gameplay-root .inventory-modal-card {
  width: min(100%, 620px);
  max-height: min(88vh, 900px);
  padding: 16px;
  border-radius: 18px;
}

body.touch-layout #gameplay-root .inventory-modal-header {
  flex-direction: column;
  gap: 10px;
}

body.touch-layout #gameplay-root .inventory-modal-close {
  min-height: 48px;
  width: 100%;
}

body.touch-layout #gameplay-root .inventory-grid-hotbar,
body.touch-layout #gameplay-root .inventory-grid-backpack {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

body.touch-layout #gameplay-root .inventory-modal .inventory-slot {
  width: 100%;
  min-width: 0;
  min-height: 72px;
}

body.touch-layout #gameplay-root .inventory-modal .inventory-label {
  font-size: 10px;
}

body.touch-layout #gameplay-root .inventory-modal .inventory-count {
  display: block;
  font-size: 10px;
}

#gameplay-root #touch-controls {
  position: fixed;
  inset: 0;
  z-index: 13;
  pointer-events: none;
}

#gameplay-root #touch-controls.hidden {
  display: none;
}

#gameplay-root .touch-look-zone,
#gameplay-root .touch-move-cluster,
#gameplay-root .touch-action-cluster,
#gameplay-root .touch-rotate-hint {
  pointer-events: auto;
}

#gameplay-root .touch-look-zone {
  position: fixed;
  top: 0;
  right: 0;
  bottom: max(158px, env(safe-area-inset-bottom) + 144px);
  left: 38vw;
  touch-action: none;
}

#gameplay-root .touch-look-zone-low {
  top: auto;
  left: 52vw;
  bottom: 0;
  height: max(172px, env(safe-area-inset-bottom) + 156px);
}

body.touch-layout.phone-layout #gameplay-root .touch-look-zone {
  left: 33vw;
  bottom: max(52px, env(safe-area-inset-bottom) + 44px);
}

body.touch-layout.phone-layout #gameplay-root .touch-look-zone-low {
  left: 50vw;
  bottom: 0;
  height: max(122px, env(safe-area-inset-bottom) + 110px);
}

body.touch-layout.phone-layout #gameplay-root .touch-move-cluster {
  left: max(10px, env(safe-area-inset-left) + 8px);
  bottom: max(6px, env(safe-area-inset-bottom) + 4px);
  width: 120px;
  height: 120px;
}

#gameplay-root .touch-move-cluster {
  position: fixed;
  left: max(26px, env(safe-area-inset-left) + 18px);
  bottom: max(108px, env(safe-area-inset-bottom) + 90px);
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

#gameplay-root .touch-joystick {
  position: relative;
  width: 146px;
  height: 146px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.08) 48%, rgba(0, 0, 0, 0.18) 100%);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
  touch-action: none;
}

body.touch-layout.phone-layout #gameplay-root .touch-joystick {
  width: 108px;
  height: 108px;
}

#gameplay-root .touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.14);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
}

body.touch-layout.phone-layout #gameplay-root .touch-joystick-knob {
  width: 44px;
  height: 44px;
}

#gameplay-root .touch-action-cluster {
  position: fixed;
  right: max(14px, env(safe-area-inset-right) + 10px);
  bottom: max(92px, env(safe-area-inset-bottom) + 76px);
  display: grid;
  grid-template-columns: repeat(2, minmax(64px, 86px));
  gap: 10px;
  align-items: end;
  justify-items: end;
  z-index: 1;
}

body.touch-layout.phone-layout #gameplay-root .touch-action-cluster {
  right: max(10px, env(safe-area-inset-right) + 8px);
  bottom: max(6px, env(safe-area-inset-bottom) + 4px);
  grid-template-columns: repeat(2, minmax(54px, 70px));
  gap: 8px;
}

#gameplay-root .touch-chip-button,
#gameplay-root .touch-action-button {
  border: 0;
  font: inherit;
  color: #142032;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  touch-action: manipulation;
}

#gameplay-root .touch-chip-button {
  grid-column: span 2;
  justify-self: end;
  min-width: 92px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

body.touch-layout.phone-layout #gameplay-root .touch-chip-button {
  min-width: 74px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 11px;
}

#gameplay-root .touch-action-button {
  min-width: 74px;
  min-height: 58px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

body.touch-layout.phone-layout #gameplay-root .touch-action-button {
  min-width: 62px;
  min-height: 48px;
  padding: 0 10px;
  font-size: 12px;
}

#gameplay-root .touch-action-button-primary {
  min-width: 88px;
  min-height: 88px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 217, 127, 0.96) 0%, rgba(243, 170, 59, 0.96) 100%);
  color: #101015;
}

body.touch-layout.phone-layout #gameplay-root .touch-action-button-primary {
  min-width: 74px;
  min-height: 74px;
  border-radius: 24px;
}

#gameplay-root .touch-action-button-secondary {
  background: rgba(238, 244, 255, 0.92);
}

#gameplay-root .touch-action-button-tertiary {
  background: rgba(222, 238, 246, 0.92);
}

#gameplay-root .touch-action-button.hidden {
  display: none;
}

#gameplay-root .touch-rotate-hint {
  position: fixed;
  top: max(84px, env(safe-area-inset-top) + 78px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(16, 20, 28, 0.86);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  z-index: 1;
}

#gameplay-root .touch-rotate-hint.hidden {
  display: none;
}

body.touch-layout #gameplay-root .dialogue-modal,
body.touch-layout #gameplay-root .banner {
  z-index: 16;
}

#system-root .touch-side-toggle,
#system-root .touch-side-backdrop {
  display: none;
}

#system-root.touch-layout .touch-side-toggle {
  display: inline-flex;
  position: fixed;
  top: max(10px, env(safe-area-inset-top) + 8px);
  right: max(10px, env(safe-area-inset-right) + 8px);
  z-index: 24;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(10, 18, 28, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #152031;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(8px);
}

#system-root.touch-layout .touch-side-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 21;
  background: rgba(9, 13, 19, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

#system-root.touch-layout.touch-panels-open .touch-side-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#system-root.touch-layout #side-panels {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  height: 100dvh;
  padding: max(58px, env(safe-area-inset-top) + 46px) 12px max(16px, env(safe-area-inset-bottom) + 12px);
  background: rgba(244, 245, 248, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: -24px 0 48px rgba(0, 0, 0, 0.16);
  transform: translateX(calc(100% + 16px));
  transition: transform 180ms ease;
  overflow-y: auto;
  z-index: 22;
}

#system-root.touch-layout.touch-panels-open #side-panels {
  transform: translateX(0);
}

#system-root.touch-layout .account-card,
#system-root.touch-layout #branch-panel {
  width: 100%;
}

#system-root.touch-layout #branch-panel {
  min-height: 0;
}

body.phone-layout #system-root.touch-layout #side-panels {
  width: 100vw;
  padding-left: max(12px, env(safe-area-inset-left) + 10px);
  padding-right: max(12px, env(safe-area-inset-right) + 10px);
}
