/* Torre das Formas e Cores — o tabuleiro de madeira com as bases, a bandeja das peças soltas e a torre de exemplo. Fundo
   calmo, a dica como um brilho amarelo, nada vermelho nem barulho no engano. Os tamanhos (--base, --peca, --exemplo)
   são calculados pelo jogo.js. Os painéis do adulto são os do Igual ao Igual. */

:root {
  --fundo: #eef3f8;
  --tinta: #1d2a38;
  --suave: #5b6b7c;
  --azul: #2563a8;
  --verde: #2e9d63;
  --linha: #d3dde7;
  --brilho: #ffc933;
  --base: 140px;
  --peca: 90px;
  --exemplo: 120px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--tinta); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overflow: hidden;
}
button { font: inherit; color: inherit; }

#app { height: 100%; display: flex; flex-direction: column; }
#topo { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; min-height: 46px; position: relative; z-index: 25; }
.titulo { font-weight: 700; color: var(--suave); font-size: 15px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botoes { display: flex; gap: 6px; }
.icone {
  position: relative; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--linha); background: #fff;
  font-size: 19px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--suave); flex: 0 0 auto;
}
.ajustes { touch-action: none; }
.ajustes .anel { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.ajustes .anel circle { fill: none; stroke: var(--azul); stroke-width: 3; stroke-dasharray: 107; stroke-dashoffset: 107; }
.ajustes.segurando .anel circle { transition: stroke-dashoffset 1.2s linear; stroke-dashoffset: 0; }

/* ---- O pedido ---- */
#instrucao-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px 6px; min-height: 56px; }
.ouvir { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--linha); background: #fff; font-size: 21px; cursor: pointer; flex: 0 0 auto; }
#instrucao { margin: 0; font-size: clamp(19px, 5.4vmin, 36px); font-weight: 800; color: var(--azul); text-align: center; line-height: 1.15; }

/* ---- A mesa: o tabuleiro (e, na etapa 5, a torre de exemplo) ---- */
#mesa { flex: 1 1 auto; min-height: 0; display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center; gap: 10px; padding: 0 12px 8px; }
#tabuleiro {
  display: grid; gap: 10px; justify-content: center; align-content: center; padding: 10px;
  background:
    repeating-linear-gradient(100deg, rgba(140, 86, 36, .07) 0 2px, transparent 2px 15px),
    linear-gradient(160deg, #e6bd84, #d39c60);
  border-radius: 18px; box-shadow: inset 0 0 0 3px rgba(150, 95, 40, .35), 0 4px 0 #b07a43;
}
.base { position: relative; width: var(--base); height: var(--base); border-radius: 16px; touch-action: none; cursor: default; transition: background .2s, box-shadow .2s; }
.base svg { width: 100%; height: 100%; display: block; }
.base.pode-tirar { cursor: grab; }
/* a base certa brilha (dica total; na parcial, quando a peça está na mão) */
.base.alvo { background: rgba(255, 236, 170, .55); box-shadow: 0 0 0 4px var(--brilho); animation: respira 1.6s ease-in-out infinite; }
@keyframes respira { 50% { box-shadow: 0 0 0 9px rgba(255, 201, 51, .35); } }
/* a peça na mão passa por cima de uma base */
.base.sob { background: rgba(255, 255, 255, .35); }
.base.escolhida { outline: 4px solid var(--azul); outline-offset: 2px; }
.base.pousou svg { animation: pousa .32s ease-out; }
@keyframes pousa { 0% { transform: translateY(-6%); } 60% { transform: translateY(1.5%); } 100% { transform: none; } }
/* o acerto: um ✓ verde na base */
.base.certa { box-shadow: 0 0 0 5px rgba(46, 157, 99, .55); background: rgba(46, 157, 99, .12); animation: none; }
.base.certa::after {
  content: "✓"; position: absolute; right: -8px; top: -8px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--verde); color: #fff; font-size: 24px; font-weight: 900; line-height: 38px; text-align: center;
}

