@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --primary: #7c3aed;
  --primary-light: rgba(124, 58, 237, 0.1);
  --secondary: #f59e0b;
  --secondary-light: rgba(245, 158, 11, 0.1);
  --accent: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.15);
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-700: #15803d;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --max-width: 480px;
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--slate-50);
  color: var(--slate-800);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background: var(--slate-50);
}

.app-frame {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100dvh;
  background: #fff;
  box-shadow: var(--shadow);
  position: relative;
  padding-bottom: 5rem;
}

.app-frame--no-nav { padding-bottom: 0; }

.page { padding: 1.5rem; }

.text-primary { color: var(--primary); }
.text-coin { color: var(--secondary); }
.text-success { color: var(--green-500); }
.text-muted { color: var(--slate-500); font-weight: 600; }
.text-xs { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

h1, h2, h3 { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 900; }
h2 { font-size: 1.875rem; font-weight: 900; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  border-radius: var(--radius);
  transition: transform 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--primary);
  color: #fff;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  box-shadow: 0 10px 25px rgba(124, 58, 237, 0.25);
}
.btn--primary:hover { filter: brightness(1.05); }
.btn--outline {
  background: #fff;
  color: var(--slate-700);
  border: 2px solid var(--slate-200);
  padding: 0.75rem 1.5rem;
}
.btn--lg {
  width: 100%;
  height: 3.5rem;
  font-size: 1.125rem;
  border-radius: var(--radius);
}
.btn--block { width: 100%; }
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  background: var(--slate-100);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-500);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}

/* Landing */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  text-align: center;
}
.landing__logo {
  width: 8rem;
  height: 8rem;
  background: var(--primary);
  border-radius: var(--radius-lg);
  transform: rotate(12deg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  box-shadow: 0 20px 40px rgba(124, 58, 237, 0.25);
}
.landing__logo span {
  font-size: 3.75rem;
  font-weight: 900;
  color: #fff;
  transform: rotate(-12deg);
}
.landing__title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}
.landing__title em { color: var(--primary); font-style: normal; }
.landing__tagline {
  font-size: 1.125rem;
  color: var(--slate-500);
  font-weight: 600;
  max-width: 280px;
  margin-bottom: 3rem;
}
.landing__actions { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1rem; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.stat-card--xp { background: var(--primary-light); }
.stat-card--coin { background: var(--secondary-light); }
.stat-card__icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.125rem;
}
.stat-card--xp .stat-card__icon { background: var(--primary); }
.stat-card--coin .stat-card__icon { background: var(--secondary); }
.stat-card__label { font-size: 0.75rem; font-weight: 700; color: var(--slate-500); text-transform: uppercase; }
.stat-card__value { font-size: 1.25rem; font-weight: 900; }
.stat-card--xp .stat-card__value { color: var(--primary); }
.stat-card--coin .stat-card__value { color: var(--secondary); }

/* Profile header */
.profile-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--secondary);
  border: 4px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}
.avatar--lg {
  width: 6rem;
  height: 6rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-size: 2.25rem;
  border: none;
}

/* Missions */
.card {
  background: #fff;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card__title { font-size: 1.125rem; font-weight: 700; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.progress-row { margin-bottom: 1rem; }
.progress-row:last-child { margin-bottom: 0; }
.progress-row__head { display: flex; justify-content: space-between; font-size: 0.875rem; font-weight: 700; margin-bottom: 0.5rem; }
.progress-track {
  height: 0.75rem;
  background: var(--slate-100);
  border-radius: 999px;
  overflow: hidden;
}
.progress-track__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}
.progress-track__fill--secondary { background: var(--secondary); }

