* { box-sizing: border-box }
body { margin: 0; overflow: hidden; background: #88c9e8; color: #fff8df; font: 16px system-ui, sans-serif }
canvas { display: block; width: 100vw; height: 100dvh; touch-action: none }
.hud, #controls, #prompt, #direction, #version, button { background: #172f2aeb; color: #fff8df; border-radius: 12px; padding: 8px 12px }
.hud { position: absolute; top: 14px; left: 14px }
h1 { margin: 0 0 4px; font-size: clamp(17px, 3vw, 25px) }
#count { font-weight: bold; color: #ffda69 }
#place, #level { font-size: 13px }
button { border: 1px solid #fff8df55; font: inherit; cursor: pointer; touch-action: none }
button:focus-visible { outline: 3px solid #ffda69 }
#hint, #direction { position: absolute; right: 14px; top: 14px }
#direction { top: 56px; margin: 0; font-size: 14px }
#version { position: absolute; bottom: 12px; right: 12px; font-size: 12px }
#controls, #prompt { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; margin: 0; text-align: center }
#prompt { bottom: 58px; background: #ffdf7b; color: #2a251a; font-weight: bold }
#touch { display: none }
#joystick, .touch-actions {
  position: fixed;
  bottom: max(35px, calc(env(safe-area-inset-bottom) + 10px));
  touch-action: none;
  user-select: none;
}
#joystick {
  left: max(12px, env(safe-area-inset-left));
  width: clamp(80px, 23vmin, 124px);
  aspect-ratio: 1;
  border: 2px solid #fff8df99;
  border-radius: 50%;
  background: #172f2a80;
  display: grid;
  place-items: center;
}
#joystick span {
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff8dfb3;
  pointer-events: none;
}
.touch-actions {
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.touch-actions button { min-height: 44px; padding: 5px 8px; background: #172f2aad; font-size: 14px }
.touch-actions button:active { background: #172f2a }
dialog { background: #fff5d5; border: 0; border-radius: 18px; padding: 24px; text-align: center; color: #172f2a; max-width: 90vw }
dialog::backdrop { background: #142a29a8 }
dialog h2 { margin: 0 }
dialog button { margin: 4px }
@media (any-pointer: coarse), (max-width: 650px) {
  html, body { overflow: hidden; overscroll-behavior: none }
  body { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100% }
  #world { height: 100svh }
  #touch { display: block }
  #controls { display: none }
  #version { position: fixed; bottom: max(8px, env(safe-area-inset-bottom)) }
  #prompt { bottom: 170px; width: max-content; max-width: 90vw }
}
