*{box-sizing:border-box}html,body{margin:0;min-height:100%;background:#10263c;color:#effbff;font-family:Trebuchet MS,Arial,sans-serif}body{background:radial-gradient(ellipse at 50% 0,#27546b,#0d1c33 80%)}button,input{font:inherit}button{cursor:pointer;touch-action:none;user-select:none;border:2px solid #bfe5ed;border-radius:16px;color:#fff;background:linear-gradient(#337c91,#164459);box-shadow:inset 0 2px #ffffff55,0 5px #061724;font-weight:bold}button:focus-visible,input:focus-visible{outline:3px solid #ffe296;outline-offset:3px}button:disabled{opacity:.55}.pressed{transform:translateY(4px);filter:brightness(1.2)}[hidden]{display:none!important}.pair{max-width:560px;margin:auto;padding:28px 24px 40px;text-align:center}.pair a{display:block;text-align:left;color:#b2e7ea}.crest{font-size:60px;color:#ffdf87;text-shadow:0 0 45px #ffcf7370}.pair small{color:#dfc27e;font-size:11px;letter-spacing:2px}.pair h1{font-size:36px;color:#fff1bf;margin:12px 0}.pair p{line-height:1.6;color:#b9d5df;font-size:15px}.pair form{display:grid;gap:14px;padding:24px;background:#193e52;border:1px solid #80b4b7;border-radius:22px;text-align:left}.pair label{font-size:14px;color:#fff1bf}.pair input{text-align:center;font-size:28px;letter-spacing:4px;width:100%;padding:14px;border:2px solid #c9dedc;border-radius:14px;color:#14394a;background:#f3fbe9;text-transform:uppercase}.pair form button{padding:16px;background:linear-gradient(#d8f289,#67a449);color:#233a1d;border-color:#edffc4}.secondary{padding:14px}.pair .fine{font-size:12px}#error{color:#ffd29a}#remote{height:100vh;min-height:310px;display:flex;flex-direction:column;padding:max(12px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));overflow:auto;touch-action:none}header{display:flex;align-items:center;gap:12px;flex-shrink:0}header>div{flex:1}header small{display:block;font-size:9px;letter-spacing:2px;color:#d1b77f}header strong{display:block;margin-top:5px;font-size:17px;color:#fff0b3}header button{width:40px;height:36px;font-size:24px}#connection{font-size:11px;color:#a8efcb;max-width:140px}nav{display:flex;justify-content:center;gap:10px;flex-wrap:wrap;margin:14px 0;flex-shrink:0}nav button{font-size:11px;padding:8px 12px;border:1px solid #71a1b0;border-radius:10px;box-shadow:none}.controller{flex:1;display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:185px}.dpad{display:grid;grid-template:repeat(3,1fr)/repeat(3,1fr);gap:5px;width:clamp(168px,42vh,255px);height:clamp(168px,42vh,255px);flex-shrink:0}.dpad button{font-size:28px;border:3px solid #eaffc4;border-radius:24%;background:linear-gradient(#c1ed66,#629f2e);color:#faffde;text-shadow:0 2px #315922}.dpad [data-key=up]{grid-area:1/2}.dpad [data-key=left]{grid-area:2/1}.dpad .center{grid-area:2/2;border-radius:50%;background:radial-gradient(at 30% 20%,#ccffff,#2595b4);border-color:#ddfbff}.dpad [data-key=right]{grid-area:2/3}.dpad [data-key=down]{grid-area:3/2}.actions{position:relative;width:clamp(170px,43vh,240px);height:clamp(175px,43vh,240px);flex-shrink:0}.actions button{position:absolute;width:52%;aspect-ratio:1;border-radius:50%;border:4px solid #e3fdff;box-shadow:0 0 0 3px #254857,inset 0 5px #ffffff77,0 7px #071725}.actions .jump{right:0;top:0;background:linear-gradient(#58e5ff,#0f7bc6)}.actions .attack{bottom:0;left:0;background:linear-gradient(#ffae82,#dd304b)}.actions b{font-size:42px;display:block;line-height:1}.actions small{font-size:10px}.menu{text-align:center;max-width:300px;flex:1}.menu>small{font-size:10px;color:#b9d4df;letter-spacing:1px}.menu>strong{display:block;color:#fff0b4;font-size:17px;margin:8px 0;min-height:22px}.menu>div{display:flex;justify-content:center;gap:8px}.menu button{padding:10px 12px}.menu #confirm{background:linear-gradient(#e6bd72,#b1803d);border-color:#fff2cb;color:#352416}.menu .back{font-size:11px;background:none;border:0;box-shadow:none;color:#bbd5df}footer{text-align:center;color:#91b3c1;font-size:11px;padding-top:10px}.playing .menu>div,.playing .menu>.back{opacity:.85}.playing .menu>small{color:#bde6ad}@media(orientation:portrait){.controller{flex-wrap:wrap;align-content:center;gap:28px 12px}.menu{order:-1;min-width:100%;max-width:none}.dpad{width:44vw;height:44vw}.actions{width:40vw;height:44vw}nav{gap:8px}nav button{padding:10px}header{flex-wrap:wrap}header strong{font-size:15px}header small{letter-spacing:1px}.pair h1{font-size:30px}}@media(max-height:380px) and (orientation:landscape){#remote{padding:6px 20px}nav{margin:6px 0}.dpad{width:160px;height:160px}.actions{width:165px;height:165px}header strong{font-size:14px}footer{padding:4px}}

.leave-dialog{position:fixed;inset:0;z-index:50;background:#071329df;display:flex;align-items:center;justify-content:center;padding:24px}.leave-dialog>div{max-width:480px;text-align:center;background:#174357;border:2px solid #f3d88a;border-radius:24px;padding:24px}.leave-dialog button{display:block;width:100%;padding:14px;margin-top:16px}#keepPlaying{background:linear-gradient(#afe46c,#4f8a35)}#confirmLeave{background:#71394b}

/* Long presses on controls must never start text/image selection. */
button,button *,[data-control],[data-control] *,[data-key],[data-key] *,[data-command],[data-command] *,#remote,#remote *,#touchControls,#touchControls *,canvas{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}
input,textarea,[contenteditable="true"]{-webkit-user-select:text;user-select:text;-webkit-touch-callout:default}
/* Visible viewport rather than the larger layout viewport; no rotation workaround. */
#remote{position:fixed;top:var(--remote-top,0px);left:var(--remote-left,0px);width:var(--remote-width,100%);height:var(--remote-height,100vh);min-height:0;overflow:hidden;padding:8px max(14px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));overscroll-behavior:none}
#remote header{height:42px;min-height:42px;flex-wrap:nowrap;padding-right:162px;gap:8px}#remote header>div{min-width:0}#remote header strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#remote #connection{max-width:120px;font-size:10px}
#full{position:fixed;z-index:50;top:calc(var(--remote-top,0px) + max(8px,env(safe-area-inset-top)));right:calc(max(14px,env(safe-area-inset-right)) + 48px);width:106px;height:38px;font-size:12px;white-space:normal;background:linear-gradient(#ffe69c,#be8e43);color:#332918;border-color:#fff0b9;border-radius:12px;touch-action:manipulation;box-shadow:0 3px #5b431f}
#disconnect{position:fixed;z-index:50;top:calc(var(--remote-top,0px) + max(8px,env(safe-area-inset-top)));right:max(14px,env(safe-area-inset-right));height:38px;width:38px}
#remote nav{flex-wrap:nowrap;overflow-x:auto;justify-content:flex-start;touch-action:pan-x;overscroll-behavior:contain;min-height:35px;margin:5px 0;gap:7px;padding:0 0 3px}#remote nav button{flex-shrink:0;white-space:nowrap;padding:7px 10px;touch-action:pan-x}
#remote .controller{min-height:0;gap:8px}#remote .dpad{width:clamp(120px,calc(var(--remote-height,360px) - 126px),245px);height:clamp(120px,calc(var(--remote-height,360px) - 126px),245px)}#remote .actions{width:clamp(125px,calc(var(--remote-height,360px) - 126px),245px);height:clamp(125px,calc(var(--remote-height,360px) - 126px),245px)}#remote .menu{min-width:0}#remote .menu>strong{font-size:14px;max-height:38px;overflow:hidden}#remote footer{flex-shrink:0;font-size:10px;padding:3px}
@media(max-height:330px) and (orientation:landscape){#remote header small,#remote footer{display:none}#remote header{height:38px;min-height:38px}#remote .menu>strong{margin:2px 0}#remote .menu button{padding:7px 10px}#remote .actions b{font-size:30px}}
@media(orientation:portrait){#remote{overflow-y:auto}#remote header{min-height:52px}#remote #connection{display:none}#remote .controller{flex:1;min-height:280px}#remote .dpad{width:42vw;height:42vw}#remote .actions{width:40vw;height:40vw}#remote .menu{min-width:100%}}

html.game-expanded,html.game-expanded body{width:100%;height:100vh;overflow:hidden}
