*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: none;
  background: #000;
}

#canvas-container {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

#canvas-container canvas { display: block; }

/* ---- Controls overlay ---- */
#controls {
  position: fixed; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
}

/* Top bar — retake / save (frozen only) */
#top-bar {
  pointer-events: all;
  display: none;
  padding: 1rem 1.25rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
  justify-content: space-between;
  align-items: center;
}
#top-bar.visible { display: flex; }

/* Bottom bar — flip / capture / settings */
#bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  pointer-events: all;
  padding: 1.25rem 2rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Round icon buttons */
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: background 0.1s;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.icon-btn:active { background: rgba(255,255,255,0.28); }

/* Shutter button */
#capture-btn {
  width: 76px; height: 76px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(255,255,255,0.25);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
#capture-btn:active { transform: scale(0.93); }
#capture-btn.frozen {
  background: #ff48b0;
  box-shadow: 0 0 0 5px rgba(255,72,176,0.35);
}

/* Text buttons (top bar) */
.text-btn {
  padding: 0.5rem 1.1rem;
  border-radius: 20px;
  background: rgba(0,0,0,0.45);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.text-btn:active { background: rgba(255,255,255,0.2); }
#save-btn {
  background: rgba(255,72,176,0.75);
  border-color: rgba(255,72,176,0.8);
}

/* ---- Settings panel ---- */
#settings-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10;
}
#settings-backdrop.visible { display: block; }

#settings-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 11;
  background: rgba(12,12,12,0.97);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px 18px 0 0;
  padding: 0 1.25rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  max-height: 75vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
#settings-panel.open { transform: translateY(0); }

.panel-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 0.8rem auto 1.25rem;
}

.s-section { margin-bottom: 1.25rem; }

.s-label {
  font-family: monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  margin-bottom: 0.55rem;
}
.s-label span { color: rgba(255,255,255,0.65); margin-left: 0.4em; }

/* Color swatches */
.swatch-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.swatch {
  width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
  touch-action: manipulation;
}
.swatch:active { transform: scale(0.88); }
.swatch.sel1 { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.45); }
.swatch.sel2 { border-color: #ff48b0; box-shadow: 0 0 0 2px rgba(255,72,176,0.45); }

/* Pill selectors */
.pill-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.pill {
  padding: 0.38rem 0.85rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  font-family: monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  transition: background 0.12s;
  touch-action: manipulation;
}
.pill:active { background: rgba(255,255,255,0.2); }
.pill.active {
  background: rgba(255,72,176,0.28);
  border-color: rgba(255,72,176,0.55);
  color: #fff;
}

/* Hide camera flip on desktop (no front/rear camera) */
@media (hover: hover) and (pointer: fine) {
  #flip-btn { visibility: hidden; }
}

/* Sliders */
.slider-row {
  display: flex; align-items: center; gap: 0.75rem;
}
.slider-row label {
  font-family: monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  min-width: 5.5em;
}
.slider-row input[type=range] {
  flex: 1;
  accent-color: #ff48b0;
  height: 4px;
}
.slider-row .val {
  font-family: monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.55);
  min-width: 2em;
  text-align: right;
}
