:root {
  --primary-color: oklch(0.65 0.25 260);
  --secondary-color: oklch(0.65 0.25 320);
  --accent-color: oklch(0.85 0.15 150);
  --bg-color: oklch(0.15 0.02 260);
  --card-bg: oklch(0.2 0.03 260);
  --text-primary: oklch(0.95 0.01 260);
  --text-secondary: oklch(0.75 0.02 260);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --font-main: 'Inter', system-ui, sans-serif;
  --font-heading: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

.background-texture {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.container {
  max-width: 600px;
  width: 90%;
  text-align: center;
  z-index: 1;
  padding: 2rem 0;
}

header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

header .highlight {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 3rem;
}

.card {
  background-color: var(--card-bg);
  border-radius: 2rem;
  padding: 3rem 2rem;
  box-shadow: 0 20px 40px var(--shadow-color), 
              0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  transition: transform 0.3s ease;
  margin-bottom: 2rem;
}

.card:hover {
  transform: translateY(-5px);
}

.ball-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100px;
  align-items: center;
  margin-bottom: 2.5rem;
}

.set-row {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  width: 100%;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 1rem;
  animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.placeholder {
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.6;
}

.glow-button {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  padding: 1rem 2.5rem;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2),
              0 0 20px var(--primary-color);
  position: relative;
  overflow: hidden;
}

.glow-button:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3),
              0 0 30px var(--secondary-color);
}

.glow-button:active {
  transform: scale(0.95);
}

footer {
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Container query example */
@container (min-width: 400px) {
  .ball-container {
    gap: 1.5rem;
  }
}

/* AI Vision Specific Styles */
.vision-container {
  max-width: 800px;
  width: 95%;
  text-align: center;
  z-index: 1;
  padding: 2rem 0;
}

.webcam-card {
  position: relative;
  background-color: var(--card-bg);
  border-radius: 2rem;
  padding: 1rem;
  box-shadow: 0 20px 40px var(--shadow-color),
              0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  margin-bottom: 2rem;
  overflow: hidden;
  aspect-ratio: 4/3;
  display: flex;
  justify-content: center;
  align-items: center;
}

.setup-container {
  text-align: center;
  z-index: 5;
  padding: 2rem;
}

.setup-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 0 15px var(--primary-color));
}

.setup-hint {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  opacity: 0.8;
}

#webcam-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  position: relative;
}

#webcam-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
  box-shadow: 0 0 15px var(--accent-color);
  z-index: 2;
  animation: scan 3s linear infinite;
  pointer-events: none;
}

@keyframes scan {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.label-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  width: 100%;
}

.result-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 1rem;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.result-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(var(--primary-color), 0.3);
}

.result-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.result-name {
  font-weight: 600;
  color: var(--text-primary);
}

.result-value {
  color: var(--accent-color);
  font-family: monospace;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  width: 0%;
  transition: width 0.2s ease-out;
}

.nav-link {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 0.75rem 1.5rem;
  border-radius: 100px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 5;
  transition: opacity 0.5s ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