/* ---- A bandeja ---- */
#bandeja {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px;
  margin: 0 12px; padding: 8px; background: #f7efe3; border: 2px dashed #d6c0a1; border-radius: 16px; transition: background .2s, border-color .2s;
}
/* tirar: a bandeja é o destino */
#bandeja.alvo { border-color: var(--brilho); border-style: solid; background: #fff4d2; }
.peca { width: var(--peca); touch-action: none; cursor: grab; border-radius: 12px; transition: opacity .25s, transform .15s; }
.peca svg { width: 100%; height: auto; display: block; pointer-events: none; }
/* a dica total: só a peça certa se deixa pegar; as outras quase somem */
.peca.apagada { opacity: .2; cursor: default; }
.peca.brilha { filter: drop-shadow(0 0 5px #ffc933) drop-shadow(0 0 9px rgba(255, 201, 51, .9)); animation: pulsa 1.6s ease-in-out infinite; }
@keyframes pulsa { 50% { transform: scale(1.07); } }
.peca.segurada { visibility: hidden; }
.peca.escolhida { outline: 4px solid var(--azul); outline-offset: 2px; animation: none; }

/* a peça na mão */
.fantasma { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .25)); will-change: transform; }
.fantasma svg { width: 100%; height: auto; display: block; }
.fantasma.voltando { transition: transform .3s ease-out; }

