/* ------------------------------------------------------------------
   Minigolf — Physics Lab
   HUD chrome only. The course itself is drawn on <canvas>.
------------------------------------------------------------------- */

:root {
  --ink: #eaf1f8;
  --muted: #91a2b3;
  --faint: #5f7183;
  --panel: rgba(11, 16, 22, 0.74);
  --panel-border: rgba(255, 255, 255, 0.085);
  --accent: #6fe3a1;
  --accent-dim: rgba(111, 227, 161, 0.16);
  --warn: #ffb454;
  --warn-dim: rgba(255, 180, 84, 0.16);
  --cool: #74b9ff;
  --cool-dim: rgba(116, 185, 255, 0.16);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #070a0e;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#scene3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

#hud2d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  touch-action: none;
  cursor: grab;
}

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

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.row { display: flex; align-items: center; gap: 8px; }
#holePanel .row { gap: 5px; flex-wrap: wrap; row-gap: 4px; }
#holePanel .chip { padding: 3px 6px; font-size: 10px; }
.spacer { flex: 1; }

.eyebrow {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}

.title {
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.01em;
  margin: 3px 0 7px;
  line-height: 1.15;
}

/* ---------- hole panel ---------- */

#holePanel { top: 16px; left: 16px; width: 300px; pointer-events: auto; }

.stats {
  font-size: 11.5px;
  color: var(--muted);
  gap: 14px;
}
.stats b { color: var(--ink); font-weight: 620; margin-left: 3px; }

.chip {
  pointer-events: auto;
  font: 500 10.5px var(--font);
  letter-spacing: 0.02em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.chip:active { transform: translateY(1px); }

.zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  pointer-events: auto;
}
.zoom-row .eyebrow { font-size: 9px; }
.zoom-range {
  flex: 1;
  min-width: 0;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  pointer-events: auto;
}
.zoom-value {
  min-width: 36px;
  text-align: right;
  font: 600 10.5px var(--mono);
  color: var(--ink);
}

/* ---------- physics panel ---------- */

#physicsPanel {
  left: 16px;
  bottom: 16px;
  width: 268px;
}

.badge {
  font: 600 9.5px var(--font);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ready   { color: var(--accent); background: var(--accent-dim); }
.badge.rolling { color: var(--cool);   background: var(--cool-dim); }
.badge.sliding { color: var(--warn);   background: var(--warn-dim); }
.badge.airborne { color: #d7b3ff; background: rgba(178, 122, 255, 0.16); }
.badge.holed   { color: var(--accent); background: var(--accent-dim); }
.badge.oob     { color: var(--warn);   background: var(--warn-dim); }

.ballcam-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 9px 0 8px;
}

#ballcam {
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #131c25 0%, #080c11 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.ballcam-side { flex: 1; min-width: 0; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 1.5px 0;
}
.kv b {
  font: 500 11px var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kv.micro {
  display: block;
  font-size: 9.5px;
  color: var(--faint);
  font-family: var(--mono);
  padding-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.impact {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 7px;
  font: 10px var(--mono);
  color: var(--faint);
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.impact.live { color: var(--warn); }

/* ---------- minimap ---------- */

#mapPanel {
  right: 16px;
  bottom: 16px;
  padding: 8px;
  border-radius: 14px;
}
#minimap { display: block; width: 190px; height: 140px; border-radius: 8px; }
.map-label {
  position: absolute;
  top: 12px;
  left: 14px;
  font: 600 8px var(--font);
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.34);
}

/* ---------- hint ---------- */

#hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 12;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 17, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #b9c8d8;
  font-size: 12px;
  letter-spacing: 0.005em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#hint b { color: var(--ink); font-weight: 600; }
#hint.gone { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* ---------- overlay ---------- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 10, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.25s ease;
}
#overlay.hidden { display: none; }

#overlay .card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(23, 31, 41, 0.98), rgba(12, 17, 23, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 28px 28px 24px;
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: card-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

#overlay h1 {
  margin: 8px 0 4px;
  font-size: 30px;
  letter-spacing: -0.02em;
  font-weight: 640;
}
#overlay p {
  margin: 0 auto 20px;
  max-width: 32ch;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.actions { display: flex; flex-direction: column; gap: 8px; }

