:root {
  --blue: #3aa0ff;
  --green: #4cd964;
  --ink: #0b1026;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060f;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #15203f, #05060f 80%);
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b1026;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  pointer-events: none;
  font-size: clamp(12px, 2.6vw, 18px);
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}
.hud-left { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-chip {
  background: rgba(10, 16, 38, 0.6);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  white-space: nowrap;
}
#hud-brother { color: #fff; }
#hud-brother.charlie { box-shadow: 0 0 0 2px var(--blue) inset; }
#hud-brother.liam { box-shadow: 0 0 0 2px var(--green) inset; }

/* ---------- Touch controls ---------- */
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.touch-cluster {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 18px;
  align-items: flex-end;
  pointer-events: auto;
  /* invisible padding = bigger capture zone, so near-miss taps still land */
  padding: 24px 16px 8px 16px;
}
.touch-cluster.left { left: calc(8px + env(safe-area-inset-left, 0px)); }
.touch-cluster.right {
  right: calc(8px + env(safe-area-inset-right, 0px));
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.trow { display: flex; gap: 16px; align-items: flex-end; }

.tbtn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(20, 28, 56, 0.6);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  touch-action: none;
  transition: transform .05s, background .05s;
  will-change: transform; /* keep the press animation on the compositor */
}
.tbtn.small {
  width: 74px;
  height: 48px;
  border-radius: 24px;
  font-size: 14px;
}
.tbtn.jump { background: rgba(58, 160, 255, 0.5); }
.tbtn[data-key="attack"] { background: rgba(255, 110, 110, 0.35); }
.tbtn:active, .tbtn.pressed { transform: scale(0.9); background: rgba(80, 110, 200, 0.75); border-color: rgba(255,255,255,0.7); }

#pause-btn {
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(50%);
  width: 40px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(10,16,38,0.6);
  color: #fff;
  font-weight: 800;
  letter-spacing: 2px;
  z-index: 6;
}

/* Hide touch controls on devices without touch */
@media (hover: hover) and (pointer: fine) {
  #touch { display: none !important; }
}
