*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;background:#000;color:#fff;font-family:"Courier New",monospace;overflow:hidden;position:fixed;inset:0;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:none;overscroll-behavior:none}
body{display:flex;justify-content:center;align-items:flex-start}
#game-wrapper{display:flex;flex-direction:column;align-items:center;gap:4px;padding-top:4px}
#topbar{width:var(--cw);min-width:220px;display:flex;justify-content:space-between;align-items:center;height:28px}
#back-link{color:#68f700;text-decoration:none;font-size:12px;letter-spacing:2px;border:1px solid #68f700;padding:4px 8px}
.mini-btn{background:#000;color:#00f7ff;border:1px solid #00f7ff;font:inherit;font-size:12px;padding:4px 8px;cursor:pointer}
#game{display:block;image-rendering:pixelated;image-rendering:crisp-edges;touch-action:none;background:#000}
#help{font-size:11px;color:#00f7ff;text-align:center;max-width:var(--cw);letter-spacing:0.5px}
#pad,#actions,#rotate-hint{display:none}
body.touch #help{display:none}
body.touch #pad{
  display:grid;
  grid-template-columns:52px 52px 52px;
  grid-template-rows:52px 52px 52px;
  gap:6px;
  position:fixed;
  left:max(12px,env(safe-area-inset-left));
  bottom:max(14px,env(safe-area-inset-bottom));
  z-index:6;
  touch-action:none;
}
.dpad-btn{
  width:52px;height:52px;border-radius:10px;
  border:3px solid #00f7ff;background:rgba(0,247,255,.08);
  color:#00f7ff;font-size:18px;line-height:1;padding:0;
  display:flex;align-items:center;justify-content:center;
  touch-action:none;
}
.dpad-btn[data-dir="U"]{grid-column:2;grid-row:1}
.dpad-btn[data-dir="L"]{grid-column:1;grid-row:2}
.dpad-btn[data-dir="R"]{grid-column:3;grid-row:2}
.dpad-btn[data-dir="D"]{grid-column:2;grid-row:3}
.dpad-center{grid-column:2;grid-row:2;border-color:#123;background:rgba(0,0,0,.4);pointer-events:none;opacity:.4}
.dpad-btn.active{background:rgba(0,247,255,.45);color:#000}
body.touch #actions{
  display:flex;flex-direction:column;gap:12px;position:fixed;z-index:6;
  right:max(14px,env(safe-area-inset-right));
  bottom:max(22px,env(safe-area-inset-bottom));
}
.act-btn{
  width:96px;height:56px;border-radius:16px;
  border:3px solid #ffa300;background:rgba(255,163,0,.12);
  color:#ffa300;font:inherit;font-size:16px;font-weight:bold;touch-action:none;
}
.act-btn.start{border-color:#68f700;background:rgba(104,247,0,.12);color:#68f700;height:72px;width:110px}
.act-btn.active{background:rgba(255,163,0,.5);color:#000}
.act-btn.start.active{background:rgba(104,247,0,.5);color:#000}
@media (orientation:landscape){
  body.touch #pad{width:auto;bottom:max(16px,env(safe-area-inset-bottom))}
  body.touch .dpad-btn{width:48px;height:48px}
  body.touch #pad{grid-template-columns:48px 48px 48px;grid-template-rows:48px 48px 48px}
  body.touch .act-btn{width:84px;height:48px;font-size:14px}
  body.touch .act-btn.start{width:96px;height:64px}
}
@media (orientation:portrait){
  body.touch #rotate-hint{display:flex;align-items:center;justify-content:center;gap:6px;color:#ff0;font-size:12px;letter-spacing:2px;animation:blink 1.2s steps(2) infinite;margin-top:2px}
body.touch #rotate-hint .rot-ico{flex:0 0 12px;display:block}
}
@keyframes blink{50%{opacity:.3}}
