*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #050816;
  --bg-soft: #0f172a;
  --card: #020617;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-strong: rgba(59, 130, 246, 0.2);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #f97373;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 22px 45px rgba(15, 23, 42, 0.9);
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #000 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.header {
  text-align: center;
  padding: 12px 10px 24px;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: 0.03em;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
}

.camera-section, .preview-section {
  width: 100%;
}

.camera-card, .preview-card {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.98));
  border-radius: var(--radius-lg);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.14);
  position: relative;
  overflow: hidden;
}

.camera-card::before, .preview-card::before {
  content: "";
  position: absolute;
  inset: -120px;
  background: conic-gradient(from 180deg, rgba(59, 130, 246, 0.4), transparent 40%, rgba(59, 130, 246, 0.3), transparent 70%);
  opacity: 0.18;
  filter: blur(22px);
  z-index: -1;
}

.camera-card::after, .preview-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--radius-lg) - 1px);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.85), rgba(2, 6, 23, 0.98));
  z-index: -1;
}

.camera-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: radial-gradient(circle at center, #020617 0, #020617 40%, #020617 100%);
  aspect-ratio: 4 / 3;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.face-box {
  width: 46%;
  max-width: 260px;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  border: 2px solid rgba(59, 130, 246, 0.9);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 0 22px rgba(37, 99, 235, 0.7);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.1), transparent 50%);
}

.overlay-text {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.btn.primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.7);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.8);
}

.btn.secondary {
  background: rgba(15, 23, 42, 0.9);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.btn.secondary:hover:not(:disabled) {
  border-color: rgba(59, 130, 246, 0.8);
  color: var(--text);
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.14), rgba(15, 23, 42, 0.98));
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.preview-card h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

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

.canvas-wrapper {
  border-radius: var(--radius-md);
  background: radial-gradient(circle at top, #111827, #020617);
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 10px;
}

#layoutCanvas {
  width: 100%;
  max-height: 70vh;
  display: block;
  background: white;
  border-radius: 8px;
}

.footer {
  margin-top: auto;
  padding-top: 18px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }

  .preview-section {
    order: 2;
  }

  .camera-section {
    order: 1;
  }

@media (max-width: 600px) {
  .app {
    padding-inline: 10px;
  }

  .camera-card, .preview-card {
    padding-inline: 12px;
  }

  .controls {
    justify-content: space-between;
  }
	#btn9 {
  position: absolute;   /* Stays at the top of the page */
  top: 20px;            /* Distance from the top */
  left: 50%;            /* Moves the left edge to the middle */
  transform: translateX(-50%); /* Shifts it back to perfectly center it */
  
  /* Optional styling to make it look like a professional button */
  padding: 10px 25px;
  background-color: #29782d;
  color: #fff;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  font-family: sans-serif;
}

#btn9:hover {
  background-color: #29782d;
}

