:root {
  --fundo: #2a1a10;
  --madeira: #6b4428;
  --plastico: #3b2417;
  --plastico2: #4d3020;
  --furo: #170d07;
  --amarelo: #ffcf3f;
  --texto: #fff6e6;
  --suave: #d9c2a3;
  --pino: 34px;
  --raio: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--texto);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; overscroll-behavior: none; }
body { background: radial-gradient(ellipse at 50% 20%, #5a3a22 0%, #2a1a10 70%) fixed;
  background-image: url(../assets/img/mesa.jpg), radial-gradient(ellipse at 50% 20%, #5a3a22 0%, #2a1a10 70%);
  background-size: cover; background-position: center; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
#app { max-width: 560px; margin: 0 auto; height: 100dvh; position: relative; }
.tela { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); }
.tela.ativa { display: flex; animation: surge .25s ease-out; }
@keyframes surge { from { opacity: 0; transform: translateY(8px); } }
.rolagem { overflow-y: auto; flex: 1; padding-bottom: 20px; }

/* Botões */
.btn { background: linear-gradient(#ffd95c, #f2ad1b); color: #3a2205; font-weight: 700; padding: 12px 18px;
  border-radius: 14px; box-shadow: 0 4px 0 #a8700a, 0 6px 14px #0006; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a8700a; }
.btn.grande { font-size: 1.3rem; padding: 16px 22px; }
.btn.secundario { background: linear-gradient(#7a5034, #5b3923); color: var(--texto); box-shadow: 0 4px 0 #2e1c10, 0 6px 14px #0006; }
.btn.confirmar { background: linear-gradient(#5fd068, #2f9e3b); color: #fff; box-shadow: 0 4px 0 #1d6b26, 0 6px 14px #0006; flex: 1; }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }
.btn-icone { background: #0004; width: 42px; height: 42px; border-radius: 50%; font-size: 1.2rem; }

/* Menu */
#tela-menu { justify-content: space-between; align-items: center; text-align: center; }
.capa { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; gap: 8px; min-height: 0; }
.capa-img { max-width: 100%; max-height: 48vh; object-fit: contain; border-radius: 22px; box-shadow: 0 10px 30px #000a; }
.logo h1 { margin: 4px 0 0; font-size: clamp(3rem, 14vw, 4.6rem); letter-spacing: .12em; color: var(--amarelo);
  text-shadow: 0 4px 0 #8a5a06, 0 8px 18px #000c; }
.logo p { margin: 0; color: var(--suave); font-size: 1.05rem; }
.logo-pinos { display: inline-flex; gap: 8px; }
.logo-pinos i { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff9 0 12%, var(--c) 40%, #0006 100%); box-shadow: 0 3px 4px #0008; }
.menu-botoes { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); margin: 10px 0; }
.rodape-menu { display: flex; justify-content: space-between; align-items: center; width: 100%; color: var(--amarelo); font-weight: 700; }

/* Topo */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.topo h2 { margin: 0; font-size: 1.3rem; }
.titulo-fase { text-align: center; line-height: 1.1; }
.titulo-fase small { display: block; color: var(--suave); font-size: .8rem; }
.estrelas-topo { color: var(--amarelo); font-weight: 700; }

/* Mapa */
.capitulo { background: #0005; border-radius: var(--raio); padding: 12px; margin-bottom: 12px; }
.capitulo h3 { margin: 0; font-size: 1.05rem; color: var(--amarelo); }
.capitulo p { margin: 2px 0 10px; color: var(--suave); font-size: .85rem; }
.capitulo.travado { opacity: .5; }
.fases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fase-btn { background: linear-gradient(var(--plastico2), var(--plastico)); border-radius: 12px; padding: 10px 4px;
  box-shadow: inset 0 2px 0 #fff2, 0 3px 0 #1a0f08; font-weight: 700; font-size: 1.2rem; }
.fase-btn small { display: block; font-size: .7rem; color: var(--amarelo); letter-spacing: 1px; min-height: 1em; }
.fase-btn:disabled { opacity: .45; cursor: default; }
.fase-btn.atual { outline: 3px solid var(--amarelo); }

/* Lista de níveis */
.explica { color: var(--suave); margin-top: 0; }
.lista-niveis { display: flex; flex-direction: column; gap: 10px; }
.nivel-btn { text-align: left; background: linear-gradient(var(--plastico2), var(--plastico)); border-radius: 14px; padding: 12px 14px;
  box-shadow: inset 0 2px 0 #fff2, 0 3px 0 #1a0f08; }
.nivel-btn b { color: var(--amarelo); font-size: 1.05rem; }
.nivel-btn span { display: block; color: var(--suave); font-size: .85rem; }

/* Guará e balão */
.guara-linha { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-height: 64px; }
.guara { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #c5672b; border: 3px solid var(--amarelo); flex: none; }
.guara.sem-img { visibility: hidden; width: 0; border: 0; }
.balao { background: #fff6e6; color: #3a2205; border-radius: 14px; padding: 8px 12px; font-size: .95rem; position: relative; flex: 1; line-height: 1.25; }
.balao::before { content: ""; position: absolute; left: -8px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-right-color: #fff6e6; border-left: 0; }
.balao.pulsa { animation: pulsa .35s; }
@keyframes pulsa { 50% { transform: scale(1.03); } }

/* Tabuleiro de plástico */
.tabuleiro { flex: 1; min-height: 0; display: flex; flex-direction: column; background: linear-gradient(90deg, #2e1b10, var(--plastico2) 20%, var(--plastico2) 80%, #2e1b10);
  border-radius: 22px; padding: 10px; box-shadow: inset 0 3px 0 #fff2, inset 0 -4px 0 #0006, 0 10px 24px #000b; }
.segredo { position: relative; padding: 6px 8px 10px; border-bottom: 3px dashed #0006; margin-bottom: 6px; }
.linha-segredo { display: flex; justify-content: center; gap: 8px; min-height: var(--pino); }
.escudo { position: absolute; inset: 2px 30px 6px; background: linear-gradient(#ffd95c, #e39a0d); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; color: #6a3e02; font-weight: 900; font-size: 1.4rem;
  box-shadow: inset 0 2px 0 #fff8, 0 4px 8px #0008; transition: transform .7s cubic-bezier(.5,-0.4,.4,1.3), opacity .7s; }
.escudo small { font-size: .8rem; letter-spacing: .3em; }
.escudo.aberto { transform: translateY(-120%) rotate(-6deg); opacity: 0; }
.linhas { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 2px; scrollbar-width: thin; }
.linha { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 12px; }
.linha.ativa { background: #ffcf3f22; box-shadow: inset 0 0 0 2px #ffcf3f88; }
.linha.futura { opacity: .55; }
.linha .num { width: 20px; text-align: right; color: var(--suave); font-size: .75rem; flex: none; }
.furos { display: flex; gap: 8px; flex: 1; justify-content: center; }
.furo { width: var(--pino); height: var(--pino); border-radius: 50%; background: radial-gradient(circle at 50% 60%, #000 0 30%, var(--furo) 60%);
  box-shadow: inset 0 3px 4px #000c, 0 1px 0 #fff2; flex: none; position: relative; padding: 0; }
.furo.sel { box-shadow: inset 0 3px 4px #000c, 0 0 0 3px var(--amarelo); }
.pino { position: absolute; inset: 2px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fffc 0 10%, var(--c) 38%, color-mix(in srgb, var(--c), #000 45%) 100%);
  box-shadow: 0 3px 3px #000a, inset 0 0 0 1px #ffffff2e; animation: encaixa .18s ease-out; }
.pino.vazio { background: none; box-shadow: none; border: 2px dashed #ffcf3f99; }
.pino.vazio::after { content: "∅"; position: absolute; inset: 0; display: grid; place-items: center; color: #ffcf3fcc; font-size: .9rem; }
@keyframes encaixa { from { transform: scale(1.35) translateY(-6px); opacity: .3; } }
.chave { display: grid; grid-template-columns: repeat(var(--colunas, 2), 12px); gap: 3px; width: max-content; flex: none; min-width: 30px;
  background: linear-gradient(#d8b98c, #b8925f); padding: 4px; border-radius: 8px; box-shadow: inset 0 1px 0 #fff6, 0 2px 3px #0007; }
.chave i { width: 12px; height: 12px; border-radius: 50%; background: #6b4a2a; box-shadow: inset 0 2px 2px #0009; }
.chave i.preto { background: radial-gradient(circle at 35% 30%, #888 0 12%, #111 60%); box-shadow: 0 1px 2px #000; animation: encaixa .2s ease-out both; }
.chave i.branco { background: radial-gradient(circle at 35% 30%, #fff 0 20%, #ddd 60%, #999); box-shadow: 0 1px 2px #000; animation: encaixa .2s ease-out both; }
.ia-info { font-size: .7rem; color: var(--amarelo); width: 38px; white-space: nowrap; text-align: right; flex: none; }

/* Controles */
.controles { padding-top: 10px; }
.paleta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 10px; }
.cor-btn { width: 46px; height: 46px; border-radius: 50%; position: relative; background: radial-gradient(circle at 50% 60%, #000 0 30%, var(--furo) 60%); }
.cor-btn .pino { inset: 3px; animation: none; }
.cor-btn:active .pino { transform: scale(.9); }
.cor-btn .tecla { position: absolute; right: -4px; bottom: -4px; font-size: .65rem; background: #000a; border-radius: 6px; padding: 0 4px; color: var(--suave); }
.cor-btn:disabled { opacity: .3; }
.acoes { display: flex; gap: 8px; }
.acoes .btn { padding: 12px 14px; }
#btn-dica small { font-size: .75rem; opacity: .8; }

/* Janelas */
.janela { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.janela[hidden] { display: none; }
.caixa { background: linear-gradient(#fff6e6, #f3dfbd); color: #3a2205; border-radius: 22px; padding: 18px; width: min(440px, 100%); max-height: 90dvh; overflow-y: auto;
  box-shadow: 0 16px 40px #000c; text-align: center; animation: surge .25s ease-out; }
.caixa h2 { margin: 0 0 6px; font-size: 1.6rem; }
.caixa p { margin: 6px 0; line-height: 1.35; }
.caixa .estrelas-res { font-size: 2.6rem; letter-spacing: 6px; margin: 6px 0; }
.caixa .estrelas-res .apagada { filter: grayscale(1) opacity(.3); }
.caixa .botoes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.caixa .exemplo { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--plastico2); border-radius: 14px; padding: 8px; margin: 8px 0; }
.caixa .exemplo .furo { --pino: 30px; width: 30px; height: 30px; }
.caixa .exemplo-txt { text-align: left; font-size: .9rem; }
.caixa ul { text-align: left; padding-left: 20px; margin: 6px 0; }
.caixa li { margin: 4px 0; }
.sugestao { display: flex; justify-content: center; gap: 6px; margin: 8px 0; background: var(--plastico2); border-radius: 12px; padding: 8px; }
.sugestao .furo { width: 30px; height: 30px; }

@media (max-height: 700px) { :root { --pino: 28px; } .guara { width: 48px; height: 48px; } .guara-linha { min-height: 48px; } .cor-btn { width: 40px; height: 40px; } }
@media (max-width: 380px) { :root { --pino: 28px; } .furos { gap: 5px; } .cor-btn { width: 40px; height: 40px; } .paleta { gap: 7px; } }
