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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  user-select: none;
  -webkit-user-select: none;
}

.hud-top-left {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 16px;
  padding-top: 12px;
}

.hud-top-right {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  right: 16px;
  padding-top: 12px;
  text-align: right;
}

#score-label {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

#combo-label {
  font-size: 20px;
  font-weight: 700;
  color: #f5c73a;
  min-height: 26px;
  transition: opacity 0.15s;
}

#combo-label.pop {
  animation: combo-pop 0.3s ease-out;
}

@keyframes combo-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

#highscore-label {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

#timer-label {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  transition: color 0.3s;
}

#timer-label.timer-low {
  color: #e83d3d;
}

#level-label {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

/* ── Menu overlay ── */
#menu-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: auto;
  background: rgba(0,0,0,0.5);
  transition: opacity 0.25s;
}

#menu-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.menu-box {
  background: rgba(0,0,0,0.9);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  max-width: 320px;
  width: 85%;
}

.menu-title {
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.menu-subtitle {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 20px;
}

.menu-score {
  font-size: 48px;
  font-weight: 800;
  color: #f5c73a;
  margin-bottom: 4px;
}

.menu-highscore {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 20px;
}

.menu-new-record {
  color: #4dc759;
  font-weight: 700;
}

.btn {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 8px auto;
  padding: 12px 0;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.btn-primary {
  background: #337df5;
  color: #fff;
}

.btn-secondary {
  background: #404040;
  color: #fff;
  font-size: 15px;
  padding: 10px 0;
}

/* ── Tutorial overlay ── */
#tutorial-overlay {
  position: fixed;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.15s ease-in;
  max-width: calc(100% - 40px);
}

#tutorial-overlay.hidden {
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

.tutorial-box {
  background: rgba(0,0,0,0.8);
  border-radius: 20px;
  padding: 16px 24px;
  display: inline-block;
}

.tutorial-title {
  font-size: 14px;
  font-weight: 700;
  color: #f5c73a;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.tutorial-message {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.tutorial-hint {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}

.tutorial-arrow {
  font-size: 36px;
  color: #fff;
  margin-top: 8px;
  animation: arrow-bounce 0.8s ease-in-out infinite alternate;
}

@keyframes arrow-bounce {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* ── Post-tutorial hint ── */
#hint-overlay {
  position: fixed;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s;
}

#hint-overlay.visible {
  opacity: 1;
}

.hint-box {
  background: rgba(0,0,0,0.7);
  border-radius: 12px;
  padding: 10px 18px;
  display: inline-block;
}

.hint-text {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
