html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  touch-action: none;
}

#touch {
  position: absolute;
  inset: 0;
}

/* ---- touch controls (src/input/touch.js) ---- */
:root {
  --sat-t: env(safe-area-inset-top, 0px);
  --sat-r: env(safe-area-inset-right, 0px);
  --sat-b: env(safe-area-inset-bottom, 0px);
  --sat-l: env(safe-area-inset-left, 0px);
}
#touch { pointer-events: auto; --tc-opacity: 0.35; font-family: system-ui, sans-serif; }
#touch .tc-pad, #touch .tc-jump {
  position: absolute; border-radius: 50%; box-sizing: border-box;
  opacity: 0; transition: opacity 0.15s;
  pointer-events: none;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.12);
  color: #fff;
}
#touch.tc-visible .tc-pad, #touch.tc-visible .tc-jump { opacity: var(--tc-opacity); }
#touch.tc-stick .tc-pad { transition: none; }
#touch .tc-pad.tc-hidden { opacity: 0; }
#touch .tc-jump { display: flex; align-items: center; justify-content: center; font-weight: 700; letter-spacing: 0.05em; }
#touch .tc-arrow { position: absolute; width: 1.2em; height: 1.2em; line-height: 1.2em; text-align: center; opacity: 0.6; }
#touch .tc-arrow.on { opacity: 1; color: #ff0; text-shadow: 0 0 0.3em #ff0; }
#touch .tc-l { left: 6%; top: 50%; transform: translateY(-50%); }
#touch .tc-r { right: 6%; top: 50%; transform: translateY(-50%); }
#touch .tc-u { top: 6%; left: 50%; transform: translateX(-50%); }
#touch .tc-d { bottom: 6%; left: 50%; transform: translateX(-50%); }
#touch .tc-knob { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.5); }
#touch .tc-jump.on { background: rgba(255,255,0,0.45); border-color: #ff0; }
#touch .tc-gear {
  position: absolute; top: calc(var(--sat-t) + 8px); right: calc(var(--sat-r) + 8px);
  width: 40px; height: 40px; border-radius: 50%; border: 0; font-size: 22px;
  background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); cursor: pointer;
}
#touch .tc-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #111; color: #eee; border: 2px solid #666; border-radius: 12px;
  padding: 16px 20px; min-width: 280px; max-width: 90vw; font-size: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
#touch .tc-panel[hidden] { display: none; }
#touch .tc-panel h2 { margin: 0 0 4px; font-size: 18px; }
#touch .tc-panel label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#touch .tc-panel select, #touch .tc-panel input[type=range] { flex: 1; max-width: 60%; font-size: 15px; }
#touch .tc-panel button { align-self: flex-end; font-size: 16px; padding: 8px 20px; border-radius: 8px; border: 0; background: #ff0; color: #000; }

#stage.top { align-items: flex-start; }
