/* Isolated touch layout; desktop retains its existing console. */
#mobileControls[hidden] { display:none; }
#mobileControls { position:absolute; inset:0; z-index:18; pointer-events:none; }
#mobileControls button,#mobileStick { pointer-events:auto; touch-action:none; -webkit-tap-highlight-color:transparent; }
#mobileControls button { min-width:44px; min-height:44px; padding:6px; color:#efdfbd; border:1px solid #a58b61; border-radius:8px; background:linear-gradient(145deg,#30353bee,#10161df2); box-shadow:inset 0 1px #ecd29c22,0 3px 12px #0008; font:12px/1.2 var(--font-game); }
#mobileControls button:active,#mobileControls button.pressed { background:#625035; border-color:#ffdaa0; }
.mobile-tools { position:absolute; top:calc(98px + env(safe-area-inset-top)); right:calc(12px + env(safe-area-inset-right)); display:flex; gap:5px; }
.mobile-tools [aria-pressed="true"] { color:#ffdc91; border-color:#e7bf6d!important; }
#mobileStick { position:absolute; bottom:calc(62px + env(safe-area-inset-bottom)); left:calc(12px + env(safe-area-inset-left)); width:132px; height:132px; display:grid; place-items:center; border-radius:50%; border:1px solid #a8906055; background:radial-gradient(circle,#141b2180 40%,#141b2140 41%,#11172099 68%,#bc9a5844 69%,#11172080 71%); }
.stick-guide { color:#dfc38b40; font:80px/1 var(--font-game); }
#mobileKnob { position:absolute; width:54px; height:54px; border:1px solid #ddc39499; border-radius:50%; background:radial-gradient(circle at 35% 25%,#6c6457cc,#282e33dd 60%,#111820ee); box-shadow:0 4px 14px #0007; pointer-events:none; }
.stick-label { position:absolute; bottom:8px; color:#ceb993aa; font:9px var(--font-game); letter-spacing:2px; pointer-events:none; }
.mobile-actions { position:absolute; bottom:calc(62px + env(safe-area-inset-bottom)); right:calc(12px + env(safe-area-inset-right)); display:grid; grid-template-columns:64px 76px; grid-template-rows:44px 76px; gap:8px; align-items:center; }
#mobileControls .mobile-combat { position:relative; border-radius:50%; height:64px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; padding:8px 5px; }
#mobileControls #mobileAttack { height:76px; border-color:#d0a465; background:radial-gradient(circle at 40% 20%,#65513ddd,#302a25f5 65%,#121922); }
#mobileControls #mobileAttack.pressed { background:#80623e; }
.mobile-combat span { font-weight:600; }
.mobile-combat small { font-size:8px; line-height:1.1; max-width:100%; max-height:19px; overflow:hidden; color:#c1b7a4; }
.mobile-combat b { position:absolute; inset:0; display:grid; place-items:center; font-size:18px; text-shadow:0 2px 4px #000; pointer-events:none; }
.mobile-combat.cooling span,.mobile-combat.cooling small { opacity:.25; }
.mobile-combat.unavailable { opacity:.5; }
#mobileControls.blocked #mobileStick,#mobileControls.blocked .mobile-actions { display:none; }
#mobileControls.blocked .mobile-tools button:not([data-action="menu"]) { visibility:hidden; }
.touch-controls #view { touch-action:none; }
.touch-controls button { touch-action:manipulation; }
.touch-controls #hud { inset:0; height:auto; padding:0; background:none; z-index:10; }
.touch-controls #hudmid { position:static; width:auto; padding:0; margin:0; border:0; background:none; box-shadow:none; pointer-events:none; }
.touch-controls #hudmid::before,.touch-controls #hudmid::after,.touch-controls .orb-caption,.touch-controls .orb-foot,.touch-controls #companionUpkeep,.touch-controls .hud-group-label,.touch-controls .active-group,.touch-controls #xpText,.touch-controls .hbtn kbd { display:none; }
.touch-controls .orbwrap { position:absolute; top:calc(6px + env(safe-area-inset-top)); width:72px; height:76px; pointer-events:none; }
.touch-controls #orbHpWrap { left:calc(8px + env(safe-area-inset-left)); }
.touch-controls #orbMpWrap { left:calc(80px + env(safe-area-inset-left)); }
.touch-controls .orbwrap canvas { top:0; left:0; width:72px; height:72px; }
.touch-controls .orblabel { top:47px; font-size:9px; }
.touch-controls #hudIdentity { position:absolute; top:calc(81px + env(safe-area-inset-top)); left:calc(12px + env(safe-area-inset-left)); width:150px; font-size:8px; letter-spacing:.5px; gap:5px; }
.touch-controls #hudLevel { padding-left:5px; }
.touch-controls #xpbar { position:absolute; top:calc(97px + env(safe-area-inset-top)); left:calc(12px + env(safe-area-inset-left)); width:140px; height:3px; }
.touch-controls #hudrow { display:contents; }
.touch-controls #beltBar,.touch-controls #quickbar { position:absolute; bottom:calc(208px + env(safe-area-inset-bottom)); display:grid; grid-template-columns:repeat(2,44px); gap:6px; pointer-events:auto; }
.touch-controls #beltBar { left:calc(12px + env(safe-area-inset-left)); }
.touch-controls #quickbar { right:calc(12px + env(safe-area-inset-right)); }
.touch-controls .beltslot,.touch-controls .qslot { width:44px; height:44px; }
.touch-controls .qslot .key { font-size:0; }
.touch-controls .qslot .key::after { content:'Skill'; font-size:8px; }
.touch-controls #hudbuttons { position:absolute; bottom:calc(6px + env(safe-area-inset-bottom)); left:calc(8px + env(safe-area-inset-left)); width:calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)); height:46px; padding:0; background:#111820e8; border:1px solid #786447; border-radius:6px; pointer-events:auto; }
.touch-controls .hbtn { min-height:44px; font-size:9px; letter-spacing:0; }
.touch-controls #minimap { top:calc(8px + env(safe-area-inset-top)); right:calc(12px + env(safe-area-inset-right)); width:112px; height:82px; pointer-events:none; }
.touch-controls #zonelabel { top:calc(112px + env(safe-area-inset-top)); left:12px; transform:none; max-width:calc(100% - 174px); font-size:11px; letter-spacing:1px; }
.touch-controls #buffs { top:calc(147px + env(safe-area-inset-top)); left:12px; }
.touch-controls #msglog { left:50%; transform:translateX(-50%); bottom:calc(62px + env(safe-area-inset-bottom)); width:calc(100% - 320px); max-height:90px; overflow:hidden; font-size:10px; }
.touch-controls #panelWorkspace { z-index:40; }
.touch-controls .panel .pclose { min-width:44px; min-height:44px; }
.touch-controls #skillPick { left:8px!important; top:auto!important; bottom:calc(60px + env(safe-area-inset-bottom)); width:calc(100% - 16px); max-width:500px; max-height:60dvh; overflow:auto; z-index:65; }
.touch-controls #escmenu { padding:env(safe-area-inset-top) 8px env(safe-area-inset-bottom); overflow:auto; }
.touch-controls #escmenu .box { max-width:100%; max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow:auto; }
.touch-controls #escmenu .menubtn { min-height:44px; width:min(280px,100%); }
.touch-controls #tooltip,.touch-controls #tooltipCmp { max-width:calc(100vw - 16px); }
.touch-controls .item-grid-scroll { max-width:100%; overflow-x:auto; overscroll-behavior:contain; padding-bottom:4px; }
.touch-controls .management-panel #equipwrap { width:min(340px,100%); height:112px; margin:12px auto 14px; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); grid-template-rows:repeat(2,44px); gap:20px 10px; }
.touch-controls .management-panel #equipwrap .eqslot { position:relative; left:auto!important; top:auto!important; width:auto!important; height:44px!important; }
.touch-controls:has(#panelWorkspace .panel:not(.hidden)) :is(.orbwrap,#hudIdentity,#xpbar,#zonelabel) { visibility:hidden; }
#touchItemMenu { margin:auto; width:min(370px,calc(100% - 24px)); max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding:16px; color:#d9cfb5; overflow:auto; }
#touchItemMenu::backdrop { background:#0009; }
.touch-item-details { font:12px/1.5 var(--font-game); }
.touch-item-actions { display:flex; flex-wrap:wrap; gap:8px; padding-top:16px; }
.touch-item-actions button { flex:1; min-height:44px; }
.touch-controls .opening-objective,.touch-controls .opening-boss .opening-objective { top:calc(153px + env(safe-area-inset-top)); left:10px; width:calc(100% - 20px); padding:8px 12px; }
.touch-controls .opening-kicker { display:none; }
.touch-controls .opening-goal { font-size:14px; margin:0 0 4px; }
.touch-controls .opening-hint { font-size:11px; line-height:1.4; }
.touch-controls .opening-caption { bottom:calc(310px + env(safe-area-inset-bottom)); max-width:calc(100% - 28px); padding:8px 10px; }
.touch-controls .opening-line { font-size:13px; line-height:1.4; }
@media (max-width:600px) {
  .touch-controls #talentBody { grid-template-columns:minmax(0,1fr); min-height:0; }
  .touch-controls .talent-board { border-right:0; padding:0; min-height:410px; }
  .touch-controls #skillDetail { overflow:visible; }
  .touch-controls .talent-wallet { position:static; margin:0 0 10px; }
  .touch-controls .talent-panel .treetab { padding:8px 4px; font-size:12px; }
  .touch-controls .talent-panel .treetab small { display:none; }
  .touch-controls .wp-body { grid-template-columns:1fr; }
  .touch-controls #msglog { display:none; }
}
@media (orientation:landscape) and (max-height:600px) {
  #mobileStick,.mobile-actions { bottom:calc(12px + env(safe-area-inset-bottom)); }
  .touch-controls #beltBar,.touch-controls #quickbar { bottom:calc(158px + env(safe-area-inset-bottom)); grid-template-columns:repeat(4,44px); }
  .touch-controls #hudbuttons { width:340px; left:50%; transform:translateX(-50%); }
  .touch-controls .opening-objective,.touch-controls .opening-boss .opening-objective { top:calc(12px + env(safe-area-inset-top)); left:210px; width:calc(100% - 410px); }
  .touch-controls .opening-caption { bottom:64px; max-width:calc(100% - 320px); }
  .mobile-tools { top:calc(98px + env(safe-area-inset-top)); }
}

/* The workspace owns mobile navigation and hides all world-facing controls. */
#workspaceHeader[hidden],#workspaceTabs[hidden],#mobileControls button[hidden] { display:none; }
#workspaceHeader { display:none; }
#workspaceHeader .workspace-heading { display:contents; }
.touch-controls .mobile-tools { display:grid;grid-template-columns:repeat(2,44px); }
.touch-controls #coopHUD { display:none!important; }
.touch-controls.mobile-menu-open :is(#mobileControls,#hud,#buffs,#minimap,#zonelabel,#msglog,.opening-objective,.opening-caption) { visibility:hidden!important;pointer-events:none!important; }
.touch-controls #panelWorkspace:has(.panel:not(.hidden)) {
  position:fixed!important;display:block!important;inset:var(--visible-top,0px) 0 auto!important;
  width:100%!important;height:var(--visible-height,100dvh)!important;max-height:none!important;
  background:#10171f;z-index:45;pointer-events:auto;padding:0!important;overflow:hidden;
  --workspace-head:calc(64px + env(safe-area-inset-top));
}
.touch-controls #panelWorkspace:has(#workspaceTabs:not([hidden])) { --workspace-head:calc(112px + env(safe-area-inset-top)); }
.touch-controls #workspaceHeader:not([hidden]) {
  position:absolute;inset:0 0 auto;z-index:8;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:4px 12px;
  padding:calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  background:#19212a;border-bottom:1px solid #756044;
}
#workspaceTitle { margin:0;color:#eee0c0;font:20px/1.15 var(--font-game); }
#workspaceHeader button { min-width:44px;min-height:44px;padding:8px 12px;background:#242d36;color:#ead7b6;border:1px solid #796747;border-radius:4px;font:13px var(--font-game); }
#workspaceTabs { display:flex;gap:8px;grid-column:1/-1; }
#workspaceTabs button { flex:1; }
#workspaceTabs button[aria-pressed=true] { background:#654e2e;border-color:#d3b87a; }
.touch-controls #panelWorkspace .panel {
  z-index:1;position:absolute!important;inset:var(--workspace-head) 0 0!important;width:100%!important;max-width:none!important;min-width:0!important;
  height:auto!important;max-height:none!important;transform:none!important;flex:none!important;
  padding:16px calc(12px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left))!important;
  border:0;border-radius:0;overflow:auto!important;overscroll-behavior:contain;box-sizing:border-box;
}
.touch-controls #panelWorkspace .panel:is(.hidden,.workspace-inactive) { display:none!important; }
.touch-controls #panelWorkspace .panel :is(.ptitle,.pclose) { display:none!important; }
.touch-controls .panel :is(button,.dlgopt,.wprow) { min-height:44px; }
.touch-controls .panel input { min-height:44px;font-size:16px; }
.touch-controls #panelWorkspace .management-panel #equipwrap { width:min(400px,100%); }
.touch-controls #panelWorkspace .item-grid-scroll { max-width:100%;overflow-x:auto; }
.touch-controls #panelWorkspace .panel #forgeCraft,.touch-controls #panelWorkspace .shop-buy { position:static; }
.touch-controls #touchItemMenu.workspace-detail {
  position:absolute;inset:0;margin:0;width:100%;max-width:none;height:100%;max-height:none;box-sizing:border-box;z-index:12;
  padding:calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background:#10171f;overflow:auto;overscroll-behavior:contain;
}
.touch-controls #panelWorkspace.item-detail-open :is(.panel,#workspaceHeader) { display:none!important; }
.touch-controls .touch-item-actions { position:sticky;bottom:0;background:#10171f;padding-bottom:8px; }
.touch-controls #skillPick {
  position:fixed!important;inset:var(--visible-top,0px) 0 auto!important;width:100%!important;max-width:none!important;
  height:var(--visible-height,100dvh);max-height:none!important;box-sizing:border-box;
  padding:calc(12px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));z-index:65;
}
.touch-controls #skillPick button { min-height:44px; }
.touch-controls #escmenu { position:fixed;top:var(--visible-top,0px);height:var(--visible-height,100dvh);box-sizing:border-box; }
.touch-controls #escmenu .box { max-height:calc(var(--visible-height,100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.touch-controls .coop-dialog {
  position:fixed!important;inset:var(--visible-top,0px) 0 auto!important;margin:0!important;width:100%!important;
  max-width:none!important;height:var(--visible-height,100dvh)!important;max-height:none!important;border-radius:0;
  padding:calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left))!important;
}
.touch-controls .coop-header { position:sticky;top:calc(-12px - env(safe-area-inset-top));background:#211c19;padding:8px 0;z-index:2; }
.touch-controls .coop-header h2 { font-size:22px; }
.critical-overlay #panelWorkspace,.critical-overlay #skillPick { visibility:hidden;pointer-events:none; }
.inventory-status { color:#eac892;font:12px/1.4 var(--font-game);min-height:1.4em; }
.inventory-status:empty { display:none; }
.inventory-pending :is(.invgrid,#equipwrap,#forgeRow,.shop-buy,#inventoryTidy) { opacity:.65; }
.touch-controls #forgeRow { flex-wrap:wrap; }
.touch-controls .saved-hero strong,.touch-controls .saved-details strong { overflow-wrap:anywhere; }
@media (orientation:landscape) and (max-height:600px) {
  .touch-controls .mobile-tools { display:flex; }
  .touch-controls #panelWorkspace .management-panel[data-kind=inv]:not(.workspace-inactive):not(.hidden) {
    display:grid;grid-template-columns:minmax(220px,.9fr) minmax(0,1.1fr);gap:8px 20px;align-content:start;
  }
  .touch-controls .management-panel[data-kind=inv] .manage-eyebrow { grid-column:1;grid-row:1;margin:0;align-self:center; }
  .touch-controls #panelWorkspace .management-panel[data-kind=inv] #equipwrap { grid-column:1;grid-row:2;margin:8px auto; }
  .touch-controls .management-panel[data-kind=inv] #goldrow { grid-column:1;grid-row:3;margin:0;padding:0; }
  .touch-controls .management-panel[data-kind=inv] .pack-toolbar { grid-column:2;grid-row:1;margin:0; }
  .touch-controls .management-panel[data-kind=inv] .item-grid-scroll { grid-column:2;grid-row:2;align-self:center; }
  .touch-controls .management-panel[data-kind=inv] .pack-help { grid-column:2;grid-row:3;margin:0; }
  .touch-controls .management-panel[data-kind=inv] .inventory-status { grid-column:1/-1; }
}
