:root {
  --primary: #4361ee;
  --primary-dark: #3a56d4;
  --primary-light: #e6e9ff;
  --secondary: #f8f9fa;
  --success: #4cc9f0;
  --success-dark: #38b6db;
  --danger: #f72585;
  --danger-dark: #e5177b;
  --warning: #f8961e;
  --info: #4895ef;
  --light: #ffffff;
  --dark: #212529;
  --gray: #6c757d;
  --light-gray: #f1f3f5;
  --border: #dee2e6;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
}

.dark-mode {
  --primary: #4cc9f0;
  --primary-dark: #38b6db;
  --primary-light: #1a365d;
  --secondary: #2d3748;
  --light: #1a202c;
  --dark: #f8f9fa;
  --gray: #a0aec0;
  --light-gray: #2d3748;
  --border: #4a5568;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  --gold: #ffdf00;
}

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

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--light);
  color: var(--dark);
  line-height: 1.6;
  transition: all 0.3s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ==================== PREMIUM COMPONENTS ==================== */
.premium-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  animation: fadeIn 0.5s ease-out;
}

.premium-header {
  text-align: center;
  margin-bottom: 2rem;
}

.premium-icon {
  font-size: 3rem;
  color: var(--gold);
  margin-bottom: 1rem;
}

.premium-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.premium-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--secondary);
  border-radius: var(--radius);
  transition: transform 0.2s ease;
}

.premium-feature:hover {
  transform: translateY(-3px);
}

.premium-feature i {
  color: var(--success);
  font-size: 1.25rem;
  margin-top: 0.2rem;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2.5rem 0;
}

.pricing-card {
  position: relative;
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  background: var(--light);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.pricing-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.pricing-card.recommended {
  border: 2px solid var(--gold);
  background: linear-gradient(to bottom, var(--light) 0%, rgba(255, 215, 0, 0.05) 100%);
}

.recommended-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--gold);
  color: #000;
  padding: 0.25rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.price-display {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 1rem 0;
  color: var(--primary);
}

.price-period {
  font-size: 1rem;
  color: var(--gray);
}

.price-savings {
  color: var(--success);
  font-weight: 600;
  margin-bottom: 1rem;
}

.payment-methods {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0 1rem;
  font-size: 2rem;
  opacity: 0.8;
}

.payment-methods i {
  color: var(--gray);
  transition: color 0.2s ease;
}

.payment-methods i:hover {
  color: var(--primary);
}

.trial-notice {
  text-align: center;
  padding: 1rem;
  background: var(--primary-light);
  border-radius: var(--radius);
  margin-top: 1.5rem;
  color: var(--primary-dark);
  border-left: 4px solid var(--primary);
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--gold), #ffcc00);
  color: #000;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}

.loading-spinner {
  text-align: center;
  color: white;
}

.loading-spinner i {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: spin 1s linear infinite;
}

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

