/* ============================================================
   MESTRE DAS PALAVRAS — MUNDO ALDEIA (storybook, infantil)
   Signature: Trilha da Aldeia + palavra com sílabas coloridas +
   celebração. Fundo é cena ilustrada, não chapado.
   ============================================================ */
:root {
  --ink:       #22332A;
  --ink-soft:  #5B6E5E;

  --sun:       #FFC24B;
  --sun-deep:  #F5A623;
  --leaf:      #34B37A;
  --forest:    #1B7A5A;
  --forest-dk: #12604A;
  --coral:     #FF7A59;
  --coral-dk:  #E85C3A;
  --river:     #35BCC9;
  --river-dk:  #2699A5;
  --bark:      #8A5A34;

  --paper:     #FFF8EC;
  --paper-2:   #FBEFD9;
  --line:      #EAD9B8;

  --shadow:    0 14px 34px rgba(30,60,40,.16);
  --shadow-sm: 0 6px 16px rgba(30,60,40,.12);
  --radius:    26px;

  --syl-1: var(--coral);
  --syl-2: var(--river);
  --syl-3: var(--forest);
  --syl-4: var(--sun-deep);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow-x: hidden; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: #BEE9E4;
  min-height: 100vh;
}

/* ── Cena de fundo (compartilhada por todas as telas) ─────────── */
.scene-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none;
}

