* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 20px 0 10px;
}

header h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #c850ff, #4fc3f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: #888;
  font-size: 0.95rem;
  margin-top: 4px;
}

.main-area {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  align-items: flex-start;
}

.video-container {
  position: relative;
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a2e;
  aspect-ratio: 4/3;
}

.video-container video,
.video-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#webcam {
  transform: scaleX(-1);
}

#output {
  z-index: 2;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 26, 0.92);
  color: #ccc;
  font-size: 0.95rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #333;
  border-top-color: #c850ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.controls {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group label {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid #333;
  border-radius: 8px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.radio-btn:hover {
  border-color: #666;
  color: #fff;
}

.radio-btn.active {
  border-color: #c850ff;
  color: #fff;
  background: rgba(200, 80, 255, 0.15);
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #c850ff, #7c4dff);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #2a2a3e;
  color: #ccc;
  border: 1px solid #444;
}

.btn-secondary:hover {
  background: #333350;
  color: #fff;
}

.btn-start {
  background: linear-gradient(135deg, #00c853, #00e676);
  color: #000;
}

.btn-start:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-stop {
  background: linear-gradient(135deg, #ff1744, #d50000);
  color: #fff;
}

.btn-stop:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.status {
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  background: #1a1a2e;
  font-size: 0.85rem;
  color: #888;
}

.status.active {
  color: #00e676;
}

.bg-preview {
  width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid #333;
}

.help {
  padding: 12px;
  background: #1a1a2e;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.help h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: #c850ff;
}

.help ul {
  list-style: none;
}

.help li {
  padding: 4px 0;
  color: #999;
}

.help li strong {
  color: #ccc;
}

footer {
  text-align: center;
  padding: 24px 0 10px;
  font-size: 0.82rem;
  color: #555;
}

footer a {
  color: #c850ff;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .main-area {
    flex-direction: column;
  }
  .controls {
    width: 100%;
  }
}
