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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0e0e14;
}

canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */

#toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: rgba(14, 14, 20, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* Brush size row */
#brush-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.brush-label {
  color: rgba(255, 255, 255, 0.4);
  font: 600 11px system-ui;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

#brush-size {
  color: rgba(255, 255, 255, 0.6);
  font: 600 12px/1 system-ui;
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}

#brush-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}
#brush-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
}
#brush-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
}

/* Material buttons row */
#mat-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.mat-btn {
  flex: 1;
  min-height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  font: 600 11px/1.2 system-ui, sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mat-btn.active {
  border-color: var(--c);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

@supports (background: color-mix(in srgb, red, transparent)) {
  .mat-btn.active {
    background: color-mix(in srgb, var(--c) 22%, transparent);
  }
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}

.erase-x {
  font-size: 16px;
  line-height: 1;
}

#clear-btn {
  flex: 0 0 54px;
  min-height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── Gyro permission banner (iOS only) ───────────────────────────────────── */

#gyro-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  border: none;
  border-radius: 22px;
  padding: 10px 20px;
  background: rgba(74, 143, 219, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font: 600 13px system-ui;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#gyro-btn.hidden {
  display: none;
}
