:root {
  --brand: #2FBF71;
  --brand-dark: #1E9C5A;
  --brand-light: #E4FBEC;
  --sun: #FFC93C;
  --sun-dark: #E6A800;
  --coral: #FF6B6B;
  --coral-dark: #E14545;
  --sky: #3DA9FC;
  --sky-dark: #1E82D6;
  --grape: #8C54FF;
  --grape-dark: #6B32D6;
  --teal: #12B5A6;
  --teal-dark: #0C8F84;
  --ink: #17281F;
  --muted: #5C7268;
  --bg: #F4FBF6;
  --bg-2: #E9F7EC;
  --card: #FFFFFF;
  --line: #E1EFE3;
  --shadow: 0 14px 34px rgba(23, 60, 40, 0.10);
  --shadow-lg: 0 22px 48px rgba(23, 60, 40, 0.16);
  --radius: 22px;
  --radius-sm: 14px;
  --font: "Baloo 2", "DM Sans", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, #d8f5e2 0%, transparent 42%),
    radial-gradient(circle at 95% 0%, #fff1cf 0%, transparent 38%),
    radial-gradient(circle at 100% 60%, #e3f0ff 0%, transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}
a { color: var(--brand-dark); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0 0 0.5rem; }
p { line-height: 1.55; }

/* ---------- Topbar & nav ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.brand .logo-dot {
  width: 30px; height: 30px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), var(--teal));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.05rem; box-shadow: 0 3px 0 var(--brand-dark);
}
.brand span { color: var(--brand-dark); }

.topbar-stats { display: flex; align-items: center; gap: 0.5rem; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.5rem;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 2px 0 var(--line);
}
.stat-pill.xp { color: var(--sun-dark); border-color: #ffe3a0; }
.stat-pill.streak { color: var(--coral-dark); border-color: #ffd0d0; }
.stat-pill .ico { font-size: 1rem; line-height: 1; }
.stat-pill.streak .ico { animation: flicker 1.6s ease-in-out infinite; display: inline-block; }
.stat-pill[data-pulse="1"] { animation: pop 0.5s ease; }

.nav-toggle {
  display: none;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
}
.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}
.topbar nav a {
  color: var(--ink);
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover { background: var(--brand-light); color: var(--brand-dark); text-decoration: none; }
.topbar nav a.muted { color: var(--muted); font-weight: 600; }
.topbar nav a.nav-cta {
  background: var(--brand); color: #fff; box-shadow: 0 3px 0 var(--brand-dark);
}
.topbar nav a.nav-cta:hover { background: var(--brand); filter: brightness(1.05); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .topbar { flex-wrap: wrap; }
  .topbar nav {
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding-top: 0.5rem;
  }
  .topbar nav.open { display: flex; }
  .topbar nav a { width: 100%; }
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 1rem 2rem;
}

/* ---------- Surfaces ---------- */
.hero, .panel, .card, .login-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero {
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% -20%, rgba(47,191,113,0.14), transparent 55%),
    var(--card);
}
.hero h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
.lead { color: var(--muted); margin: 0; line-height: 1.6; font-size: 1.02rem; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  color: var(--brand-dark);
  font-weight: 800;
  margin-bottom: 0.45rem;
  background: var(--brand-light);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card, .panel { padding: 1.3rem; }
.card h3 { margin-top: 0; font-family: var(--display); }
.meta { color: var(--muted); font-size: 0.9rem; }
.card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.4rem;
  background: var(--brand);
  color: #fff;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--brand-dark), 0 10px 18px rgba(31, 124, 75, 0.22);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-dark); }
.btn.secondary {
  background: #fff;
  color: var(--brand-dark);
  box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--brand);
}
.btn.secondary:active { box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--brand); }
.btn.ghost {
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: 0 4px 0 #d8ebdb;
}
.btn.ghost:active { box-shadow: 0 1px 0 #d8ebdb; }
.btn.warn { background: var(--coral); box-shadow: 0 4px 0 var(--coral-dark), 0 10px 18px rgba(225,69,69,0.22); }
.btn.small { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }

/* ---------- Progress ---------- */
.progress {
  height: 14px;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.85rem 0;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--teal));
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.08);
  transition: width 1s cubic-bezier(.22,1,.36,1);
}
.progress.sun > span { background: linear-gradient(90deg, var(--sun), var(--sun-dark)); }

