:root {
  --bg: #0b0d12;
  --panel: #151922;
  --panel-2: #1d222d;
  --line: #2a313f;
  --text: #e8ecf4;
  --dim: #8b93a7;
  --accent: #4dabf7;
}

* { box-sizing: border-box; }

/* A class selector beats the UA's [hidden] rule, so any element styled with a
   display value would ignore .hidden = true. Make the attribute authoritative. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 0 3rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

#video { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 0; }

h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.sub { margin: 0.3rem 0 1rem; color: var(--dim); max-width: 66ch; }

/* ---- stage ---- */
.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { touch-action: none; cursor: crosshair; }

.status, .badge {
  position: absolute;
  top: 10px;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.78rem;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.status { left: 10px; }
.badge { right: 10px; color: var(--dim); }

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: linear-gradient(160deg, #10141d, #1b2130);
  z-index: 5;
}
.start-big {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
.start-big:hover { filter: brightness(1.1); }
.start-big svg { width: 24px; height: 24px; fill: currentColor; }
.start-alt {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
}
.start-alt:hover { color: var(--text); border-color: var(--dim); }
.start-hint { color: var(--dim); font-size: 0.8rem; margin: 0.2rem 0 0; }
button:disabled { opacity: 0.5; cursor: default; }

.error {
  margin: 0.8rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: #3a1d22;
  border: 1px solid #6b2c36;
  color: #ffc9c9;
}

/* ---- control bars ---- */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.7rem;
}
.spacer { flex: 1 1 auto; }

.bar button {
  padding: 0.42rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.87rem;
  cursor: pointer;
}
.bar button:hover { border-color: var(--dim); }
.bar button.primary { background: var(--accent); border-color: var(--accent); color: #08111c; font-weight: 600; }
.bar button.primary:hover { filter: brightness(1.1); }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button { border: 0; background: none; color: var(--dim); padding: 0.34rem 0.7rem; border-radius: 8px; font-weight: 600; }
.seg button:hover { color: var(--text); border-color: transparent; }
.seg button.on { background: var(--accent); color: #08111c; }

.bar label { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--dim); font-size: 0.85rem; }
input[type="range"] { width: 150px; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
.check { cursor: pointer; }

/* ---- effect chips ---- */
.effects { display: flex; flex-wrap: wrap; gap: 0.35rem; width: 100%; }
.fx {
  --fx: var(--accent);
  position: relative;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--dim);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}
.fx:hover { color: var(--text); border-color: var(--fx); }
.fx.on {
  color: #08111c;
  background: var(--fx);
  border-color: var(--fx);
  font-weight: 600;
  padding-right: 1.5rem;
}
/* Stack position, so the order effects were picked in stays visible. */
.fx.on::after {
  content: attr(data-pos);
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.65;
}

/* ---- footer note ---- */
.foot { margin: 1rem 0 0; color: var(--dim); font-size: 0.83rem; max-width: 78ch; }
.foot b { color: var(--text); font-weight: 600; }
.keys { display: block; margin-top: 0.35rem; }
kbd {
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: #000;
  border: 1px solid var(--line);
  font-size: 0.72rem;
}

@media (max-width: 620px) {
  input[type="range"] { width: 100px; }
  .spacer { display: none; }
}

/* The catalogue is large enough now that chips need to stay tight to avoid
   pushing the controls off-screen. */
.effects { gap: 0.28rem; }
.fx { padding: 0.3rem 0.6rem; font-size: 0.79rem; }
.fx.on { padding-right: 1.35rem; }
