/* KidArcadeControls — touch + desktop HUD kit (GitHub Pages static) */

#kid-arcade-controls {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  font-family: Nunito, system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#kid-arcade-controls.kac-hidden {
  display: none !important;
}

/* Right-half look drag (invisible hit area) */
#kac-look {
  position: absolute;
  top: 0;
  right: 0;
  width: 55%;
  height: 70%;
  pointer-events: auto;
  touch-action: none;
  /* debug: background: rgba(255,0,0,0.05); */
}

#kac-look.kac-look-off {
  pointer-events: none;
}

/* Left joystick */
#kac-stick {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}

#kac-stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(12, 16, 28, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

#kac-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  will-change: transform;
}

/* Action cluster — bottom right */
#kac-actions {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 10px;
  max-width: min(220px, 48vw);
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
}

.kac-btn {
  min-width: 64px;
  min-height: 64px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(16, 22, 36, 0.55);
  color: #fff;
  font: 800 12px/1.15 Nunito, system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px #000a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  text-align: center;
}

.kac-btn:active,
.kac-btn.kac-down {
  transform: scale(0.94);
  background: rgba(90, 160, 255, 0.45);
  border-color: rgba(180, 220, 255, 0.7);
}

.kac-btn[data-id="jump"],
.kac-btn[data-id="primary"],
.kac-btn[data-id="punch"] {
  min-width: 72px;
  min-height: 72px;
  font-size: 13px;
  background: rgba(40, 90, 160, 0.55);
}

.kac-btn[data-id="secondary"],
.kac-btn[data-id="poop"] {
  background: rgba(90, 70, 40, 0.55);
}

.kac-btn[data-id="boost"],
.kac-btn[data-id="fly"] {
  background: rgba(40, 120, 90, 0.55);
}

.kac-btn.kac-sm {
  min-width: 52px;
  min-height: 52px;
  font-size: 11px;
}

/* Small phones: slightly tighter */
@media (max-width: 420px) {
  #kac-stick {
    width: 112px;
    height: 112px;
  }
  .kac-btn {
    min-width: 56px;
    min-height: 56px;
  }
  .kac-btn[data-id="jump"],
  .kac-btn[data-id="primary"],
  .kac-btn[data-id="punch"] {
    min-width: 64px;
    min-height: 64px;
  }
}

/* Prefer game canvas never scrolling */
canvas#c {
  touch-action: none;
}
