* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #120d0a;
  color: #f4e9d8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* Fit a 9:16 play field into the window, letterboxed on the other axis. */
#stage {
  position: relative;
  width: min(100vw, calc(100vh * 360 / 640));
  aspect-ratio: 360 / 640;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Sound toggle, always visible during play. */
.chip {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 240, 200, 0.7);
  background: rgba(20, 12, 8, 0.78);
  color: #fff3dc;
  font: 700 13px/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
}

/* Joystick: fixed, large, high contrast, bottom-left so the thumb never covers the spider. */
#joystick {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 150px;
  height: 150px;
  z-index: 4;
  touch-action: none;
}

#joystick.hidden {
  display: none;
}

#joy-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 240, 200, 0.16);
  border: 3px solid rgba(255, 240, 200, 0.75);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.28), inset 0 0 22px rgba(0, 0, 0, 0.35);
}

#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  border: 2px solid #fff3dc;
  background: radial-gradient(circle at 35% 35%, #ffd98a, #c9782a);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 8, 6, 0.74);
}

.overlay.hidden {
  display: none;
}

.panel {
  max-width: 320px;
  padding: 20px 18px 22px;
  text-align: center;
  border: 2px solid #d9a441;
  border-radius: 16px;
  background: rgba(40, 26, 18, 0.95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

h1 {
  margin: 2px 0 8px;
  font-size: 26px;
  letter-spacing: 0.5px;
  color: #ffd27a;
}

h2 {
  margin: 2px 0 8px;
  font-size: 22px;
  color: #ffb3a0;
}

.tagline {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.4;
}

.howto {
  margin: 0 0 6px;
  padding: 0 0 0 4px;
  list-style: none;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
}

.howto li {
  margin-bottom: 6px;
}

.reason {
  margin: 0 0 6px;
  font-size: 15px;
  color: #ffd9c9;
}

.stat {
  margin: 4px 0;
  font-size: 17px;
  font-weight: 700;
}

.big-btn {
  min-width: 200px;
  min-height: 52px;
  margin-top: 14px;
  padding: 14px 26px;
  border: 0;
  border-radius: 12px;
  background: #ffb547;
  color: #2a1606;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.big-btn:active {
  transform: translateY(1px);
}
