/* =========================
   Estudia Libre Chile - styles.css
   ========================= */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: #f8fafc;
  color: #1e293b;
}

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

img {
  max-width: 100%;
  display: block;
}

/* =========================
   Layout
   ========================= */

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 84px 0;
}

.section.alt {
  background: #ffffff;
}

.section-head h3 {
  font-size: 2.2rem;
  margin: 0;
  color: #0f172a;
}

.section-head p {
  margin-top: 10px;
  color: #64748b;
  font-size: 1rem;
}

.center {
  text-align: center;
}

/* =========================
   Header
   ========================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background:
    linear-gradient(90deg, rgba(212, 175, 55, 0.16), transparent 24%, rgba(16, 185, 129, 0.16)),
    linear-gradient(90deg, #061426, #0f2b4c 48%, #0f766e);
  color: #ffffff;
  border-bottom: 1px solid rgba(250, 204, 21, 0.24);
  box-shadow: 0 12px 32px rgba(6, 20, 38, 0.28);
}

.nav-wrap {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 18px;
  padding: 10px 20px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  min-width: 0;
  color: #fff7ed;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: clamp(1.15rem, 1.8vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.015em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.logo img {
  width: 88px;
  height: 46px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(250, 204, 21, 0.58);
  border-radius: 12px;
  background: #061426;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.logo span {
  white-space: nowrap;
  color: #f8e3a2;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(10px, 1.6vw, 22px);
  min-width: 0;
}

.nav-links a {
  color: #f8fafc;
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-links a:hover {
  color: #fde68a;
  opacity: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  flex-shrink: 0;
}

.btn-header-cta {
  padding: 10px 16px;
  font-size: 0.88rem;
  border-radius: 14px;
  white-space: nowrap;
}

.header-actions .btn:not(.btn-header-cta) {
  padding: 10px 16px;
  font-size: 0.88rem;
  border-radius: 14px;
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  justify-content: center;
  padding: 0 24px 16px;
}

/* =========================
   Buttons
   ========================= */

.btn {
  display: inline-block;
  padding: 14px 22px;
  border-radius: 18px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: #facc15;
  color: #111827;
}

.btn-light {
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid rgba(250, 204, 21, 0.52);
}

.btn-outline {
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: #ffffff;
}

/* =========================
   Hero
   ========================= */

.hero {
  background:
    radial-gradient(circle at 12% 18%, rgba(250, 204, 21, 0.22), transparent 26%),
    linear-gradient(135deg, #061426, #1e3a8a 50%, #155e75);
  color: #ffffff;
  padding: 84px 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 40px;
  align-items: center;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.badge-row .badge {
  margin-bottom: 0;
}

.btn-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-back-icon:hover {
  background: rgba(255,255,255,0.3);
}

.badge {
  display: inline-block;
  background: #facc15;
  color: #111827;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero h2 {
  margin: 0 0 18px;
  font-size: 3.5rem;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.hero h2 span {
  color: #fde047;
}

.hero p {
  max-width: 680px;
  font-size: 1.1rem;
  line-height: 1.7;
  color: #dbeafe;
}

.hero-actions {
  display: flex;
  gap: 14px;
  margin-top: 28px;
}

/* =========================
   Hero panel
   ========================= */

.hero-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: rgba(255, 255, 255, 0.14);
  padding: 20px;
  border-radius: 28px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mini-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #ffffff;
  color: #0f172a;
  padding: 20px;
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.mini-card strong {
  font-size: 1rem;
}

.mini-card span {
  font-size: 0.9rem;
  color: #64748b;
}

/* =========================
   Levels
   ========================= */

.levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 28px;
}

.level-card {
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  font-weight: 800;
  color: #1e293b;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.level-card:hover {
  border-color: #38bdf8;
  box-shadow: 0 14px 28px rgba(14, 116, 144, 0.14);
  transform: translateY(-3px);
}

.level-card.active {
  background: linear-gradient(135deg, #2563eb, #0891b2);
  border-color: transparent;
  color: #ffffff;
}

/* =========================
   Subject cards
   ========================= */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.subject-card {
  --card-accent: #2563eb;
  display: block;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  border-left: 6px solid var(--card-accent);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.subject-card:hover {
  border-color: color-mix(in srgb, var(--card-accent) 42%, #ffffff);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
  transform: translateY(-5px);
}

.subject-card h4 {
  margin: 0 0 8px;
  color: #0f172a;
}

.subject-card h5 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 1rem;
}

.subject-card p {
  margin: 0;
  color: #64748b;
  line-height: 1.5;
}

.level-course-groups {
  display: grid;
  gap: 28px;
  margin-top: 28px;
}

section[id] {
  scroll-margin-top: 80px;
}

.level-course-group {
  scroll-margin-top: 80px;
  --level-accent: #2563eb;
  --level-soft: #eff6ff;
  background: var(--level-soft);
  border: 1px solid color-mix(in srgb, var(--level-accent) 18%, #ffffff);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.level-course-group:nth-child(2) {
  --level-accent: #0891b2;
  --level-soft: #ecfeff;
}

.level-course-group:nth-child(3) {
  --level-accent: #16a34a;
  --level-soft: #f0fdf4;
}

.level-course-group:nth-child(4) {
  --level-accent: #c2410c;
  --level-soft: #fff7ed;
}

.level-course-group h4 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #0f172a;
  font-size: 1.35rem;
}

.level-course-group h4::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--level-accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--level-accent) 14%, transparent);
}

.level-course-group .cards {
  margin-top: 20px;
}

.level-course-group .subject-card:nth-child(5n + 1) {
  --card-accent: #2563eb;
}

.level-course-group .subject-card:nth-child(5n + 2) {
  --card-accent: #0891b2;
}

.level-course-group .subject-card:nth-child(5n + 3) {
  --card-accent: #16a34a;
}

.level-course-group .subject-card:nth-child(5n + 4) {
  --card-accent: #c2410c;
}

.level-course-group .subject-card:nth-child(5n) {
  --card-accent: #7c3aed;
}

/* =========================
   Method cards
   ========================= */

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 28px;
}

