/* Touch / phone layout. Everything is scoped to body.touch, which touch.js sets on a coarse-pointer device (or ?touch=1). */
body.touch { position:fixed; inset:0; height:100%; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font-size:11px; overscroll-behavior:none; touch-action:manipulation; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; }
body.touch #wrap { height:100%; }
body.touch canvas { border:0; touch-action:none; }

/* ---- HUD, shrunk ---- */
body.touch .hudbox { font-size:10px; z-index:3; }
body.touch #quests { top:4px; left:4px; width:min(200px,34%); padding:4px 6px; max-height:45%; overflow-y:auto; -webkit-overflow-scrolling:touch; touch-action:pan-y; overscroll-behavior:contain; }
body.touch #logbox { top:46px; right:auto; left:50%; transform:translateX(-50%); width:min(280px,36%); }   /* opened by the 📜 button */
body.touch #logbox .lh { display:none; }
body.touch #logbox.t-empty { visibility:hidden; }
body.touch #logbox .lb { max-height:110px; border-top:0; }
body.touch #allybox { left:4px; bottom:4px; width:118px; padding:4px 6px; }
/* action bar: abilities fanned around the attack pad (bottom right). The pad centre is (--cx, --cy) from the corner. */
body.touch { --cx:94px; --cy:84px; }   /* a bit in from the corner: easier to reach, clear of the notch / rounded corners */
body.touch #actionbar { inset:0; transform:none; padding:0; background:none; border:0; pointer-events:none; z-index:4; }
body.touch #actionbar .slots { display:block; }
body.touch #actionbar .gap { display:none; }
body.touch .as { position:absolute; width:48px; height:48px; border-radius:10px; pointer-events:auto; background:rgba(36,30,24,.88); }
body.touch .as.wpn { width:48px; }
body.touch .as .k { font-size:9px; }
body.touch .as .n { inset:11px 0 9px; font-size:8px; line-height:9px; }
body.touch .as .c { font-size:8px; }
body.touch .as .cdt { font-size:12px; }
body.touch #actionbar .slots > :nth-child(4) { right:calc(var(--cx) - (-104px) - 24px); bottom:calc(var(--cy) + (18px) - 24px); }
body.touch #actionbar .slots > :nth-child(5) { right:calc(var(--cx) - (-80px) - 24px); bottom:calc(var(--cy) + (67px) - 24px); }
body.touch #actionbar .slots > :nth-child(6) { right:calc(var(--cx) - (-35px) - 24px); bottom:calc(var(--cy) + (98px) - 24px); }
body.touch #actionbar .slots > :nth-child(7) { right:calc(var(--cx) - (18px) - 24px); bottom:calc(var(--cy) + (104px) - 24px); }
body.touch #actionbar .slots > :nth-child(2) { right:calc(var(--cx) - (-165px) - 24px); bottom:calc(var(--cy) + (-29px) - 24px); }
body.touch #actionbar .slots > :nth-child(10) { right:calc(var(--cx) - (-157px) - 24px); bottom:calc(var(--cy) + (57px) - 24px); }
body.touch #actionbar .slots > :nth-child(9) { right:calc(var(--cx) - (-107px) - 24px); bottom:calc(var(--cy) + (128px) - 24px); }
body.touch #actionbar .slots > :nth-child(11) { right:calc(var(--cx) - (71px) - 24px); bottom:calc(var(--cy) + (66px) - 24px); }   /* the path action (Beast Master: Command Wolf) */
body.touch #actionbar .slots > :nth-child(1) { right:calc(var(--cx) - (-29px) - 24px); bottom:calc(var(--cy) + (165px) - 24px); }
body.touch #actionbar .herobar, body.gp #actionbar .herobar { position:absolute; left:50%; bottom:16px; transform:translateX(-50%); width:min(320px,40%); margin:0; }
body.touch .xpbar { position:absolute; left:50%; bottom:4px; transform:translateX(-50%); width:min(300px,36%); height:8px; margin:0; }
body.touch .xpbar span { font-size:8px; line-height:7px; }

/* ---- dialogs / menus: scroll inside the panel, big tap targets ---- */
body.touch #overlay { padding:6px; align-items:center; }
body.touch #panel { padding:10px 12px; max-height:100%; overflow-y:auto; -webkit-overflow-scrolling:touch; touch-action:pan-y; font-size:12px; }
body.touch #panel .txt { font-size:12px; margin-bottom:8px; }
body.touch .mbody { max-height:none; overflow:visible; }
body.touch .opt { padding:10px 10px; margin:5px 0; }
body.touch .tab { padding:8px 10px; }
body.touch .card { min-height:0; flex-basis:150px; }
body.touch .bag .grid { grid-template-columns:repeat(auto-fill,56px); }
body.touch .bagcell, body.touch .eslot { width:56px; height:56px; }
body.touch .figure { height:200px; }

/* ---- touch controls ---- */
.t-zone { position:absolute; top:34%; bottom:0; width:38%; z-index:2; touch-action:none; }
#tz-move { left:0; }
.t-zone::after { content:''; position:absolute; bottom:max(34px,6%); width:84px; height:84px; border-radius:50%; border:2px dashed rgba(217,180,74,.28); box-sizing:border-box;
  display:flex; align-items:center; justify-content:center; font-size:26px; color:rgba(217,180,74,.35); opacity:var(--hint,1); }
