:root{font:14px/1.5 system-ui,"Microsoft YaHei",sans-serif;color:#fff;background:#111214;color-scheme:dark}*{box-sizing:border-box}html,body{width:100%;height:100%;margin:0;overflow:hidden;overscroll-behavior:none;touch-action:none}body{position:fixed;inset:0}#handheld,#console-face{touch-action:none}button{font:inherit;cursor:pointer;touch-action:none;-webkit-tap-highlight-color:transparent}button:focus-visible{outline:2px solid #54c838;outline-offset:3px}[hidden]{display:none!important}
/* One measured portrait console. All mounts stay at the reference coordinates. */
#handheld{--viewport-height:100dvh;--console-width:min(calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)),calc((var(--viewport-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom))*.627921668));width:100%;height:var(--viewport-height);display:grid;place-items:center;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);overflow:hidden;background:#111214}
#console-face{position:relative;width:var(--console-width);height:calc(var(--console-width)*1.592555332);max-width:100%;max-height:100%;background:var(--fixed-shell) center/100% 100% no-repeat;isolation:isolate;user-select:none;-webkit-user-select:none}
#play-area{position:absolute;left:7.7475%;top:12.6342%;width:83.6016%;height:39.1029%;overflow:hidden;border-radius:2%;background:#000;z-index:1}
#unity-canvas{position:absolute;left:50%;top:50%;display:block;width:var(--canvas-width,100%)!important;height:var(--canvas-height,100%)!important;transform:translate(-50%,-50%);touch-action:none;outline:none;padding:0!important;margin:0!important}
#launch{position:absolute;inset:0;display:grid;place-items:center;background:#101113}.launch-content{padding:12px;text-align:center;max-width:95%;color:#eee}#status{font-size:clamp(12px,2.4vw,18px);margin:0 0 10px}#start{border:1px solid #8a8c8d;background:#303235;color:#fff;border-radius:6px;padding:8px 18px}#compatibility{font-size:clamp(10px,1.8vw,12px);color:#aaa;max-width:220px;margin:12px auto 0}progress{display:block;width:min(180px,55vw);height:7px;accent-color:#3bcc34;margin:12px auto}
.fixed-controls{position:absolute;inset:0;pointer-events:none;z-index:2}.fixed-controls button,.movement-pad,.aim-pad{pointer-events:auto}.control-item,.movement-pad{position:absolute;transform:translate(-50%,-50%);border:0;padding:0;background:transparent;touch-action:none;perspective:400px}
.button-surface,.touch-knob{display:block;position:absolute;inset:0;background:transparent none center/contain no-repeat;pointer-events:none;transition:transform 110ms cubic-bezier(.2,.7,.3,1.2),filter 110ms;will-change:transform;transform-style:preserve-3d}
#touch-fire{left:50.7042%;top:66.9615%;width:17%;height:10.6747%}#touch-weapon{left:67.6056%;top:66.0139%;width:17%;height:10.6747%}#touch-fire .button-surface{background-image:var(--white-a)}#touch-weapon .button-surface{background-image:var(--white-b)}
#touch-move-zone{left:20.1207%;top:68.0985%;width:32%;height:20.093%}#touch-move{position:absolute;inset:0;pointer-events:none}.joystick-base{position:absolute;inset:0;background:var(--joystick-base) center/contain no-repeat;pointer-events:none}.touch-knob{inset:24%;background-image:var(--joystick-cap);transform:translate3d(var(--move-shift-x,0px),var(--move-shift-y,0px),0) rotateX(var(--move-tilt-x,0deg)) rotateY(var(--move-tilt-y,0deg))}
#touch-move-zone[data-active="true"] .touch-knob{filter:brightness(1.13);transition:none}.aim-pad{position:fixed;inset:0;width:100%;height:100%;z-index:0;touch-action:none;pointer-events:none}.fixed-controls[data-state="playing"] .aim-pad{pointer-events:auto}.control-item,.movement-pad,#touch-menu-toggle{z-index:2}#fullscreen-shortcut{left:87%;top:5.7%;width:10.2%;height:6.405%}#fullscreen-shortcut .button-surface{background-image:var(--fullscreen-button)}
#touch-pause{left:37.9276%;top:85.913%;width:15%;height:5.9%}#touch-start{left:59.9598%;top:85.913%;width:15%;height:5.9%}.system-key .button-surface{background-image:var(--white-pill)}
.control-item[data-pressed="true"] .button-surface{transform:translateY(2px) scale(.95);filter:brightness(.8)}#touch-fire[data-held="true"] .button-surface{animation:fire-feedback 180ms ease-in-out infinite}@keyframes fire-feedback{0%,100%{transform:translateY(2px) scale(.95);filter:brightness(.85)}50%{transform:translateY(3px) scale(.93);filter:brightness(1.1)}}
/* The power lamp provides a fixed menu target without extra visual buttons. */
#touch-menu-toggle{position:absolute;left:63.3%;top:5.82%;transform:translate(-50%,-50%);width:8%;height:5%;padding:0;border:0;border-radius:50%;background:transparent}
#touch-menu{position:absolute;left:8%;right:8%;top:18%;max-height:65%;overflow:auto;z-index:10;color:#262729;background:#eeece7f7;border:1px solid #8c8981;border-radius:10px;padding:14px;touch-action:pan-y;box-shadow:0 5px 30px #0009}#touch-menu header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}#touch-menu button{border:1px solid #b5b0a7;background:#d9d6ce;color:#24262a;padding:9px 6px;border-radius:6px;min-height:36px;font-size:12px}.menu-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.menu-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}#feedback-status{position:absolute;z-index:20;left:8%;right:8%;bottom:3%;margin:0;padding:7px 10px;border-radius:6px;background:#24262af5;color:#fff;font-size:11px;pointer-events:none}#feedback-status:empty{display:none}
#handheld:fullscreen,#handheld:-webkit-full-screen{width:100vw;height:100dvh;margin:0}
@media(prefers-reduced-motion:reduce){.button-surface,.touch-knob{transition:none}#touch-fire[data-held="true"] .button-surface{animation:none;transform:translateY(2px) scale(.95);filter:brightness(.85)}}

/* Native fullscreen: corner HUD remains clear, thumbs sit inward and above items. */
.fullscreen-label{display:none}
#handheld[data-fullscreen="true"]{padding:0;--frame-size:clamp(7px,2vmin,12px);--frame-left:max(var(--frame-size),env(safe-area-inset-left));--frame-right:max(var(--frame-size),env(safe-area-inset-right));--frame-top:max(var(--frame-size),env(safe-area-inset-top));--frame-bottom:max(var(--frame-size),env(safe-area-inset-bottom));--pad-size:clamp(104px,34vmin,156px);--action-size:clamp(64px,20vmin,92px);--toolbar-bottom:max(10px,env(safe-area-inset-bottom))}
#handheld[data-fullscreen="true"] #console-face{width:100%;height:100%;max-width:none;max-height:none;background:linear-gradient(145deg,#f4f1eb,#9e9d99 35%,#dfdcd5 65%,#777975);box-shadow:inset 0 0 0 2px #ffffff70,inset 0 0 0 5px #101113}
#handheld[data-fullscreen="true"] #play-area{inset:var(--frame-top) var(--frame-right) var(--frame-bottom) var(--frame-left);width:auto;height:auto;border-radius:10px;outline:3px solid #17191b;box-shadow:0 0 0 4px #777875}
#handheld[data-fullscreen="true"] .fullscreen-label{position:absolute;inset:0;display:grid;place-items:center;color:#eee;font-size:11px;pointer-events:none;text-shadow:0 1px 3px #000}
#handheld[data-fullscreen="true"] #touch-move-zone{left:max(calc(env(safe-area-inset-left) + var(--pad-size)*.5 + 12px),16%);top:69%;bottom:auto;width:var(--pad-size);height:var(--pad-size);transform:translate(-50%,-50%);opacity:.78}
#handheld[data-fullscreen="true"] #touch-fire{left:min(calc(100% - env(safe-area-inset-right) - var(--action-size)*.5 - 12px),82%);top:62%;right:auto;bottom:auto;width:var(--action-size);height:var(--action-size);transform:translate(-50%,-50%);opacity:.88}
#handheld[data-fullscreen="true"] #touch-weapon{left:calc(82% - var(--action-size)*1.08);top:51%;right:auto;bottom:auto;width:calc(var(--action-size)*.78);height:calc(var(--action-size)*.78);transform:translate(-50%,-50%);opacity:.83}
#handheld[data-fullscreen="true"] .face-button .fullscreen-label{top:100%;bottom:auto;height:17px}
#handheld[data-fullscreen="true"] #touch-pause,#handheld[data-fullscreen="true"] #touch-start,#handheld[data-fullscreen="true"] #touch-menu-toggle,#handheld[data-fullscreen="true"] #fullscreen-shortcut{top:auto;bottom:var(--toolbar-bottom);right:auto;width:52px;height:44px;transform:translateX(-50%);border:1px solid #ffffff40;border-radius:9px;background:#15171caa;box-shadow:0 2px 8px #0005}
#handheld[data-fullscreen="true"] #touch-menu-toggle{left:calc(50% - 102px)}
#handheld[data-fullscreen="true"] #touch-pause{left:calc(50% - 34px)}
#handheld[data-fullscreen="true"] #touch-start{left:calc(50% + 34px)}
#handheld[data-fullscreen="true"] #fullscreen-shortcut{left:calc(50% + 102px)}
#handheld[data-fullscreen="true"] .system-key .button-surface{background:none}
#handheld[data-fullscreen="true"] #fullscreen-shortcut .button-surface{inset:8px}
#handheld[data-fullscreen="true"] #touch-menu{left:50%;right:auto;top:max(20px,env(safe-area-inset-top));transform:translateX(-50%);width:min(340px,90vw);max-height:calc(100% - 85px)}
@media (orientation:portrait){#handheld[data-fullscreen="true"] #touch-move-zone{left:21%}#handheld[data-fullscreen="true"] #touch-fire{left:81%}#handheld[data-fullscreen="true"] #touch-weapon{left:calc(81% - var(--action-size)*1.05);top:54%}}
@media (max-width:360px){#handheld[data-fullscreen="true"]{--pad-size:100px;--action-size:60px}#handheld[data-fullscreen="true"] #touch-menu-toggle{left:calc(50% - 90px)}#handheld[data-fullscreen="true"] #touch-pause{left:calc(50% - 30px)}#handheld[data-fullscreen="true"] #touch-start{left:calc(50% + 30px)}#handheld[data-fullscreen="true"] #fullscreen-shortcut{left:calc(50% + 90px)}}


#handheld[data-fullscreen="true"] .fixed-controls{inset:var(--frame-top) var(--frame-right) var(--frame-bottom) var(--frame-left)}

/* Mouse has direct access to Unity HUD; touch keeps swipe-to-aim. */
.fixed-controls[data-input-mode="keyboard"] .aim-pad{pointer-events:none}
#handheld[data-fullscreen="true"][data-input-mode="keyboard"] .fixed-controls{visibility:hidden;pointer-events:none}
/* Menu, shop and pause screens must receive native canvas taps unobstructed. */
#handheld[data-fullscreen="true"] .fixed-controls[data-state="idle"]{visibility:hidden;pointer-events:none}
#fullscreen-tools{display:none}
#handheld[data-fullscreen="true"][data-game-phase="menu"] #fullscreen-tools,
#handheld[data-fullscreen="true"][data-game-phase="paused"] #fullscreen-tools{display:block;position:absolute;z-index:5;left:var(--frame-left);top:var(--frame-top);width:36px;height:36px;border:1px solid #ffffff50;border-radius:8px;color:#ddd;background:#161719b0;font-size:24px;line-height:1}

.keyboard-help{font-size:11px;line-height:1.7;margin:10px 0;color:#555}

.control-preferences{border:1px solid #bbb6ad;border-radius:8px;margin:12px 0 0;padding:10px;display:grid;gap:7px}
.control-preferences legend{font-weight:700}.control-preferences label{display:flex;justify-content:space-between;font-size:12px}
.control-preferences input,.control-preferences select{width:100%;min-height:32px;accent-color:#437d35;touch-action:pan-y}
.control-preferences select{background:#fff;color:#262729;border:1px solid #b5b0a7;border-radius:5px;padding:6px}.settings-note{font-size:11px;margin:2px 0;color:#555}
#layout-editor{position:absolute;z-index:30;left:50%;top:max(27%,105px);transform:translate(-50%,-100%);width:min(540px,92%);background:#eeece7f5;color:#24262a;border:1px solid #777;border-radius:10px;padding:10px;box-shadow:0 3px 20px #0008;font-size:12px}
.layout-fields{display:flex;gap:16px;margin-top:5px}.layout-fields label{flex:1;display:flex;gap:8px;align-items:center}.layout-fields input{width:100%;min-width:0;accent-color:#437d35}
#layout-message{margin:5px 0}.layout-actions{display:flex;justify-content:flex-end;gap:8px}#layout-editor button{min-height:36px;border:1px solid #aaa69c;border-radius:5px;padding:4px 10px;background:#d9d6ce;color:#24262a}#layout-save{font-weight:700}
#handheld[data-fullscreen="true"][data-editing="true"] .fixed-controls{visibility:visible;pointer-events:none}
#handheld[data-editing="true"] .aim-pad{pointer-events:none}
#handheld[data-editing="true"] .control-item,#handheld[data-editing="true"] .movement-pad,#handheld[data-editing="true"] #touch-menu-toggle{pointer-events:auto;cursor:grab;outline:1px dashed #eee;outline-offset:3px}
#handheld[data-editing="true"] [data-selected="true"]{outline:3px solid #70db4d;outline-offset:3px}
@media(max-height:430px){#layout-editor{font-size:11px;padding:6px}#layout-editor strong{display:none}.layout-fields{margin:0}.layout-fields input{height:20px}#layout-message{margin:2px 0}#layout-editor button{min-height:30px}}