button.primary,
button.ghost {
  pointer-events: auto;
  width: 100%;
  padding: 11px 16px;
  border-radius: 11px;
  font: 600 13px var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
button.primary {
  background: linear-gradient(180deg, #7cebb0, #4fcf8a);
  color: #042113;
  box-shadow: 0 8px 24px rgba(80, 207, 138, 0.22);
}
button.primary:hover { filter: brightness(1.05); }
button.primary:active { transform: translateY(1px); }

button.ghost {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.09);
  color: var(--muted);
}
button.ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--ink); }

/* ---------- level builder ---------- */

#builderPanel {
  z-index: 25;
  top: 16px;
  left: 16px;
  width: 378px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  pointer-events: auto;
  padding: 12px 14px 11px;
}
#builderPanel[hidden] { display: none; }

body.building #holePanel,
body.building #physicsPanel,
body.building #hint { display: none; }

body.building #hud2d { cursor: crosshair; }

button.primary.mini {
  width: auto;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  box-shadow: none;
}

.build-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0 2px;
}
.build-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: var(--ink);
  font: 600 14px var(--font);
  padding: 4px 8px;
  outline: none;
  pointer-events: auto;
}
.build-input:focus { border-color: rgba(111, 227, 161, 0.5); }
.build-par {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}
.build-par input {
  width: 38px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--ink);
  font: 600 11px var(--mono);
  padding: 3px 5px;
  outline: none;
  pointer-events: auto;
}

.build-tools,
.build-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.build-row { gap: 5px; }
.build-row .eyebrow { margin-right: 1px; }

.build-grid-note {
  font: 10px var(--mono);
  color: var(--faint);
  white-space: nowrap;
}

/* A plain crosshair centred on the view: two 1px bars crossing at the exact
   middle of an odd-sized box, with a thin dark keyline so it reads on both
   bright and dark ground. */
