:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 30px -10px rgba(99, 102, 241, 0.15), 0 10px 15px -5px rgba(0, 0, 0, 0.04);
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-malayalam: 'Noto Sans Malayalam', 'Plus Jakarta Sans', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Utilities */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 0;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2.2rem;
  background: var(--primary-light);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.highlight {
  color: var(--primary);
}

.logo-subtitle {
  font-family: var(--font-malayalam);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.badge {
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* Main Layout */
.main-content {
  flex: 1;
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

.section-intro {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-intro h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.section-intro p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Categories Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(99, 102, 241, 0.3);
}

.category-card:hover::before {
  opacity: 1;
}

.category-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.category-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.category-malayalam {
  font-family: var(--font-malayalam);
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.category-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-gradient);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
}

/* Toolbar in Flashcard View */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #f1f5f9;
}

.btn-control {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-control:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#card-counter {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.progress-bar-bg {
  width: 120px;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* 3D Flashcard flip styling */
.card-wrapper {
  perspective: 1000px;
  max-width: 480px;
  height: 340px;
  margin: 0 auto 2rem auto;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.card-front {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
  border-color: rgba(168, 85, 247, 0.2);
}

.card-header {
  width: 100%;
  display: flex;
  justify-content: center;
}

.card-hint-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--border-color);
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  width: 100%;
}

.image-container {
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.card-emoji {
  font-size: 6rem;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.12));
}

.word-english {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.divider {
  width: 40px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 0.5rem 0;
}

.word-malayalam {
  font-family: var(--font-malayalam);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-hover);
  margin-bottom: 0.2rem;
  line-height: 1.2;
}

.word-phonetic {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-style: italic;
}

.card-footer {
  width: 100%;
  display: flex;
  justify-content: center;
}

.flip-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-audio {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-audio:hover {
  background: var(--primary);
  color: white;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.keyboard-tip {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background: var(--surface);
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .card-wrapper {
    height: 300px;
  }
  .image-container {
    width: 130px;
    height: 130px;
  }
  .card-emoji {
    font-size: 4.8rem;
  }
  .word-malayalam {
    font-size: 2rem;
  }
  .controls {
    flex-wrap: wrap;
  }
}
