/* KidArcadeControls — touch + desktop HUD kit (GitHub Pages static) */
/* Pads sit above home-indicator / Mac window chrome; larger hit targets for kids */

#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) — taller so thumbs don't fight HUD */
#kac-look {
  position: absolute;
  top: 8%;
  right: 0;
  width: 58%;
  height: 72%;
  pointer-events: auto;
  touch-action: none;
}

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

/* Left joystick — raised + larger */
#kac-stick {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 40px));
  width: 156px;
  height: 156px;
  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.48);
  border: 2.5px solid rgba(255, 255, 255, 0.34);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

#kac-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  border: 2.5px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  will-change: transform;
}

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

.kac-btn {
  min-width: 76px;
  min-height: 76px;
  padding: 8px 12px;
  border: 2.5px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  background: rgba(16, 22, 36, 0.6);
  color: #fff;
  font: 800 13px/1.15 Nunito, system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px #000a;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.4);
  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.5);
  border-color: rgba(180, 220, 255, 0.75);
}

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

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

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

.kac-btn[data-id="mine"],
.kac-btn[data-id="place"],
.kac-btn[data-id="build"] {
  background: rgba(60, 100, 70, 0.58);
}

.kac-btn.kac-sm {
  min-width: 62px;
  min-height: 62px;
  font-size: 12px;
}

/* Phones still large enough to hit; slightly compact on very narrow screens */
@media (max-width: 420px) {
  #kac-stick {
    width: 140px;
    height: 140px;
    bottom: max(48px, calc(env(safe-area-inset-bottom) + 32px));
  }
  #kac-stick-knob {
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
  }
  .kac-btn {
    min-width: 68px;
    min-height: 68px;
  }
  .kac-btn[data-id="jump"],
  .kac-btn[data-id="primary"],
  .kac-btn[data-id="punch"],
  .kac-btn[data-id="use"] {
    min-width: 76px;
    min-height: 76px;
  }
  #kac-actions {
    bottom: max(46px, calc(env(safe-area-inset-bottom) + 30px));
  }
}

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