/* CTA */
.cta-play {
  background: var(--accent);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  display: block;
  box-shadow: 0 16px 32px rgba(59, 130, 246, 0.3);
}
.cta-play h3 { font-size: 1.5rem; font-weight: 900; margin-bottom: 0.5rem; }
.cta-play p { opacity: 0.85; font-weight: 600; margin-bottom: 1.5rem; }
.cta-play__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  color: var(--accent);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 700;
}
.cta-play__deco {
  position: absolute;
  right: -1rem;
  bottom: -1rem;
  font-size: 8rem;
  opacity: 0.2;
}

/* World list */
.world-list { display: flex; flex-direction: column; gap: 1rem; }
.world-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--slate-100);
  background: #fff;
  transition: transform 0.15s;
}
.world-card:active { transform: scale(0.98); }
.world-card--locked {
  background: var(--slate-50);
  opacity: 0.6;
  pointer-events: none;
}
.world-card__icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.world-purple { background: #a855f7; }
.world-blue { background: #3b82f6; }
.world-green { background: #22c55e; }
.world-orange { background: #f97316; }
.world-pink { background: #ec4899; }
.world-teal { background: #14b8a6; }
.world-card__body { flex: 1; min-width: 0; }
.world-card__chevron { color: var(--slate-200); font-size: 1.25rem; }

.star { font-size: 0.875rem; }
.star--off { opacity: 0.25; }
.stars-lg { display: flex; gap: 0.25rem; justify-content: center; margin: 1rem 0; font-size: 1.75rem; }
.stars-lg .star--off { opacity: 0.2; }

/* Level list */
.page-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.level-card {
  border-radius: var(--radius);
  padding: 1rem;
  border: 2px solid var(--slate-100);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.level-card--locked { background: var(--slate-50); opacity: 0.5; }
.level-card__num {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.125rem;
  flex-shrink: 0;
}
.level-card__num--locked { background: var(--slate-300); }
.level-card__body { flex: 1; }
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--slate-200);
}
.bottom-nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
}
.bottom-nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  min-width: 4rem;
  color: var(--slate-400);
}
.bottom-nav__link--active { color: var(--primary); }
.bottom-nav__icon {
  font-size: 1.25rem;
  padding: 0.375rem;
  border-radius: 0.75rem;
}
.bottom-nav__link--active .bottom-nav__icon { background: var(--primary-light); }
.bottom-nav__label { font-size: 0.625rem; font-weight: 700; margin-top: 0.25rem; }

/* Play */
.play-frame { max-width: var(--max-width); margin: 0 auto; min-height: 100dvh; background: #fff; box-shadow: var(--shadow); }
.play-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--slate-100);
}
.progress-bar {
  flex: 1;
  height: 0.75rem;
  background: var(--slate-100);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.5s;
}
.hearts-sm { display: flex; gap: 2px; font-size: 1.125rem; }
.heart--off { opacity: 0.2; }
.play-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1rem 0.5rem;
}
.xp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 900;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}
.play-main { flex: 1; padding: 0 1rem 1.5rem; }
.play-main--locked .answer-area { pointer-events: none; }
.question-box {
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--primary-light);
}
.question-box--ok { background: var(--green-50); }
.question-box--bad { background: var(--red-50); }
.question-text {
  font-size: 1.25rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.35;
  margin: 0;
}
.feedback-msg {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 700;
  margin-bottom: 1rem;
}
.feedback-msg--correct { background: var(--green-100); color: var(--green-700); }
.feedback-msg--wrong { background: var(--red-100); color: var(--red-600); }
.options-list { display: flex; flex-direction: column; gap: 0.75rem; }
.option-btn {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--slate-100);
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--slate-800);
  transition: border-color 0.15s, background 0.15s;
}
.option-btn:hover:not(:disabled) { border-color: rgba(124, 58, 237, 0.4); }
.option-btn--correct { border-color: #4ade80; background: var(--green-50); color: var(--green-700); }
.option-btn--wrong { border-color: #f87171; background: var(--red-50); color: var(--red-600); }
.option-btn--muted { color: var(--slate-400); }
.tf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.input-essay {
  width: 100%;
  height: 4rem;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius);
  font-size: 1.5rem;
  font-weight: 900;
  text-align: center;
  font-family: inherit;
  margin-bottom: 0.5rem;
}
.input-essay:focus { outline: none; border-color: var(--primary); }
.input--error { border-color: var(--red-500); }
.field-error {
  color: var(--red-600);
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  text-align: center;
}
.essay-wrap .btn { margin-top: 0.5rem; }
.sort-hint { text-align: center; font-size: 0.875rem; color: var(--slate-500); font-weight: 600; }
.sort-chips { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin: 1rem 0; }
.sort-chip {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius);
  border: 2px solid var(--slate-200);
  background: #fff;
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
}
.sort-chip--selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}
.play-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  text-align: center;
}
.play-done__trophy {
  width: 6rem;
  height: 6rem;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 16px 32px rgba(124, 58, 237, 0.25);
}
.play-done__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  margin: 2rem 0;
}
.play-done__stats > div {
  background: var(--slate-50);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-value { font-size: 1.5rem; font-weight: 900; margin: 0; }
.stat-label { font-size: 0.75rem; font-weight: 700; color: var(--slate-400); margin: 0.25rem 0 0; }
.play-empty {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--slate-500);
  font-weight: 600;
}