#tz-move::after { left:44px; }
.t-base, .t-knob { position:fixed; border-radius:50%; pointer-events:none; z-index:6; display:none; }
.t-base { width:112px; height:112px; margin:-56px 0 0 -56px; border:2px solid rgba(217,180,74,.5); background:rgba(20,16,12,.3); }
.t-knob { width:48px; height:48px; margin:-24px 0 0 -24px; background:rgba(217,180,74,.55); border:2px solid rgba(255,230,150,.7); }
.t-btn { position:absolute; z-index:4; min-width:44px; height:44px; padding:0 12px; border-radius:22px; border:2px solid var(--gold); background:rgba(28,20,8,.85); color:var(--gold);
  font:inherit; font-size:14px; font-weight:bold; touch-action:none; display:none; align-items:center; justify-content:center; }
.t-btn:active { background:rgba(80,60,24,.95); }
/* Use / Rekindle / Level up: a row near the bottom, a bit right of centre (the far edge was too far; dead centre is hard to reach) */
#t-ctx { position:absolute; right:calc(var(--cx) + 196px); bottom:54px; z-index:4; display:flex; flex-direction:row-reverse; align-items:center; gap:8px; pointer-events:none; }   /* a row just right of centre, ending where the ability arc starts */
#t-ctx > * { pointer-events:auto; }
#t-ctx .t-btn, #t-ctx #lvbtn { position:static; transform:none; left:auto; bottom:auto; width:52px; height:52px; min-width:52px; padding:0; border-radius:50%; font-size:13px; }
#t-ctx #lvbtn { font-size:0; animation:lvpulse 1.4s ease-in-out infinite; }   /* just a pulsing ★ (the level-up count is in the log) */
#t-ctx #lvbtn .dim { display:none; }
#t-ctx #lvbtn::before { content:'★'; font-size:24px; }
#t-rk { border-color:var(--red); color:#ff9a9a; }
.t-top { position:absolute; top:4px; right:150px; z-index:4; display:flex; gap:6px; }   /* JS puts it just left of the minimap */
.t-top .t-btn { position:static; display:flex; height:36px; min-width:36px; border-radius:18px; padding:0 8px; font-size:15px; }

/* ---- portrait: ask for landscape ---- */
#t-rotate { position:fixed; inset:0; z-index:50; background:#100e0c; color:var(--gold); align-items:center; justify-content:center; flex-direction:column; text-align:center; font-size:16px; padding:24px; display:none; }
#t-rotate b { font-size:42px; display:block; margin-bottom:10px; }
@media (orientation:portrait) { body.touch #t-rotate { display:flex; } }

/* attack pad: hold to attack, drag to aim */
#t-atk { position:absolute; right:calc(var(--cx) - 44px); bottom:calc(var(--cy) - 44px); width:88px; height:88px; border-radius:50%; z-index:4; touch-action:none;
  border:2px solid var(--gold); background:rgba(120,40,30,.35); color:rgba(255,230,150,.85); font-size:34px; display:flex; align-items:center; justify-content:center; }
#t-atk:active, #t-atk.on { background:rgba(180,60,40,.55); }
/* a controller is in use: drop the on-screen sticks */
body.gp .t-zone, body.gp #t-atk, body.gp .t-top, body.gp #t-act, body.gp #t-rk { display:none !important; }   /* nothing to tap */
body.gp #actionbar .as { pointer-events:none; }
/* controller in use (phone or desktop): the slots are laid out like the pad — shoulders (LB/LT · RB/RT) on the outer edges,
   the D-pad's slots on the left, the face buttons' on the right. A slot follows its button if you rebind it. */
body.gp #actionbar { inset:auto 0 4px 0; left:0; right:0; transform:none; padding:0; background:none; border:0; height:0; z-index:4; }
body.gp #actionbar .gap { display:none; }
body.gp #actionbar .slots > .as { position:absolute; left:auto; right:auto; top:auto; bottom:auto; width:42px; height:42px; border-radius:8px; background:rgba(28,22,16,.85); }
body.gp #actionbar .as .k { font-size:9px; } body.gp #actionbar .as .n { inset:11px 0 9px; font-size:8px; line-height:9px; } body.gp #actionbar .as .c { font-size:8px; }
/* the face buttons as a diamond (Y top · X left · B right · A bottom), R1 and R2 side by side above it, the D-pad's potion / swap and
   the path action in a column to its left: everything on the right, where the right thumb is */
body.gp #actionbar .slots > .as.pb3 { right:66px; bottom:100px; }   /* Y  ability 2 */
body.gp #actionbar .slots > .as.pb2 { right:116px; bottom:52px; }   /* X  ability 1 */
body.gp #actionbar .slots > .as.pb1 { right:16px; bottom:52px; }    /* B  ability 3 */
body.gp #actionbar .slots > .as.pb0 { right:66px; bottom:4px; }     /* A  dash */
body.gp #actionbar .slots > .as.pb5 { right:116px; bottom:158px; }  /* RB ability 4 */
body.gp #actionbar .slots > .as.pb7 { right:16px; bottom:158px; }   /* RT ultimate */
body.gp #actionbar .slots > .as.pb12 { right:176px; bottom:76px; }  /* D↑ potion */
body.gp #actionbar .slots > .as.pb13 { right:176px; bottom:28px; }  /* D↓ swap weapon */
body.gp #actionbar .slots > .as.pb10 { right:176px; bottom:124px; } /* L3 path action */
body.gp .xpbar { position:absolute; left:50%; bottom:0; transform:translateX(-50%); width:min(300px,36%); height:8px; margin:0; }
/* controller menu focus */
.gp-focus { outline:2px solid var(--gold); outline-offset:1px; background:#3a2f20 !important; }

/* tap and hold: an item's or a slot's details (touch.js) */
.t-tip { position:fixed; z-index:60; display:none; background:rgba(14,11,8,.96); color:#e8dcc4; border:1px solid #c9a24a; padding:6px 8px; font-size:12px; line-height:1.35; white-space:pre-line; pointer-events:none; border-radius:4px; box-shadow:0 2px 10px #000a; }