/* ==================== EXISTING STYLES ==================== */
.ad-container {
  margin: 1rem auto;
  text-align: center;
  max-width: 728px;
}
body.logged-in .ad-container {
  display: none !important;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.speech-loading {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.speech-loading::after {
  content: "Loading...";
  position: absolute;
  left: 100%;
  margin-left: 8px;
  font-size: 0.8em;
  color: var(--gray);
  white-space: nowrap;
}

.correct-input {
  border: 2px solid var(--success) !important;
  background-color: rgba(76, 201, 240, 0.1);
  animation: pulseCorrect 0.5s ease;
}

.incorrect-input {
  border: 2px solid var(--danger) !important;
  background-color: rgba(247, 37, 133, 0.1);
  animation: pulseIncorrect 0.5s ease;
}

@keyframes pulseCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes pulseIncorrect {
  0% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

.word-transition {
  transition: all 0.3s ease;
}

.word-status i {
  margin-left: 8px;
  font-size: 1.5rem;
  vertical-align: middle;
}

.real-time-feedback {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
}

.input-wrapper {
  position: relative;
}

.correct-feedback {
  color: var(--success);
}

.incorrect-feedback {
  color: var(--danger);
}

.dark-mode .correct-input {
  background-color: rgba(76, 201, 240, 0.15) !important;
}

.dark-mode .incorrect-input {
  background-color: rgba(247, 37, 133, 0.15) !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  text-decoration: none;
}

.brand img {
  height: 2.5rem;
}

.subtitle {
  font-size: 0.75rem;
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  margin-left: 0.5rem;
  font-weight: 500;
}

.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.card {
  background: var(--light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.card-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
}

.btn {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

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

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

.btn-secondary {
  background-color: var(--secondary);
  color: var(--dark);
}

.btn-secondary:hover {
  background-color: #e2e6ea;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-flag {
  background: transparent;
  color: var(--warning);
  border: 1px solid var(--warning);
}

.btn-flag.active {
  background: var(--warning);
  color: var(--dark);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--light);
  color: var(--dark);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

textarea.form-control {
  min-height: 6rem;
  resize: vertical;
}

.mode-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  flex: 1;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--secondary);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  text-align: center;
}

.mode-btn.selected {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

.input-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.word-progress {
  color: var(--gray);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.word-audio-feedback {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

.word-status i {
  font-size: 1.25rem;
}

.auto-recording-info {
  background: var(--primary-light);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin: 1rem 0;
  color: var(--primary-dark);
  border-left: 3px solid var(--primary);
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.feedback {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.feedback.correct {
  background: rgba(76, 201, 240, 0.1);
  color: var(--success-dark);
  border: 1px solid var(--success);
}

.feedback.incorrect {
  background: rgba(247, 37, 133, 0.1);
  color: var(--danger-dark);
  border: 1px solid var(--danger);
}

.spelling-visual {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.letter-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1.25rem;
  background: var(--light);
}

.letter-tile.correct {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.letter-tile.incorrect {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.results-card {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--light);
  box-shadow: var(--shadow);
}

.results-card.correct {
  border-top: 4px solid var(--success);
}

.results-card.incorrect {
  border-top: 4px solid var(--danger);
}

.score-display {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

.score-number {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.word-item {
  background: var(--secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
}

.summary-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.alert {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.5s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-error {
  background: var(--danger);
}

.alert-success {
  background: var(--success);
}

.fade-out {
  opacity: 0;
}

/* ==================== RESPONSIVE STYLES ==================== */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .input-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .button-group {
    flex-wrap: wrap;
  }
  
  .mode-selector {
    flex-direction: column;
  }
  
  .navbar {
    padding: 1rem 0;
  }
  
  .card {
    padding: 1.25rem;
  }

  .premium-container {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .pricing-grid {
    grid-template-columns: 1fr;
  }
  
  .premium-features {
    grid-template-columns: 1fr;
  }
  
  .payment-methods {
    font-size: 1.5rem;
  }
  
  .price-display {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .premium-container {
    padding: 1rem;
  }
  
  .pricing-card {
    padding: 1.25rem;
  }
  
  .premium-icon {
    font-size: 2rem;
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.3s ease-out;
}

/* ==================== UTILITY CLASSES ==================== */
.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.hidden {
  display: none;
}

#feedback {
  position: fixed;
  bottom: -100px;
  left: 1rem;
  right: 1rem;
  padding: 1rem;
  border-radius: 12px;
  z-index: 1000;
  transition: transform 0.3s ease, bottom 0.3s ease;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  max-width: calc(100% - 2rem);
}

#feedback.visible {
  bottom: 1rem;
}

#feedback.keyboard-active {
  bottom: calc(1rem + env(safe-area-inset-bottom) + 60px);
}

@media (max-width: 768px) {
  #feedback.visible {
    bottom: calc(60px + env(safe-area-inset-bottom));
  }
}

/* ==================== DARK MODE OVERRIDES ==================== */
.dark-mode .pricing-card {
  background: var(--secondary);
  border-color: var(--border);
}

.dark-mode .premium-feature {
  background: rgba(255, 255, 255, 0.05);
}

.dark-mode .trial-notice {
  background: rgba(67, 97, 238, 0.15);
  color: var(--primary);
}

.dark-mode .premium-container {
  background: var(--secondary);
  border-color: var(--border);
}

.dark-mode .pricing-card.recommended {
  background: linear-gradient(to bottom, var(--secondary) 0%, rgba(255, 215, 0, 0.1) 100%);
}