/* ── Telas ────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.wrap { max-width: 640px; margin: 0 auto; padding: 30px 20px 60px; }

/* ── Marca ────────────────────────────────────────────────────── */
.brand { text-align: center; margin-bottom: 22px; }
.brand.small { margin-bottom: 14px; }
.brand-logo { font-size: 52px; line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.brand h1 {
  font-family: 'Fredoka', 'Baloo 2', cursive; font-weight: 700;
  font-size: 38px; color: #fff; margin-top: 4px;
  text-shadow: 0 2px 0 var(--forest-dk), 2px 0 0 var(--forest-dk), -2px 0 0 var(--forest-dk), 0 6px 16px rgba(0,0,0,.28);
  letter-spacing: .5px;
}
.brand-sub { color: #fff; font-weight: 800; margin-top: 4px; text-shadow: 0 2px 6px rgba(0,0,0,.3); }
.brand.small h1 { font-size: 28px; }

/* ── Card ─────────────────────────────────────────────────────── */
.card {
  background: var(--paper); border: 3px solid #fff;
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px;
}
.card-title { font-family: 'Fredoka','Baloo 2',cursive; font-weight: 600; font-size: 20px; color: var(--forest-dk); margin: 20px 0 12px; }
.card-title:first-child { margin-top: 0; }

/* ── Opções (mundo / modo) ────────────────────────────────────── */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 12px; border: 3px solid var(--line); border-radius: 20px;
  background: #fff; color: var(--ink); cursor: pointer; font: inherit;
  font-weight: 800; font-size: 17px; transition: transform .12s, border-color .15s, background .15s, box-shadow .15s;
}
.option small { display: block; font-weight: 700; font-size: 12px; color: var(--ink-soft); }
.option-emoji { font-size: 36px; }
.option:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-sm); }
.option.selected { border-color: var(--leaf); background: #EAFBF1; box-shadow: 0 0 0 4px rgba(52,179,122,.18); }
.option.soon { opacity: .55; }

/* ── Caixa do professor ───────────────────────────────────────── */
.prof-box { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 12px; }
.prof-box summary { cursor: pointer; font-weight: 800; color: var(--ink-soft); }
.prof-fields { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.prof-fields label { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 14px; }
.prof-fields input { padding: 11px 13px; border: 2px solid var(--line); border-radius: 13px; font: inherit; font-weight: 700; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.warn { background: #FFEDE6; color: var(--coral-dk); padding: 10px 12px; border-radius: 13px; font-weight: 800; font-size: 14px; margin-top: 10px; }

/* ── Botões ───────────────────────────────────────────────────── */
.btn-primary {
  width: 100%; margin-top: 22px; padding: 17px; border: none; border-radius: 18px;
  background: var(--coral); color: #fff; font: inherit; font-family: 'Fredoka','Baloo 2',cursive;
  font-weight: 600; font-size: 21px; cursor: pointer; box-shadow: 0 6px 0 var(--coral-dk); transition: transform .08s, box-shadow .08s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--coral-dk); }
.btn-ghost { padding: 12px 16px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }

/* ══════════════════════════════════════════════════════════════
   TELA DE JOGO — a Trilha da Aldeia
   ══════════════════════════════════════════════════════════════ */
.game { max-width: 560px; margin: 0 auto; padding: 14px 18px 22px; min-height: 100vh; display: flex; flex-direction: column; gap: 12px; }
.game-top { display: flex; justify-content: space-between; align-items: center; }
.btn-back { background: rgba(255,255,255,.7); border: none; border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 800; color: var(--forest-dk); cursor: pointer; font-size: 15px; }
.mode-badge { background: #fff; color: var(--forest-dk); font-weight: 800; padding: 7px 14px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-sm); }

/* Guia — companheiro da história */
.guia { display: flex; gap: 10px; align-items: flex-end; }
.guia-avatar {
  font-size: 46px; flex-shrink: 0; line-height: 1;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.18));
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.guia-bubble {
  position: relative; background: #fff; border-radius: 20px; border-bottom-left-radius: 5px;
  padding: 12px 15px; font-weight: 700; line-height: 1.45; color: var(--ink); font-size: 15px;
  max-height: 20vh; overflow-y: auto; flex: 1; box-shadow: var(--shadow-sm);
}
.guia-bubble::before {
  content: ''; position: absolute; left: -9px; bottom: 6px;
  border: 9px solid transparent; border-right-color: #fff; border-left: 0;
}
.guia-bubble p { margin-bottom: 8px; } .guia-bubble p:last-child { margin-bottom: 0; }

/* Palco da palavra */
.stage {
  background: var(--paper); border: 4px solid #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; text-align: center;
  animation: pop-in .45s cubic-bezier(.2,1.3,.4,1);
}
@keyframes pop-in { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.word-emoji { font-size: 62px; line-height: 1; filter: drop-shadow(0 6px 8px rgba(0,0,0,.15)); }
.word-syllables { font-family: 'Fredoka','Baloo 2',cursive; font-weight: 700; font-size: 46px; margin-top: 6px; line-height: 1.05; display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 2px; }
.syl { display: inline-block; }
.syl-dot { color: var(--line); font-weight: 700; margin: 0 4px; }
.word-context { font-size: 13px; color: var(--ink-soft); font-weight: 700; margin-top: 8px; }

/* Controles */
.controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 0; }
.btn-mic {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  width: 116px; height: 116px; border-radius: 50%; border: 5px solid #fff; cursor: pointer;
  background: radial-gradient(circle at 38% 32%, #FF9576, var(--coral)); color: #fff; font-size: 48px;
  box-shadow: 0 8px 0 var(--coral-dk), var(--shadow); transition: transform .08s, box-shadow .08s;
  animation: invite 2.4s ease-in-out infinite;
}
.btn-mic span { font-family: 'Fredoka','Baloo 2',cursive; font-weight: 600; font-size: 18px; }
.btn-mic:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--coral-dk); animation: none; }
@keyframes invite { 0%,100% { box-shadow: 0 8px 0 var(--coral-dk), 0 0 0 0 rgba(255,122,89,.5); } 50% { box-shadow: 0 8px 0 var(--coral-dk), 0 0 0 16px rgba(255,122,89,0); } }
.btn-mic.listening { animation: listen .9s ease-in-out infinite; background: radial-gradient(circle at 38% 32%, #7FE0C0, var(--leaf)); box-shadow: 0 8px 0 var(--forest-dk), var(--shadow); }
@keyframes listen { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.mic-status { font-weight: 800; color: var(--forest-dk); background: #fff; padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow-sm); }

.fisico-hint { font-weight: 800; color: var(--forest-dk); text-align: center; background: rgba(255,255,255,.75); padding: 8px 12px; border-radius: 14px; }
.fisico-buttons { display: grid; grid-template-columns: 1fr; gap: 12px; width: 100%; }
.btn-res { padding: 17px; border: 4px solid #fff; border-radius: 18px; font: inherit; font-family: 'Fredoka','Baloo 2',cursive; font-weight: 600; font-size: 19px; color: #fff; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .08s; }
.btn-res:active { transform: scale(.97); }
.btn-res.acerto  { background: var(--leaf); }
.btn-res.parcial { background: var(--sun-deep); }
.btn-res.tentar  { background: var(--river); }

/* ── Trilha da Aldeia (progresso como jornada) ────────────────── */
.trail { margin-top: auto; padding-top: 10px; }
.trail-stones { position: relative; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 22px 6px 6px; flex-wrap: wrap; }
.trail-stones::before {
  content: ''; position: absolute; left: 8%; right: 8%; top: 50%; height: 4px;
  background-image: linear-gradient(90deg, var(--bark) 55%, transparent 0);
  background-size: 12px 4px; opacity: .35; z-index: 0;
}
.stone {
  position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 50%;
  background: #fff; border: 3px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: var(--ink-soft); box-shadow: var(--shadow-sm);
}
.stone.done.r-dominada    { background: var(--leaf); border-color: #fff; color: #fff; }
.stone.done.r-parcial     { background: var(--sun); border-color: #fff; color: #fff; }
.stone.done.r-nao_dominada{ background: var(--river); border-color: #fff; color: #fff; }
.stone.current { border-color: var(--coral); box-shadow: 0 0 0 5px rgba(255,122,89,.25), var(--shadow-sm); animation: stone-pulse 1.4s ease-in-out infinite; }
@keyframes stone-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.stone .avatar { position: absolute; top: -30px; font-size: 26px; animation: hop .8s ease-in-out infinite; filter: drop-shadow(0 3px 3px rgba(0,0,0,.2)); }
@keyframes hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ══════════════════════════════════════════════════════════════
   CELEBRAÇÃO
   ══════════════════════════════════════════════════════════════ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 11px; height: 14px; border-radius: 2px; opacity: .95; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(104vh) rotate(680deg); opacity: 1; } }
.big-star { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 71; pointer-events: none; font-size: 130px; animation: star-pop .9s cubic-bezier(.2,1.4,.4,1) forwards; filter: drop-shadow(0 8px 12px rgba(0,0,0,.25)); }
@keyframes star-pop { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 40% { transform: scale(1.25) rotate(8deg); opacity: 1; } 75% { transform: scale(1) rotate(0); opacity: 1; } 100% { transform: scale(1.1); opacity: 0; } }

/* ══════════════════════════════════════════════════════════════
   RELATÓRIO (professor)
   ══════════════════════════════════════════════════════════════ */
.rep-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
.rep-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--paper-2); border-radius: 14px; }
.rep-k { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--ink-soft); letter-spacing: .5px; }
.rep-v { font-weight: 700; }
.rep-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.rep-table th, .rep-table td { text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--line); font-size: 14px; }
.rep-table th { font-weight: 800; color: var(--ink-soft); }
.tag { padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; color: #fff; }
.tag.ok { background: var(--leaf); } .tag.mid { background: var(--sun-deep); } .tag.low { background: var(--river); }
.json { background: var(--ink); color: #DFF5E8; padding: 14px; border-radius: 14px; overflow-x: auto; font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.5; }
.rep-actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.rep-actions .btn-primary { margin-top: 0; flex: 1; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 16px; font-weight: 800; box-shadow: var(--shadow); z-index: 80; max-width: 90%; text-align: center; }
.toast.error { background: var(--coral-dk); } .toast.info { background: var(--forest-dk); }

/* ── Overlay de carregamento ──────────────────────────────────── */
.busy { position: fixed; inset: 0; background: rgba(20,50,35,.4); display: none; align-items: center; justify-content: center; z-index: 75; }
.busy.show { display: flex; }
.busy-card { background: #fff; padding: 24px 30px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.busy-label { font-weight: 800; color: var(--ink); }
.spinner { width: 44px; height: 44px; border: 6px solid var(--line); border-top-color: var(--leaf); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsivo ───────────────────────────────────────────────── */
@media (max-width: 420px) {
  .brand h1 { font-size: 30px; }
  .word-syllables { font-size: 40px; }
  .word-emoji { font-size: 56px; }
  .btn-mic { width: 108px; height: 108px; }
}

/* ── Movimento reduzido ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
