:root {
  --bg: #14171c;
  --surface: rgba(24, 28, 35, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f4f7;
  --muted: #a7afbb;
  --accent: #e5393f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* El escenario ocupa toda la pantalla; los gestos se manejan en JS. */
#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; }

#camera { width: 100%; height: 100%; object-fit: cover; display: block; }

#overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
  pointer-events: none;
}

#grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
  background-size: calc(100% / 4) calc(100% / 6);
}

button, .btn {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  min-height: 42px;
  cursor: pointer;
}

button[aria-pressed="true"], button.active, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

#topbar {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  background-color: var(--surface);
}
#topbar > .primary, #topbar > [aria-pressed="true"] { background-color: var(--accent); }

#panel {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  transform: translateX(-50%);
  width: min(520px, calc(100% - 16px));
  max-height: 55%;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 14px;
}

#panelToggle { width: 100%; border: 0; background: none; color: var(--muted); min-height: 32px; padding: 4px; }

.tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.tabs button { flex: 1; }

.tab label { display: grid; grid-template-columns: 1fr auto; margin-bottom: 6px; }
.tab output { color: var(--muted); font-variant-numeric: tabular-nums; }
.tab input[type="range"] { grid-column: 1 / -1; width: 100%; height: 32px; accent-color: var(--accent); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.row > button { flex: 1 1 auto; }

#colors span { color: var(--muted); margin-right: auto; }
#colors button { flex: 0 0 38px; min-height: 38px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid var(--line); }
#colors button.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

.hint { color: var(--muted); margin: 0 0 10px; }

.card {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 68px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

#unlock {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  touch-action: none;
  opacity: 0.75;
}
#unlock span { position: relative; }
#unlock::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}
#unlock.holding { opacity: 1; }
#unlock.holding::before { transform: scaleX(1); transition: transform 1.2s linear; }

/* En horizontal el panel va a un lado para no tapar el dibujo. */
@media (orientation: landscape) {
  #panel {
    left: auto;
    right: calc(env(safe-area-inset-right) + 8px);
    transform: none;
    width: min(340px, 45%);
    max-height: calc(100% - 76px);
  }
}
