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

body {
  background: #000;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  z-index: 10;
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Countdown ───────────────────────────────────── */
@keyframes cd-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  72%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
}

#countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  /* transform set by animation */
  font-size: 160px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -4px;
  pointer-events: none;
  user-select: none;
  text-shadow:
    0 0 40px rgba(255, 255, 255, 0.6),
    0 4px 16px rgba(0, 0, 0, 0.8);
}

/* ── Game-over dialog ────────────────────────────── */
#gameover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

#gameover-card {
  position: relative;
  background: rgba(12, 22, 14, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 44px 56px 36px;
  text-align: center;
  color: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

#close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  pointer-events: auto;
}
#close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

#go-score {
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  color: #ffd060;
  text-shadow: 0 0 30px rgba(255, 208, 60, 0.5);
  letter-spacing: -2px;
}

#go-label {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 3px;
  margin: 10px 0 36px;
}

#replay-btn {
  display: block;
  width: 100%;
  background: #cc1111;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 4px;
  padding: 13px 0;
  cursor: pointer;
  transition: background 0.15s;
  pointer-events: auto;
}

#replay-btn:hover  { background: #e52222; }
#replay-btn:active { background: #aa0d0d; }

#go-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
  margin-top: 14px;
}

/* ── Power meter (bottom-center) ─────────────────── */
#power-meter {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
}

#power-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 7px;
}

#power-num {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  min-width: 2.5ch;
  text-align: right;
}

#power-track {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  overflow: hidden;
}

#power-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #44e87a, #f5d020, #f5330a);
  border-radius: 7px;
  transition: width 0.04s linear;
}

/* ── Test mode controls (top-right) ──────────────────── */
#test-bar {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 999;
}

#test-bar button {
  padding: 6px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s;
}

#test-bar button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

#test-btn { border-color: rgba(100, 220, 130, 0.4); }
#test-btn:hover { background: rgba(60, 180, 90, 0.3); }

#stop-btn { border-color: rgba(220, 80, 80, 0.4); }
#stop-btn:hover { background: rgba(180, 50, 50, 0.3); }

/* ── Birthday dialog (trick mode) ───────────────── */
#birthday-overlay {
  /* Backdrop only — no card inside */
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

#birthday-card {
  /* Fixed above fireworks canvas (z-index 20) */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  background: linear-gradient(145deg, rgba(18, 8, 38, 0.96), rgba(8, 18, 42, 0.96));
  border: 1px solid rgba(255, 200, 80, 0.35);
  border-radius: 20px;
  padding: 48px 52px 40px;
  text-align: center;
  color: #fff;
  box-shadow:
    0 0 60px rgba(255, 160, 40, 0.25),
    0 8px 40px rgba(0, 0, 0, 0.7);
  width: min(420px, calc(100vw - 32px));
  pointer-events: auto;
}

#birthday-title {
  font-size: 15px;
  letter-spacing: 8px;
  color: rgba(255, 200, 80, 0.7);
  margin-bottom: 24px;
  text-transform: uppercase;
}

#birthday-msg {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.85;
  color: #ffd060;
  text-shadow: 0 0 24px rgba(255, 208, 60, 0.55);
  margin-bottom: 36px;
  letter-spacing: 1px;
}

#birthday-replay-btn {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #d4200a, #f5730a);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 5px;
  padding: 14px 0;
  cursor: pointer;
  transition: opacity 0.15s;
  pointer-events: auto;
}
#birthday-replay-btn:hover  { opacity: 0.88; }
#birthday-replay-btn:active { opacity: 0.7; }

/* ── Mobile hint (below power meter) ────────────── */
#mobile-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  letter-spacing: 2px;
  margin-top: 8px;
}

/* ── Mobile / touch overrides ────────────────────── */
@media (pointer: coarse), (max-width: 600px) {
  #countdown {
    font-size: clamp(72px, 22vw, 140px);
    letter-spacing: -2px;
  }

  #gameover-card {
    padding: 32px 20px 24px;
    border-radius: 14px;
    width: min(360px, calc(100vw - 32px));
  }

  #go-score {
    font-size: clamp(56px, 18vw, 88px);
  }

  #go-hint {
    font-size: 13px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 12px;
  }

  #power-meter {
    width: min(320px, calc(100% - 48px));
    bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 20px));
  }

  #replay-btn {
    font-size: 17px;
    padding: 15px 0;
  }
}
