:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --card-bg: rgba(22, 31, 52, 0.75);
  --card-border: rgba(255, 255, 255, 0.1);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* Flash Screen Effect */
.flash-overlay {
  position: fixed;
  inset: 0;
  background-color: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.05s ease-out;
}
.flash-overlay.flash {
  opacity: 0.95;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: rgba(11, 15, 25, 0.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}
.logo-icon {
  font-size: 24px;
}
.logo .highlight {
  color: var(--primary);
  margin-left: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* App Main Container */
.app-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  position: relative;
}

/* Step Screens */
.step-screen {
  display: none;
  width: 100%;
  max-width: 1100px;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.step-screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  padding: 40px;
}

.step-indicator {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary);
  margin-bottom: 12px;
}

.screen-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.screen-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 30px;
}

/* Step 1: Email Screen */
.email-card {
  max-width: 580px;
  width: 100%;
  text-align: center;
}

.input-group {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 6px 16px;
  margin-bottom: 16px;
  transition: all 0.25s;
}
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
.input-icon {
  font-size: 20px;
  margin-right: 12px;
  opacity: 0.8;
}
.input-group input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 18px;
  font-family: inherit;
  padding: 12px 0;
}
.input-group input::placeholder {
  color: #64748b;
}

.quick-domains {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}
.btn-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-chip:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #ffffff;
}

.privacy-note {
  margin-top: 24px;
  font-size: 13px;
  color: #64748b;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.25s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
  color: #ffffff;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
  transform: translateY(-2px);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}
.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
  color: #ffffff;
}
.btn-large {
  width: 100%;
  padding: 16px 28px;
  font-size: 18px;
}
.btn-full {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
}
.btn-glow {
  box-shadow: 0 8px 24px var(--primary-glow);
}
.btn-glow:hover {
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.6);
}

/* Step 2: Templates Selection */
.template-header {
  text-align: center;
  margin-bottom: 24px;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
  margin-bottom: 30px;
}

.template-card {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.template-card:hover {
  transform: translateY(-6px);
  border-color: var(--primary);
  box-shadow: 0 16px 36px var(--primary-glow);
}
.template-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary);
}

.template-preview-wrapper {
  background: #0f172a;
  height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.template-preview-img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  transition: transform 0.3s ease;
}
.template-card:hover .template-preview-img {
  transform: scale(1.03);
}

.template-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-name {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}
.template-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}
.template-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.badge-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.step-footer {
  display: flex;
  justify-content: center;
}

/* Step 3: Camera Capture */
.camera-wrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 600px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera feed */
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  pointer-events: none;
}

.camera-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}
.pose-badge {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.template-badge {
  background: rgba(99, 102, 241, 0.7);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

/* Countdown Circle */
.countdown-circle {
  align-self: center;
  width: 140px;
  height: 140px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  border: 4px solid #ffffff;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(255, 255, 255, 0.6);
  animation: pulseScale 1s infinite alternate;
}
.countdown-circle.active {
  display: flex;
}
#countdown-number {
  font-size: 72px;
  font-weight: 900;
  color: #ffffff;
}

@keyframes pulseScale {
  from { transform: scale(0.95); }
  to { transform: scale(1.05); }
}

.pose-thumbnails {
  position: absolute;
  bottom: 100px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}
.pose-thumb {
  width: 70px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.camera-bottombar {
  display: flex;
  justify-content: center;
  pointer-events: auto;
}

.btn-capture {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  padding: 14px 36px;
  font-size: 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.btn-capture:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

/* Step 4: Preview Screen */
.preview-layout {
  display: flex;
  gap: 36px;
  width: 100%;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.preview-canvas-container {
  background: #000000;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 75vh;
}

#composite-canvas {
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.preview-controls {
  max-width: 420px;
  width: 100%;
}

.preview-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
}
.preview-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.preview-info-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}
.info-label {
  color: var(--text-muted);
}
.info-value {
  color: #ffffff;
  font-weight: 600;
}

.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Step 5: Success Screen */
.success-card {
  max-width: 600px;
  width: 100%;
  text-align: center;
  padding: 48px 36px;
}

.success-icon-wrapper {
  width: 100px;
  height: 100px;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid rgba(16, 185, 129, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px auto;
}
.success-icon {
  font-size: 54px;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 32px 0 24px 0;
}

.auto-reset-timer {
  font-size: 14px;
  color: var(--text-muted);
}
#reset-counter {
  color: var(--primary);
  font-weight: 700;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .topbar {
    padding: 12px 18px;
  }
  .app-container {
    padding: 14px;
  }
  .glass-card {
    padding: 24px;
  }
  .screen-title {
    font-size: 24px;
  }
  .camera-wrapper {
    height: 480px;
  }
  .preview-layout {
    flex-direction: column;
  }
}
