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

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  width: 100vw;
  height: 56.25vw;
  max-height: 100dvh;
  max-width: 177.78dvh;
  image-rendering: auto;
  cursor: crosshair;
  display: block;
}

/* Comic burst layer: drawn at full device pixel ratio over the game, never takes clicks or touches. */
#hud {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
}

/* Phone controls: two joysticks in the bottom corners, NADE / SWAP above the right one.
   Touching anywhere else on the screen shoots. */
.stick {
  display: none;
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.12));
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
#stick-move { left: calc(24px + env(safe-area-inset-left)); }
#stick-look { right: calc(24px + env(safe-area-inset-right)); }
.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.stick span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -16px;
  text-align: center;
  font: bold 10px monospace;
  color: rgba(255, 255, 255, 0.5);
}
.stick.on { border-color: rgba(255, 255, 255, 0.6); }
.stick.on .knob { background: rgba(255, 210, 63, 0.55); }
body.touch .stick { display: block; }
body.pad .stick { display: none; }

#touch-buttons {
  display: none;
  position: fixed;
  right: calc(30px + env(safe-area-inset-right));
  bottom: calc(168px + env(safe-area-inset-bottom));
  gap: 14px;
  align-items: flex-end;
}

body.touch #touch-buttons { display: flex; }
body.pad #touch-buttons { display: none; }

.btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font: bold 12px monospace;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn:active { background: rgba(255, 210, 63, 0.45); }

/* Login screen: Public play or Developer (PIN) */
#login {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(40, 10, 10, 0.85), rgba(0, 0, 0, 0.95));
  font-family: monospace; color: #fff;
}
.lg-box { text-align: center; }
.lg-title { font: 900 44px "RR Comic", Impact, "Arial Black", sans-serif; color: #ffe3f3; letter-spacing: 3px; margin-bottom: 24px;
  text-shadow: 0 0 4px #ff4fb0, 0 0 12px #ff4fb0, 0 0 26px #ff2a9a; }
.lg-title span { display: block; font-size: 0.7em; letter-spacing: 6px; animation: neon-buzz 6s infinite; }
@keyframes neon-buzz { 0%, 92%, 96%, 100% { opacity: 1; } 94% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .lg-title span { animation: none; } }
@font-face { font-family: "RR Comic"; src: url(bangers.ttf) format("truetype"); font-weight: 900; font-display: swap; }
.lg-sub { font: bold 14px monospace; color: #ffd23f; margin-bottom: 10px; }
#lg-choose { display: flex; flex-direction: column; gap: 14px; align-items: center; }
#lg-choose button {
  width: 240px; padding: 14px 0; font: bold 18px monospace; color: #fff; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 10px; background: rgba(255, 70, 70, 0.35);
}
#lg-choose #lg-dev { background: rgba(60, 140, 255, 0.3); }
#lg-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
#lg-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #ffd23f; }
#lg-dots i.on { background: #ffd23f; }
#lg-pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; justify-content: center; }
#lg-pad button {
  height: 50px; font: bold 20px monospace; color: #fff; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 10px; background: rgba(255, 255, 255, 0.12);
}
#lg-pad button.sm { font-size: 11px; }
#lg-pad button:active { background: rgba(255, 210, 63, 0.5); }
#lg-msg { height: 18px; margin-top: 8px; color: #ff5050; font: bold 14px monospace; }
@media (max-height: 420px) {
  .lg-title { font-size: 30px; margin-bottom: 10px; }
  #lg-pad { grid-template-columns: repeat(3, 56px); gap: 6px; }
  #lg-pad button { height: 40px; }
}

[hidden] { display: none !important; }

#lg-devmenu { display: flex; flex-direction: column; gap: 14px; align-items: center; }
#lg-devmenu button {
  width: 260px; padding: 14px 0; font: bold 17px monospace; color: #fff; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 10px; background: rgba(60, 140, 255, 0.3);
}
#lg-devmenu #lg-boss { background: rgba(255, 70, 70, 0.35); }

#lg-age { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.lg-note { font: bold 13px monospace; color: #ddd; max-width: 320px; }
.lg-row { display: flex; gap: 12px; }
#lg-age button {
  padding: 12px 18px; font: bold 15px monospace; color: #fff; cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 10px; background: rgba(255, 70, 70, 0.35);
}
#lg-age #lg-age-no { background: rgba(255, 255, 255, 0.12); }
#lg-age-msg { height: 16px; color: #ff5050; font: bold 13px monospace; }

#lg-age select {
  font: bold 16px monospace; color: #fff; background: #1b1b22; padding: 10px 8px;
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 8px;
}
#lg-age #lg-age-back { background: rgba(255, 255, 255, 0.12); }

/* Toy slot button (Ball Gag) */
#btn-toy { border-color: rgba(255, 111, 192, 0.8); color: #ffc2e2; }

/* Crafting bench menu */
#craft { position: fixed; inset: 0; background: rgba(10, 4, 14, .82); display: flex; align-items: center; justify-content: center; z-index: 20; font-family: monospace; color: #fff; }
#craft[hidden] { display: none; }
.cr-box { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; padding: 16px; border: 2px solid #35e0ff; border-radius: 10px; background: #160c1c; }
.cr-title { font: 900 28px "RR Comic", Impact, sans-serif; color: #35e0ff; letter-spacing: 2px; text-align: center; margin-bottom: 8px; }
#craft-parts { font: bold 12px monospace; color: #ff9fd2; margin-bottom: 10px; line-height: 1.5; }
#craft-list button, #craft-close { display: block; width: 100%; text-align: left; margin: 0 0 8px; padding: 10px 12px; font: bold 14px monospace; color: #fff; background: #2a1830; border: 2px solid #ff4fa6; border-radius: 8px; cursor: pointer; }
#craft-list button small { font-size: 11px; color: #ccc; font-weight: normal; }
#craft-list button:disabled { opacity: .45; cursor: default; border-color: #555; }
#craft-close { text-align: center; border-color: #35e0ff; background: #0e2a30; }
#btn-craft { border-color: rgba(53, 224, 255, .9); color: #bff4ff; }
#btn-craft[hidden] { display: none; }