/* Leaderboard */
.podium { display: flex; justify-content: center; gap: 1rem; margin-bottom: 2rem; align-items: flex-end; }
.podium__item { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.podium__bar {
  width: 4rem;
  border-radius: 0.75rem 0.75rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
}
.rank-gold { background: #facc15; color: #713f12; }
.rank-silver { background: var(--slate-300); color: var(--slate-700); }
.rank-bronze { background: #fb923c; color: #7c2d12; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--slate-100);
  margin-bottom: 0.5rem;
  background: #fff;
}
.lb-row--me { background: var(--primary-light); border-color: rgba(124, 58, 237, 0.3); }
.lb-rank {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 900;
  background: var(--slate-100);
  color: var(--slate-500);
}

/* Profile */
.profile-center { text-align: center; margin-bottom: 2rem; }
.level-pill {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 900;
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-top: 0.5rem;
}
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.badge-item {
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  border: 2px solid var(--slate-100);
}
.badge-item--earned { background: #fff; border-color: rgba(124, 58, 237, 0.2); }
.badge-item--locked { background: var(--slate-50); opacity: 0.5; }
.badge-item__icon { font-size: 1.5rem; margin-bottom: 0.375rem; }
.badge-item__name { font-size: 0.625rem; font-weight: 700; line-height: 1.2; }

/* Teacher */
.teacher-header {
  background: #fff;
  border-bottom: 1px solid var(--slate-100);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.teacher-body { max-width: 42rem; margin: 0 auto; padding: 1.5rem; }
.teacher-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.teacher-stat {
  background: #fff;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius);
  padding: 1rem;
}
.menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: #fff;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.link-logout {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--slate-400);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.link-logout:hover { color: var(--red-500); }

/* Forms (CMS & login) */
.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--slate-100);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  background: #fff;
}
.form-input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-input--error,
.form-input.form-input--error { border-color: var(--red-500); }
.field-error {
  color: var(--red-600);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0;
}
.msg-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin-bottom: 1rem;
}
.msg-banner--ok { background: var(--green-100); color: var(--green-700); }
.tag {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--slate-100);
  color: var(--slate-600);
  margin-right: 0.25rem;
}
.tag--easy { background: var(--green-100); color: var(--green-700); }
.tag--medium { background: #fef9c3; color: #a16207; }
.tag--hard { background: var(--red-100); color: var(--red-600); }
.question-image { max-width: 100%; border-radius: var(--radius); margin-bottom: 0.75rem; }
.question-audio { width: 100%; margin-bottom: 0.75rem; }
.feedback-msg--hint {
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 0.875rem;
  font-weight: 600;
}
