* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120303;
  color: #eee;
  font-family: Impact, "Haettenschweiler", "Arial Black", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
canvas#game {
  position: absolute;
  inset: 0;
  display: block;
  cursor: none;
}
body:has(.overlay:not([hidden])) canvas#game { cursor: default; }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20, 0, 0, 0.35), rgba(0, 0, 0, 0.8));
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  z-index: 10;
  overflow-y: auto;
}
.overlay[hidden], [hidden] { display: none !important; }
.panel {
  text-align: center;
  max-width: 720px;
  width: 100%;
}
h1 {
  margin: 0;
  font-size: clamp(48px, 13vw, 120px);
  line-height: 0.9;
  letter-spacing: 2px;
  color: #f2f2f2;
  text-shadow: 4px 4px 0 #000, 0 0 30px rgba(255, 0, 0, 0.5);
}
h1 span {
  display: block;
  font-size: 0.42em;
  color: #d01818;
  letter-spacing: 0.35em;
  margin-top: 6px;
}
h2 {
  font-size: clamp(40px, 10vw, 80px);
  margin: 0 0 12px;
  text-shadow: 3px 3px 0 #000;
}
h2.dead { color: #d01818; }
.tag {
  margin: 8px 0 22px;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: #b99;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
button {
  font-family: inherit;
  color: #fff;
  background: #7a0c0c;
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  letter-spacing: 0.08em;
  touch-action: manipulation;
}
button:hover { background: #a01414; }
button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
button.big {
  font-size: 32px;
  padding: 10px 56px;
  margin: 6px;
}
button.small {
  font-size: 15px;
  padding: 7px 14px;
  margin: 6px 4px;
  background: #2a1010;
}
.row { margin: 10px 0; display: flex; justify-content: center; flex-wrap: wrap; }
#best { color: #f0c060; font-size: 18px; min-height: 22px; }
.controls {
  margin-top: 16px;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.7;
  color: #caa;
}
.controls b { color: #fff; font-family: Impact, "Arial Black", sans-serif; font-weight: normal; letter-spacing: 0.05em; }
.controls.mob { display: none; }
body.touch .controls.desk { display: none; }
body.touch .controls.mob { display: block; }
.tip {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: #866;
  font-style: italic;
}
#overStats {
  font-size: 22px;
  line-height: 1.6;
  color: #ccc;
}
#overStats b { color: #fff; font-size: 28px; }

@media (max-height: 460px) {
  h1 { font-size: 56px; }
  .tag { margin: 4px 0 10px; }
  button.big { font-size: 24px; padding: 6px 40px; }
  .controls { margin-top: 6px; font-size: 12px; line-height: 1.5; }
}

/* ---------- stage (rotated on upright phones) ---------- */
#stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  transform-origin: 0 0;
  overflow: hidden;
}
#stage > canvas#game, #stage > .overlay, #stage > #touch { position: absolute; }

/* ---------- touch controls ---------- */
#touch {
  inset: 0;
  z-index: 5;
}
#touch svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.stick {
  position: absolute;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.12s;
}
.stick.on { opacity: 1; }
.stick .lbl {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.45);
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 3px solid rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
}
#stickR { border-color: rgba(255, 70, 50, 0.5); }
#stickR .knob { background: rgba(255, 60, 40, 0.5); }

.cluster {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 170px;
  height: 90px;
  pointer-events: none;
}
.tbtn {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border-radius: 50%;
  background: rgba(30, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1;
}
.tbtn span { max-width: 88%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbtn.jump { right: 0; bottom: 0; width: 84px; height: 84px; font-size: 13px; background: rgba(150, 12, 12, 0.55); }
.tbtn.jump svg { width: 30px; height: 30px; }
.tbtn.roll { right: 96px; bottom: 4px; width: 62px; height: 62px; }
.tbtn.act { right: 10px; bottom: 98px; width: 76px; height: 76px; font-size: 10px; transition: background 0.15s, border-color 0.15s, opacity 0.15s; }
.tbtn.act.off { opacity: 0.3; }
.tbtn.act.ready { background: rgba(230, 170, 30, 0.8); border-color: #fff2c0; color: #1a0a00; animation: pulse 0.35s ease-in-out infinite alternate; }
.tbtn.act.grab { background: rgba(170, 120, 20, 0.6); border-color: #ffd98a; }
.tbtn.act.hot { background: rgba(200, 30, 20, 0.75); border-color: #ff9a80; animation: pulse 0.7s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .tbtn.act.hot, .tbtn.act.ready { animation: none; } }
.tbtn.on { background: rgba(220, 30, 30, 0.8) !important; transform: scale(0.93); }
.tbtn:hover { background: rgba(30, 0, 0, 0.5); }
.pausebtn {
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  font-size: 15px;
}
