* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; background: #0c0616;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
  font-family: ui-monospace, Menlo, monospace; color: #fff8f0;
}
body {
  --stick: 140px; --btn: 84px; --gap: 14px;
  --sl: max(env(safe-area-inset-left), 0px); --sr: max(env(safe-area-inset-right), 0px);
  --sb: max(env(safe-area-inset-bottom), 0px); --st: max(env(safe-area-inset-top), 0px);
  background: radial-gradient(ellipse at 50% 120%, #3a0a3a 0, #0c0616 70%);
}
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#game { image-rendering: pixelated; image-rendering: crisp-edges; display: block; background: #2a0a4a; touch-action: none; }

#loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 10px; justify-items: center; letter-spacing: 3px; color: #ff7ab6; font-size: 12px; background: #0c0616; z-index: 5; }
#loading .bar { width: 160px; height: 8px; border: 2px solid #ff3e7a; padding: 1px; }
#loading .bar i { display: block; height: 100%; width: var(--p, 5%); background: #ffd23a; transition: width 120ms linear; }

#touch { position: fixed; inset: 0; display: none; z-index: 2; touch-action: none; }
body.touch.playing:not(.paused) #touch { display: block; }

#stick {
  position: absolute; width: var(--stick); height: var(--stick);
  left: calc(var(--sl) + var(--gap)); bottom: calc(var(--sb) + var(--gap));
  pointer-events: none;
}
#stick .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid #ffffff55; background: radial-gradient(circle, #120a1c18 0 55%, #120a1c40 56% 100%);
  box-shadow: inset 0 0 0 6px #ff3e7a22;
}
#stick .knob {
  position: absolute; left: 31%; top: 31%; width: 38%; height: 38%; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ff7ab6c0, #ff3e7a90 60%); border: 2px solid #ffffffb0;
}
#stick.on .ring { border-color: #ffd23a90; }

#buttons {
  position: absolute; pointer-events: none;
  right: calc(var(--sr) + var(--gap)); bottom: calc(var(--sb) + var(--gap));
  width: calc(var(--btn) * 2.3); height: calc(var(--btn) * 2.05);
}
.btn {
  position: absolute; width: var(--btn); height: var(--btn); border-radius: 50%;
  display: grid; place-items: center;
  font: bold 11px ui-monospace, Menlo, monospace; letter-spacing: 1px; color: #fff; text-shadow: 0 1px 0 #000;
  border: 2px solid #ffffffa0;
}
.btn.attack { left: 0; bottom: 0; width: calc(var(--btn) * 1.22); height: calc(var(--btn) * 1.22); background: #ff3e7a50; font-size: 12px; }
.btn.jump { right: 0; bottom: calc(var(--btn) * 0.08); background: #ffd23a3c; }
.btn.shoot { right: calc(var(--btn) * 0.32); top: 0; width: calc(var(--btn) * 0.86); height: calc(var(--btn) * 0.86); background: #4af0ff38; }
.btn.on { background-color: #ffffff70; transform: scale(0.93); border-color: #fff; }

#pausebtn {
  position: absolute; display: grid; place-items: center; color: #fff;
  font: bold 10px ui-monospace, Menlo, monospace; letter-spacing: 1px;
  border: 2px solid #ffffff60; background: #120a1c90; border-radius: 8px;
}
#pausebtn {
  top: calc(var(--st) + 4px); left: 50%; transform: translateX(-50%);
  width: 48px; height: 34px; grid-auto-flow: column; gap: 5px; justify-content: center;
}
#pausebtn i { display: block; width: 5px; height: 14px; background: #fff; }

#rotate {
  position: fixed; inset: 0; display: none; place-content: center; justify-items: center; gap: 22px;
  background: linear-gradient(#2a0a4a, #6a2a9a 60%, #ff3e7a); color: #ffd23a; letter-spacing: 2px;
  font-weight: bold; font-size: 14px; text-align: center; z-index: 10; padding: 24px;
  text-shadow: 2px 2px 0 #120a1c;
}
#rotate .phone {
  width: 54px; height: 92px; border: 5px solid #fff8f0; border-radius: 10px; box-shadow: 4px 4px 0 #120a1c;
  animation: turn 2.2s ease-in-out infinite;
}
@keyframes turn { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) { body.touch #rotate { display: grid; } }
