* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a120c;
  color: #fff6e8;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  touch-action: none;
  user-select: none;
}
button { font-family: inherit; }
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #2a160e;
}
#bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
}
#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hud {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  z-index: 3;
}
.hud-left { min-width: 180px; }
.nameplate {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #ff8a3d;
  color: #3a1808;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.who { font-size: 16px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.subline { font-size: 12px; color: #ffe0b8; text-shadow: 0 1px 2px #000; }
.bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: rgba(0,0,0,.45);
  overflow: hidden;
  margin-top: 4px;
}
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: #3dcc6a;
}
.bar.mp i { background: #4aa3ff; }
.bar em {
  position: absolute;
  inset: 0;
  font-style: normal;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
.hud-mid { flex: 1; text-align: center; padding-top: 2px; }
.wave { font-size: 13px; color: #ffe7c4; text-shadow: 0 1px 2px #000; }
.score { font-size: 22px; font-weight: 800; text-shadow: 0 2px 4px #000; }
.coin { font-size: 13px; color: #ffd56a; text-shadow: 0 1px 2px #000; }
.pause {
  width: 64px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: rgba(20,10,6,.62);
  color: #fff;
  font-size: 15px;
}
.lane { display: none; }
.toast {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  min-height: 28px;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.45);
  font-size: 16px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.toast.show { opacity: 1; }
.pad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 92px;
  z-index: 3;
}
.stick, .act {
  position: absolute;
  border: 0;
  color: #fff;
  border-radius: 16px;
}
.stick {
  bottom: 8px;
  width: 72px;
  height: 72px;
  background: rgba(20,10,6,.55);
  color: #fff6e8;
}
.stick.left { left: 18px; }
.stick.right { left: 102px; }
.stick .mp-icon { font-size: 36px; }
.act {
  bottom: 10px;
  height: 68px;
  min-width: 108px;
  font-size: 18px;
  font-weight: 800;
}
.charm { right: 140px; background: #2f6bff; }
.slash { right: 16px; background: #ff8a3d; color: #3a1808; }
.mask {
  position: absolute;
  inset: 0;
  background: rgba(12,6,4,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
.mask.show { display: flex; }
.panel {
  width: min(420px, 86vw);
  background: rgba(42, 22, 14, .92);
  border-radius: 16px;
  padding: 22px 20px 18px;
  text-align: center;
}
.panel h2 { margin: 0 0 8px; font-size: 26px; color: #ffb06a; }
.panel p { margin: 0 0 16px; font-size: 15px; line-height: 1.5; color: #ffe8d0; }
.panel button {
  height: 48px;
  min-width: 160px;
  border: 0;
  border-radius: 12px;
  background: #ff8a3d;
  color: #3a1808;
  font-size: 18px;
  font-weight: 800;
}

/* Keep all four controls independently tappable on narrow touch screens. */
.pad {
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(2, minmax(44px, 72px)) minmax(0, 1fr) repeat(2, minmax(62px, 108px));
  align-items: end;
  gap: clamp(4px, 1.5vw, 12px);
  pointer-events: none;
}
.pad > button {
  position: static;
  width: 100%;
  min-width: 0;
  height: clamp(48px, 15vw, 72px);
  padding-inline: 2px;
  pointer-events: auto;
}
.pad .charm { grid-column: 4; }
.pad > button:active { filter: brightness(1.25); }
