* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  justify-content: center;
}

main {
  width: 100%;
  max-width: 720px;
  padding: 24px 16px;
  text-align: center;
}

h1 { margin: 0 0 8px; }

.status { margin: 0 0 16px; color: #94a3b8; }
.status.ok { color: #4ade80; }
.status.error { color: #f87171; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* efecto espejo */
}

.loader {
  margin-top: 20px;
  transition: opacity .3s;
}
.loader p { font-size: 1.1rem; color: #cbd5e1; }
.loader.hidden { display: none; }
.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border: 5px solid #334155;
  border-top-color: #4ade80;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Imagen a pantalla completa */
.result {
  position: fixed;
  inset: 0;
  z-index: 10;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  transition: opacity .3s;
}
.result img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.result p {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(24px, env(safe-area-inset-bottom));
  margin: 0;
  padding: 12px;
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
  background: rgba(22, 101, 52, .85);
}
.result.hidden { opacity: 0; pointer-events: none; }

/* Celular: cámara más grande y sin márgenes */
@media (max-width: 600px) {
  main { padding: 12px 0; }
  h1 { font-size: 1.3rem; }
  .stage { aspect-ratio: 3 / 4; border-radius: 0; }
}