.build-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 21px;
  height: 21px;
  margin: -10.5px 0 0 -10.5px;
  z-index: 17;
  pointer-events: none;
}
.build-reticle::before,
.build-reticle::after {
  content: "";
  position: absolute;
  background: rgba(240, 250, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.build-reticle::before {
  left: 0;
  right: 0;
  top: 10px;
  height: 1px;
}
.build-reticle::after {
  top: 0;
  bottom: 0;
  left: 10px;
  width: 1px;
}
.build-reticle[hidden] { display: none; }

#btnBorder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#btnBorder svg.iso {
  width: 22px;
  height: 18px;
  display: block;
  flex: 0 0 auto;
}

/* ---------- inventory ---------- */

.build-inventory { margin-top: 8px; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
}
.inv-item {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  color: var(--muted);
  font: 500 9px var(--font);
  padding: 3px 2px 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.inv-item:hover { background: rgba(255, 255, 255, 0.09); color: var(--ink); }
.inv-item.active {
  border-color: rgba(111, 227, 161, 0.52);
  background: rgba(111, 227, 161, 0.13);
  color: var(--ink);
}
.inv-thumb,
.hb-thumb {
  display: block;
  flex: 0 0 auto;
  width: 30px;
  height: 24px;
  line-height: 0;
}
.inv-thumb .iso,
.hb-thumb .iso {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
}
.inv-item > span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ---------- hotbar ---------- */

.build-backdrop {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(2, 6, 10, 0.58);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}
.build-backdrop[hidden] { display: none; }

.build-quick {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + var(--safe-r, 0px));
  z-index: 18;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(8, 12, 17, 0.82);
  color: var(--ink);
  font: 600 11px var(--font);
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.build-quick[hidden] { display: none; }
.build-quick:hover { background: rgba(22, 30, 39, 0.92); }
.build-quick kbd {
  font: 700 9px var(--mono);
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--muted);
}

.build-hotbar {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-b, 0px));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 12px;
  background: rgba(8, 12, 17, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  z-index: 16;
}
.build-hotbar[hidden] { display: none; }
.hb-slot {
  position: relative;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.hb-slot:hover { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.hb-slot.active {
  border-color: rgba(111, 227, 161, 0.8);
  background: rgba(111, 227, 161, 0.16);
  color: var(--ink);
  transform: translateY(-2px);
}
.hb-num {
  position: absolute;
  top: 2px;
  left: 4px;
  font: 600 8px var(--mono);
  color: var(--faint);
}
/* The pictogram fills 80% of its slot; the tight SVG crop makes the drawing
   itself fill that box. */
.hb-thumb {
  width: 80%;
  height: 80%;
}


/* ---------- mobile thumbsticks ---------- */

/* The sticks sit inside the safe area and away from the screen edges. The
   bottom/left/right system gesture zones (home indicator, back swipe) would
   otherwise cancel drags towards them, which left only "forward" working. */
#hud {
  --stick-size: 104px;
  --stick-edge: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

.build-stick {
  position: absolute;
  bottom: calc(var(--stick-edge) + var(--safe-b));
  width: var(--stick-size);
  height: var(--stick-size);
  display: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%,
    rgba(255, 255, 255, 0.10), rgba(8, 12, 17, 0.72) 70%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: auto;
  z-index: 14;
}
.build-stick *,
.build-stick *::before,
.build-stick *::after {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.build-stick[hidden] { display: none; }
.build-stick-move { left: calc(var(--stick-edge) + var(--safe-l)); }
.build-stick-look { right: calc(var(--stick-edge) + var(--safe-r)); }
.build-stick.active {
  border-color: rgba(111, 227, 161, 0.5);
  background: radial-gradient(circle at 50% 45%,
    rgba(111, 227, 161, 0.16), rgba(8, 12, 17, 0.78) 70%);
}
.build-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #cfe7ff, #6f9ec4 70%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: transform 0.05s linear;
  pointer-events: none;
}
.build-stick-look .build-stick-knob {
  background: radial-gradient(circle at 40% 35%, #ffe3bd, #c29a63 70%);
}
.build-stick-look.active { border-color: rgba(255, 180, 84, 0.55); }
.build-stick-look.active .build-stick-knob {
  box-shadow: 0 0 0 5px rgba(255, 180, 84, 0.16), 0 4px 14px rgba(0, 0, 0, 0.45);
}
.build-stick-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  text-align: center;
  font: 600 8px var(--mono);
  letter-spacing: 0.16em;
  color: rgba(220, 235, 250, 0.6);
  pointer-events: none;
}
.build-altitude {
  position: absolute;
  left: calc(var(--stick-edge) + var(--safe-l));
  bottom: calc(var(--stick-edge) + var(--safe-b) + var(--stick-size) + 10px);
  width: var(--stick-size);
  display: none;
  flex-direction: column;
  gap: 4px;
  pointer-events: auto;
  z-index: 14;
}
.build-altitude[hidden] { display: none; }
.alt-btn {
  width: var(--stick-size);
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 17, 0.76);
  color: rgba(215, 232, 248, 0.9);
  font: 700 12px var(--mono);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.alt-btn:active { background: rgba(111, 227, 161, 0.2); color: var(--ink); }

/* Touch-only builder actions: Build/Destroy above the look stick and the
   undo/redo pair top right. Hidden by default; shown on touch layouts. */
.build-touch-actions,
.build-top-actions {
  position: absolute;
  display: none;
  pointer-events: auto;
}
.build-touch-actions {
  flex-direction: column;
  gap: 8px;
  z-index: 14;
}
.build-top-actions {
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + var(--safe-r, 0px));
  gap: 8px;
  z-index: 18;
}
.build-touch-actions[hidden],
.build-top-actions[hidden] { display: none; }
.touch-btn {
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 17, 0.76);
  color: rgba(215, 232, 248, 0.92);
  font: 700 12px var(--font);
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.touch-btn:active { background: rgba(111, 227, 161, 0.2); color: var(--ink); }
.touch-btn-danger { color: #ffb4a8; border-color: rgba(255, 122, 110, 0.4); }
.touch-btn-danger:active { background: rgba(255, 122, 110, 0.2); }
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 17, 0.76);
  color: rgba(215, 232, 248, 0.92);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:active:not(:disabled) { background: rgba(111, 227, 161, 0.2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

@media (pointer: coarse), (max-width: 760px) {
  body.building .build-stick { display: block; }
  body.building .build-altitude { display: flex; }
  body.building .build-touch-actions { display: flex; }
  body.building .build-top-actions { display: flex; }
  /* Hidden while the settings modal is open; these beat the rules above. */
  body.building .build-altitude[hidden],
  body.building .build-touch-actions[hidden],
  body.building .build-top-actions[hidden] { display: none; }
}
@media (pointer: fine) and (min-width: 761px) {
  body.building .build-stick { display: none; }
  body.building .build-altitude { display: none; }
}

/* A connected pad drives everything the thumb furniture drives, and the
   sticks and action buttons sit on top of the scene the reticle aims at.
   The hotbar stays because it shows the selected slot; the settings button
   stays because it is the visible way in to the inventory. */
body.pad-active .build-stick,
body.pad-active .build-altitude,
body.pad-active .build-touch-actions,
body.pad-active .build-top-actions { display: none !important; }

.tool {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--muted);
  font: 500 10px var(--font);
  padding: 4px 7px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.tool:hover { background: rgba(255, 255, 255, 0.09); color: var(--ink); }
.tool.active {
  border-color: rgba(111, 227, 161, 0.52);
  background: rgba(111, 227, 161, 0.13);
  color: var(--ink);
}
.build-select {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--ink);
  font: 500 10px var(--font);
  padding: 3px 5px;
  outline: none;
  cursor: pointer;
}

.build-status {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font: 10px var(--mono);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.build-status.ok { color: var(--accent); }
.build-status.warn { color: var(--warn); }
.build-status.bad { color: #ff8a8a; }

.build-hint {
  margin-top: 5px;
  font-size: 9.5px;
  line-height: 1.4;
  color: var(--faint);
  min-height: 26px;
}

.chip:disabled,
button:disabled {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  #mapPanel { display: none; }
  #holePanel { width: auto; min-width: 210px; }
  #physicsPanel { width: 236px; bottom: 12px; left: 12px; padding: 10px 12px; }
  #holePanel { top: 12px; left: 12px; }
  .zoom-row { flex-wrap: wrap; row-gap: 4px; }
  .zoom-row .zoom-range { flex-basis: 100%; order: 3; }
  .zoom-value { margin-left: auto; }
  #ballcam { width: 66px; height: 66px; }
  #hint { bottom: 16px; font-size: 11px; padding: 7px 12px; }
  #builderPanel { width: 336px; }
}

@media (max-width: 620px) {
  #holePanel { left: 10px; top: 10px; padding: 10px 12px; }
  .title { font-size: 16px; }
  #physicsPanel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    padding: 9px 12px;
  }
  .ballcam-wrap { margin: 6px 0; }
  #ballcam { width: 56px; height: 56px; }
  .impact { display: none; }
  #hint {
    bottom: 168px;
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 40px);
  }
  #overlay .card { padding: 22px; }
  #overlay h1 { font-size: 25px; }
  #builderPanel {
    top: 10px;
    bottom: auto;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 46vh;
    padding: 10px 12px 9px;
  }
  .build-hint { min-height: 0; }
  .build-status { white-space: normal; }
}

