html,body{margin:0;height:100%;background:#000;overflow:hidden;overscroll-behavior:none;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;-webkit-text-size-adjust:100%}
body{position:fixed;inset:0}
#wrap{display:flex;align-items:center;justify-content:center;height:100%;}
#screen{image-rendering:pixelated;image-rendering:crisp-edges;display:block;background:#000;box-shadow:0 0 40px #1c2ca060}

/* ---- comandi touch ---- */
#touch{display:none;position:fixed;pointer-events:none;box-sizing:border-box}
body.touch #touch{display:flex}
#touch button,#touch .arm{pointer-events:auto;background:linear-gradient(#2c48b8,#0c1660);color:#f8e8b0;border:2px solid #e8c070;box-shadow:0 0 0 2px #1a1220,inset 0 1px 0 #6c88e8;font:bold 16px monospace;touch-action:none;-webkit-tap-highlight-color:transparent;padding:0;display:flex;align-items:center;justify-content:center;box-sizing:border-box}
#touch .on{background:linear-gradient(#4c68d8,#2c3ca0);color:#fff;transform:scale(.94)}
.dpad{position:relative;width:150px;height:150px;pointer-events:auto;touch-action:none}
.dpad .arm{position:absolute;width:50px;height:50px;border-radius:10px;pointer-events:none}
.dpad .hub{position:absolute;left:50px;top:50px;width:50px;height:50px;background:#0c1660;border:2px solid #e8c070;box-sizing:border-box;box-shadow:0 0 0 2px #1a1220}
.dpad .u{left:50px;top:0;border-radius:10px 10px 0 0}.dpad .d{left:50px;bottom:0;border-radius:0 0 10px 10px}
.dpad .l{left:0;top:50px;border-radius:10px 0 0 10px}.dpad .r{right:0;top:50px;border-radius:0 10px 10px 0}
.btns{position:relative;width:170px;height:150px}
.btns .a{position:absolute;right:0;top:22px;width:72px;height:72px;border-radius:50%;font-size:22px}
.btns .b{position:absolute;right:84px;top:62px;width:62px;height:62px;border-radius:50%;font-size:20px}
.btns .m{position:absolute;left:0;top:0;width:70px;height:30px;border-radius:15px;font-size:12px}
.btns .a small,.btns .b small{display:none}

/* verticale: schermo sopra, comandi sotto */
body.touch.portrait #wrap{align-items:center;padding-top:env(safe-area-inset-top)}
body.touch.portrait #touch{left:0;right:0;bottom:0;height:230px;padding:0 max(14px,env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));justify-content:space-between;align-items:flex-end}
/* orizzontale: croce a sinistra, tasti a destra */
body.touch.landscape #touch{inset:0;padding:0 max(10px,env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px,env(safe-area-inset-left));justify-content:space-between;align-items:center}
body.touch.landscape .btns{width:150px;height:170px}
body.touch.landscape .btns .a{right:0;top:30px}
body.touch.landscape .btns .b{right:74px;top:86px}
body.touch.landscape .btns .m{left:auto;right:0;top:auto;bottom:-2px}
@media (max-height:340px){ body.touch.landscape .dpad{transform:scale(.85)} body.touch.landscape .btns{transform:scale(.85)} }
@media (max-width:340px){ body.touch.portrait .dpad,body.touch.portrait .btns{transform:scale(.88)} }

#fs{position:fixed;top:max(6px,env(safe-area-inset-top));right:max(6px,env(safe-area-inset-right));z-index:6;width:34px;height:34px;border-radius:8px;background:#0c1660c0;color:#f8e8b0;border:1px solid #e8c070;font:16px monospace;padding:0;touch-action:manipulation}
#fs[hidden]{display:none}

/* riquadro per copiare il codice dal telefono */
#reward{position:fixed;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;background:#000a;padding:16px;box-sizing:border-box}
#reward[hidden]{display:none}
#reward .box{background:linear-gradient(#2c48b8,#0c1660);border:3px solid #e8c070;box-shadow:0 0 0 3px #1a1220;border-radius:10px;padding:14px 16px;color:#fff;font:15px monospace;text-align:center;max-width:420px;width:100%}
#reward .title{color:#a8d8ff;margin-bottom:6px}
#reward .code{display:block;width:100%;box-sizing:border-box;font:bold 20px monospace;color:#f8e060;background:#0008;border:1px solid #e8c070;border-radius:6px;padding:8px;text-align:center;margin:6px 0 10px;user-select:text;-webkit-user-select:text;touch-action:auto}
#reward .hint{font-size:12px;color:#d0d8ff;margin-bottom:10px}
#reward button{background:#3858d8;color:#fff;border:2px solid #f8e8b0;border-radius:8px;padding:10px 16px;font:bold 15px monospace;margin:0 4px;touch-action:manipulation}
@media (max-height:340px){ body.touch.landscape .dpad{transform:scale(.8);transform-origin:left center} body.touch.landscape .btns{transform:scale(.8);transform-origin:right center} }
