 :root{color-scheme:dark;font-family:Arial,Helvetica,sans-serif}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#181818;color:#f2f2f2}
button,input,select{font:inherit}.hidden{display:none!important}.screen{position:fixed;inset:0;display:grid;place-items:center;background:#202020}
.panel{background:#252525;border:1px solid #444;border-radius:6px}.joinPanel{width:min(420px,calc(100% - 28px));padding:20px}
.joinPanel h1{margin:0 0 14px;font-size:24px}.joinPanel p{margin:0 0 12px;color:#bbb}
input,select,button{border:1px solid #555;background:#303030;color:#f2f2f2;border-radius:4px;padding:8px}
.joinPanel input{width:100%;margin:5px 0}button{cursor:pointer}button:hover{background:#3a3a3a}.primary{width:100%;margin-top:8px;background:#3a3a3a}
.status{min-height:22px;margin-top:10px;color:#bbb;font-size:13px}#gameUI{position:fixed;inset:0}#game{display:block;width:100%;height:100%}
#topbar{position:fixed;z-index:20;top:0;left:0;right:0;height:46px;display:flex;align-items:center;gap:14px;padding:0 12px;background:#1d1d1d;border-bottom:1px solid #444}
#topbar #leaveBtn{margin-left:auto}.floating{position:fixed;z-index:15}
#sideMenu{top:58px;left:12px;width:270px;padding:10px;max-height:calc(100vh - 74px);overflow:auto}
#sideMenu.collapsed{width:auto;overflow:hidden}#sideMenu.collapsed .modeTabs,#sideMenu.collapsed section{display:none!important}
.derpTitle{display:flex;align-items:center;justify-content:space-between;margin-bottom:9px}.derpTitle button{padding:2px 8px}
.modeTabs{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-bottom:10px}.modeTabs button{padding:7px 4px}.modeTabs button.on{background:#555}
#sideMenu h2{margin:4px 0 10px;font-size:17px}#sideMenu h3{font-size:14px;margin:0 0 8px}
#sideMenu label{display:block;margin:8px 0}.check{display:flex!important;gap:8px;align-items:center}.check input{width:auto}
#sideMenu input[type=color]{width:70px;height:34px;padding:2px;vertical-align:middle}
#sideMenu input[type=range],#sideMenu select,#sideMenu input[type=number]{width:100%;margin-top:4px}
#sideMenu output{float:right;color:#bbb}.row{display:flex;gap:6px}.row>*{flex:1}.tiny{font-size:12px;color:#aaa;line-height:1.35}
.subbox{border-top:1px solid #444;margin-top:10px;padding-top:10px}.selectionName{display:block;color:#bbb;margin:5px 0 10px}
.chatHeader{display:flex;align-items:center;justify-content:space-between}.chatHeader h2{margin:0}.chatHeader button{padding:5px 8px}
#messages{height:220px;overflow:auto;font-size:13px;line-height:1.35;padding:6px;background:#1d1d1d;border:1px solid #444;border-radius:4px}
.message{margin:4px 0;word-break:break-word}.message .who{font-weight:700}.chatRow{display:flex;gap:6px;margin-top:8px}.chatRow input{flex:1;min-width:0}
#help{right:12px;bottom:12px;padding:10px;font-size:12px;color:#aaa}
@media(max-width:700px){#sideMenu{width:220px}#help{display:none}}

/* v0.7 mobile controls */
#mobileControls{position:fixed;inset:0;z-index:14;pointer-events:none;touch-action:none}
.mobilePad{position:absolute;left:max(18px,env(safe-area-inset-left));bottom:max(24px,env(safe-area-inset-bottom));width:118px;height:118px;border-radius:50%;background:#222b;border:2px solid #777;pointer-events:auto;touch-action:none}
#joystickKnob{position:absolute;left:34px;top:34px;width:46px;height:46px;border-radius:50%;background:#777;border:1px solid #aaa;transform:translate(0,0)}
#mobileButtons{position:absolute;right:max(14px,env(safe-area-inset-right));bottom:max(18px,env(safe-area-inset-bottom));display:grid;grid-template-columns:repeat(2,72px);gap:8px;pointer-events:auto}
#mobileButtons button,#mobileLift button{min-height:52px;background:#2f2f2fe8;border:1px solid #777;font-weight:700;touch-action:manipulation}
#mobileLift{position:absolute;right:max(14px,env(safe-area-inset-right));bottom:150px;display:flex;gap:8px;pointer-events:auto}
#mobileHint{position:absolute;left:50%;bottom:8px;transform:translateX(-50%);font-size:11px;color:#ddd;background:#222a;padding:4px 7px;border-radius:4px}
#mobileCrosshair{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:26px;color:#fff;pointer-events:none;text-shadow:0 1px 2px #000}
body.mobile #help{display:none}
body.mobile #sideMenu{left:8px;top:52px;width:min(265px,78vw);max-height:calc(100vh - 112px)}
body.mobile #sideMenu.mobileClosed{display:none}
body.mobile #topbar{height:44px;font-size:12px}
body.mobile #roomLabel{max-width:34vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.mobile input,body.mobile select,body.mobile button{min-height:42px}
body.mobile .modeTabs{grid-template-columns:repeat(3,1fr)}
@media (pointer:coarse),(max-width:820px){
  #mobileControls{display:block!important}
}

/* v0.8 */
#chatBubbles{position:fixed;inset:0;z-index:13;pointer-events:none}
.chatBubble{
  position:absolute;
  max-width:180px;
  padding:6px 8px;
  border-radius:8px;
  background:#fff;
  color:#111;
  border:1px solid #333;
  font-size:12px;
  line-height:1.25;
  text-align:center;
  transform:translate(-50%,-100%);
  word-break:break-word;
}
.chatBubble::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-6px;
  transform:translateX(-50%);
  border:6px solid transparent;
  border-top-color:#fff;
  border-bottom:0;
}
body.mobile #game{touch-action:none}
body.mobile #sideMenu,
body.mobile #topbar,
body.mobile #mobileButtons,
body.mobile #joystick,
body.mobile #mobileLift{touch-action:manipulation}

#secretEditor{position:fixed;inset:0;z-index:30;pointer-events:none}#editorTop{height:46px;background:#181818;border-bottom:1px solid #555;display:flex;align-items:center;gap:8px;padding:6px 10px;pointer-events:auto}#editorTop span{color:#aaa;margin-right:auto}#editorPanel{position:absolute;right:12px;top:58px;width:280px;max-height:calc(100vh - 70px);overflow:auto;padding:10px;pointer-events:auto;background:#242424}#editorPanel label{display:block;margin:7px 0}#editorPanel input[type=number],#editorPanel select{width:100%}.fileButton{border:1px solid #555;background:#303030;padding:7px;border-radius:4px}.fileButton input{display:none}body.secretEditor #topbar,body.secretEditor #sideMenu,body.secretEditor #mobileControls,body.secretEditor #help{display:none!important}
