:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #8a8a8a;
  --line: #ececec;
  --card: #ffffff;
  --accent: #d4233b;       /* Paraguay red */
  --accent-soft: #fde8eb;
  --green: #2bb673;
  --green-soft: #e4f7ee;
  --gold: #f6c945;
  --shadow: 0 2px 10px rgba(0,0,0,.05);
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; }
.brand-mascot { width: 30px; height: 40px; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px; }
.stats { display: flex; align-items: center; gap: 12px; }
.stat { font-size: .95rem; font-weight: 600; }
.stat.level { background: var(--accent-soft); color: var(--accent); padding: 4px 11px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.lang-toggle { border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 700; font-size: .85rem; }
.lang-toggle:hover { border-color: var(--ink); }

/* ---------- Layout ---------- */
#app { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 24px 20px 80px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; border-top: 1px solid var(--line); }
.back { background: none; border: none; color: var(--accent); font-weight: 800; font-size: 1.4rem; cursor: pointer; padding: 0; }

/* ---------- Hero ---------- */
.hero { display: flex; align-items: center; gap: 20px; justify-content: center; padding: 10px 0 20px; text-align: left; }
.hero-mascot { width: 96px; height: 125px; }
.hero h1 { font-size: 2rem; margin: 0 0 2px; letter-spacing: -1px; }
.hero p { color: var(--muted); margin: 0; }
.path-head h2 { font-size: 1.2rem; margin: 18px 0 2px; }
.path-head p { margin: 0 0 16px; font-size: .9rem; }

/* ---------- World map ---------- */
.worlds { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.world {
  display: flex; align-items: flex-start; gap: 14px; text-align: left;
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: .15s; box-shadow: var(--shadow); position: relative;
}
.world:hover:not(.locked) { transform: translateY(-2px); border-color: var(--accent); }
.world.locked { opacity: .55; cursor: not-allowed; }
.world-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
}
.world-meta { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.world-grade { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.world-title { font-weight: 700; font-size: 1rem; }
.world-sub { font-size: .8rem; color: var(--muted); }
.world-bar { display: block; height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.world-bar-fill { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.world-check { position: absolute; top: 12px; right: 14px; color: var(--green); font-weight: 900; }
.world.done .world-bar-fill { background: var(--green); }

/* ---------- Expresiones Comunes ---------- */
.expr-entry {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: .15s; box-shadow: var(--shadow);
}
.expr-entry:hover { transform: translateY(-2px); border-color: var(--accent); }
.expr-entry-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff); }
.expr-entry-go { margin-left: auto; color: var(--accent); font-weight: 800; font-size: .85rem; white-space: nowrap; }

.expr-search {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 16px;
  font-size: 1rem; font-family: inherit; margin-bottom: 14px; background: #fff; color: var(--ink);
}
.expr-search:focus { outline: none; border-color: var(--accent); }

.filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-pill {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
  border-radius: 999px; padding: 6px 14px; font-size: .85rem; font-weight: 600; transition: .12s;
}
.filter-pill:hover { border-color: var(--accent); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.expr-count { font-size: .82rem; margin-bottom: 12px; }

.expr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.expr-card {
  border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.expr-pron-note { font-size: .78rem; margin: -4px 0 12px; }
.expr-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.expr-gn { font-size: 1.15rem; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.expr-pron { margin: 2px 0 0; font-size: .82rem; color: var(--green); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.expr-es { color: var(--muted); margin: 4px 0 0; font-size: .92rem; }

/* pronunciation controls */
.pron-play { border: none; background: none; cursor: pointer; font-size: 1.15rem; line-height: 1;
  padding: 2px 4px; border-radius: 8px; opacity: .7; flex: none; }
.pron-play:hover { opacity: 1; background: #f2f2f2; }
.has-rec .pron-play { opacity: 1; }
.expr-rec-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.pron-rec { display: inline-flex; align-items: center; gap: 5px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-size: .78rem; font-weight: 600; font-family: inherit; }
.pron-rec:hover { border-color: var(--accent); }
.pron-rec.recorded { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.pron-rec.recording { border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
  animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.55} }
.pron-del { border: 1.5px solid var(--line); background: #fff; cursor: pointer; border-radius: 999px;
  padding: 5px 9px; font-size: .8rem; line-height: 1; }
.pron-del:hover { border-color: var(--accent); }
.expr-badge {
  align-self: flex-start; margin-top: 8px; font-size: .7rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; color: var(--badge, var(--accent));
  background: color-mix(in srgb, var(--badge, var(--accent)) 12%, #fff);
}
.expr-empty { grid-column: 1 / -1; text-align: center; padding: 30px 0; }

/* ---------- Grade head + lessons ---------- */
.grade-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.grade-head h2 { margin: 0; font-size: 1.4rem; }
.grade-head p { margin: 0; }
.grade-icon { width: 48px; height: 48px; border-radius: 14px; font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, #fff); }
.lessons { display: flex; flex-direction: column; gap: 10px; }
.lesson-card { display: flex; align-items: center; gap: 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer; background: #fff; transition: .15s; }
.lesson-card:hover { border-color: var(--accent); transform: translateX(2px); }
.lesson-num { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.lesson-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lesson-title { font-weight: 700; }
.lesson-go { color: var(--accent); font-weight: 800; font-size: .85rem; }
.stars { letter-spacing: 2px; color: var(--gold); font-size: .9rem; }
.stars.big { font-size: 2rem; letter-spacing: 6px; }

/* ---------- Lesson player ---------- */
.lesson { max-width: 620px; margin: 0 auto; }
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.icon-btn { background: none; border: none; font-size: 1.2rem; color: var(--muted); cursor: pointer; }
.progressbar { flex: 1; height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progressbar-fill { height: 100%; background: var(--green); width: 0; transition: width .3s; }
.hearts { font-size: 1rem; letter-spacing: 1px; }
.ask { text-align: center; color: var(--muted); font-size: .95rem; margin: 0 0 8px; }
.prompt-word { text-align: center; font-size: 2rem; font-weight: 800; letter-spacing: -.5px; margin: 0 0 6px; }
.prompt-sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
.options { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 8px; }
.options-tf { grid-template-columns: 1fr 1fr; }
.option { border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 16px;
  font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: .12s; }
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--ink); background: #f7f7f7; }
.option.correct { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.option.wrong { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.option:disabled { cursor: default; opacity: .5; }

/* build word */
.build-slot { text-align: center; font-size: 1.5rem; font-weight: 800; min-height: 2.2rem;
  letter-spacing: 3px; margin: 4px 0 14px; border-bottom: 2px dashed var(--line); padding-bottom: 10px; }
.build-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.tile { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 15px; font-weight: 800;
  cursor: pointer; background: #fff; font-size: 1.1rem; }
.tile:hover:not(:disabled) { border-color: var(--accent); }
.tile:disabled { opacity: .3; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 14px;
  font-weight: 600; cursor: pointer; transition: .12s; }
.match-item:hover { border-color: var(--accent); }
.match-item.selected { border-color: var(--ink); background: #f7f7f7; }
.match-item.done { background: var(--green-soft); border-color: var(--green); color: var(--green); cursor: default; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* feedback */
.feedback { display: flex; align-items: center; gap: 12px; min-height: 0; margin: 22px 0 8px; padding: 0 4px;
  font-weight: 700; opacity: 0; transition: opacity .2s; }
.feedback.show { opacity: 1; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: var(--accent); }
.fb-mascot { width: 34px; height: 44px; }
.lesson-actions { margin-top: 10px; }

/* buttons */
.btn { background: var(--accent); color: #fff; border: none; border-radius: 14px; padding: 15px 26px;
  font-weight: 800; font-size: 1rem; cursor: pointer; transition: .12s; width: 100%; }
.btn:hover:not(:disabled) { filter: brightness(.95); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: var(--accent); }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ok { background: var(--green); }
.btn-bad { background: var(--accent); }
.btn-ghost.danger { color: var(--accent); border-color: var(--accent-soft); }

/* complete */
.complete { text-align: center; padding: 24px 0; }
.complete-mascot { width: 110px; height: 143px; }
.complete h2 { font-size: 1.7rem; margin: 10px 0 4px; }
.complete-stats { display: inline-flex; gap: 26px; background: #f8f8f8; border-radius: 14px;
  padding: 16px 28px; margin: 14px 0 22px; }
.complete-stats .num { display: block; font-size: 1.5rem; font-weight: 800; }
.complete-stats .lbl { color: var(--muted); font-size: .8rem; }
.complete-actions { display: flex; flex-direction: column; gap: 10px; max-width: 300px; margin: 16px auto 0; }

/* profile */
.profile { text-align: center; }
.profile .back { float: left; }
.profile-mascot { width: 100px; height: 130px; }
.profile h2 { margin: 6px 0 2px; }
.rank { color: var(--accent); font-weight: 800; margin: 0 0 18px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; }
.pcard { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px; }
.pcard .num { font-size: 1.5rem; font-weight: 800; display: block; }
.pcard .lbl { color: var(--muted); font-size: .8rem; }
.profile .btn { max-width: 280px; margin: 24px auto 0; }

/* mascot expressions */
.happy .mouth, .fb-mascot.happy { }
.sad .face-happy path { d: path("M88 74 q12 -10 24 0"); }

/* ---------- Learn step (teaching pages before the quiz) ---------- */
.teach { max-width: 620px; margin: 0 auto; }
.teach-bar .progressbar-fill { background: var(--accent); }
.teach-count { color: var(--muted); font-size: .85rem; font-weight: 700; flex: none; }
.teach-kicker { color: var(--accent); font-weight: 800; font-size: .75rem; letter-spacing: .08em;
  text-transform: uppercase; margin: 0 0 2px; }
.teach-title { font-size: 1.5rem; margin: 0 0 14px; letter-spacing: -.5px; }
.teach-body { min-height: 240px; }
.teach-focus { font-size: 1.05rem; font-weight: 700; line-height: 1.45; margin: 0 0 16px;
  padding-left: 14px; border-left: 3px solid var(--accent); }
.teach-p { margin: 0 0 14px; line-height: 1.65; }
.teach-h3 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 22px 0 10px; }
.teach-points { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.teach-points li { position: relative; padding-left: 26px; line-height: 1.5; font-size: .95rem; }
.teach-points li::before { content: "✓"; position: absolute; left: 0; top: 0;
  color: var(--green); font-weight: 800; }
.teach-skip { display: block; margin: 26px 0 0; background: none; border: none; padding: 0;
  color: var(--muted); font-weight: 700; font-size: .9rem; cursor: pointer; text-decoration: underline; }
.teach-skip:hover { color: var(--accent); }

/* word + example cards */
.teach-words, .teach-exs { display: flex; flex-direction: column; gap: 10px; }
.teach-word, .teach-ex { border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: var(--card); box-shadow: var(--shadow); }
.teach-word-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.teach-gn { font-size: 1.35rem; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.teach-ex-gn { font-size: 1.05rem; font-weight: 800; margin: 0; line-height: 1.35; }
.teach-pron { margin: 2px 0 0; font-size: .82rem; color: var(--green);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.teach-mean { margin: 6px 0 0; color: var(--ink); }
.teach-ex .teach-mean { color: var(--muted); font-size: .95rem; }
.teach-play { flex: none; }
.teach-note { font-size: .78rem; margin: 12px 0 0; }

/* culture note */
.teach-culture { display: flex; gap: 14px; align-items: flex-start;
  background: color-mix(in srgb, var(--accent) 7%, #fff); border-radius: var(--radius); padding: 18px 20px; }
.teach-culture-title { margin: 0 0 8px; font-size: 1.05rem; color: var(--accent); letter-spacing: -.2px; }
.teach-culture .teach-p { margin: 0; font-size: .95rem; }
.teach-culture-icon { font-size: 1.5rem; line-height: 1.2; flex: none; }
.teach-ready { display: flex; align-items: center; gap: 14px; justify-content: center;
  margin: 24px 0 4px; color: var(--muted); font-weight: 600; text-align: left; }
.teach-mascot { width: 46px; height: 60px; flex: none; }

.teach-actions { display: flex; gap: 10px; margin-top: 26px; }
.teach-actions .btn-ghost { max-width: 140px; }

.lesson-badge { font-size: .8rem; opacity: .55; }

@media (max-width: 520px) {
  .options, .match { grid-template-columns: 1fr 1fr; }
  .hero { flex-direction: column; text-align: center; gap: 10px; }
  .hero h1 { font-size: 1.7rem; }
  .teach-title { font-size: 1.3rem; }
  .teach-actions .btn { padding: 14px 16px; }
}
