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

:root {
  --bg: #0b2239;
  --bg-deep: #081a2e;
  --card: #14324f;
  --card-soft: #0f2a44;
  --line: #1f4a73;
  --accent: #ffc93c;
  --accent2: #ff9f1c;
  --text: #f4f7fb;
  --muted: #9fb3c8;
  --green: #2ecc71;
  --red: #ff6b6b;
  --radius: 20px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

.hidden { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 2px 14px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.stat {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}

.iconbtn {
  margin-left: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.iconbtn:active { transform: scale(0.94); }

/* ---------- Héroe ---------- */
.hero {
  background: linear-gradient(160deg, var(--card) 0%, var(--card-soft) 100%);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  margin-bottom: 22px;
}

.hero-sun {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 14px;
  box-shadow: 0 0 40px rgba(255, 201, 60, 0.35);
}

.win-sun { animation: bounce 1.2s ease infinite; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.hero h1 {
  font-size: 30px;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

.subtitle {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

h2 {
  font-size: 24px;
  margin: 4px 2px 4px;
}

.section-sub {
  color: var(--muted);
  font-size: 15px;
  margin: 0 2px 14px;
}

/* ---------- Lecciones ---------- */
.lesson-list { display: flex; flex-direction: column; gap: 12px; }

.lesson-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.lesson-card:active { transform: scale(0.98); }

.lesson-num {
  background: var(--bg-deep);
  color: var(--accent);
  font-weight: 800;
  font-size: 20px;
  border-radius: 14px;
  min-width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.lesson-info { flex: 1; min-width: 0; }

.lesson-info h3 { font-size: 19px; margin-bottom: 4px; }

.lesson-info p { color: var(--muted); font-size: 14px; line-height: 1.4; }

.lesson-done {
  color: var(--green);
  font-size: 15px;
  font-weight: 700;
  display: block;
  margin-top: 6px;
}

.playbtn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent2) 100%);
  color: #4a2f00;
  font-size: 22px;
  cursor: pointer;
  flex: 0 0 auto;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 26px;
  line-height: 1.6;
}

/* ---------- Lección ---------- */
.lesson-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 18px;
}

.lesson-top .iconbtn { margin-left: 0; }

.progress {
  flex: 1;
  height: 14px;
  background: var(--card-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.ex-label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.ex-prompt {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 20px;
}

.ex-hint {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ---------- Opciones ---------- */
.options { display: flex; flex-direction: column; gap: 12px; }

.option {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px;
  font-size: 19px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  min-height: 60px;
  line-height: 1.4;
}

.option:active { transform: scale(0.98); }

.option.correct { border-color: var(--green); background: rgba(46, 204, 113, 0.15); }

.option.wrong { border-color: var(--red); background: rgba(255, 107, 107, 0.12); }

.option:disabled { cursor: default; opacity: 1; }

/* ---------- Escucha ---------- */
.listen-box {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  margin-bottom: 18px;
}

.listen-play {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent2) 100%);
  font-size: 36px;
  cursor: pointer;
  margin-bottom: 10px;
}

.listen-play:active { transform: scale(0.94); }

.listen-box p { color: var(--muted); font-size: 15px; }

/* ---------- Ordenar palabras ---------- */
.answer-line {
  min-height: 64px;
  background: var(--card-soft);
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}

.answer-line .empty { color: var(--muted); font-size: 15px; padding: 6px 10px; }

.word-bank { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.word {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.word:active { transform: scale(0.95); }

.word.in-answer { background: var(--bg-deep); border-color: var(--accent); }

/* ---------- Botones ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 58px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  padding: 14px;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent2) 100%);
  border: none;
  color: #4a2f00;
}

.btnrow { display: flex; gap: 12px; margin-top: 20px; }

.btnrow .btn { flex: 1; }

/* ---------- Feedback ---------- */
.feedback {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 22, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  padding: 0 0 max(24px, env(safe-area-inset-bottom));
}

.feedback-card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 8px;
  animation: slideup 0.25s ease;
}

@keyframes slideup {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.feedback-card.good { border-top: 4px solid var(--green); }

.feedback-card.bad { border-top: 4px solid var(--red); }

.feedback-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; }

.feedback-card.good .feedback-title { color: var(--green); }

.feedback-card.bad .feedback-title { color: var(--red); }

.feedback-sub { color: var(--muted); font-size: 17px; line-height: 1.5; margin-bottom: 18px; }

.feedback-sub strong { color: var(--text); }

/* ---------- Celebración ---------- */
.xp-badge {
  display: inline-block;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent2) 100%);
  color: #4a2f00;
  font-size: 26px;
  font-weight: 800;
  border-radius: 999px;
  padding: 12px 30px;
  margin: 16px 0 4px;
}

@media (max-width: 380px) {
  .hero h1 { font-size: 26px; }
  .ex-prompt { font-size: 23px; }
  .option { font-size: 17px; }
}

/* ---------- Niveles (Mirella) ---------- */
.level-box { margin: 0 2px 16px; }

.level-label {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.level-btns { display: flex; gap: 10px; }

.level-btn {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.level-btn:active { transform: scale(0.96); }

.level-btn span { font-size: 15px; font-weight: 800; }

.level-btn.active {
  border-color: var(--accent);
  background: rgba(255, 201, 60, 0.12);
}

.lesson-count {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-top: 4px;
}

/* ---------- Perfiles ---------- */
.profile-list { display: flex; flex-direction: column; gap: 12px; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.profile-card:active { transform: scale(0.98); }

.profile-emoji { font-size: 42px; flex: 0 0 auto; }

.profile-name { font-size: 26px; font-weight: 800; }
