:root {
  --fundo: #fff7ea;
  --papel: #ffffff;
  --tinta: #14233c;
  --suave: #5b6476;
  --primaria: #1f8a8a;
  --primaria-clara: #2bb3a3;
  --laranja: #f29e4c;
  --vermelho: #d9534f;
  --verde: #3c9d4f;
  --grama: #cfe8b0;
  --grama-escura: #b9da95;
  --agua: #7cc4e8;
  --pedra: #c9c2b5;
  --sombra: 0 3px 0 rgba(20, 35, 60, 0.18);
  --raio: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fundo);
  color: var(--tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 0 16px 24px; }
h1, h2, h3 { margin: 0.4em 0; line-height: 1.2; }
button { font: inherit; color: inherit; }

/* botões */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 8px 16px; border: 2px solid var(--tinta); border-radius: var(--raio);
  background: var(--papel); box-shadow: var(--sombra); cursor: pointer; text-decoration: none; color: var(--tinta);
  font-weight: 600;
}
.botao:active { transform: translateY(2px); box-shadow: none; }
.botao.primario { background: var(--primaria); color: #fff; }
.botao.grande { min-height: 60px; font-size: 1.25rem; padding: 10px 28px; }
.botao.pequeno { min-height: 44px; min-width: 44px; padding: 4px 10px; }
.botao.perigo { border-color: var(--vermelho); color: var(--vermelho); }
.linha-botoes { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0; }

/* início */
.inicio { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 24px; gap: 6px; }
.inicio .logo { width: 84px; height: 84px; }
.inicio h1 { font-size: 2rem; margin-bottom: 0; }
.subtitulo { margin: 0; color: var(--primaria); font-weight: 700; font-size: 1.15rem; }
.bit-capa { width: 150px; margin: 12px 0; animation: flutuar 2.4s ease-in-out infinite; }
.versao { color: var(--suave); font-size: 0.8rem; }
@keyframes flutuar { 50% { transform: translateY(-8px); } }

.centro { text-align: center; padding-top: 32px; }
.dica-texto { color: var(--suave); text-align: center; font-size: 0.95rem; }
.avatares { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.avatar { font-size: 2.6rem; aspect-ratio: 1; border: 2px solid var(--tinta); border-radius: var(--raio); background: var(--papel); box-shadow: var(--sombra); cursor: pointer; }

/* história */
.historia { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 40px; gap: 12px; }
.falante { width: 130px; height: 130px; display: grid; place-items: center; }
.falante .bit-arte { width: 120px; }
.emoji-grande { font-size: 5rem; line-height: 1; }
.emoji-gigante { font-size: 6rem; text-align: center; }
.balao { background: var(--papel); border: 2px solid var(--tinta); border-radius: 18px; padding: 14px 18px; box-shadow: var(--sombra); font-size: 1.15rem; }
.balao p { margin: 6px 0 0; }

/* topo */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; position: sticky; top: 0; background: var(--fundo); z-index: 5; }
.topo .titulo { font-weight: 700; flex: 1; text-align: center; }
.topo .eu { font-weight: 700; flex: 1; font-size: 1.1rem; }
.topo .eu small { color: var(--suave); font-weight: 500; }

/* mapa */
.mapa { text-align: center; }
.trilha { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 20px; }
.no {
  position: relative; aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--tinta); background: var(--papel);
  box-shadow: var(--sombra); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0;
}
.no:nth-child(8n+5), .no:nth-child(8n+6), .no:nth-child(8n+7), .no:nth-child(8n+8) { transform: translateX(10px); }
.no-icone { font-size: 1.7rem; line-height: 1; }
.no-num { position: absolute; top: -6px; left: -6px; background: var(--tinta); color: #fff; border-radius: 50%; width: 24px; height: 24px; font-size: 0.75rem; display: grid; place-items: center; }
.no-estrelas { font-size: 0.75rem; color: var(--laranja); min-height: 1em; }
.no.feito { background: #e5f5ef; }
.no.trancado { opacity: 0.45; }
.no.desafio { border-color: var(--laranja); }
.no.chefe { border-width: 4px; border-color: var(--vermelho); }
.aviso { background: #fff1d6; border: 2px dashed var(--laranja); border-radius: var(--raio); padding: 10px; }
.em-breve { margin-top: 16px; padding: 14px; border-radius: var(--raio); background: #e9f3df; font-weight: 700; }

/* jogo */
.jogo { display: flex; flex-direction: column; gap: 10px; }
.fala { display: flex; gap: 10px; align-items: flex-start; background: var(--papel); border: 2px solid var(--tinta); border-radius: var(--raio); padding: 8px 12px; }
.fala .mentor { font-size: 2rem; line-height: 1; }
.fala p { margin: 0; font-size: 1rem; }

.tabuleiro {
  position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr);
  width: min(100%, calc(var(--cols) * 84px)); margin: 0 auto;
  border: 3px solid var(--tinta); border-radius: var(--raio); overflow: hidden; background: var(--grama);
}
.cel { aspect-ratio: 1; display: grid; place-items: center; position: relative; font-size: clamp(1.4rem, 7vw, 2.2rem); border: 1px solid rgba(20, 35, 60, 0.08); }
.cel.chao:nth-child(odd) { background: var(--grama-escura); }
.cel.agua { background: var(--agua); background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255, 255, 255, 0.35) 10px 14px); }
.cel.pedra { background: var(--pedra); }
.cel > span { grid-area: 1 / 1; }
.pao { transition: transform 0.3s, opacity 0.3s; }
.pao.pego { transform: scale(0) rotate(90deg); opacity: 0; }
.marca { grid-area: 1 / 1; font-size: 1.6rem; width: 80%; height: 80%; border-radius: 50%; border: 3px dashed var(--tinta); background: rgba(255, 255, 255, 0.7); cursor: pointer; z-index: 2; }
.marca.escolhida { border-style: solid; border-color: var(--laranja); }

.bit { position: absolute; left: 0; top: 0; display: grid; place-items: center; transition: left 0.35s ease, top 0.35s ease; z-index: 3; pointer-events: none; }
.bit svg { width: 82%; height: 82%; }
.bit.sem-anim { transition: none; }
.bit.bateu { animation: bater 0.4s; }
.bit.festa svg { animation: pular 0.5s 2; }
@keyframes bater { 25% { transform: translateX(-8%) rotate(-8deg); } 75% { transform: translateX(8%) rotate(8deg); } }
@keyframes pular { 50% { transform: translateY(-25%) scale(1.1); } }

.status { display: flex; justify-content: space-between; align-items: center; min-height: 28px; gap: 8px; font-weight: 600; }
.mensagem { flex: 1; text-align: right; }
.mensagem.bom { color: var(--verde); }
.mensagem.ruim { color: var(--vermelho); }

.programa {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 64px; padding: 8px;
  background: #eef3f8; border: 2px dashed var(--suave); border-radius: var(--raio);
}
.programa .vazio { color: var(--suave); font-size: 0.9rem; margin: auto; }
.bloco {
  width: 46px; height: 46px; border-radius: 10px; border: 2px solid var(--tinta); font-size: 1.5rem; font-weight: 800;
  background: #4a90d9; color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: var(--sombra);
}
.bloco.cmd-P { background: var(--laranja); }
.bloco.grande { width: 52px; height: 52px; font-size: 1.7rem; }
.bloco.ativo { outline: 4px solid #ffd23f; transform: scale(1.12); }
.bloco.errado { background: var(--vermelho); outline: 3px solid var(--vermelho); }
.vao { width: 10px; height: 46px; border: none; background: transparent; padding: 0; cursor: pointer; border-radius: 4px; }
.vao.cursor { background: var(--tinta); width: 5px; margin: 0 3px; animation: piscar 1s steps(2) infinite; }
@keyframes piscar { 50% { opacity: 0.2; } }

.paleta { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.controles { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.controles .botao { min-width: 52px; padding: 8px 10px; font-size: 1.3rem; }
.controles .rodar { min-width: 72px; }
.controles .rodar { font-size: 1.5rem; }
.sugerido { animation: sugerir 0.9s ease-in-out infinite; outline: 4px solid #ffd23f; }
@keyframes sugerir { 50% { transform: scale(1.12); } }
.pulsar { animation: sugerir 0.9s ease-in-out infinite; background: #fff4b8; }

/* ordem certa */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; }
.slot { position: relative; aspect-ratio: 1; border: 3px dashed var(--suave); border-radius: var(--raio); background: var(--papel); cursor: pointer; display: grid; place-items: center; }
.slot .num { position: absolute; top: 4px; left: 8px; font-weight: 800; color: var(--suave); }
.slot.errado { border-color: var(--vermelho); border-style: solid; background: #fde8e7; }
.cartas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.carta { border: 2px solid var(--tinta); border-radius: var(--raio); background: var(--papel); box-shadow: var(--sombra); padding: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.emoji-carta { font-size: 2.4rem; }
.carta small { font-size: 0.85rem; color: var(--suave); }

/* guardião */
.chefe-barra { display: flex; align-items: center; gap: 10px; background: #fde8e7; border: 2px solid var(--vermelho); border-radius: var(--raio); padding: 6px 12px; margin-bottom: 6px; }
.chefe-barra .emoji-grande { font-size: 2.2rem; }
.chefe-barra .vida { margin-left: auto; font-size: 1.4rem; }
.chefe-barra .vida .perdeu { opacity: 0.2; filter: grayscale(1); }
.festa { animation: pular 0.6s 3; display: inline-block; }

/* missão e páginas */
.caixa-adulto { background: var(--papel); border: 2px solid var(--suave); border-radius: var(--raio); padding: 10px 14px; font-size: 0.95rem; }
.caixa-adulto ol { margin: 6px 0 0; padding-left: 20px; }
.lista-paginas { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.pagina { background: var(--papel); border: 2px solid var(--tinta); border-radius: var(--raio); padding: 12px 16px; }
.pagina p { margin: 6px 0 10px; }
.pagina.trancada { opacity: 0.55; border-style: dashed; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20, 35, 60, 0.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal .caixa-modal { background: var(--papel); border: 3px solid var(--tinta); border-radius: 20px; padding: 18px; width: min(100%, 380px); text-align: center; }
.estrelas-grandes { font-size: 3rem; letter-spacing: 6px; color: #d8d8d8; }
.estrelas-grandes .ganhou { color: #ffc43d; text-shadow: 0 2px 0 #c98a00; }
.visor { font-size: 2rem; font-weight: 800; border: 2px solid var(--tinta); border-radius: 10px; margin: 8px auto; width: 120px; min-height: 52px; display: grid; place-items: center; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- v0.2: Vale, editor em árvore, padrões, esteira ---------- */
.vale { text-align: center; }
.regioes { display: flex; flex-direction: column; align-items: stretch; margin: 12px 0; }
.regiao {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; cursor: pointer;
  border: 3px solid var(--tinta); border-radius: 18px; background: var(--papel); box-shadow: var(--sombra);
}
.regiao.vencida { background: #e5f5ef; }
.regiao.trancada { opacity: 0.5; }
.regiao-emoji { font-size: 2.4rem; }
.regiao-texto { display: flex; flex-direction: column; flex: 1; }
.regiao-texto small { color: var(--suave); }
.regiao-chefe { font-size: 1.6rem; }
.trilho { width: 6px; height: 18px; margin: 0 auto; background: repeating-linear-gradient(var(--suave) 0 4px, transparent 4px 8px); }
.voltar-vale { float: left; }
.secao { margin-top: 12px; }

.mundos { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mundos .dica-texto { font-size: 0.8rem; text-align: left; flex: 1; }
.contador-blocos { font-weight: 700; }

.bloco.cmd-R { background: #8e6bd8; }
.bloco.cmd-S { background: #e07b39; }
.bloco.cmd-A { background: #e0a800; }

.programa { flex-direction: column; align-items: stretch; gap: 6px; }
.faixa { border-radius: 12px; padding: 4px 6px; }
.faixa .rotulo { display: block; font-size: 0.75rem; font-weight: 700; color: var(--suave); }
.faixa .linha { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 50px; }
.faixa.feitico { background: #fff3c4; border: 2px solid #e0a800; }

.caixa { display: inline-flex; flex-direction: column; max-width: 100%; border: 2px solid var(--tinta); border-radius: 12px; padding: 4px; margin: 2px; }
.caixa.repita { background: #e8defc; }
.caixa.se { background: #fde3d0; }
.caixa.ativo { outline: 4px solid #ffd23f; }
.caixa.errado { outline: 3px solid var(--vermelho); }
.caixa .cab { display: flex; align-items: center; gap: 6px; }
.caixa .cab .bloco { width: 40px; height: 40px; font-size: 1.2rem; }
.num, .sensor {
  min-width: 46px; height: 40px; border: 2px solid var(--tinta); border-radius: 10px; background: #fff;
  font-weight: 800; font-size: 1.15rem; cursor: pointer; display: grid; place-items: center; padding: 0 6px;
}
.livre { display: inline-grid; place-items: center; width: 30px; height: 28px; border-radius: 6px; background: #bfe6b3; border: 2px solid var(--verde); font-weight: 800; }
.corpo, .ramo { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 50px; margin-top: 4px; padding: 2px 4px; border-radius: 8px; background: rgba(255, 255, 255, 0.65); }
.marca-ramo { font-weight: 800; width: 22px; text-align: center; }
.ramo.sim .marca-ramo { color: var(--verde); }
.ramo.nao .marca-ramo { color: var(--vermelho); }
.caixa.deu-sim .ramo.sim, .caixa.deu-nao .ramo.nao { background: #fff6b0; outline: 3px solid #ffd23f; }
.vao.vazio-vao { width: 44px; height: 40px; border: 2px dashed var(--suave); background: rgba(255, 255, 255, 0.6); }
.vao.vazio-vao.cursor { background: #fff6b0; border-color: var(--tinta); animation: piscar 1s steps(2) infinite; }
.nada { color: var(--suave); padding: 0 6px; }

.sequencia { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 2.2rem; padding: 10px; background: var(--papel); border: 2px solid var(--tinta); border-radius: var(--raio); }
.sequencia .falta { border: 3px dashed var(--laranja); border-radius: 10px; padding: 0 4px; }
.sequencia .falta.certo { border-style: solid; border-color: var(--verde); }
.opcoes { display: flex; justify-content: center; gap: 14px; }
.opcao { font-size: 2.6rem; width: 84px; height: 84px; border: 3px solid var(--tinta); border-radius: 18px; background: var(--papel); box-shadow: var(--sombra); cursor: pointer; }
.opcao.errado { opacity: 0.35; }

.esteira-cestas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cesta { border: 3px solid var(--tinta); border-radius: var(--raio); background: var(--papel); min-height: 110px; padding: 6px; }
.cesta-topo { font-size: 1.6rem; text-align: center; border-bottom: 2px dashed var(--suave); padding-bottom: 4px; }
.cesta-itens { display: flex; flex-wrap: wrap; gap: 2px; font-size: 1.5rem; padding-top: 4px; }
.cesta-itens .errado { background: #fde8e7; border-radius: 6px; outline: 2px solid var(--vermelho); }
.esteira { height: 64px; display: grid; place-items: center; font-size: 2.4rem; border-radius: var(--raio); background: repeating-linear-gradient(90deg, #c9c2b5 0 18px, #b5ad9f 18px 36px); border: 3px solid var(--tinta); }
.regra { display: flex; justify-content: center; }
.seta-cesta { background: #4a90d9; }
.barra-baixo { position: sticky; bottom: 0; z-index: 4; display: flex; flex-direction: column; gap: 8px; padding: 8px 0 10px; background: var(--fundo); box-shadow: 0 -6px 10px -8px rgba(20, 35, 60, 0.35); }

/* Conta Épiro (v0.3) */
.conta-barra { margin: 14px auto 4px; padding: 10px 12px; border-radius: var(--raio); background: #e6f6f3; border: 2px solid #2BB3A3; max-width: 420px; display: grid; gap: 8px; justify-items: center; }
.conta-barra.convidado { background: #fff7e6; border-color: var(--laranja); }
.conta-barra .linha-botoes { margin: 0; }
.erro { color: #b3261e; font-weight: 700; min-height: 1.2em; margin: 4px 0; }