/* ---------- Dashboard module cards ---------- */
.module-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
}
@media (max-width: 900px) {
  .module-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .module-card-grid { grid-template-columns: 1fr; }
}
.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.module-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #c5e8d1;
}
.module-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.module-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  background: var(--brand-light);
  box-shadow: inset 0 0 0 2px rgba(47, 191, 113, 0.18);
}
.module-card h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.3;
  min-height: 2.6em;
}
.module-card-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}
.module-card-progress { margin-top: auto; }
.module-card-progress .progress { margin: 0.55rem 0 0.4rem; }
.module-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
}
.module-card-meta strong { color: var(--brand-dark); }
.module-card .btn { width: 100%; }
.module-card--sky::before { background: linear-gradient(90deg, var(--sky), var(--grape)); }
.module-card--sky .module-card-icon {
  background: #e8f4ff;
  box-shadow: inset 0 0 0 2px rgba(61, 169, 252, 0.22);
}
.module-card--sky .module-card-meta strong { color: var(--sky-dark); }
.module-card--coral::before { background: linear-gradient(90deg, var(--coral), var(--sun)); }
.module-card--coral .module-card-icon {
  background: #ffe8e8;
  box-shadow: inset 0 0 0 2px rgba(255, 107, 107, 0.22);
}
.module-card--coral .module-card-meta strong { color: var(--coral-dark); }
.module-card--done {
  background: linear-gradient(180deg, #fff, var(--brand-light));
}
.module-card--progress {
  border-color: #cfe9d8;
}

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--brand-light);
  color: var(--brand-dark);
  border: 1.5px solid #cdf0da;
}
.badge.warn { background: #FFF1DD; color: var(--sun-dark); border-color: #ffe3a0; }
.badge.locked { background: #EDEFEE; color: #7a7f7c; border-color: #dfe2e0; }
.badge.danger { background: #FFE7E7; color: var(--coral-dark); border-color: #ffd0d0; }
.badge.grape { background: #F1E9FF; color: var(--grape-dark); border-color: #ddc9ff; }

.characters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
}
.chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: #fff; flex-shrink: 0;
  overflow: hidden;
  border: 2px solid transparent;
  background-size: cover;
  background-position: top center;
}
.chip .avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.chip[data-char="laura"] .avatar { background: var(--grape); border-color: var(--grape); }
.chip[data-char="mateo"] .avatar { background: var(--sky); border-color: var(--sky); }
.chip[data-char="sofia"] .avatar { background: var(--sun-dark); border-color: var(--sun-dark); }
.chip[data-char="carlos"] .avatar { background: var(--teal); border-color: var(--teal); }
.chip[data-char="diana"] .avatar { background: var(--coral); border-color: var(--coral); }
.chip[data-char="andres"] .avatar { background: var(--brand); border-color: var(--brand); }

/* Personajes a tamaño completo (panel de login, portadas de historia) */
.character-portrait {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
}
.character-portrait img {
  max-width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.22));
}

/* Elenco detectado dentro de un texto: quién habla o quiénes participan en la escena */
.cast-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.55rem 0 0.7rem;
}
.cast-row .char-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 2px solid var(--card);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 0 0 2px var(--line);
  margin-left: -12px;
  flex-shrink: 0;
}
.cast-row .char-avatar:first-child { margin-left: 0; }
.cast-row .cast-names {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Nota-guía antes de entrar a las lecciones de un módulo */
.callout {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: var(--brand-light);
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
}
.callout-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.callout p { margin: 0; color: var(--brand-dark); font-weight: 700; line-height: 1.5; }

/* Mascota decorativa dentro de un .hero (celebraciones, portadas) */
.hero .hero-mascot {
  position: absolute;
  right: 0.75rem;
  bottom: -0.4rem;
  width: 130px;
  max-width: 30%;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.18));
}
@media (max-width: 700px) {
  .hero .hero-mascot { display: none; }
}

/* ---------- Lesson blocks ---------- */
.lesson-block {
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.9rem;
  background: #fff;
  opacity: 0;
  transform: translateY(14px);
}
.lesson-block.revealed { opacity: 1; transform: none; transition: opacity 0.5s ease, transform 0.5s ease; }
.lesson-block h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.lesson-block p { margin: 0; }
.tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--brand-dark);
  margin-bottom: 0.45rem;
}