.method-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.method-card h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #0f172a;
}

.method-card p {
  margin: 0;
  color: #64748b;
  line-height: 1.6;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 36px;
}

.about-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.about-card--featured {
  max-width: 820px;
  margin: 0 auto;
}

.about-card-label {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.about-card h4 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 1.15rem;
}

.about-card p {
  margin: 0 0 14px;
  color: #64748b;
  line-height: 1.65;
}

.about-card p:last-child {
  margin-bottom: 0;
}

.course-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.course-title-row h1 {
  margin: 0;
  flex: 1 1 240px;
  min-width: 0;
}

.course-title-row .course-actions {
  margin: 0;
  flex-shrink: 0;
}

.rpg-zone-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.rpg-zone-title-row h3 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.rpg-zone-title-row .plan-test-button {
  padding: 10px 16px;
  font-size: 0.88rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Course page
   ========================= */

.hero-course {
  padding: 56px 0;
}

/* ── Level themes ── */
[data-level-theme="segundo-basico"] .hero-course {
  background:
    radial-gradient(circle at 14% 16%, rgba(251, 191, 36, 0.28), transparent 30%),
    linear-gradient(135deg, #1c1917, #d97706 48%, #92400e);
}
[data-level-theme="segundo-basico"] .rpg-select {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #78350f;
}
[data-level-theme="segundo-basico"] .rpg-hero-panel {
  border-color: rgba(245, 158, 11, 0.3);
}

[data-level-theme="tercero-basico"] .hero-course {
  background:
    radial-gradient(circle at 14% 16%, rgba(45, 212, 191, 0.24), transparent 30%),
    linear-gradient(135deg, #0f172a, #0d9488 48%, #166534);
}
[data-level-theme="tercero-basico"] .rpg-select {
  border-color: #14b8a6;
  background: #f0fdfa;
  color: #134e4a;
}
[data-level-theme="tercero-basico"] .rpg-hero-panel {
  border-color: rgba(20, 184, 166, 0.3);
}

[data-level-theme="quinto-basico"] .hero-course {
  background:
    radial-gradient(circle at 14% 16%, rgba(34, 211, 238, 0.22), transparent 28%),
    linear-gradient(135deg, #0f172a, #0891b2 48%, #0f766e);
}
[data-level-theme="quinto-basico"] .rpg-select {
  border-color: #06b6d4;
  background: #ecfeff;
  color: #164e63;
}
[data-level-theme="quinto-basico"] .rpg-hero-panel {
  border-color: rgba(6, 182, 212, 0.3);
}

[data-level-theme="sexto-basico"] .hero-course {
  background:
    radial-gradient(circle at 14% 16%, rgba(167, 139, 250, 0.22), transparent 28%),
    linear-gradient(135deg, #0f172a, #6d28d9 48%, #5b21b6);
}
[data-level-theme="sexto-basico"] .rpg-select {
  border-color: #8b5cf6;
  background: #f5f3ff;
  color: #4c1d95;
}
[data-level-theme="sexto-basico"] .rpg-hero-panel {
  border-color: rgba(139, 92, 246, 0.3);
}

[data-level-theme="septimo-basico"] .hero-course {
  background:
    radial-gradient(circle at 14% 16%, rgba(129, 140, 248, 0.18), transparent 30%),
    linear-gradient(135deg, #020617, #1e1b4b 48%, #0f172a);
}
[data-level-theme="septimo-basico"] .rpg-select {
  border-color: #6366f1;
  background: #eef2ff;
  color: #312e81;
}
[data-level-theme="septimo-basico"] .rpg-hero-panel {
  border-color: rgba(99, 102, 241, 0.3);
}

.course-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 48px 0;
}

.course-sidebar {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #dbeafe;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.1);
  height: max-content;
  position: sticky;
  top: 100px;
}

.course-sidebar h3 {
  margin-top: 0;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}

.sidebar-group {
  margin-top: 10px;
}

.sidebar-accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #bae6fd;
  border-radius: 14px;
  background: #eff6ff;
  color: #075985;
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 12px 14px;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sidebar-accordion-trigger::after {
  content: "⌄";
  color: #0891b2;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.sidebar-accordion-trigger:hover {
  background: #dbeafe;
  border-color: #38bdf8;
}

.sidebar-accordion-trigger[aria-expanded="true"] {
  background: linear-gradient(135deg, #2563eb, #0891b2);
  border-color: transparent;
  color: #ffffff;
}

.sidebar-accordion-trigger[aria-expanded="true"]::after {
  color: #ffffff;
  transform: rotate(180deg);
}

.sidebar-accordion-panel {
  padding-top: 10px;
}

.sidebar-link {
  display: block;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #334155;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-link:hover {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #155e75;
  transform: translateX(2px);
}

.sidebar-link.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.course-content {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.09);
}

.oa-main {
  width: 100%;
  padding: 0;
}

.oa-main .course-content {
  width: 100%;
  border-radius: 18px;
  padding: clamp(20px, 2.4vw, 36px);
}

.course-content h1,
.course-content h2,
.course-content h3 {
  color: #0f172a;
}

.course-layout .course-content h1 {
  color: #0f172a;
  border-bottom: 2px solid #dbeafe;
  padding-bottom: 12px;
}

.course-layout .course-content h3 {
  color: #075985;
}

.course-content p,
.course-content li {
  color: #334155;
  line-height: 1.7;
}

.course-content ul {
  padding-left: 20px;
}

.course-content img {
  width: min(100%, 520px);
  height: auto;
  margin: 18px auto 26px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.course-content a:not(.button-link) {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: none;
}

.course-content a:not(.button-link):hover {
  color: #0f172a;
}

.course-layout .course-content a:not(.button-link) {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 4px 0 10px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.course-layout .course-content a:not(.button-link):hover {
  background: #facc15;
  color: #111827;
  transform: translateY(-1px);
}

.question-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 24px;
  margin: 24px 0;
}

.question-card h2 {
  margin-top: 0;
  margin-bottom: 16px;
  color: #0f172a;
}

.question-prompt {
  margin: 0 0 18px;
  color: #334155;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.question-options {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 14px 16px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.option-label:hover {
  border-color: #93c5fd;
}

.option-label input {
  accent-color: #1d4ed8;
}

.option-label.correct-option {
  background: #d1fae5;
  border-color: #10b981;
}

.option-label.incorrect-option {
  background: #fee2e2;
  border-color: #ef4444;
}

.question-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.question-feedback {
  margin-top: 6px;
  color: #334155;
  font-weight: 600;
}

.question-feedback.correct {
  color: #047857;
}

.question-feedback.incorrect {
  color: #b91c1c;
}

.question-feedback.warning {
  color: #92400e;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 600;
    transition: transform 0.15s ease, background 0.15s ease;
  }

  .button-link:hover {
    transform: translateY(-1px);
    background: #1d4ed8;
  }

  .test-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 99;
  }

  .failure-rain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
  }

  .failure-rain::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.22));
    animation: failure-rain-flash 4.1s ease forwards;
  }

  .failure-raindrop {
    position: absolute;
    top: -12vh;
    width: 3px;
    height: 34px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(191, 219, 254, 0), rgba(59, 130, 246, 0.82));
    transform: rotate(12deg);
    animation-name: failure-rain-drop;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
  }

  .test-overlay.active {
    display: flex;
  }

  .test-panel {
    background: #ffffff;
    border-radius: 28px;
    width: min(100%, 980px);
    max-height: min(100%, 90vh);
    overflow: auto;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
    padding: 24px;
  }

  .test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
  }

  .test-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
  }

  #plan-test-overlay .test-header-actions .btn,
  #test-overlay .test-header-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }

  #test-overlay .test-header-actions .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .test-header h2 {
    flex: 1 1 auto;
    margin: 0;
    font-size: clamp(1.1rem, 1.5vw, 1.5rem);
    color: #0f172a;
  }

  .test-header-stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .test-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  .test-header-row .test-settings {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    justify-content: flex-start;
  }

  .test-header-row .test-setting-label {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .test-header-row .test-question-count {
    min-width: 70px;
    padding: 6px 28px 6px 10px;
    font-size: 0.85rem;
  }

  .test-content {
    display: grid;
    gap: 18px;
  }

  .test-settings {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
  }

  .test-setting-label {
    color: #334155;
    font-weight: 700;
  }

  .test-question-count {
    min-width: 140px;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
    font-weight: 700;
    padding: 11px 36px 11px 14px;
  }

  .test-slider-wrapper {
    overflow: hidden;
    position: relative;
  }

  .test-slider-track {
    display: flex;
    transition: transform 0.35s ease;
    width: 100%;
  }

  .test-slider-track .question-card {
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 100%;
    margin: 0;
  }

  .question-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .question-position {
    color: #334155;
    font-weight: 600;
    text-align: center;
    flex: 1;
  }

  .question-navigation-button {
    min-width: 120px;
  }

  .test-summary {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 18px;
    padding: 18px 20px;
    margin-top: 10px;
  }

  .validation-warning {
    margin-top: 16px;
    color: #92400e;
    font-weight: 700;
  }

  .test-summary.sad-result {
    background: #fff1f2;
    border-color: #fecaca;
    color: #991b1c;
  }

  .test-summary.sad-result p {
    color: #991b1c;
  }

  @keyframes failure-rain-drop {
    from {
      transform: translate3d(0, -12vh, 0) rotate(12deg);
    }

    to {
      transform: translate3d(-34px, 118vh, 0) rotate(12deg);
    }
  }

  @keyframes failure-rain-flash {
    0% {
      opacity: 0;
    }

    18% {
      opacity: 1;
    }

    100% {
      opacity: 0;
    }
  }

  /* ── Video Modal ── */
  .video-panel {
    width: min(100%, 840px);
  }

  .video-player-wrap {
    margin-bottom: 16px;
  }

  .video-aspect-ratio {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
  }

  .video-aspect-ratio iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
  }

  .video-counter {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 600;
  }

  .video-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .btn-close-overlay {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
  }

  .btn-close-overlay:hover {
    background: #f1f5f9;
    color: #0f172a;
  }

  /* ── Related Video Cards ── */
  .video-related-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
  }

  .video-related-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s;
  }

  .video-related-card:hover {
    border-color: #94a3b8;
  }

  .video-related-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #e2e8f0;
  }

  .video-related-info {
    padding: 8px 10px 10px;
    min-width: 0;
  }

  .video-related-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #0f172a;
    margin: 0 0 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
  }

  .video-related-channel {
    font-size: 0.78rem;
    color: #64748b;
    margin: 0;
  }

  .video-related-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.2s, transform 0.2s;
    pointer-events: none;
  }

  .video-related-card:hover .video-related-play {
    background: rgba(29, 78, 216, 0.95);
    transform: translate(-50%, -50%) scale(1.1);
  }

  @media (prefers-reduced-motion: reduce) {
    .failure-rain,
    .failure-raindrop,
    .failure-rain::before {
      animation: none;
    }

    .failure-rain {
      display: none;
    }
  }

  .test-summary strong {
    display: block;
    margin-bottom: 6px;
    color: #0f172a;
  }

  .test-summary p {
    margin: 0;
    color: #334155;
  }

  .test-warning {
    color: #92400e;
    font-weight: 600;
  }

  .btn-light {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
  }

  .btn-light:hover {
    background: #e2e8f0;
  }

  .hero-course {
    background:
      radial-gradient(circle at 18% 18%, rgba(250, 204, 21, 0.22), transparent 28%),
      linear-gradient(135deg, #0f172a, #1e3a8a 48%, #0f766e);
    color: #ffffff;
    padding: 32px 0;
  }

  .hero-course h1,
  .hero-course h2 {
    margin: 8px 0 6px;
    font-size: clamp(1.5rem, 2.8vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.03em;
  }

  .hero-course p {
    max-width: 760px;
    margin: 0 auto;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.92rem;
    line-height: 1.6;
  }

  .hero-course .hero-actions {
    margin-top: 24px;
    display: flex;
    justify-content: center;
  }

  .hero-course .hero-actions .btn,
  .course-actions .btn {
    min-width: 150px;
  }

  .course-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin: 0;
  }

  .course-title-row .course-actions .btn {
    min-width: 0;
    padding: 10px 16px;
    font-size: 0.88rem;
  }

  .hero-course .badge {
    background: #facc15;
    color: #111827;
  }

  .oa-header {
    padding: 24px 28px;
    background: linear-gradient(90deg, #1d4ed8, #0891b2, #10b981);
    color: #ffffff;
    text-align: center;
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.16);
  }

  .oa-header h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3rem);
    letter-spacing: -0.03em;
  }

  .oa-header nav {
    margin-top: 12px;
    font-size: 0.98rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    opacity: 0.92;
  }

  .oa-header nav a {
    color: #f8fafc;
    font-weight: 600;
    transition: opacity 0.2s ease;
  }

  .oa-header nav a:hover {
    opacity: 0.8;
  }

  .oa-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .oa-actions-bottom {
    justify-content: space-between;
    margin-top: 28px;
    margin-bottom: 0;
  }

  .oa-arrow-button {
    min-width: 56px;
    padding-inline: 18px;
    font-size: 1.35rem;
    line-height: 1;
  }

  .oa-actions-bottom .oa-next-button {
    margin-left: auto;
  }

  .oa-actions-bottom .oa-prev-button {
    margin-right: auto;
  }

  .oa-section-accordion {
    display: grid;
    gap: 12px;
    margin-top: 24px;
    width: 100%;
  }

  .oa-section-item {
    border: 1px solid #dbeafe;
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
  }

  .oa-section-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    padding: 16px 18px;
    text-align: left;
    transition: background 0.2s ease, color 0.2s ease;
  }

  .oa-section-trigger::after {
    content: "⌄";
    color: #64748b;
    font-size: 1.15rem;
    line-height: 1;
    transition: transform 0.2s ease;
  }

  .oa-section-trigger:hover {
    background: #d0ebf5;
  }

  .oa-section-trigger[aria-expanded="true"] {
    background: #dbeafe;
    color: #1d4ed8;
  }

  .oa-section-trigger[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }

  .oa-section-panel {
    padding: clamp(14px, 1.8vw, 22px);
  }

  .oa-section-panel > :first-child {
    margin-top: 0;
  }

  .oa-section-panel > :last-child {
    margin-bottom: 0;
  }

  .error-box {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    padding: 18px 20px;
    border-radius: 18px;
  }

  .notice-box {
    background: #ecfeff;
    color: #155e75;
    border: 1px solid #67e8f9;
    padding: 18px 20px;
    border-radius: 18px;
    margin-bottom: 22px;
    line-height: 1.6;
  }

  .learning-plan {
    padding: 48px 0;
  }

  .learning-plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
  }

  .learning-plan-header h2 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: clamp(1.8rem, 2.4vw, 2.4rem);
  }

  .learning-plan-header p,
  .learning-muted {
    margin: 0;
    color: #64748b;
  }

  .learning-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
  }

  .learning-metric {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 86px;
    justify-content: center;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: #ffffff;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  }

  .learning-metric span {
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .learning-metric strong {
    color: #0f172a;
    font-size: 1.35rem;
  }

  .learning-plan-grid {
    display: grid;
    gap: 18px;
  }

  .learning-course-card {
    border: 1px solid #dbeafe;
    border-radius: 18px;
    background: #ffffff;
    padding: 20px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
  }

  .learning-course-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
  }

  .learning-course-head span {
    color: #0891b2;
    font-size: 0.86rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .learning-course-head h3 {
    margin: 6px 0;
    color: #0f172a;
    font-size: 1.35rem;
  }

  .learning-course-head h3 a {
    color: inherit;
  }

  .learning-course-head h3 a:hover {
    color: #1d4ed8;
  }

  .learning-course-head p {
    margin: 0;
    color: #64748b;
  }

  .learning-course-head > strong {
    color: #0f766e;
    font-size: 1.8rem;
  }

  .learning-course-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 16px;
  }

  .learning-course-details .learning-metric {
    min-height: 72px;
    box-shadow: none;
    background: #f8fafc;
  }

  .learning-recommendation {
    margin: 16px 0 0;
    border: 1px solid #fde68a;
    border-radius: 14px;
    background: #fffbeb;
    color: #92400e;
    font-weight: 700;
    padding: 12px 14px;
  }

  .learning-oa-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
  }

  .learning-oa-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 240px) 110px;
    align-items: center;
    gap: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
    color: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  }

  .learning-oa-row:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: translateY(-1px);
  }

  .learning-oa-row strong {
    display: block;
    color: #0f172a;
  }

  .learning-oa-row span {
    color: #64748b;
    font-size: 0.92rem;
  }

  .learning-progress-meter {
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
  }

  .learning-progress-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0ea5e9, #22c55e);
  }

  .learning-status {
    display: inline-flex;
    justify-content: center;
    border-radius: 999px;
    padding: 8px 10px;
    background: #e0f2fe;
    color: #075985;
    font-size: 0.82rem;
    font-weight: 800;
  }

  .learning-status.reforzar {
    background: #fee2e2;
    color: #991b1b;
  }

  .learning-status.dominado {
    background: #dcfce7;
    color: #166534;
  }

