:root {
  --blue-900: #023E5E;
  --blue-700: #046999;
  --blue-500: #0583C7;
  --blue-300: #4DAEE0;
  --blue-100: #E0F2FA;
  --red-600: #d62828;
  --red-500: #e63946;
  --red-400: #f06565;
  --yellow-500: #f4a020;
  --yellow-400: #ffc857;
  --yellow-300: #ffe08a;
  --white: #ffffff;
  --gray-900: #1a1a2e;
  --gray-700: #4a4a68;
  --gray-500: #7a7a9a;
  --gray-200: #e8e8f0;
  --gray-100: #f5f5fa;
  --shadow-sm: 0 2px 8px rgba(5, 131, 199, 0.08);
  --shadow-md: 0 8px 24px rgba(5, 131, 199, 0.12);
  --shadow-lg: 0 16px 48px rgba(5, 131, 199, 0.16);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: linear-gradient(135deg, var(--blue-100) 0%, var(--white) 50%, #fff8e8 100%);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Background decoration */
.bg-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-shapes .shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.06;
}

.bg-shapes .shape-1 {
  width: 400px;
  height: 400px;
  background: var(--blue-500);
  top: -100px;
  right: -100px;
}

.bg-shapes .shape-2 {
  width: 300px;
  height: 300px;
  background: var(--red-500);
  bottom: -80px;
  left: -80px;
}

.bg-shapes .shape-3 {
  width: 200px;
  height: 200px;
  background: var(--yellow-500);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.logo-img {
  height: 72px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
}

.header-subtitle {
  color: var(--gray-500);
  font-size: 0.95rem;
}

/* Screens */
.screen {
  display: none;
  animation: fadeInUp 0.5s ease forwards;
}

.screen.active {
  display: block;
}

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

/* Card */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  border: 1px solid rgba(5, 131, 199, 0.08);
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 8px;
  text-align: center;
}

.card-desc {
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 28px;
  font-size: 0.95rem;
}

/* Language selection */
.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.lang-btn:hover {
  border-color: var(--blue-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.lang-btn.selected {
  border-color: var(--blue-500);
  background: var(--blue-100);
  box-shadow: 0 0 0 3px rgba(5, 131, 199, 0.15);
}

.lang-btn img,
.lang-btn .lang-flag {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lang-btn svg {
  width: 56px;
  height: 56px;
}

.lang-btn span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-900);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: var(--white);
  box-shadow: 0 4px 16px rgba(5, 131, 199, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(5, 131, 199, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-whatsapp {
  background: #25D366;
  color: var(--white);
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.35);
  text-decoration: none;
}

.btn-whatsapp:hover {
  background: #20BD5A;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
  color: var(--white);
}

.result-cta {
  margin-bottom: 20px;
}

/* Gamification HUD */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.hud-item svg {
  width: 18px;
  height: 18px;
}

.hud-xp {
  background: linear-gradient(135deg, var(--yellow-300), var(--yellow-400));
  color: var(--blue-900);
}

.hud-streak {
  background: linear-gradient(135deg, #ffe0e0, var(--red-400));
  color: var(--red-600);
}

.hud-level {
  background: linear-gradient(135deg, var(--blue-100), var(--blue-300));
  color: var(--blue-900);
}

/* Progress bar */
.progress-wrapper {
  margin-bottom: 24px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.progress-bar {
  height: 10px;
  background: var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-500), var(--yellow-500), var(--red-500));
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

/* Question */
.question-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--blue-100);
  color: var(--blue-700);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.question-badge svg {
  width: 16px;
  height: 16px;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 24px;
  line-height: 1.5;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  color: var(--gray-900);
}

.option-btn:hover:not(.disabled) {
  border-color: var(--blue-300);
  background: var(--blue-100);
}

.option-btn.selected {
  border-color: var(--blue-500);
  background: var(--blue-100);
}

.option-btn.correct {
  border-color: #2ecc71;
  background: #e8f8ef;
  animation: pulseCorrect 0.5s ease;
}

.option-btn.incorrect {
  border-color: var(--red-500);
  background: #fde8e8;
  animation: shake 0.4s ease;
}

.option-btn.disabled {
  pointer-events: none;
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--blue-700);
  flex-shrink: 0;
  transition: var(--transition);
}

.option-btn.selected .option-letter,
.option-btn.correct .option-letter {
  background: var(--blue-500);
  color: var(--white);
}

.option-btn.incorrect .option-letter {
  background: var(--red-500);
  color: var(--white);
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Feedback toast */
.feedback-toast {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-top: 20px;
  font-weight: 600;
  font-size: 0.95rem;
  animation: fadeInUp 0.3s ease;
}

.feedback-toast.show {
  display: flex;
}

.feedback-toast.correct {
  background: #e8f8ef;
  color: #1a7a3a;
}

.feedback-toast.incorrect {
  background: #fde8e8;
  color: var(--red-600);
}

.feedback-toast svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Result */
.result-hero {
  text-align: center;
  margin-bottom: 28px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--yellow-500));
  margin-bottom: 16px;
  animation: scaleIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-badge svg {
  width: 56px;
  height: 56px;
}

.result-level {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue-700), var(--red-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-label {
  color: var(--gray-500);
  font-size: 1rem;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-item {
  text-align: center;
  padding: 16px 8px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue-700);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Form */
.form-hero {
  text-align: center;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
  background: var(--white);
  color: var(--gray-900);
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(5, 131, 199, 0.12);
}

.form-group input.error {
  border-color: var(--red-500);
}

.form-error {
  color: var(--red-500);
  font-size: 0.8rem;
  margin-top: 4px;
  display: none;
}

.form-error.show {
  display: block;
}

/* Success */
.success-icon {
  text-align: center;
  margin-bottom: 20px;
}

.success-icon svg {
  width: 80px;
  height: 80px;
  animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Confetti particles */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confettiFall 2s ease forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* XP popup */
.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2rem;
  font-weight: 800;
  color: var(--yellow-500);
  text-shadow: 0 2px 8px rgba(244, 160, 32, 0.4);
  pointer-events: none;
  z-index: 50;
  animation: xpPop 0.8s ease forwards;
}

@keyframes xpPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  30% { transform: translate(-50%, -60%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.8); opacity: 0; }
}

/* Responsive */
@media (max-width: 480px) {
  .card {
    padding: 24px 18px;
  }

  .lang-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hud {
    flex-wrap: wrap;
  }

  .question-text {
    font-size: 1.1rem;
  }
}
