* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: #06070f;
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.game-wrapper {
  width: 100%;
  max-width: 480px;
  padding: 0 8px;
  margin: 0 auto;
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #cbd5e1;
}
.hud { flex-wrap: wrap; gap: 6px 0; }
.hud-left, .hud-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hud-score { color: #5eead4; font-variant-numeric: tabular-nums; }
.hud-speed { color: #e2e8f0; font-variant-numeric: tabular-nums; }
.hud-speed #hudSpeed { color: #fbbf24; }
.hud-wave { color: #e2e8f0; font-variant-numeric: tabular-nums; }
.hud-wave #hudWave { color: #5eead4; }
.hud-best { color: #f59e0b; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.hud-pause {
  background: none;
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  color: #cbd5e1;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.hud-pause:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }

/* Canvas — ratio portrait 2:3 */
.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(94, 234, 212, 0.22);
  background: #06070f;
  box-shadow: 0 0 32px rgba(20, 184, 166, 0.16);
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.touch-hint {
  display: none;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  padding: 8px 0;
}
@media (pointer: coarse) {
  .touch-hint { display: block; }
}

/* Overlays */
.overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 16, 0.86);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  justify-content: center;
  align-items: center;
}
.overlay.visible { display: flex; }
.overlay-card {
  background: rgba(12, 22, 30, 0.96);
  border: 1px solid rgba(94, 234, 212, 0.28);
  border-radius: 18px;
  padding: 26px 28px;
  text-align: center;
  max-width: 340px;
  width: 90%;
}
.overlay-card h2 {
  font-size: 1.7rem;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #5eead4, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.overlay-card .score-final {
  font-size: 2rem;
  font-weight: 900;
  color: #5eead4;
  margin: 12px 0 4px;
  font-variant-numeric: tabular-nums;
}
.overlay-card p { color: #cbd5e1; margin-bottom: 6px; line-height: 1.4; }
.overlay-card p.muted { color: #94a3b8; font-size: 0.85rem; }
.overlay-btns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  display: inline-block;
}
.btn-primary {
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  box-shadow: 0 0 16px rgba(20, 184, 166, 0.4);
}
.btn-primary:hover { transform: scale(1.04); box-shadow: 0 0 22px rgba(20, 184, 166, 0.6); }
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); }

/* Sur mobile : l'overlay couvre tout l'écran */
@media (max-width: 720px), (pointer: coarse) {
  .overlay { position: fixed; }
  .overlay-card { max-height: 88vh; overflow-y: auto; }
}