/* ---- A torre de exemplo (etapa 5) ---- */
#exemplo {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px 8px;
  background: #fff; border: 3px dashed #9fb3c8; border-radius: 16px;
}
#exemplo[hidden] { display: none; }
#exemplo .rotulo { margin: 0; font-weight: 800; font-size: 14px; color: var(--suave); }
#exemplo-torre { width: var(--exemplo); height: var(--exemplo); }
#exemplo-torre svg { width: 100%; height: 100%; display: block; }
#exemplo-cortina {
  position: absolute; left: 6px; right: 6px; top: 26px; height: var(--exemplo); border-radius: 12px; background: #dfe8f1;
  display: flex; align-items: center; justify-content: center; font-size: calc(var(--exemplo) * .4); font-weight: 900; color: #9fb3c8;
}
#exemplo-cortina[hidden] { display: none; }
.espiar { margin-top: 4px; border-radius: 12px; border: 1px solid var(--linha); background: #fff; padding: 6px 12px; font-weight: 700; color: var(--azul); cursor: pointer; }

/* ---- O Pronto da Contar ---- */
#acao { flex: 0 0 auto; display: flex; justify-content: center; padding: 8px 12px 0; }
#acao[hidden] { display: none; }
.pronto {
  height: 54px; padding: 0 30px; border-radius: 16px; border: 0; background: var(--verde); color: #fff;
  font-size: 22px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 #1f7a4a;
}
.pronto[hidden] { visibility: hidden; display: inline-block; }
.pronto:active { transform: translateY(2px); box-shadow: 0 2px 0 #1f7a4a; }

#progresso { flex: 0 0 auto; list-style: none; margin: 0; padding: 8px 12px 12px; display: flex; justify-content: center; gap: 7px; flex-wrap: wrap; }
#progresso li { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--linha); }
#progresso li.feita { background: var(--azul); border-color: var(--azul); }

.dica {
  position: fixed; left: 50%; top: 52px; transform: translateX(-50%); background: #1d2a38; color: #fff;
  padding: 8px 14px; border-radius: 10px; font-size: 14px; margin: 0; z-index: 35; max-width: 90vw; text-align: center;
}

/* ---- Camadas ---- */
.camada { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 14px; }
.camada[hidden] { display: none; }
.camada.suave { background: rgba(238, 243, 248, .94); }
.camada.clara { background: rgba(238, 243, 248, .97); align-items: flex-start; overflow-y: auto; z-index: 30; }
.caixa-inicio { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.grande-titulo { margin: 0; font-size: clamp(28px, 8vmin, 52px); font-weight: 900; color: var(--azul); }
.explica-inicio { margin: 0; font-size: 18px; color: var(--suave); max-width: 520px; }
.explica-inicio:empty { display: none; }
.estrela { width: min(32vw, 26vh, 150px); height: auto; }
.comecar {
  height: 72px; padding: 0 34px; border-radius: 20px; border: 0; background: var(--verde); color: #fff;
  font-size: 26px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 #1f7a4a;
}
.comecar:active { transform: translateY(2px); box-shadow: 0 2px 0 #1f7a4a; }

.folha { width: 100%; max-width: 560px; background: #fff; border: 1px solid var(--linha); border-radius: 18px; padding: 16px 16px 12px; margin: auto 0; -webkit-user-select: text; user-select: text; }
.folha.larga { max-width: 780px; }
.folha h2 { margin: 0 0 10px; font-size: 20px; color: var(--azul); }
.folha h3 { margin: 16px 0 6px; font-size: 15px; }
.folha p { margin: 0 0 8px; line-height: 1.45; font-size: 15px; }
.folha section[hidden] { display: none; }
.explica { color: var(--suave); font-size: 13.5px !important; }
.explica.pequeno { font-size: 12.5px !important; margin-top: 8px !important; }
.conta { color: var(--suave); font-weight: 600; font-size: 13px; }
.aviso { color: #a8670b; font-size: 13.5px; min-height: 1em; margin: 6px 0 0 !important; }
.rodape { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.principal, .secundario, .opcoes button { border-radius: 12px; padding: 10px 16px; font-weight: 700; cursor: pointer; font-size: 15px; }
.principal { background: var(--azul); color: #fff; border: 1px solid var(--azul); }
.secundario { background: #fff; color: var(--azul); border: 1px solid var(--linha); }
.opcoes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.opcoes button { background: #fff; border: 1px solid var(--linha); padding: 8px 14px; font-weight: 600; color: var(--tinta); text-align: left; }
.opcoes button[aria-pressed="true"] { background: #e6f0fa; border-color: var(--azul); color: var(--azul); box-shadow: inset 0 0 0 1px var(--azul); }

.grupo-cartoes { display: flex; flex-wrap: wrap; gap: 8px; }
.escolha, .mini { position: relative; display: flex; flex-direction: column; align-items: center; width: 92px; padding: 6px 4px 4px; border-radius: 12px; background: #fff; font-size: 12.5px; font-weight: 700; text-align: center; line-height: 1.15; }
.escolha { border: 2px dashed var(--linha); cursor: pointer; color: var(--suave); }
.escolha .fig, .mini .fig { width: 64px; height: 46px; display: flex; align-items: center; justify-content: center; }
.escolha .fig svg, .mini .fig svg { width: 100%; height: 100%; }
.escolha .fig { opacity: .45; }
.escolha[aria-pressed="true"] { border: 3px solid var(--azul); color: var(--tinta); }
.escolha[aria-pressed="true"] .fig { opacity: 1; }
.mini { border: 2px solid var(--linha); }
.mini .numero { font-size: 30px; font-weight: 900; color: var(--azul); height: 46px; line-height: 46px; }
.selo { margin-top: 3px; font-size: 10.5px; font-weight: 700; border-radius: 8px; padding: 1px 6px; background: #eef1f4; color: var(--suave); }
.selo.n0 { background: #fdf1dc; color: #a8670b; }
.selo.n1 { background: #e6f0fa; color: var(--azul); }
.selo.n2 { background: #e5f4ec; color: var(--verde); }

@media (prefers-reduced-motion: reduce) {
  .base.alvo, .peca.brilha, .base.pousou svg { animation: none; }
  .fantasma.voltando { transition: none; }
  .ajustes.segurando .anel circle { transition: none; }
}
