*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  position: relative;
  z-index: 1;
}
.back {
  position: fixed;
  top: max(0.6rem, env(safe-area-inset-top));
  left: max(0.6rem, env(safe-area-inset-left));
  z-index: 20;
  padding: 0.4rem 0.65rem;
  background: rgba(255,255,255,0.85);
  color: #333;
  font-size: 0.82rem;
  text-decoration: none;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.back.dark { background: rgba(0,0,0,0.55); color: #eee; }
.toolbar {
  position: fixed;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.toolbar.dark { background: rgba(20,20,28,0.85); }
.toolbar button {
  border: none;
  background: transparent;
  padding: 0.5rem 0.85rem;
  font-size: 0.78rem;
  border-radius: 999px;
  cursor: pointer;
  color: #444;
}
.toolbar.dark button { color: #ccc; }
.toolbar button.active {
  background: #222;
  color: #fff;
}
.toolbar.dark button.active { background: #fff; color: #111; }
