html, body {
  margin: 0;
  padding: 0;
  background: #0e0f12;
  color: #e7e7e7;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
}
.wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 24px;
  height: 100%;
  justify-content: center;
}
canvas {
  background: #17181c;
  box-shadow: 0 10px 30px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.35) inset;
  border-radius: 10px;
  image-rendering: pixelated;
  width: 100%;
  max-width: 96vw;
  height: auto;
  aspect-ratio: 20/12;
}
.hud {
  width: 100%;
  max-width: 96vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #cfcfcf;
}
.hud strong { color: #fff; }

/* Dialogue bubble */
.bubble {
  position: absolute;
  background: #ffffff;
  color: #111;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  max-width: 240px;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -100%);
  margin-top: -18px;
}
.bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}
@keyframes bubblePanic {
  0%   { transform: translate(-50%, -100%) translateX(-1.5px) rotate(-1deg); }
  25%  { transform: translate(-50%, -100%) translateX( 1.5px) rotate( 1deg); }
  50%  { transform: translate(-50%, -100%) translateX(-1.2px) rotate(-0.8deg); }
  75%  { transform: translate(-50%, -100%) translateX( 1.2px) rotate( 0.8deg); }
  100% { transform: translate(-50%, -100%) translateX( 0px)   rotate( 0deg); }
}
.bubble-panic { color: #d0021b; animation: bubblePanic 90ms linear infinite; }

/* Mobile Controls */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 150px;
  height: 150px;
  z-index: 100;
  pointer-events: none;
}
@media (hover: none) and (pointer: coarse) {
  .mobile-controls { display: block; }
}
.dpad-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(4px);
}
.dpad-btn:active { background: rgba(255, 255, 255, 0.3); color: #fff; }
.dpad-up { top: 0; left: 50%; transform: translateX(-50%); }
.dpad-down { bottom: 0; left: 50%; transform: translateX(-50%); }
.dpad-left { left: 0; top: 50%; transform: translateY(-50%); }
.dpad-right { right: 0; top: 50%; transform: translateY(-50%); }

.action-btn {
  position: fixed;
  bottom: 60px;
  right: 40px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 59, 59, 0.25);
  border: 2px solid rgba(255, 59, 59, 0.4);
  pointer-events: auto;
  display: none;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: bold;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-size: 14px;
  backdrop-filter: blur(4px);
}
.action-btn:active { background: rgba(255, 59, 59, 0.5); transform: scale(0.95); }
@media (hover: none) and (pointer: coarse) {
  .action-btn { display: flex; }
}
