:root{
  --bg:#eef4ff;
  --card:#ffffff;
  --line:#dce6fb;
  --ink:#14214d;
  --muted:#7683a6;
  --blue:#116cff;
  --purple:#7133f2;
  --pink:#ff4779;
  --green:#29b86f;
  --green-soft:#effcf5;
  --red:#e84c6d;
  --red-soft:#fff1f4;
  --soft:#f7faff;
  --shadow:0 14px 36px rgba(53,80,162,.09);
}
*{box-sizing:border-box}
html,body{
  margin:0;min-height:100%;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  color:var(--ink);
  background:
    radial-gradient(circle at 0% 8%,rgba(100,174,255,.17),transparent 28%),
    radial-gradient(circle at 100% 90%,rgba(113,51,242,.12),transparent 25%),
    var(--bg);
}
button,input{font:inherit}
button{cursor:pointer}
[hidden]{display:none!important}

/* SPLASH */
.welcome-screen{min-height:100vh;display:grid;place-items:center;padding:18px}
.welcome-shell{
  width:min(100%,420px);min-height:calc(100vh - 36px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  position:relative;padding:18px 12px 28px;
}
.splash-logo{width:min(88vw,350px);height:auto;position:relative;z-index:2}
.splash-btn{width:100%;max-width:360px;margin-top:26px;min-height:56px;position:relative;z-index:2}
.splash-graphic{position:absolute;border-radius:50%;filter:blur(9px);opacity:.9}
.glow-1{width:230px;height:230px;background:radial-gradient(circle,rgba(72,170,255,.28),rgba(72,170,255,0));top:calc(50% - 165px);left:10px}
.glow-2{width:250px;height:250px;background:radial-gradient(circle,rgba(117,63,255,.2),rgba(117,63,255,0));bottom:calc(50% - 170px);right:0}

/* APP */
.app-shell{
  width:min(100%,430px);min-height:100vh;margin:0 auto;
  padding:10px 12px calc(84px + env(safe-area-inset-bottom));position:relative;
}

/* Cabeçalho compacto */
.topbar{display:grid;grid-template-columns:1fr auto auto;gap:8px;align-items:center;margin-bottom:10px}
.compact-stat{
  background:rgba(255,255,255,.92);border:1px solid var(--line);border-radius:15px;
  min-height:52px;padding:8px 11px;box-shadow:0 8px 20px rgba(46,71,147,.05);
}
.mission-compact{min-width:0}
.stat-row{display:flex;align-items:baseline;gap:7px}
.stat-label{color:var(--muted);font-size:9px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}
.stat-value{font-size:18px;font-weight:950;line-height:1}
.xp-compact{width:68px;text-align:center}
.xp-compact .stat-value{font-size:19px;margin-top:3px}
.progress-track{height:4px;border-radius:999px;background:#e8eefc;overflow:hidden;margin-top:7px}
.progress-fill{height:100%;width:0;background:linear-gradient(90deg,var(--blue),var(--purple));border-radius:inherit;transition:width .28s ease}
.close-btn{
  width:36px;height:36px;border-radius:12px;border:1px solid var(--line);background:#fff;color:#334677;
  font-size:22px;line-height:1;display:flex;align-items:center;justify-content:center;padding:0;
  box-shadow:0 8px 20px rgba(46,71,147,.05);
}

/* Quest */
.quest-card{
  background:rgba(255,255,255,.97);border:1px solid #e3eafb;border-radius:22px;
  padding:15px 13px 16px;box-shadow:var(--shadow);
}
.quest-head{display:flex;justify-content:space-between;gap:9px;align-items:flex-start;margin-bottom:14px}
.challenge-type{margin:0;font-size:19px;line-height:1.12;font-weight:950;letter-spacing:-.02em;min-width:0}
.head-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-shrink:0}
.category-badge{
  background:#fff1f6;border:1px solid #ffd7e3;color:#e63f6f;border-radius:999px;
  padding:7px 9px;font-size:10px;font-weight:850;white-space:nowrap;
}
.hint-btn{
  border:1px solid #dbe5fb;background:#f8faff;color:#3852a6;border-radius:999px;
  min-height:29px;padding:6px 8px;font-size:10px;font-weight:850;white-space:nowrap;
}
.case-box{
  background:linear-gradient(180deg,#f9fbff,#f4f7ff);border:1px solid #e3eafb;
  border-radius:17px;padding:13px;line-height:1.5;color:#2b3767;margin-bottom:14px;font-size:14px;
}
.question-title{font-size:17px;line-height:1.35;margin:0 0 13px}

/* Multiple choice */
.options{display:grid;gap:8px}
.option{
  width:100%;display:flex;gap:10px;align-items:flex-start;text-align:left;
  border:1px solid #dbe5fb;background:#fff;border-radius:16px;padding:12px;color:var(--ink);transition:.15s ease;
}
.option:not(:disabled):active{transform:scale(.995)}
.option-letter{
  width:30px;height:30px;border-radius:50%;display:grid;place-items:center;
  background:#ecf1ff;color:#2045b2;font-weight:900;flex:0 0 auto;
}
.option.correct{border-color:#54c987;background:var(--green-soft);color:#157348}
.option.correct .option-letter{background:#dff7e9;color:#148253}
.option.wrong{border-color:#f08ba2;background:var(--red-soft);color:#a92f4c}
.option.wrong .option-letter{background:#ffe0e7;color:#c43b5b}
.option:disabled{cursor:default}

/* True false */
.tf-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.tf-btn{
  min-height:92px;border-radius:17px;border:1px solid #dbe5fb;background:#fff;
  color:var(--ink);font-size:15px;font-weight:900;
}
.tf-btn span{display:block;font-size:26px;margin-bottom:4px}
.tf-btn.correct{background:var(--green-soft);border-color:#54c987;color:#157348}
.tf-btn.wrong{background:var(--red-soft);border-color:#f08ba2;color:#a92f4c}

/* TERM */
.term-clue{font-size:14px;line-height:1.5;color:#374679;margin:0 0 12px}
.term-slots{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;margin:13px 0 9px}
.term-slot{width:28px;height:36px;border-bottom:3px solid #6979b0;display:grid;place-items:center;font-size:19px;font-weight:950;color:#173eae}
.term-space{width:14px;border-bottom:0}
.term-status{text-align:center;color:var(--muted);font-size:12px;margin-bottom:9px}
.term-lives{display:flex;gap:5px;justify-content:center;margin:7px 0 12px}
.life-dot{width:7px;height:7px;border-radius:50%;background:#dbe4fb}
.life-dot.used{background:#ff6f92}
.letter-bank{display:flex;gap:7px;flex-wrap:wrap;justify-content:center}
.letter{width:37px;height:37px;border-radius:11px;border:1px solid #dbe5fb;background:#fff;color:var(--ink);font-weight:900}
.letter.correct-letter{background:linear-gradient(180deg,#4e77ff,#6e35f5);color:#fff;border-color:transparent}
.letter.wrong-letter{background:#fff1f5;color:#c52a58;border-color:#ffb3c6}

/* COMPLETE */
.complete-sentence{font-size:16px;line-height:2.15;margin:6px 0 14px}
.blank{
  display:inline-flex;vertical-align:middle;min-width:112px;min-height:34px;padding:4px 10px;margin:0 3px;
  border:1px solid #d8e2fb;border-radius:11px;background:#f7f9ff;
  align-items:center;justify-content:center;color:#492ed0;font-weight:900;
}
.blank.empty::after{content:"toque em um termo";font-size:10px;font-weight:700;color:#9aa5c3}
.chips{display:flex;gap:7px;flex-wrap:wrap}
.chip{border:1px solid #dbe5fb;background:#fff;border-radius:999px;padding:9px 12px;font-weight:850;color:var(--ink)}
.chip.used{opacity:.32}

/* CONNECT - estilo Duolingo */
.match-meta{display:flex;justify-content:space-between;align-items:center;margin:0 0 10px;color:var(--muted);font-size:12px}
.connect-wrap{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.connect-col{display:grid;gap:9px}
.connect-btn{
  min-height:60px;border:1px solid #dbe5fb;background:#fff;border-radius:15px;
  padding:10px;text-align:center;color:var(--ink);font-size:13px;font-weight:800;transition:.15s ease;
}
.connect-btn.active{border-color:#775cff;background:#f4f0ff;box-shadow:0 0 0 2px rgba(119,92,255,.08)}
.connect-btn.matched{border-color:#56cb89;background:var(--green-soft);color:#157348;opacity:.48;transform:scale(.97)}
.connect-btn.match-wrong{border-color:#f08ba2;background:var(--red-soft);color:#a92f4c;animation:shake .22s linear 2}
@keyframes shake{25%{transform:translateX(-3px)}75%{transform:translateX(3px)}}

/* ORDER */
.order-hint{font-size:12px;color:var(--muted);margin:0 0 10px}
.order-list{display:grid;gap:8px}
.order-row{
  display:flex;align-items:center;gap:9px;background:#fff;border:1px solid #dbe5fb;
  border-radius:15px;padding:11px;user-select:none;touch-action:none;
}
.order-row.dragging{opacity:.55;border-color:#6c53f4}
.drag-handle{width:27px;height:36px;border-radius:9px;background:#edf2ff;display:grid;place-items:center;color:#5e6b9b;font-weight:900;cursor:grab;flex:0 0 auto}
.order-index{width:25px;height:25px;border-radius:50%;background:#edf2ff;color:#2148b5;display:grid;place-items:center;font-weight:900;flex:0 0 auto}
.order-text{font-size:13px;line-height:1.35;flex:1 1 auto}
.order-controls{margin-left:auto;display:grid;grid-template-columns:1fr;gap:6px;flex:0 0 auto}
.order-arrow{
  width:34px;height:34px;border-radius:10px;border:1px solid #dbe5fb;background:#f8faff;color:#3852a6;
  display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:900;padding:0;touch-action:manipulation;
}
.order-arrow:disabled{opacity:.38;cursor:not-allowed}

/* Feedback */
.feedback{margin-top:14px;display:grid;grid-template-columns:36px 1fr;gap:9px;padding:13px;border-radius:17px;background:#f4f7ff}
.feedback.success{background:var(--green-soft)}
.feedback.fail{background:var(--red-soft)}
.feedback-icon{width:36px;height:36px;border-radius:12px;background:#fff;display:grid;place-items:center;font-size:19px;font-weight:900}
.feedback p{margin:4px 0;color:#435079;line-height:1.4;font-size:13px}
.link-btn{border:0;background:transparent;padding:0;color:#5035df;font-weight:900;font-size:12px}
.explanation{padding-top:9px;border-top:1px solid #e0e7fa;margin-top:9px!important}

/* Nerdizin */
.guide-layer{
  /* O Nerdizin fica ancorado ao viewport, nunca ao conteúdo da questão. */
  position:fixed;left:50%;transform:translateX(-50%);
  bottom:max(0px,env(safe-area-inset-bottom));
  width:min(100%,430px);height:170px;
  pointer-events:none;z-index:12;transition:.18s ease;
}
.guide-layer.closed{opacity:0;transform:translateX(-50%) translateY(10px);visibility:hidden}
.npc-dialog{
  /* O balão permanece acima da base enquanto o mascote toca o limite inferior. */
  position:absolute;left:12px;right:108px;bottom:80px;min-height:88px;border-radius:18px;
  background:rgba(255,255,255,.985);border:1px solid #dbe5fb;box-shadow:0 10px 28px rgba(45,71,145,.11);
  padding:31px 13px 11px;color:#243164;
}
.npc-name{
  position:absolute;top:-12px;left:9px;border-radius:999px;background:linear-gradient(90deg,var(--blue),var(--purple));
  color:#fff;font-size:11px;font-weight:950;padding:6px 11px;
}
.npc-dialog p{margin:0;font-size:11px;line-height:1.43;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.typing-cursor{display:inline-block;width:2px;height:14px;background:var(--blue);margin-left:2px;vertical-align:-2px;animation:blink .8s infinite}
@keyframes blink{50%{opacity:0}}
.npc-asset{
  position:absolute;right:3px;bottom:0;width:112px;height:auto;max-height:152px;
  object-fit:contain;object-position:bottom right;filter:drop-shadow(0 9px 16px rgba(26,36,78,.14));
  /* Consome o toque sobre o personagem para não atingir alternativas atrás dele. */
  pointer-events:auto;user-select:none;-webkit-user-drag:none;
}
.summon-guide{
  position:fixed;right:max(13px,calc((100vw - 430px)/2 + 13px));bottom:80px;
  width:42px;height:42px;border-radius:50%;border:0;color:#fff;font-size:13px;font-weight:950;
  line-height:1;display:flex;align-items:center;justify-content:center;padding:0;text-align:center;
  background:linear-gradient(145deg,var(--blue),var(--purple));box-shadow:0 10px 24px rgba(62,60,197,.22);z-index:11;
}

/* Footer */
.actions{
  position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:min(100%,430px);
  padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:rgba(238,244,255,.95);
  backdrop-filter:blur(16px);border-top:1px solid #dce5fa;z-index:10;
}
.actions .btn{width:100%}
.btn{border:0;border-radius:16px;min-height:50px;font-size:14px;font-weight:950}
.primary{color:#fff;background:linear-gradient(90deg,var(--blue),var(--purple));box-shadow:0 9px 22px rgba(76,70,238,.2)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.wide{width:100%}

/* Result modal */
.modal{position:fixed;inset:0;z-index:50;background:rgba(14,23,59,.42);backdrop-filter:blur(10px);display:grid;place-items:center;padding:18px}
.modal-card{width:min(100%,390px);background:#fff;border-radius:26px;padding:24px 20px;text-align:center;box-shadow:0 24px 70px rgba(14,23,59,.24)}
.result-logo{width:155px;height:auto;margin:0 auto 8px;display:block}
.modal-card h2{margin:6px 0 9px;font-size:25px}
.result-score{font-size:18px}

@media(max-width:360px){
  .challenge-type{font-size:17px}
  .category-badge{display:none}
  .hint-btn{font-size:9px;padding:6px 7px}
}
@media(min-width:780px){.app-shell{padding-top:14px}.welcome-shell{min-height:700px}}


/* =========================================================
   v4.1 — ajustes de UX
   ========================================================= */

/* Enunciado + pergunta juntos */
.case-box .case-question{
  display:block;
  margin-top:10px;
  font-weight:950;
  color:var(--ink);
  line-height:1.4;
}

/* Botão X do Nerdizin */
.npc-dialog{
  padding-right:42px;
}
.npc-close{
  pointer-events:auto;
  position:absolute;
  top:7px;
  right:7px;
  width:26px;
  height:26px;
  border:0;
  border-radius:50%;
  background:#f1f4fc;
  color:#425177;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:17px;
  line-height:1;
  padding:0;
  z-index:3;
}

/* Explicação em tela cheia */
.explanation-overlay{
  position:fixed;
  inset:0;
  z-index:80;
  background:rgba(12,22,56,.46);
  backdrop-filter:blur(8px);
  display:flex;
  align-items:flex-end;
  justify-content:center;
}
.explanation-sheet{
  width:min(100%,430px);
  max-height:94dvh;
  min-height:72dvh;
  background:#fff;
  border-radius:26px 26px 0 0;
  padding:20px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -18px 50px rgba(15,28,74,.18);
  display:flex;
  flex-direction:column;
}
.explanation-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:16px;
}
.explanation-kicker{
  font-size:11px;
  font-weight:950;
  letter-spacing:.12em;
  color:var(--purple);
}
.explanation-top h2{
  margin:5px 0 0;
  font-size:25px;
  line-height:1.1;
  letter-spacing:-.02em;
}
.overlay-close{
  flex:0 0 auto;
  width:38px;
  height:38px;
  border-radius:13px;
  border:1px solid var(--line);
  background:#f7f9ff;
  color:#334677;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:24px;
  line-height:1;
  padding:0;
}
.explanation-result{
  border-radius:16px;
  padding:12px 13px;
  margin-bottom:14px;
  font-weight:900;
  line-height:1.4;
}
.explanation-result.success{
  background:var(--green-soft);
  color:#157348;
  border:1px solid #aee6c6;
}
.explanation-result.fail{
  background:var(--red-soft);
  color:#a92f4c;
  border:1px solid #f4b5c4;
}
.explanation-body{
  flex:1;
  overflow:auto;
  font-size:16px;
  line-height:1.62;
  color:#33416d;
  padding:2px 2px 18px;
  white-space:pre-line;
}
.explanation-actions{
  display:grid;
  grid-template-columns:1fr 1.15fr;
  gap:9px;
  padding-top:12px;
  border-top:1px solid #e7ecf8;
}
.overlay-secondary{
  background:#f4f7ff;
  color:#314892;
  border:1px solid #dce5fb;
}
.explanation-overlay[hidden]{
  display:none!important;
}

/* No mobile, a explicação ocupa praticamente toda a tela */
@media(max-width:520px){
  .explanation-overlay{
    align-items:stretch;
  }
  .explanation-sheet{
    width:100%;
    max-height:none;
    min-height:100dvh;
    border-radius:0;
    padding-top:calc(16px + env(safe-area-inset-top));
  }
}


/* =========================================================
   v4.2 — header / reset
   ========================================================= */

.topbar{
  align-items:stretch;
}

.close-btn{
  width:54px;
  height:auto;
  min-height:54px;
  border-radius:15px;
  align-self:stretch;
  font-size:24px;
  background:rgba(255,255,255,.92);
}

/* Garante que os três blocos tenham a mesma altura */
.compact-stat,
.close-btn{
  min-height:54px;
}

@media(max-width:380px){
  .close-btn{
    width:50px;
  }
}


/* =========================================================
   v4.3 — Nerdizin fixo no limite inferior do viewport
   ========================================================= */
@supports (height: 100dvh){
  .guide-layer{
    bottom:max(0px,env(safe-area-inset-bottom));
  }
}