/* =========================
   Responsive
   ========================= */

@media (max-width: 900px) {
  .nav-wrap {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 14px;
  }

  .nav-links {
    display: none;
  }

  .logo {
    gap: 10px;
    font-size: 1.05rem;
  }

  .logo img {
    width: 72px;
    height: 40px;
    border-radius: 9px;
  }

  .hero-grid,
  .levels-grid,
  .method-grid,
  .course-layout {
    grid-template-columns: 1fr;
  }

  .hero h2 {
    font-size: 2.4rem;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .course-sidebar {
    position: relative;
    top: 0;
  }

  .oa-main {
    padding: 0;
  }

  .oa-main .course-content {
    border-radius: 14px;
    padding: 14px;
  }

  .question-card {
    border-radius: 16px;
    padding: 16px;
  }

  .option-label {
    border-radius: 12px;
    padding: 12px;
  }

  .learning-plan-header,
  .learning-course-head {
    flex-direction: column;
  }

  .learning-oa-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .logo {
    font-size: 0.98rem;
    gap: 8px;
  }

  .logo img {
    width: 68px;
    height: 38px;
  }
}
.btn-donate {
  background: #22c55e;
  color: white;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-donate:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

/* --- RPG progress map (plan.html) --- */
.rpg-hero-inner {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: center;
}

.rpg-hero-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(6, 20, 38, 0.18);
}

.rpg-pixel-sprite {
  width: 80px;
  height: 80px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(250, 204, 21, 0.7);
  border-radius: 16px;
  background: rgba(6, 20, 38, 0.35);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.rpg-pixel-sprite:hover {
  transform: scale(1.08);
  border-color: #facc15;
}

.rpg-sprite-icono {
  font-size: 2.4rem;
  line-height: 1;
}

.rpg-sprite-canelo { border-color: rgba(34, 197, 94, 0.7); background: rgba(22, 101, 52, 0.45); }
.rpg-sprite-canelo:hover { border-color: #22c55e; }
.rpg-sprite-chucao { border-color: rgba(162, 98, 7, 0.7); background: rgba(120, 53, 15, 0.35); }
.rpg-sprite-chucao:hover { border-color: #a16207; }
.rpg-sprite-pudu { border-color: rgba(217, 119, 6, 0.7); background: rgba(180, 83, 9, 0.3); }
.rpg-sprite-pudu:hover { border-color: #d97706; }
.rpg-sprite-monito { border-color: rgba(180, 83, 9, 0.7); background: rgba(120, 53, 15, 0.3); }
.rpg-sprite-monito:hover { border-color: #b45309; }
.rpg-sprite-matuasto { border-color: rgba(148, 163, 184, 0.7); background: rgba(100, 116, 139, 0.35); }
.rpg-sprite-matuasto:hover { border-color: #cbd5e1; }
.rpg-sprite-puye { border-color: rgba(56, 189, 248, 0.7); background: rgba(14, 116, 144, 0.3); }
.rpg-sprite-puye:hover { border-color: #38bdf8; }
.rpg-sprite-concon { border-color: rgba(99, 102, 241, 0.7); background: rgba(55, 48, 163, 0.3); }
.rpg-sprite-concon:hover { border-color: #6366f1; }
.rpg-sprite-zorro { border-color: rgba(249, 115, 22, 0.7); background: rgba(194, 65, 12, 0.3); }
.rpg-sprite-zorro:hover { border-color: #f97316; }
.rpg-sprite-rana { border-color: rgba(16, 185, 129, 0.7); background: rgba(6, 95, 70, 0.3); }
.rpg-sprite-rana:hover { border-color: #10b981; }
.rpg-sprite-huillin { border-color: rgba(20, 184, 166, 0.7); background: rgba(15, 118, 110, 0.3); }
.rpg-sprite-huillin:hover { border-color: #14b8a6; }
.rpg-sprite-condor { border-color: rgba(168, 85, 247, 0.7); background: rgba(88, 28, 135, 0.25); }
.rpg-sprite-condor:hover { border-color: #a855f7; }

.rpg-hero-stats {
  display: grid;
  gap: 8px;
}

.rpg-hero-stats span {
  color: #f8fafc;
  font-size: 1.25rem;
  font-weight: 700;
}

.rpg-hero-stats strong {
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 600;
}

.rpg-xp-bar {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.rpg-xp-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #10b981);
  transition: width 0.35s ease;
}

.rpg-main {
  padding: 42px 0 56px;
}

.rpg-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.rpg-label {
  display: block;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 0.92rem;
  font-weight: 700;
}

.rpg-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.rpg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #ffffff;
}

.rpg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 0.92rem;
  font-weight: 600;
}

.rpg-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.rpg-summary-card {
  padding: 16px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.rpg-summary-card span {
  display: block;
  margin-bottom: 6px;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 700;
}

.rpg-summary-card strong {
  color: #0f172a;
  font-size: 1.35rem;
}

.rpg-summary-card--ok strong { color: #16a34a; }
.rpg-summary-card--fail strong { color: #dc2626; }
.rpg-summary-card--pending strong { color: #64748b; }
.rpg-summary-card--blue strong { color: #0891b2; }

.rpg-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: #64748b;
  font-weight: 600;
}

.rpg-loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0891b2;
  animation: rpg-blink 0.8s ease-in-out infinite;
}

@keyframes rpg-blink {
  50% { opacity: 0.25; }
}

.rpg-course-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.rpg-course-tab {
  display: grid;
  gap: 4px;
  min-width: 148px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #ffffff;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.rpg-course-tab:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
}

.rpg-course-tab.active {
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.rpg-course-tab[data-course*="lenguaje"].active { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.rpg-course-tab[data-course*="matematicas"].active { background: linear-gradient(135deg, #0891b2, #0e7490); }
.rpg-course-tab[data-course*="naturales"].active { background: linear-gradient(135deg, #22c55e, #16a34a); }
.rpg-course-tab[data-course*="sociales"].active { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.rpg-course-tab[data-course*="historia"].active { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.rpg-course-tab[data-course*="ingles"].active { background: linear-gradient(135deg, #f59e0b, #d97706); }
.rpg-course-tab.active:not([data-course*="lenguaje"]):not([data-course*="matematicas"]):not([data-course*="naturales"]):not([data-course*="sociales"]):not([data-course*="historia"]):not([data-course*="ingles"]) {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.rpg-course-tab-title {
  font-weight: 800;
  font-size: 0.95rem;
}

.rpg-course-tab-meta {
  font-size: 0.82rem;
  opacity: 0.86;
}

.rpg-board {
  display: grid;
  gap: 20px;
}

.rpg-zone {
  border: 1px solid #dbeafe;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.rpg-zone[data-course*="lenguaje"] { border-color: #bfdbfe; background: linear-gradient(180deg, #f8faff, #ffffff); }
.rpg-zone[data-course*="matematicas"] { border-color: #a5f3fc; background: linear-gradient(180deg, #f4fdff, #ffffff); }
.rpg-zone[data-course*="naturales"] { border-color: #bbf7d0; background: linear-gradient(180deg, #f6fef9, #ffffff); }
.rpg-zone[data-course*="sociales"] { border-color: #ddd6fe; background: linear-gradient(180deg, #faf8ff, #ffffff); }
.rpg-zone[data-course*="historia"] { border-color: #ddd6fe; background: linear-gradient(180deg, #faf8ff, #ffffff); }
.rpg-zone[data-course*="ingles"] { border-color: #fde68a; background: linear-gradient(180deg, #fffcf5, #ffffff); }

.rpg-zone[data-course*="lenguaje"] .rpg-zone-head { background: linear-gradient(180deg, #eff6ff, #ffffff); }
.rpg-zone[data-course*="matematicas"] .rpg-zone-head { background: linear-gradient(180deg, #ecfeff, #ffffff); }
.rpg-zone[data-course*="naturales"] .rpg-zone-head { background: linear-gradient(180deg, #f0fdf4, #ffffff); }
.rpg-zone[data-course*="sociales"] .rpg-zone-head { background: linear-gradient(180deg, #f5f3ff, #ffffff); }
.rpg-zone[data-course*="historia"] .rpg-zone-head { background: linear-gradient(180deg, #f5f3ff, #ffffff); }
.rpg-zone[data-course*="ingles"] .rpg-zone-head { background: linear-gradient(180deg, #fffbeb, #ffffff); }

.rpg-zone[data-course*="lenguaje"] .rpg-zone-meter span { background: linear-gradient(90deg, #2563eb, #1d4ed8); }
.rpg-zone[data-course*="matematicas"] .rpg-zone-meter span { background: linear-gradient(90deg, #0891b2, #0e7490); }
.rpg-zone[data-course*="naturales"] .rpg-zone-meter span { background: linear-gradient(90deg, #22c55e, #16a34a); }
.rpg-zone[data-course*="sociales"] .rpg-zone-meter span { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.rpg-zone[data-course*="historia"] .rpg-zone-meter span { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.rpg-zone[data-course*="ingles"] .rpg-zone-meter span { background: linear-gradient(90deg, #f59e0b, #d97706); }

.rpg-zone-head {
  display: grid;
  grid-template-columns: 1fr minmax(120px, 180px);
  gap: 16px;
  align-items: center;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
}

.rpg-zone-tag {
  display: inline-block;
  margin-bottom: 8px;
  color: #0891b2;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rpg-zone-head h3 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.35;
}

.rpg-zone-head h3 a {
  color: #0f172a;
}

.rpg-zone-head h3 a:hover {
  color: #1d4ed8;
}

.rpg-zone-head p {
  margin: 0;
  color: #64748b;
}

.rpg-zone-meter {
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.rpg-zone-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1d4ed8, #0891b2, #10b981);
}

.rpg-quest-list {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.rpg-quest {
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fafc;
}

.rpg-quest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.rpg-quest-title {
  color: #0f172a;
  font-weight: 700;
  line-height: 1.35;
}

button.rpg-quest-title {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rpg-quest-title:hover {
  color: #1d4ed8;
}

.plan-oa-header {
  margin-bottom: 14px;
  flex-wrap: nowrap;
  gap: 12px;
}

.plan-oa-header .badge {
  flex-shrink: 0;
}

.plan-oa-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.plan-oa-btn {
  padding: 6px 11px;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
}

.plan-oa-panel .oa-content-body {
  padding-top: 0;
}

.rpg-quest-badge {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 800;
}

.rpg-loot-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

.rpg-loot {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rpg-loot:hover {
  transform: translateY(-2px);
}

.rpg-loot--ok {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.rpg-loot--fail {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.rpg-loot--pending {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}

.rpg-empty {
  margin: 0;
  color: #64748b;
}

@media (max-width: 900px) {
  .rpg-hero-inner,
  .rpg-toolbar,
  .rpg-zone-head {
    grid-template-columns: 1fr;
  }

  .rpg-loot-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .rpg-loot-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .rpg-toolbar,
  .rpg-course-tabs {
    gap: 12px;
  }

  .rpg-course-tab {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
  }
}

/* =========================
   Gemini Agent Widget
   ========================= */

#gemini-agent {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: Inter, Arial, sans-serif;
}

.gemini-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.45);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.gemini-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(102, 126, 234, 0.55);
}

.gemini-fab-icon {
  line-height: 1;
}

.gemini-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 380px;
  max-height: 580px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  overflow: hidden;
}

.gemini-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.gemini-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.gemini-panel-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.gemini-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.gemini-close-btn:hover {
  opacity: 1;
}

.gemini-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 380px;
  background: #fafcff;
}

.gemini-msg {
  display: flex;
  flex-direction: column;
}

.gemini-msg-user {
  align-items: flex-end;
}

.gemini-msg-bot {
  align-items: flex-start;
}

.gemini-msg-content {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.gemini-msg-user .gemini-msg-content {
  background: #667eea;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.gemini-msg-bot .gemini-msg-content {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.gemini-msg-bot .gemini-msg-content p {
  margin: 0 0 8px;
}

.gemini-msg-bot .gemini-msg-content p:last-child {
  margin-bottom: 0;
}

.gemini-msg-bot .gemini-msg-content ul,
.gemini-msg-bot .gemini-msg-content ol {
  margin: 6px 0;
  padding-left: 20px;
}

.gemini-msg-bot .gemini-msg-content li {
  margin-bottom: 4px;
}

.gemini-msg-bot .gemini-msg-content code {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.gemini-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fafcff;
}

.gemini-input-row input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.gemini-input-row input:focus {
  border-color: #667eea;
}

.gemini-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #667eea;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.gemini-send-btn:hover {
  background: #5a6fd6;
}

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

/* Typing indicator */
.gemini-typing .gemini-msg-content {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: geminiTyping 1.4s infinite both;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes geminiTyping {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

@media (max-width: 480px) {
  #gemini-agent {
    bottom: 16px;
    right: 16px;
  }

  .gemini-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: translateY(20px);
  }

  .gemini-panel.open {
    transform: translateY(0);
  }
  .gemini-messages {
    max-height: none;
  }

  .test-overlay {
    padding: 0;
  }

  .test-panel {
    border-radius: 0;
    padding: 0;
    max-height: 100%;
  }

  .question-card {
    margin: 0;
  }
}

/* =========================
   Level System
   ========================= */

/* -- Gemini FAB with level -- */

.gemini-fab {
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}



/* -- Level-up overlay -- */

.el-levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  animation: elFadeIn 0.3s ease;
}

.el-levelup-hide {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.el-levelup-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: elBounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}

.el-levelup-icon {
  font-size: 56px;
  margin-bottom: 8px;
  line-height: 1;
}

.el-levelup-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.el-levelup-number {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
}

.el-levelup-sub {
  font-size: 0.95rem;
  color: #64748b;
  margin: 8px 0 20px;
}

.el-levelup-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  background: #f1f5f9;
  color: #1e293b;
  transition: background 0.15s;
}

.el-levelup-btn:hover {
  background: #e2e8f0;
}

.el-canelo .el-levelup-label { color: #22c55e; }
.el-canelo .el-levelup-number { color: #166534; }
.el-chucao .el-levelup-label { color: #a16207; }
.el-chucao .el-levelup-number { color: #713f12; }
.el-pudu .el-levelup-label { color: #d97706; }
.el-pudu .el-levelup-number { color: #b45309; }
.el-monito .el-levelup-label { color: #b45309; }
.el-monito .el-levelup-number { color: #78350f; }
.el-matuasto .el-levelup-label { color: #94a3b8; }
.el-matuasto .el-levelup-number { color: #475569; }
.el-puye .el-levelup-label { color: #38bdf8; }
.el-puye .el-levelup-number { color: #0e7490; }
.el-concon .el-levelup-label { color: #6366f1; }
.el-concon .el-levelup-number { color: #3730a3; }
.el-zorro .el-levelup-label { color: #f97316; }
.el-zorro .el-levelup-number { color: #9a3412; }
.el-rana .el-levelup-label { color: #10b981; }
.el-rana .el-levelup-number { color: #065f46; }
.el-huillin .el-levelup-label { color: #14b8a6; }
.el-huillin .el-levelup-number { color: #115e59; }
.el-condor .el-levelup-label { color: #a855f7; }
.el-condor .el-levelup-number {
  background: linear-gradient(135deg, #a855f7, #d946ef, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes elFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes elBounceIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* -- Level page -- */

.levels-hero {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  padding: 32px 0 24px;
  text-align: center;
}

.levels-hero h1 {
  font-size: 1.8rem;
  margin: 0 0 6px;
}

.levels-hero p {
  font-size: 0.92rem;
  opacity: 0.8;
  max-width: 600px;
  margin: 0 auto;
}

.levels-intro {
  max-width: 1180px;
  margin: 28px auto;
  padding: 0 24px;
}

.levels-intro h2 {
  font-size: 1.5rem;
  margin: 0 0 12px;
}

.levels-intro p {
  line-height: 1.7;
  color: #475569;
  margin: 0 0 16px;
}

.levels-table-wrap {
  overflow-x: auto;
  max-width: 1180px;
  margin: 0 auto 48px;
  padding: 0 24px;
}

.levels-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.levels-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
}

.levels-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.levels-table tr:hover td {
  background: #fafcff;
}

.levels-tier-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot-canelo { background: #22c55e; }
.dot-chucao { background: #a16207; }
.dot-pudu { background: #d97706; }
.dot-monito { background: #b45309; }
.dot-matuasto { background: #94a3b8; }
.dot-puye { background: #38bdf8; }
.dot-concon { background: #6366f1; }
.dot-zorro { background: #f97316; }
.dot-rana { background: #10b981; }
.dot-huillin { background: #14b8a6; }
.dot-condor { background: linear-gradient(135deg, #a855f7, #d946ef, #f472b6); }

.levels-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.levels-tier-badge .tier-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.levels-tier-badge.canelo { background: #f0fdf4; color: #166534; }
.levels-tier-badge.chucao { background: #fef3c7; color: #713f12; }
.levels-tier-badge.pudu { background: #fef3c7; color: #92400e; }
.levels-tier-badge.monito { background: #fef3c7; color: #78350f; }
.levels-tier-badge.matuasto { background: #f1f5f9; color: #475569; }
.levels-tier-badge.puye { background: #ecfeff; color: #0e7490; }
.levels-tier-badge.concon { background: #eef2ff; color: #3730a3; }
.levels-tier-badge.zorro { background: #fff7ed; color: #9a3412; }
.levels-tier-badge.rana { background: #ecfdf5; color: #065f46; }
.levels-tier-badge.huillin { background: #f0fdfa; color: #115e59; }
.levels-tier-badge.condor { background: #f5f3ff; color: #7c3aed; }

@media (max-width: 520px) {
  .levels-hero h1 { font-size: 1.8rem; }
  .levels-table td, .levels-table th { padding: 8px 10px; font-size: 0.85rem; }
}

.btn-speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.btn-speak:hover {
  background: #c7d2fe;
  transform: scale(1.08);
}
.btn-speak.speaking {
  background: #fecaca;
  color: #b91c1c;
}
.btn-speak.speaking svg {
  animation: speak-pulse 0.8s ease infinite;
}
@keyframes speak-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.oa-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.oa-section-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-guide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.btn-guide:hover {
  background: #bfdbfe;
  transform: scale(1.08);
}
.question-card .question-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.question-card .question-header h2 {
  margin: 0;
}
.question-card > .btn-speak {
  float: left;
  margin: 0 8px 4px 0;
}