/* Phone and coarse-pointer layout, bottom to top: the hotbar sits centred at
   the bottom, just as wide as its nine slots; the two thumbsticks stand above
   it. The altitude rocker sits above the move stick on the left, Build and
   Destroy above the look stick on the right. Undo/redo go top right and the
   settings button top left. */
@media (max-width: 620px), (pointer: coarse) {
  #hud {
    --stick-size: 92px;
    --stick-edge: 20px;
    --hb-slot: 38px;
    --hb-h: calc(var(--hb-slot) + 10px);
    --stick-bottom: calc(12px + var(--safe-b) + var(--hb-h) + 14px);
    --side-bottom: calc(var(--stick-bottom) + var(--stick-size) + 10px);
  }
  .build-stick {
    width: var(--stick-size);
    height: var(--stick-size);
    bottom: var(--stick-bottom);
  }
  .build-stick-knob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
  .build-altitude {
    left: calc(var(--stick-edge) + var(--safe-l));
    bottom: var(--side-bottom);
    width: 64px;
    gap: 6px;
  }
  .alt-btn { width: 100%; height: 42px; }
  .build-touch-actions {
    right: calc(var(--stick-edge) + var(--safe-r));
    bottom: var(--side-bottom);
    width: var(--stick-size);
  }
  .touch-btn { height: 44px; }
  .build-hotbar {
    left: 50%;
    right: auto;
    bottom: calc(12px + var(--safe-b));
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 20px);
    overflow-x: auto;
    gap: 2px;
    padding: 4px;
  }
  .hb-slot { width: var(--hb-slot); height: var(--hb-slot); }
  /* Touch users rarely have a keyboard, so the 1–9 slot numbers go too. */
  .hb-num { display: none; }
  .build-quick { left: calc(16px + var(--safe-l)); right: auto; }
  .build-quick kbd { display: none; }
}

@media (max-width: 380px) {
  #hud { --stick-size: 80px; --stick-edge: 12px; --hb-slot: 34px; }
  .build-stick-knob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
}
