/* ── Animal Academy - Main Styles ── */

:root {
  --bg: #1a0a2e;
  --bg-card: #2d1b4e;
  --text: #f0e6ff;
  --text-muted: #b8a9d4;
  --primary: #f97316;
  --primary-hover: #ea580c;
  --success: #10b981;
  --error: #ef4444;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-yellow: #eab308;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screen Management ── */
.screen {
  display: none;
  min-height: 100vh;
  animation: fadeSlideIn 0.5s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Buttons ── */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #fb923c);
  color: white;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(249, 115, 22, 0.6);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 2px solid rgba(255,255,255,0.2);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.btn-large {
  padding: 18px 40px;
  font-size: 1.2rem;
}

.btn-small {
  padding: 8px 20px;
  font-size: 0.9rem;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 12px;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: var(--transition);
  font-family: inherit;
}

.btn-back:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* ── Splash Screen ── */
#splash {
  position: relative;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(ellipse at center, #2d1b4e 0%, #1a0a2e 70%);
}

.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(139,92,246,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(249,115,22,0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(16,185,129,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 1;
  padding: 40px 20px;
}

.splash-animals {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.float-animal {
  font-size: 2.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(3deg); }
  75% { transform: translateY(-4px) rotate(-3deg); }
}

.title {
  font-size: 3rem;
  background: linear-gradient(135deg, #f97316, #fb923c, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 40px;
  line-height: 1.6;
}

.splash-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ── Auth Screen ── */
#login {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.08);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-mascot {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
}

.auth-header h2 {
  font-size: 1.5rem;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition);
  font-family: inherit;
}

.auth-tab.active {
  background: var(--primary);
  color: white;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition);
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255,255,255,0.08);
}

.avatar-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-option input {
  display: none;
}

.avatar-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 1.6rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

.avatar-option input:checked + span {
  border-color: var(--primary);
  background: rgba(249,115,22,0.15);
  transform: scale(1.1);
}

.form-error {
  color: var(--error);
  font-size: 0.85rem;
  min-height: 20px;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(26,10,46,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 12px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  font-size: 1.8rem;
}

.user-name {
  font-weight: 600;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.points-display,
.streak-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── Dashboard ── */
.dashboard-main {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

.dashboard-title {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.dashboard-subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

@media (max-width: 400px) {
  .subjects-grid {
    grid-template-columns: 1fr;
  }
}

.subject-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px 16px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.subject-card:active {
  transform: scale(0.97);
}

.subject-emoji {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 8px;
}

.subject-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.subject-progress {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  height: 6px;
  overflow: hidden;
  margin-top: 8px;
}

.subject-progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}

.subject-stat {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Progress Overview ── */
.progress-overview {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.05);
}

.progress-overview h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.progress-bar-container {
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  height: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
  transition: width 0.8s ease;
  min-width: 2%;
}

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  padding: 8px 16px 20px;
  background: rgba(26,10,46,0.95);
  border-top: 1px solid rgba(255,255,255,0.05);
  gap: 8px;
}

.nav-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  border-radius: 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.nav-btn.active {
  background: var(--primary);
  color: white;
}

/* ── Quiz Screen ── */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(26,10,46,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.quiz-points-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(249,115,22,0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
}

.quiz-main {
  flex: 1;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.quiz-timer {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 1s linear;
}

.question-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  animation: fadeSlideIn 0.4s ease;
}

.question-difficulty {
  text-align: center;
  margin-bottom: 16px;
}

.question-difficulty .star {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.2);
}

.question-difficulty .star.filled {
  color: #fbbf24;
}

.question-text {
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: 24px;
  text-align: center;
}

.options-grid {
  display: grid;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font-size: 1rem;
  font-family: inherit;
}

.option-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.correct {
  background: rgba(16,185,129,0.2);
  border-color: var(--success);
  animation: pop 0.3s ease;
}

.option-btn.wrong {
  background: rgba(239,68,68,0.2);
  border-color: var(--error);
  animation: shake 0.4s ease;
}

.option-btn:disabled {
  pointer-events: none;
  opacity: 0.7;
}

.option-letter {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ── Quiz Feedback ── */
.quiz-feedback {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  animation: fadeSlideIn 0.3s ease;
  border: 1px solid rgba(255,255,255,0.08);
}

.feedback-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.feedback-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.fun-fact {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(139,92,246,0.15);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 20px;
  text-align: left;
}

.fun-fact span {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.fun-fact p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Quiz Complete Screen ── */
#quiz-complete {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.complete-container {
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-card);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
}

.complete-animals {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.complete-container h2 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.complete-subject {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.complete-score {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.complete-stats {
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.complete-achievements {
  margin-bottom: 24px;
}

.complete-achievements .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(139,92,246,0.2);
  padding: 8px 16px;
  border-radius: 20px;
  margin: 4px;
  font-size: 0.85rem;
  animation: pop 0.5s ease;
}

.complete-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Achievements Screen ── */
.achievements-main {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 400px) {
  .achievements-grid {
    grid-template-columns: 1fr;
  }
}

.achievement-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.05);
  transition: var(--transition);
}

.achievement-card.earned {
  border-color: rgba(249,115,22,0.3);
}

.achievement-card:not(.earned) {
  opacity: 0.4;
  filter: grayscale(0.6);
}

.achievement-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.achievement-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.achievement-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.achievement-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Admin Screen ── */
.admin-main {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
}

.admin-section {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.05);
}

.admin-section h3 {
  margin-bottom: 16px;
}

.admin-answers,
.admin-stats {
  margin-top: 16px;
}

.admin-answer-item {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 8px;
}

.admin-answer-item .question {
  font-weight: 600;
  margin-bottom: 6px;
}

.admin-answer-item .answer {
  color: var(--success);
  font-weight: 600;
}

/* ── Responsive ── */
@media (min-width: 768px) {
  .subjects-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .achievements-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-main {
    max-width: 800px;
    margin: 0 auto;
  }

  .quiz-main {
    max-width: 700px;
    margin: 0 auto;
  }
}

@media (min-width: 1024px) {
  .subjects-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Loading Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Confetti ── */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}
