:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa1ac;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --danger: #ff5c5c;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  padding: 24px 24px 8px;
  text-align: center;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 1.8rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 3 1 800px;
  max-width: 1200px;
}

.stage {
  position: relative;
  width: 100%;
  /* Matches the 1280x720 (16:9) camera request in app.js -- the canvas
     stretches to fill whatever box shape it's given regardless of its
     actual pixel content, so a mismatched ratio here visibly squashes
     the picture. */
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

#video {
  /* Kept out of view but NOT display:none -- some browsers (notably Safari)
     pause frame decoding on display:none video elements, which would starve
     the canvas drawImage() calls that read from it every frame. */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#output {
  width: 100%;
  height: 100%;
  display: block;
}

.overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  padding: 20px;
}

.overlay-msg.hidden {
  display: none;
}

.status-text {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 420px;
  margin: 0;
}

.status-text.error {
  color: var(--danger);
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.controls {
  display: flex;
  gap: 10px;
}

.controls button {
  flex: 1;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.controls button:hover:not(:disabled) {
  background: #20242e;
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.guide {
  flex: 1 1 280px;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
}

.guide h2 {
  font-size: 1rem;
  margin: 0 0 12px;
}

.guide h2:not(:first-child) {
  margin-top: 20px;
}

.gesture-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gesture-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid var(--panel-border);
}

.eraser-swatch {
  background: repeating-conic-gradient(#3a3f4b 0% 25%, #24272f 0% 50%) 0 0 / 8px 8px;
}

.fist-swatch {
  background: #2a2f3a;
}

.note {
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
}

.privacy {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.footer a {
  color: var(--text-dim);
}

@media (max-width: 700px) {
  .layout {
    flex-direction: column;
    align-items: stretch;
  }
  .guide {
    max-width: none;
  }
}