.lesson-block--story {
  position: relative;
  overflow: hidden;
  border: 0;
  padding: 1.35rem 1.4rem 1.4rem 1.55rem;
  background:
    linear-gradient(135deg, rgba(255, 201, 60, 0.22) 0%, rgba(255, 255, 255, 0.95) 42%, rgba(61, 169, 252, 0.12) 100%);
  box-shadow: var(--shadow);
}
.lesson-block--story::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, var(--sun), var(--sky));
}
.lesson-block--story .tag {
  color: var(--sun-dark);
  background: rgba(255, 201, 60, 0.28);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.7rem;
}
.lesson-block--story .story-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sky-dark);
  margin: 0 0 0.55rem;
}
.lesson-block--story p:not(.story-kicker) {
  font-family: var(--display);
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--ink);
}
.lesson-block--roble {
  border-color: #cfe8d6;
  background: linear-gradient(180deg, #fff, var(--brand-light));
}
.lesson-block--avira {
  border-color: #c9e4ff;
  background: linear-gradient(180deg, #fff, #eef7ff);
}
.lesson-block--term {
  border-color: #dfd0ff;
  background: linear-gradient(180deg, #fff, #f4eeff);
}
.lesson-block--essential {
  border-color: #ffe3a8;
  background: linear-gradient(180deg, #fff, #fff7e3);
}

/* ---------- Lesson audio player ---------- */
.audio-panel {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.1rem;
  padding: 0.9rem 1.1rem;
  background: var(--brand-light);
  border: 2px solid #cdf0da;
  border-radius: var(--radius-sm);
}
.audio-panel .audio-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 3px 0 var(--brand-dark);
}
.audio-panel-body { flex: 1; min-width: 0; }
.audio-panel audio {
  width: 100%;
  max-width: 420px;
  accent-color: var(--brand);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 82vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(900px, 100%);
  padding: 0;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
}
.login-side {
  background: linear-gradient(155deg, var(--brand), var(--teal));
  color: #fff;
  padding: 2.2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
}
.login-side h1 { color: #fff; }
.login-side > *:not(.mascot-portrait) {
  position: relative;
  z-index: 1;
  max-width: 80%;
}
.login-side .mascot-portrait {
  position: absolute;
  right: -0.5rem;
  bottom: 0;
  width: 190px;
  max-width: 42%;
  height: auto;
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
}
@media (max-width: 760px) {
  .login-side .mascot-portrait { display: none; }
}
.login-side .lead { color: rgba(255,255,255,0.9); }
.login-form-side { padding: 2.2rem; }
@media (max-width: 760px) {
  .login-card { grid-template-columns: 1fr; }
  .login-side { padding: 1.6rem; }
}

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* ---------- Choices (quiz / case stations) ---------- */
.choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.1rem;
  margin-bottom: 0.6rem;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.choice:hover { border-color: var(--sky); transform: translateY(-1px); }
.choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-light);
}
.choice input { margin-right: 0.3rem; width: 18px; height: 18px; accent-color: var(--brand); }

.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 2px solid transparent;
  font-weight: 700;
}
.alert.ok { background: #E6F5EC; color: var(--brand-dark); border-color: #c9ecd6; }
.alert.err { background: #FDEAEA; color: var(--coral-dark); border-color: #ffd0d0; }

.stack { display: grid; gap: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }

.order-list { list-style: none; padding: 0; margin: 0; }
.order-list li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  cursor: grab;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.order-list li.dragging { opacity: 0.4; }
.order-list li.drag-over { border-color: var(--sky); box-shadow: 0 0 0 3px #dceefe; }
.order-list li .drag-handle { color: var(--muted); font-size: 1.1rem; cursor: grab; }

.result-item { border: 2px solid var(--line); }
.result-item.ok { border-color: #bfe9cf; background: #F3FCF6; }
.result-item.bad { border-color: #ffd0d0; background: #FFF6F6; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 2px solid var(--line);
}
th { color: var(--muted); font-weight: 800; }

/* ---------- Module learning path ---------- */
.path {
  position: relative;
  padding: 1rem 0 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.path-connector {
  position: absolute;
  left: 50%;
  top: 44px;
  bottom: 44px;
  width: 6px;
  background: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 10px, transparent 10px, transparent 18px);
  transform: translateX(-50%);
  z-index: 0;
  border-radius: 6px;
}
.path-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 auto 1.35rem;
  width: 100%;
  max-width: 560px;
}
.path-node:nth-child(even) { flex-direction: row-reverse; }
.path-node:nth-child(even) .path-info { text-align: right; }
.path-orb {
  flex-shrink: 0;
  width: 84px; height: 84px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  background: var(--card);
  border: 4px solid var(--line);
  box-shadow: 0 6px 0 var(--line);
  color: var(--muted);
  transition: transform 0.2s ease;
}
.path-node.unlocked .path-orb {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-light);
  box-shadow: 0 6px 0 var(--brand-dark), 0 0 0 6px rgba(47,191,113,0.14);
  animation: bob 2.6s ease-in-out infinite;
}
.path-node.completed .path-orb {
  border-color: var(--sun);
  color: var(--sun-dark);
  background: #FFF7E3;
  box-shadow: 0 6px 0 var(--sun-dark);
}
.path-node.locked .path-orb { opacity: 0.65; }
.path-info { flex: 1; }
.path-info h3 { margin: 0.2rem 0; font-size: 1.05rem; }
.path-node:nth-child(even) .path-orb { order: 2; }

@media (max-width: 640px) {
  .path-connector { left: 42px; }
  .path-node, .path-node:nth-child(even) { flex-direction: row; max-width: none; }
  .path-node:nth-child(even) .path-info { text-align: left; }
  .path-orb { width: 64px; height: 64px; font-size: 1.5rem; }
  .path-node:nth-child(even) .path-orb { order: 0; }
}

/* ---------- Case wizard ---------- */
.stepper { display: flex; gap: 0.5rem; margin: 0.75rem 0 1.25rem; }
.stepper .step {
  flex: 1; height: 10px; border-radius: 999px; background: var(--bg-2); border: 2px solid var(--line);
  overflow: hidden;
}
.stepper .step.done { background: var(--brand); border-color: var(--brand-dark); }
.stepper .step.current { background: var(--sun); border-color: var(--sun-dark); }

.competency-meter { display: flex; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.competency-meter .pip {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--line); background: #fff; color: var(--muted); font-weight: 800;
}
.competency-meter .pip.ok { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
.competency-meter .pip.pending { border-color: var(--line); }

.case-card { border: 2px solid var(--brand); background: var(--brand-light); }
.case-card.locked { opacity: 0.65; border-color: var(--line); background: var(--card); }

/* ---------- Badges page ---------- */
.badge-card {
  text-align: center;
  padding: 1.4rem 1rem;
}
.badge-card .badge-icon {
  width: 64px; height: 64px; border-radius: 50%;
  margin: 0 auto 0.6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  background: linear-gradient(145deg, var(--sun), var(--sun-dark));
  color: #fff;
  box-shadow: 0 5px 0 var(--sun-dark);
}
.badge-card.locked .badge-icon {
  background: #E9EBEA; color: #a7ada9; box-shadow: 0 5px 0 #d3d6d4; filter: grayscale(1);
}
.badge-card.locked { opacity: 0.7; }
.badge-card h3 { font-size: 0.98rem; margin: 0 0 0.3rem; }

/* ---------- Glossary inline term + modal ---------- */
.glossary-term {
  display: inline;
  background: linear-gradient(180deg, transparent 65%, #cdeedb 65%);
  border: none;
  padding: 0 0.05em;
  margin: 0;
  font: inherit;
  color: var(--brand-dark);
  font-weight: 800;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.glossary-term:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
}
.glossary-term::after {
  content: "";
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 40, 31, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 300;
  opacity: 0;
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: min(440px, 100%);
  width: 100%;
  position: relative;
  transform: scale(0.85) translateY(10px);
}
.modal-card .modal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: var(--grape-dark);
  background: #F1E9FF;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}
.modal-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.3rem;
}
.modal-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}
.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg-2);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.modal-close:hover { background: #fff; color: var(--ink); }

/* ---------- Toast / celebration ---------- */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
}
.toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 210;
  display: flex; flex-direction: column; gap: 0.6rem;
  max-width: min(340px, calc(100vw - 2rem));
}
.toast {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1rem;
  display: flex; align-items: center; gap: 0.7rem;
  transform: translateX(120%);
  opacity: 0;
}
.toast .toast-ico { font-size: 1.6rem; }
.toast strong { display: block; font-size: 0.92rem; }
.toast span { color: var(--muted); font-size: 0.82rem; }
.toast.xp { border-color: #ffe3a0; }
.toast.badge { border-color: #ddc9ff; }

/* ---------- Keyframes ---------- */
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(-4deg); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@media (max-width: 800px) {
  .grid-3 { grid-template-columns: 1fr; }
  .topbar-stats { order: 3; }
}
