/* Construtora do Gemalino — visual próprio (prefixo cg13-). Alvos de 80 px (--alvo), nada pisca. */
:root {
  --tema: #96d06e;
  --tema-escuro: #4f8f34;
  --cg13-madeira: #d9a066;
  --cg13-madeira-escura: #85572d;
  --cg13-vao: 6px;
}

/* ---------- menu ---------- */
.cg13-menu {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(var(--alvo), 1fr);
  gap: 10px; align-content: stretch; max-width: 1100px; margin: 0 auto; width: 100%;
}
.cg13-cartao {
  position: relative; min-height: var(--alvo); min-width: var(--alvo); border: 0; border-radius: 20px; padding: 8px 10px;
  background: var(--branco); box-shadow: var(--sombra); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; text-align: center; color: var(--azul); overflow: hidden;
}
.cg13-cartao strong { font-size: clamp(15px, 2vw, 22px); line-height: 1.15; }
.cg13-cartao span { font-size: clamp(12px, 1.5vw, 16px); }
.cg13-figura { flex: 0 1 auto; min-height: 0; height: 42%; display: flex; justify-content: center; }
.cg13-figura img { height: 100%; width: auto; max-width: 100%; object-fit: contain; }
.cg13-cartao-livre { background: linear-gradient(160deg, #c9ecb0, var(--tema)); border: 4px solid var(--cg13-madeira-escura); }
.cg13-numero { color: var(--cg13-madeira-escura); font-weight: bold; }
.cg13-feito { background: #eef9e4; }
.cg13-selo { position: absolute; top: 6px; right: 8px; color: var(--tema-escuro); font-weight: bold; background: #fff; border-radius: 999px; padding: 0 8px; }
.cg13-cartao:active { transform: translateY(2px); }

/* ---------- vagas do modo livre ---------- */
.cg13-vagas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 1000px; margin: 0 auto; }
.cg13-vaga { display: flex; flex-direction: column; gap: var(--cg13-vao); min-height: 0; }
.cg13-abrir-vaga { flex: 1; }
.cg13-miniatura { width: 100%; flex: 1; min-height: 0; }
.cg13-apagar {
  align-self: center; width: var(--alvo); height: var(--alvo); flex: 0 0 var(--alvo); border: 0; border-radius: 50%;
  background: #ffe1e1; font-size: 32px; box-shadow: var(--sombra);
}
.cg13-confirma {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  align-content: center; gap: 12px; padding: 8px; background: rgba(255, 253, 247, 0.96); border-radius: var(--raio);
}
.cg13-confirma p { flex: 1 1 100%; margin: 0; text-align: center; font-size: clamp(17px, 2.4vw, 24px); font-weight: bold; color: var(--azul); }

/* ---------- a obra ---------- */
.cg13-obra { gap: 8px; }
.cg13-paleta, .cg13-ferramentas, .cg13-escolha {
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--alvo); gap: var(--cg13-vao); align-content: center;
}
.cg13-paleta { display: none; }
.cg13-largo .cg13-paleta { display: grid; }
.cg13-largo .cg13-so-compacto { display: none; }
.cg13-campo { position: relative; flex: 1 1 auto; min-width: 0; }
.cg13-tela { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.cg13-escolha {
  position: absolute; inset: 0; z-index: 3; justify-content: center; padding: 8px;
  background: rgba(255, 253, 247, 0.94); border-radius: var(--raio);
}
.cg13-escolha[hidden] { display: none; }

.cg13-ferramenta, .cg13-mat {
  width: var(--alvo); height: var(--alvo); border: 0; border-radius: 18px; background: var(--branco);
  box-shadow: var(--sombra); font-size: 34px; color: var(--azul); padding: 0;
}
.cg13-ferramenta:active, .cg13-mat:active { transform: translateY(2px); }
.cg13-apagado { opacity: 0.45; }
.cg13-dica { background: #fff3c4; }
.cg13-salvar { background: #dff3d2; }
.cg13-mat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.cg13-mat[aria-pressed="true"] { outline: 4px solid var(--azul); outline-offset: -4px; background: #fff3c4; }
.cg13-mat-nome { font-size: 14px; font-weight: bold; line-height: 1; }

/* amostras dos materiais: desenho próprio, liso, sem textura pixelada */
.cg13-amostra { display: block; width: 46px; height: 34px; border-radius: 8px; border: 2px solid rgba(70, 45, 25, 0.45); }
.cg13-amostra-madeira {
  background:
    radial-gradient(ellipse 9px 3px at 30% 30%, transparent 70%, rgba(120, 70, 30, 0.4) 72%, transparent 90%),
    repeating-linear-gradient(180deg, transparent 0 9px, rgba(120, 70, 30, 0.38) 9px 11px),
    var(--cg13-madeira);
}
.cg13-amostra-telha {
  background:
    radial-gradient(circle at 50% 0, transparent 6px, rgba(115, 40, 20, 0.5) 6.5px 8px, transparent 8.5px) 0 0 / 15px 10px,
    radial-gradient(circle at 50% 0, transparent 6px, rgba(115, 40, 20, 0.5) 6.5px 8px, transparent 8.5px) 7.5px 5px / 15px 10px,
    #d8714b;
}
.cg13-amostra-vidro {
  background: linear-gradient(135deg, transparent 35%, rgba(255, 255, 255, 0.85) 42%, transparent 52%), rgba(150, 205, 240, 0.75);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85);
}
.cg13-amostra-flor {
  background:
    radial-gradient(circle at 25% 40%, #f9a825 2px, #f48fb1 3px 6px, transparent 6.5px),
    radial-gradient(circle at 68% 30%, #f9a825 2px, #ffd54f 3px 6px, transparent 6.5px),
    radial-gradient(circle at 50% 72%, #f9a825 2px, #ffffff 3px 6px, transparent 6.5px),
    #6cbf4a;
}
.cg13-amostra-cerca {
  background:
    linear-gradient(180deg, transparent 8px, #f4ead6 8px 12px, transparent 12px 20px, #f4ead6 20px 24px, transparent 24px),
    repeating-linear-gradient(90deg, transparent 0 4px, #f4ead6 4px 9px, transparent 9px 15px),
    #a9db8a;
}
.cg13-amostra-agua {
  background:
    radial-gradient(ellipse 10px 3px at 30% 35%, rgba(255, 255, 255, 0.8) 40%, transparent 70%),
    radial-gradient(ellipse 10px 3px at 70% 70%, rgba(255, 255, 255, 0.7) 40%, transparent 70%),
    #5fb0e4;
}
.cg13-amostra-tirar { border: 0; display: grid; place-items: center; }
.cg13-amostra-tirar::before { content: "✖"; font-size: 30px; color: #c0392b; }

/* contador de blocos e a lista do desafio, por cima do canvas (os toques passam) */
.cg13-contador {
  position: absolute; top: 4px; right: 6px; z-index: 2; pointer-events: none; padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 253, 247, 0.9); font-weight: bold; font-size: 16px; color: var(--azul);
}
.cg13-contador.cg13-passou { background: #ffe1c4; color: #8a3b12; }
.cg13-lista {
  display: none; position: absolute; top: 4px; left: 4px; z-index: 2; margin: 0; padding: 6px 12px; list-style: none;
  pointer-events: none; background: rgba(255, 253, 247, 0.88); border-radius: 14px; font-size: 15px; line-height: 1.45; color: #50606f;
}
.cg13-com-lista .cg13-lista { display: block; }
.cg13-lista .cg13-ok { color: var(--tema-escuro); font-weight: bold; }

/* o fim do desafio */
.cg13-fim {
  position: absolute; left: 0; right: 0; bottom: 4px; z-index: 3; margin: 0 auto; width: max-content; max-width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px;
  background: rgba(255, 253, 247, 0.95); border-radius: var(--raio); box-shadow: var(--sombra); animation: entra 0.3s ease-out;
}
.cg13-fim-texto { display: flex; flex-direction: column; max-width: 460px; font-size: 17px; color: var(--azul); }
.cg13-fim-texto strong { font-size: 22px; }
.cg13-fim-botoes { display: flex; gap: 8px; }

/* ---------- celular deitado (pouca altura) ---------- */
@media (max-height: 460px) {
  .cg13-fim-texto { display: none; }
  .cg13-fim { padding: 6px; }
  .cg13-menu, .cg13-vagas { gap: 6px; }
  .cg13-cartao { padding: 4px 6px; }
  .cg13-contador { font-size: 14px; padding: 2px 8px; }
}

/* na hora de construir, o galinheiro do fundo (desenho da base) sai de trás das ferramentas */
body[data-lugar="desafio"] .fundo svg > :nth-child(n + 3),
body[data-lugar="livre"] .fundo svg > :nth-child(n + 3) { display: none; }
