@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700;900&display=swap');

:root {
  --bg-color: #0f172a;
  --container-bg: rgba(30, 41, 59, 0.4);
  --accent: #8b5cf6;
  --accent-light: #c4b5fd;
  --text: #f8fafc;
  --success: #10b981;
}

body {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  background: var(--bg-color);
  background-image: radial-gradient(circle at top right, rgba(139, 92, 246, 0.15), transparent 40%),
                    radial-gradient(circle at bottom left, rgba(56, 189, 248, 0.15), transparent 40%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 3rem 1rem;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}

.container {
  background: var(--container-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2.5rem;
  border-radius: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  max-width: 900px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.header h1 {
  margin-top: 0;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
}

.header h1 span {
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header p {
  color: #94a3b8;
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  font-weight: 300;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: auto; /* Biarkan JS yang menentukan berdasarkan kamera asli */
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 0 2px rgba(255,255,255,0.05);
  background: #000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}


.video-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 30px 60px rgba(0,0,0,0.5), 0 0 0 2px rgba(255,255,255,0.1);
}

#webcam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror */
  filter: brightness(1.1) contrast(1.05);
}

#cat-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  /* Tetap di DOM agar canvas bisa baca frame-nya, tapi tidak terlihat */
}

.badge {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.badge.detected {
  background: rgba(16, 185, 129, 0.85);
  color: white;
  border-color: #34d399;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.badge.detected .spinner {
  display: none;
}

.instructions {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2.5rem;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.8rem 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.instruction-item .icon {
  font-size: 1.5rem;
}

.instruction-item span {
  font-weight: 500;
  color: #cbd5e1;
}

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

#sticker-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}
#sticker-canvas.active {
  opacity: 1;
}

#command-text {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  font-weight: 900;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
#command-text.active {
  opacity: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(5px);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 50;
  cursor: pointer;
  transition: opacity 0.4s;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 600px) {
  .header h1 { font-size: 2rem; }
  .instructions { flex-direction: column; gap: 1rem; }
  .container { padding: 1.5rem; border-radius: 24px; }
}
