/* Pocket-style game panels: square beveled controls, compact slots, readable type. */
:root{--pe-ink:#171717;--pe-panel:#c6c6c6;--pe-dark:#313131;--pe-edge:#101010;--pe-light:#fff;--pe-green:#3c8527;--pe-type:Arial,Helvetica,sans-serif;--pe-display:ui-monospace,"Courier New",monospace}
#mobile-ui[hidden],#mobile-hud[hidden],#mobile-hotbar[hidden],#mobile-notices[hidden],#mobile-tabs[hidden],#mobile-worlds[hidden],.mobile-item-tools[hidden]{display:none!important}
#mobile-ui{position:absolute;inset:0;z-index:10;display:flex;flex-direction:column;background:#242424;color:#fff;font:16px/1.35 var(--pe-type);touch-action:pan-y;user-select:none;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
#mobile-ui *{min-width:0;box-sizing:border-box}
#mobile-ui button,body.touch dialog button,body.touch dialog select{border:2px solid var(--pe-edge);border-radius:0;min-height:48px;padding:9px 14px;background:#c6c6c6;color:#171717;box-shadow:inset 2px 2px #fff9,inset -2px -3px #0005;font:700 16px/1.25 var(--pe-type);cursor:pointer;text-shadow:0 1px #fff5;touch-action:manipulation}
#mobile-ui button:active,body.touch dialog button:active{background:#999;box-shadow:inset 2px 3px #0005,inset -2px -2px #fff6}
#mobile-ui button[aria-pressed=true],#mobile-ui button[aria-checked=true]{background:#3c8527;color:#fff;text-shadow:1px 2px #183410;box-shadow:inset 2px 2px #72b44d,inset -2px -3px #225118}
#mobile-ui button:focus-visible,#mobile-ui input:focus-visible,body.touch dialog button:focus-visible{outline:3px solid white;outline-offset:2px}
#mobile-ui button:disabled{opacity:1;background:#858585;color:#353535;box-shadow:inset 2px 2px #aaa,inset -2px -2px #555;cursor:default}
.mobile-topbar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px;background:#222d;border-bottom:2px solid #000}
.mobile-topbar strong{font:700 18px var(--pe-display);text-shadow:2px 2px #000;letter-spacing:.03em}
.mobile-topbar button{min-width:72px}.mobile-eyebrow{display:none}
.mobile-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;flex:none}
#mobile-title{font:700 23px/1.2 var(--pe-display);text-shadow:2px 2px #000;margin:0}
#mobile-worlds{font-size:14px!important;min-height:44px!important;padding:6px 10px!important;max-width:165px}
#mobile-content{flex:1;overflow:auto;min-height:0;overscroll-behavior:contain;padding:4px 16px 20px;scrollbar-color:#bcbcbc #333}
.mobile-controls{display:grid;grid-template-columns:1fr;gap:8px;max-width:760px;margin:auto}
.mobile-action{width:100%;display:flex;align-items:center;justify-content:space-between;text-align:left;gap:6px 16px;flex-wrap:wrap;min-height:52px!important}
.mobile-label{font-size:16px;font-weight:700;line-height:1.3;overflow-wrap:anywhere}
.mobile-detail{font-size:15px;font-weight:400;line-height:1.35}.mobile-action .mobile-detail{flex-basis:100%;color:#333}
.mobile-action:not(button){display:block;background:#333c;border:2px solid #777;padding:12px}.mobile-action:not(button) .mobile-detail{display:block;margin-top:6px;color:#ddd}
.mobile-copy{max-width:760px;margin:12px auto;color:#ddd}.mobile-copy p{font-size:16px;line-height:1.45;margin:0 0 10px;overflow-wrap:anywhere}.mobile-copy h2{font:700 20px/1.3 var(--pe-display);color:white;margin:14px 0 10px;text-shadow:2px 2px #000}
.mobile-control>label{display:block;background:#3c3c3c;border:2px solid #777;padding:12px;color:#fff;font-weight:700}
.mobile-control input[type=text],.mobile-control input[type=password]{display:block;width:100%;min-height:48px;border:2px solid #111;border-radius:0;box-shadow:inset 2px 2px #0008;background:#292929;color:#fff;font:16px var(--pe-type);padding:10px;margin-top:7px}
.mobile-value-line{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:8px}.mobile-value-line button{width:48px;padding:0!important;font-size:24px!important}.mobile-value-line output{font:700 20px var(--pe-display)}
.mobile-control input[type=range]{width:100%;min-height:44px;display:block;accent-color:#5eac3b;touch-action:pan-x}
.mobile-navigation,#mobile-tabs{display:flex;gap:4px;overflow:auto;flex:none;scrollbar-width:thin;padding:0 0 8px}.mobile-navigation{max-width:760px;margin:auto}.mobile-navigation button,#mobile-tabs button{flex-shrink:0;white-space:nowrap;padding:8px 12px!important;font-size:15px!important;min-height:48px}
#mobile-tabs{padding:0 8px 8px;border-bottom:2px solid #161616;background:#444}
#mobile-held{margin:0;padding:8px 12px;background:#1e431b;color:#fff;border-bottom:2px solid #101010;font-size:16px}
/* A real inventory grid. Item names and actions have one shared footer. */
#mobile-ui.is-inventory{background:#c6c6c6;color:#171717}
.is-inventory .mobile-topbar{background:#c6c6c6;border-bottom:0;box-shadow:inset 0 3px #fff8}
.is-inventory .mobile-topbar strong{color:#333;text-shadow:none;font-size:16px}
.is-inventory .mobile-heading{padding:5px 10px 10px}.is-inventory #mobile-title{font-size:20px;text-shadow:none;color:#222}
.is-inventory #mobile-content{padding:8px;box-shadow:inset 2px 2px #0005;background:#8b8b8b;margin:0 8px;border:2px solid #373737}
.is-inventory .mobile-copy{color:#222}.is-inventory .mobile-copy h2{color:#111;text-shadow:none}
.mobile-items{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:3px;max-width:900px;margin:auto;align-content:start}
.mobile-items .mobile-control:not([data-kind=slot]):not([data-kind$=recipe]){grid-column:1/-1}
.mobile-items .mobile-control>label{padding:7px;background:#c6c6c6;color:#222;border-color:#777;font-size:15px}
.mobile-items input[type=text]{margin-top:4px;background:#333;min-height:44px;padding:8px}
.mobile-items .mobile-value-line{margin-top:4px}.mobile-items .mobile-value-line output{font-size:16px}.mobile-items .mobile-value-line button{min-height:40px!important;height:40px}.mobile-items input[type=range]{min-height:28px}
#mobile-ui .mobile-slot{display:flex;position:relative;width:100%;aspect-ratio:1;min-height:48px;padding:4px;background:#8b8b8b;border:2px solid #373737;box-shadow:inset 2px 2px #555,inset -2px -2px #fff9;align-items:center;justify-content:center;text-shadow:none}
#mobile-ui .mobile-slot.selected{border-color:#fff;outline:2px solid #fff;outline-offset:-4px;background:#aaa}
.mobile-slot img{width:42px;height:42px;max-width:90%;max-height:90%;object-fit:contain;image-rendering:pixelated;filter:drop-shadow(2px 2px #0005)}
.mobile-slot.has-sprite .mobile-label{display:none}.mobile-slot .mobile-label{font-size:11px;line-height:1.05;text-align:center;color:#333;font-weight:400}.mobile-slot .mobile-detail{position:absolute;bottom:1px;right:3px;font:700 15px var(--pe-display);color:white;text-shadow:1px 1px #000,2px 2px #000}.mobile-slot .mobile-detail:empty{display:none}
.mobile-item-tools{padding:8px;background:#c6c6c6;border-top:2px solid #eee;flex:none}.mobile-item-name{min-height:24px;text-align:center;font-size:16px;font-weight:700;padding-bottom:5px;color:#222}.mobile-item-modes{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;max-width:600px;margin:auto}.mobile-item-modes button{padding:8px 5px!important;font-size:15px!important}
.mobile-recipe{display:grid;grid-template-columns:40px 1fr;gap:5px 12px;width:100%;text-align:left}.mobile-recipe img{width:36px;height:36px;object-fit:contain;image-rendering:pixelated;grid-row:1/3}.mobile-recipe .mobile-detail{grid-column:2}.mobile-recipe:disabled .mobile-label::after{content:' · Missing materials';font-size:14px;font-weight:400}
.mobile-skin{display:block;width:min(100%,384px);aspect-ratio:1;image-rendering:pixelated;touch-action:none;border:3px solid #111;background:repeating-conic-gradient(#888 0% 25%,#ccc 0% 50%) 0/16px 16px}.mobile-control:has(.mobile-skin){grid-column:1/-1}.mobile-control input[type=file]{width:100%;font-size:16px}
.mobile-delete{min-height:44px!important;background:#555!important;color:#eee!important}.mobile-delete .mobile-label{font-size:14px}
/* Gameplay stays visible under translucent, squared touch controls. */
body.touch-playing>header,body.mobile-menu>header,body.touch footer,body.mobile-menu #touch-menu,body.touch .touch-hotbar{display:none!important}
body.touch #canvas-container{min-height:0}
#mobile-hud{position:absolute;top:max(8px,env(safe-area-inset-top));left:8px;padding:6px 8px;background:#0009;color:#fff;font:700 14px var(--pe-type);text-shadow:1px 1px #000;pointer-events:none;max-width:calc(100% - 110px)}
#mobile-notices{position:absolute;top:48px;left:8px;right:8px;max-width:500px;max-height:18vh;overflow:hidden;padding:8px;background:#000a;color:white;font:16px/1.35 var(--pe-type);text-shadow:1px 1px #000;pointer-events:none}
body.touch dialog{border:3px solid #101010;border-radius:0;box-shadow:inset 3px 3px #fff7,inset -3px -3px #0005;background:#c6c6c6;color:#171717;font:16px/1.4 var(--pe-type);padding:16px;max-height:calc(100dvh - 24px)}
body.touch dialog h2{font:700 22px var(--pe-display);margin-bottom:20px}body.touch dialog p,body.touch dialog .notice{color:#252525!important;font-size:16px!important}body.touch dialog input,body.touch dialog select{font-size:16px;min-height:44px;border-radius:0}body.touch dialog input[type=checkbox]{width:28px;height:28px;min-height:28px;accent-color:#3c8527}body.touch dialog .actions{gap:6px}body.touch dialog button{flex:1}body.touch dialog .close{min-height:44px;padding:6px 10px}
@media(max-width:420px){#mobile-worlds{max-width:140px}.mobile-topbar strong{font-size:16px}.mobile-topbar button{min-width:64px;padding:8px 10px!important}#mobile-hud{max-width:calc(100% - 170px);font-size:13px}#mobile-notices{top:62px;max-height:16vh}.mobile-heading{padding:10px}.mobile-items{grid-template-columns:repeat(6,minmax(0,1fr))}.mobile-slot img{width:36px;height:36px}#mobile-content{padding-left:10px;padding-right:10px}}
@media(min-width:601px){.mobile-items{grid-template-columns:repeat(9,minmax(0,1fr))}.is-inventory .mobile-heading{padding:4px 12px 8px}.is-inventory #mobile-content{margin-left:12px;margin-right:12px}.mobile-item-tools{display:flex;align-items:center;gap:16px}.mobile-item-name{flex:1;text-align:left;padding:0}.mobile-item-modes{flex:1;min-width:320px}.is-inventory .mobile-slot{max-height:74px}.mobile-controls{grid-template-columns:repeat(2,minmax(0,1fr))}#mobile-ui[data-screen="1"] .mobile-controls,#mobile-ui[data-screen="6"] .mobile-controls{grid-template-columns:1fr;max-width:440px}#mobile-notices{left:180px;right:200px;top:14px;font-size:15px}#mobile-hud{max-width:180px}}
@media(max-height:500px){.mobile-topbar{padding:4px 8px}.mobile-heading{padding:6px 12px}#mobile-title{font-size:20px}.mobile-item-tools{padding:5px 8px}#mobile-tabs{padding-bottom:4px}.mobile-navigation{padding-bottom:5px}.mobile-copy{margin-top:8px}}
.mobile-slot.empty-slot .mobile-label{visibility:hidden}#mobile-hud{display:flex;flex-direction:column;gap:2px;background:#0005;padding:3px 5px;max-width:155px!important}.pe-hearts,.pe-food{display:flex;gap:2px;height:17px;align-items:center}.pe-hearts span{font:19px/1 Arial;color:#3b1c1c;-webkit-text-stroke:1px #1a0808;text-shadow:1px 2px #000}.pe-hearts span.filled{color:#ef3d3d}.pe-food span{width:12px;height:12px;border:2px solid #352213;background:#332a22;box-shadow:inset 1px 1px #ffffff30;transform:rotate(-30deg)}.pe-food span.filled{background:#c98749;border-color:#583719}
.mobile-navigation{position:sticky;top:0;z-index:2;background:#242424}.mobile-navigation+.mobile-navigation{top:56px}.is-inventory .mobile-categories{background:#8b8b8b}
.mobile-controls:has([data-kind=skin]){grid-template-columns:repeat(6,minmax(0,1fr))}.mobile-controls:has([data-kind=skin])>.mobile-control{grid-column:1/-1}.mobile-controls:has([data-kind=skin])>[data-kind=color]{grid-column:auto}#mobile-ui [data-kind=color] button{padding:0;min-height:48px;aspect-ratio:1;width:100%;box-shadow:inset 2px 2px #fff5,inset -2px -2px #0005}#mobile-ui [data-kind=color] button[aria-pressed=true]{outline:3px solid #fff;outline-offset:-6px}[data-kind=color] .mobile-label,[data-kind=color] .mobile-detail{display:none}
.mobile-skin{height:auto}
body.mobile-menu #touch-layer,body.mobile-menu #mobile-hud,body.mobile-menu #mobile-hotbar,body.mobile-menu #mobile-notices{display:none!important}
body.touch-playing #mobile-notices{max-height:30vh}
@media(max-height:500px) and (min-width:601px){.is-inventory .mobile-heading{display:none}.is-inventory .mobile-topbar{padding:0 8px}.is-inventory #mobile-content{padding:4px 8px}.is-inventory .mobile-items{max-width:500px}.is-inventory .mobile-items [data-kind=input]>label{font-size:0;padding:3px}.is-inventory .mobile-items [data-kind=input] input{margin:0;min-height:44px}.is-inventory .mobile-slot{max-height:56px!important}.is-inventory .mobile-item-tools{padding:4px 8px}}
/* A controller drives the canvas menus and gameplay; hide every touch surface. */
body.pad-active #touch-layer,body.pad-active #mobile-ui,body.pad-active #mobile-hud,body.pad-active #mobile-hotbar,body.pad-active #mobile-notices{display:none!important}
body.pad-active canvas{cursor:none}

/* ---- Pocket Edition classic touch layout --------------------------------
   Arrow pad bottom-left (centre = sneak toggle, top corners = forward
   diagonals while moving forward), jump bottom-right with Mine / Use beside
   it, chat / more / pause top-right, hotbar centred with the ••• inventory
   button. Squares, 2px dark rims, translucent grey: readable over any scene. */
:root{--pe-pad:min(40vh,184px);--pe-btn:min(14vh,60px);--pe-slot:clamp(30px,calc((100vw - 2 * var(--pe-pad) - 120px) / 10),46px);--pe-glass:#30303080;--pe-glass-hot:#e8e8e877;--pe-rim:#000a}
body.touch .touch-button{border-radius:0;backdrop-filter:none;background:var(--pe-glass);border:2px solid var(--pe-rim);box-shadow:inset 2px 2px #fff4,inset -2px -2px #0006;color:#fff;text-shadow:1px 2px #000;font:700 13px var(--pe-type);padding:2px;min-height:0;display:grid;place-items:center;touch-action:none}
body.touch .touch-button:active,body.touch .touch-button.pressed{background:var(--pe-glass-hot);box-shadow:inset 2px 3px #0005,inset -2px -2px #fff4}
#dpad{position:absolute;left:max(12px,env(safe-area-inset-left));bottom:max(12px,env(safe-area-inset-bottom));width:var(--pe-pad);height:var(--pe-pad);display:grid;grid-template:repeat(3,1fr)/repeat(3,1fr);gap:3px;pointer-events:auto;touch-action:none}
#dpad[hidden]{display:none}
.pe-cell{position:relative;background:var(--pe-glass);border:2px solid var(--pe-rim);box-shadow:inset 2px 2px #fff4,inset -2px -2px #0006}
.pe-cell.pressed{background:var(--pe-glass-hot)}
.pe-arrow::after,.pe-diag::after{content:'';position:absolute;inset:26%;background:#fffe;filter:drop-shadow(2px 2px 0 #000a)}
.pe-up::after{clip-path:polygon(50% 12%,92% 82%,8% 82%)}.pe-down::after{clip-path:polygon(50% 88%,92% 18%,8% 18%)}
.pe-left::after{clip-path:polygon(12% 50%,82% 8%,82% 92%)}.pe-right::after{clip-path:polygon(88% 50%,18% 8%,18% 92%)}
.pe-diag{visibility:hidden}.pe-diag::after{inset:30%;clip-path:polygon(10% 10%,90% 10%,10% 90%)}.pe-diag-r::after{clip-path:polygon(90% 10%,90% 90%,10% 10%)}
#dpad.forward .pe-diag{visibility:visible}
.pe-blank{visibility:hidden}
.pe-sneak{margin:14%;background:#1a1a1a99}.pe-sneak::after{content:'';position:absolute;inset:28%;border-radius:50%;border:3px solid #fffc}
#dpad.sneaking .pe-sneak{background:#3c8527d0}#dpad.sneaking .pe-sneak::after{background:#fff;border-color:#fff}
#dpad.sprinting .pe-up{background:#5fa0e0b0}
body.touch.stick-mode #stick{display:grid;width:var(--pe-pad);height:var(--pe-pad);left:max(12px,env(safe-area-inset-left));bottom:max(12px,env(safe-area-inset-bottom));border-radius:50%;background:var(--pe-glass);border:2px solid var(--pe-rim)}
#stick[hidden]{display:none!important}
.pe-actions{position:absolute;right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));display:grid;grid-template-columns:var(--pe-btn) calc(var(--pe-btn) * 1.3);grid-template-rows:var(--pe-btn) var(--pe-btn);gap:6px}
.pe-actions .pe-small{grid-column:1}
.pe-actions .pe-jump{grid-column:2;grid-row:1/3}
.pe-jump::before{content:'';width:46%;height:30%;background:#fffe;clip-path:polygon(50% 0,100% 100%,72% 100%,50% 45%,28% 100%,0 100%);filter:drop-shadow(2px 2px 0 #000a)}
.pe-jump{font-size:0!important}
.pe-fly{display:none!important}
body.pe-flying .pe-jump{display:none!important}
body.pe-flying .pe-fly{display:grid!important;grid-column:2}
body.pe-flying .pe-fly-up{grid-row:1}body.pe-flying .pe-fly-down{grid-row:2}
.pe-top{position:absolute;top:max(8px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));display:flex;gap:6px}
.pe-top .touch-button{width:52px;height:44px;font-size:12px}
#mobile-hotbar{position:absolute;bottom:max(8px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);display:flex;gap:0;padding:2px;background:#000a;border:2px solid #000;z-index:3;touch-action:none}
#mobile-hotbar button{position:relative;width:var(--pe-slot);height:var(--pe-slot);border-radius:0;padding:3px;border:2px solid #5a5a5a;background:#8b8b8b55;box-shadow:inset 1px 1px #fff3;touch-action:none;display:grid;place-items:center}
#mobile-hotbar button.selected{border:3px solid #fff;outline:2px solid #000;z-index:1;background:#ffffff40}
#mobile-hotbar img{width:76%;height:76%;object-fit:contain;image-rendering:pixelated}
#mobile-hotbar span{font:700 12px var(--pe-display);color:#fff8}
#mobile-hotbar small{position:absolute;right:2px;bottom:0;font:700 13px var(--pe-display);color:#fff;text-shadow:2px 2px #000}
#mobile-hotbar .pe-inv{display:flex;gap:3px;align-items:center;justify-content:center;background:#3a3a3acc}
#mobile-hotbar .pe-inv i{width:5px;height:5px;background:#fff;box-shadow:1px 1px #000}
@media (orientation:portrait){:root{--pe-slot:clamp(28px,calc((100vw - 40px) / 10),46px)}#mobile-hotbar{bottom:calc(max(12px,env(safe-area-inset-bottom)) + var(--pe-pad) + 10px)}}

/* Pocket Edition crafting: a grid of result tiles (dim = missing materials)
   and one footer with the chosen recipe and Craft / Craft all. */
#mobile-ui .mobile-tile{display:flex;position:relative;width:100%;aspect-ratio:1;min-height:48px;padding:4px;background:#8b8b8b;border:2px solid #373737;box-shadow:inset 2px 2px #555,inset -2px -2px #fff9;align-items:center;justify-content:center;text-shadow:none}
#mobile-ui .mobile-tile .mobile-label,#mobile-ui .mobile-tile .mobile-detail{display:none}
#mobile-ui .mobile-tile.has-sprite .mobile-label{display:none}
#mobile-ui .mobile-tile:not(:has(img)) .mobile-label{display:block;font-size:11px;font-weight:400;color:#222;text-align:center}
#mobile-ui .mobile-tile[aria-disabled=true] img{opacity:.35;filter:grayscale(.6)}
#mobile-ui .mobile-tile[aria-disabled=true]{background:#6f6f6f}
#mobile-ui .mobile-tile.selected{border-color:#fff;outline:3px solid #f6d34a;outline-offset:-5px;background:#a9a9a9}
.mobile-tile img{width:42px;height:42px;max-width:88%;max-height:88%;object-fit:contain;image-rendering:pixelated;filter:drop-shadow(2px 2px #0005)}
.mobile-craft-tools[hidden]{display:none!important}
.mobile-craft-tools{display:grid;grid-template-columns:1fr auto;grid-template-areas:"name buttons" "needs buttons";gap:2px 12px;align-items:center;padding:8px 12px;background:#c6c6c6;border-top:2px solid #eee;color:#222;flex:none}
.mobile-craft-name{grid-area:name;font:700 17px var(--pe-type)}
.mobile-craft-needs{grid-area:needs;font-size:14px;color:#333;overflow-wrap:anywhere}
.mobile-craft-buttons{grid-area:buttons;display:flex;gap:6px}
.mobile-craft-buttons button{min-width:96px}
.mobile-craft-buttons button:first-child:not(:disabled){background:#3c8527;color:#fff;text-shadow:1px 2px #183410;box-shadow:inset 2px 2px #72b44d,inset -2px -3px #225118}
@media(max-width:600px){.mobile-craft-tools{grid-template-columns:1fr;grid-template-areas:"name" "needs" "buttons"}.mobile-craft-buttons button{flex:1}}
/* Landscape phones and tablets: inventory sections as a left tab column,
   like Pocket Edition's creative / crafting tabs, so the grid gets the height. */
@media (orientation:landscape) and (min-width:601px){
  #mobile-ui.is-inventory{display:grid;grid-template-columns:minmax(120px,18%) 1fr;grid-template-rows:auto auto auto 1fr auto auto}
  #mobile-ui.is-inventory>.mobile-topbar{grid-column:1/-1;grid-row:1}
  #mobile-ui.is-inventory>.mobile-heading{grid-column:2;grid-row:2}
  #mobile-ui.is-inventory>#mobile-tabs{grid-column:1;grid-row:2/7;flex-direction:column;overflow:auto;border-bottom:0;border-right:2px solid #161616;padding:8px 6px;gap:4px;background:#8b8b8b}
  #mobile-ui.is-inventory>#mobile-tabs button{width:100%;text-align:left}
  #mobile-ui.is-inventory>#mobile-held{grid-column:2;grid-row:3}
  #mobile-ui.is-inventory>#mobile-content{grid-column:2;grid-row:4;min-height:0}
  #mobile-ui.is-inventory>.mobile-item-tools,#mobile-ui.is-inventory>.mobile-craft-tools{grid-column:2;grid-row:5}
}
