* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e14;
}

body { cursor: crosshair; }

#stage {
  display: block;
  width: 100vw;
  height: 100vh;
  /* Without touch-action, a tap fires pointerdown AND the browser's compatibility mouse events, so a
     single tap was handled twice (double ghost, double leaderboard toggle). Also kills double-tap zoom
     and the grey tap flash on mobile. */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.hint {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* sits in the lower third, clear of the title the canvas draws at ~44% height —
     centring it put the cursor animation straight on top of the game's name */
  justify-content: flex-end;
  padding-bottom: 14vh;
  gap: 18px;
  color: #eaf2ff;
  pointer-events: none;
  user-select: none;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.hint.gone { opacity: 0; }
.hint .demo-cursor { position: relative; display: inline-block; font-size: clamp(3.4rem, 12vw, 6rem); line-height: 0; animation: demoPress 2s ease-in-out infinite; }
.hint .demo-cursor svg { display: block; filter: drop-shadow(0 3px 16px rgba(10, 18, 40, 0.5)); }
.hint .demo-cursor::after {
  content: ""; position: absolute; left: 0.1em; top: 0.1em;
  width: 1.4em; height: 1.4em; border-radius: 50%;
  border: 0.09em solid rgba(150, 210, 255, 0.85);
  transform: translate(-50%, -50%); transform-origin: center;
  animation: demoClick 2s ease-out infinite;
}
.hint .demo-cap { font: 800 clamp(24px, 5vw, 46px)/1 system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(210, 228, 255, 0.95); text-shadow: 0 3px 20px rgba(10, 18, 40, 0.6); }
@keyframes demoPress { 0%, 12%, 62%, 100% { transform: translate(0, 0); } 18% { transform: translate(0.05em, 0.09em); } 26% { transform: translate(0, 0); } }
@keyframes demoClick { 0%, 14% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 20% { opacity: 0.8; } 50%, 100% { transform: translate(-50%, -50%) scale(1.9); opacity: 0; } }

.panel {
  position: fixed;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(16, 20, 28, 0.7);
  border: 1px solid rgba(150, 180, 255, 0.18);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.75);
  font: 600 12px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  user-select: none;
  backdrop-filter: blur(6px);
}

.panel span { color: #7fd0ff; }

.panel input[type="range"] {
  width: 150px;
  accent-color: #5bc8ff;
  cursor: pointer;
}

.pname {
  position: fixed;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: 240px;
  padding: 12px 16px;
  text-align: center;
  background: rgba(16, 20, 28, 0.85);
  border: 1px solid rgba(150, 180, 255, 0.4);
  border-radius: 10px;
  color: #cfe0ff;
  font: 700 20px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  outline: none;
  backdrop-filter: blur(6px);
  display: none;
}
.pname.show { display: block; }
.pname::placeholder { color: rgba(180, 200, 240, 0.4); }
.pname:focus { border-color: rgba(150, 200, 255, 0.7); }

/* Audio panel — hidden until the speaker is tapped. Sits above the scores footer that opens it. */
/* bottom-right corner, with the panel opening straight above the button */
.audiobtn {
  position: fixed; right: 12px; bottom: 12px; z-index: 6;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; cursor: pointer;
  background: rgba(12, 16, 26, 0.9); color: #8fe6ff;
  border: 1px solid rgba(150, 180, 255, 0.28);
  transition: border-color .2s ease, transform .2s ease;
}
.audiobtn:hover { border-color: rgba(143, 230, 255, 0.7); transform: translateY(-2px); }
.audiobtn.muted { color: rgba(170, 190, 220, 0.4); }

.audiopanel {
  position: fixed; right: 12px; bottom: 58px; z-index: 6;
  display: none; flex-direction: column; gap: 10px;
  padding: 14px 16px; border-radius: 12px;
  background: rgba(12, 16, 26, 0.92); border: 1px solid rgba(150, 180, 255, 0.22);
  backdrop-filter: blur(4px);
}
.audiopanel.show { display: flex; }
.audiopanel label {
  display: flex; align-items: center; gap: 10px;
  font: 800 11px/1 system-ui, sans-serif; letter-spacing: 0.12em;
  color: rgba(190, 210, 240, 0.75); text-transform: uppercase;
}
.audiopanel input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 132px; height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.16); outline: none;
}
.audiopanel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: #8fe6ff; cursor: pointer; border: 0;
}
.audiopanel input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: #8fe6ff; cursor: pointer; border: 0;
}

.mutebtn {
  margin-top: 2px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  font: 800 11px/1 system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(255, 255, 255, 0.06); color: rgba(190, 210, 240, 0.8);
  border: 1px solid rgba(150, 180, 255, 0.22);
}
.mutebtn.on { background: rgba(255, 120, 120, 0.16); color: #ff9d9d; border-color: rgba(255, 120, 120, 0.45); }
