/* PUNT — combat feel slice.
   Everything here is HUD chrome. The game is the canvas underneath. */

:root {
  --ink: #f4ecdf;
  --ink-dim: #a89880;
  --lantern: #ffb347;
  --coin: #d9b45a;
  --bg: #141018;

  --btn: 68px;
  --btn-big: 88px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/1.35 ui-monospace, "SF Mono", Menlo, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* Invisible capture zones. Left half drives the stick, right half the camera.
   Buttons sit above the look zone and take their own presses first.

   touch-action: none is REQUIRED here and is not redundant with the rule on
   body — touch-action does not inherit. Without it iOS may claim the touch for
   a native gesture mid-drag, and the pointerup lands somewhere we never see. */
.zone {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: auto;
  touch-action: none;
}
#stickzone { left: 0; width: 50%; }
#lookzone  { right: 0; width: 50%; }

/* ---------- floating stick ---------- */

#stick {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  pointer-events: none;
}
#stickbase, #stickknob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
#stickbase {
  width: 132px; height: 132px;
  border: 2px solid rgba(244, 236, 223, 0.28);
  background: rgba(20, 16, 24, 0.22);
}
#stickknob {
  width: 58px; height: 58px;
  border: 2px solid rgba(244, 236, 223, 0.6);
  background: rgba(244, 236, 223, 0.16);
}

/* ---------- action buttons ---------- */

#buttons {
  position: absolute;
  right: calc(var(--gap) + env(safe-area-inset-right));
  bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto auto;
  gap: var(--gap);
  align-items: end;
  justify-items: end;
  pointer-events: none;
}

.btn {
  pointer-events: auto;
  touch-action: none;
  width: var(--btn);
  height: var(--btn);
  border-radius: 50%;
  border: 2px solid rgba(244, 236, 223, 0.45);
  background: rgba(20, 16, 24, 0.42);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(3px);
  transition: transform 60ms ease-out, background 60ms ease-out;
}
.btn.big {
  width: var(--btn-big);
  height: var(--btn-big);
  font-size: 30px;
  border-color: rgba(255, 179, 71, 0.7);
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
}
.btn.small {
  width: 52px;
  height: 52px;
  font-size: 19px;
  opacity: 0.8;
}
.btn[data-held] {
  transform: scale(0.92);
  background: rgba(255, 179, 71, 0.35);
}

#btn-lockon {
  pointer-events: auto;
  touch-action: none;
  position: absolute;
  right: calc(var(--gap) + env(safe-area-inset-right));
  top: calc(var(--gap) + env(safe-area-inset-top));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(244, 236, 223, 0.45);
  background: rgba(20, 16, 24, 0.42);
  color: var(--ink);
  font-size: 24px;
  padding: 0;
  backdrop-filter: blur(3px);
}
#btn-lockon[data-on] {
  border-color: var(--lantern);
  color: var(--lantern);
  background: rgba(255, 179, 71, 0.22);
}

/* ---------- debug readout ---------- */

#readout {
  position: absolute;
  left: calc(var(--gap) + env(safe-area-inset-left));
  top: calc(var(--gap) + env(safe-area-inset-top));
  margin: 0;
  font: 500 11px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink-dim);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  white-space: pre;
}
#readout:empty { display: none; }

/* ---------- tuning panel ---------- */

#tuning-handle {
  position: fixed;
  left: calc(var(--gap) + env(safe-area-inset-left));
  bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  z-index: 20;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(244, 236, 223, 0.35);
  background: rgba(20, 16, 24, 0.6);
  color: var(--ink-dim);
  font-size: 18px;
  padding: 0;
  backdrop-filter: blur(3px);
}

#tuning {
  position: fixed;
  z-index: 19;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(360px, 88vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(14, 11, 18, 0.94);
  border-right: 1px solid rgba(244, 236, 223, 0.16);
  padding: calc(var(--gap) + env(safe-area-inset-top)) var(--gap)
           calc(72px + env(safe-area-inset-bottom)) var(--gap);
  backdrop-filter: blur(10px);
}
#tuning[hidden] { display: none; }

#tuning h2 {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--coin);
}
#tuning .hint {
  margin: 0 0 14px;
  font-size: 11px;
  color: var(--ink-dim);
}

#tuning .group {
  margin: 14px 0 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(244, 236, 223, 0.12);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  padding: 4px 0;
}
.row label {
  font-size: 12px;
  color: var(--ink);
}
.row output {
  font-size: 12px;
  color: var(--coin);
  font-variant-numeric: tabular-nums;
}
.row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: var(--lantern);
  background: transparent;
}
.row.toggle { padding: 7px 0; }
.row.toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--lantern);
}

#tuning .actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
#tuning .actions button {
  flex: 1;
  padding: 11px 8px;
  border-radius: 10px;
  border: 1px solid rgba(244, 236, 223, 0.3);
  background: rgba(244, 236, 223, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}
#tuning .actions button:active { background: rgba(255, 179, 71, 0.3); }

/* Landscape phones: shorter viewport, so shrink the furniture. */
@media (max-height: 460px) {
  :root { --btn: 58px; --btn-big: 74px; --gap: 12px; }
  #tuning { width: min(420px, 60vw); }
}
