/* A Torre do Saltitão — visual próprio do jogo (o comum está em base.css).
   Torre de blocos vista de lado, na fazenda: madeira natural nos blocos fixos e cores vivas nas
   peças que mexem. Tudo em "casas" (--ts-casa). Nada pisca. */
:root {
  --tema: #ff8a80;
  --tema-escuro: #c62828;
  --ts-borda: #8a5a26;
  --ts-laranja: #f57c00;
  --ts-verde: #2e9d4a;
  --ts-roxo: #8e44c8;
  --ts-painel: calc(var(--alvo) * 3 + 12px);
}

/* ---------- 1. escolher a torre: três partes, uma por linha, e a torre nova ao lado ---------- */
.ts-menu { flex-direction: row; align-items: safe center; justify-content: center; gap: 10px; overflow-y: auto; }
.ts-partes { flex: 0 1 auto; display: flex; flex-direction: column; gap: 8px; max-height: 100%; }
.ts-parte {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 4px 10px;
  background: rgba(255, 253, 247, 0.85); border-radius: var(--raio);
}
.ts-parte-nome { flex: 0 0 clamp(112px, 16vw, 210px); display: flex; flex-direction: column; gap: 2px; }
.ts-parte-nome strong { font-size: clamp(16px, 2vw, 24px); color: var(--azul); line-height: 1.1; }
.ts-parte-nome span { font-size: clamp(12px, 1.4vw, 16px); line-height: 1.15; }
.ts-parte-fases { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-fase-botao {
  --ts-fase: max(var(--alvo), min(8.4vw, 14vh));
  position: relative; flex: 0 0 auto; width: var(--ts-fase); height: var(--ts-fase); padding: 0;
  border: 4px solid var(--ts-borda); border-radius: 14px; background: linear-gradient(#efd09c, #d8a868);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2); color: #6b3f12; font-size: 32px; font-weight: bold;
}
.ts-fase-botao:active { transform: translateY(2px); }
.ts-fase-botao.fechada { filter: grayscale(0.7); opacity: 0.6; }
.ts-selo { position: absolute; right: -6px; top: -8px; width: 32px; height: 32px; }
.ts-selo svg, .ts-torre-nova svg { width: 100%; height: 100%; display: block; }
.ts-extra { position: absolute; left: 3px; top: -4px; font-size: 22px; color: var(--amarelo); text-shadow: 0 0 2px var(--ts-borda), 0 1px 0 var(--ts-borda); }
.ts-cadeado { position: absolute; right: 2px; bottom: 0; font-size: 18px; }

/* a torre nova: cresce um bloco a cada torre feita */
.ts-torre-nova {
  --tn: clamp(14px, 3.2vh, 26px);
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px;
  background: rgba(255, 253, 247, 0.85); border-radius: var(--raio);
}
.ts-torre-nova-topo { width: calc(var(--tn) * 1.6); height: calc(var(--tn) * 1.6); }
.ts-torre-nova-pilha { display: grid; grid-template-columns: repeat(3, var(--tn)); grid-auto-rows: var(--tn); gap: 2px; transform: scaleY(-1); }
.ts-tn-bloco { display: block; border: 2px dashed #b9a07a; border-radius: 5px; transform: scaleY(-1); }
.ts-tn-bloco.feito { border: 0; }
.ts-torre-nova-nome { font-size: 13px; font-weight: bold; color: var(--azul); }

/* ---------- 2. a fase: a torre à esquerda, os controles à direita ---------- */
.ts-fase { display: flex; flex-direction: row; gap: 10px; }
.ts-area { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; display: grid; place-items: center; }
.ts-contador {
  position: absolute; left: 4px; top: 2px; padding: 2px 10px; border-radius: 999px;
  background: rgba(255, 253, 247, 0.85); font-size: 15px; font-weight: bold; color: var(--azul);
}

.ts-torre {
  --ts-casa: 40px;
  position: relative; width: calc(var(--ts-casa) * var(--colunas));
  height: calc(var(--ts-casa) * (var(--andares) + 0.75 + var(--chao)));
}
.ts-chao { position: absolute; left: -12px; right: -12px; bottom: 0; height: calc(var(--ts-casa) * var(--chao) + 4px); }
.ts-chao svg { width: 100%; height: 100%; display: block; }
.ts-grade {
  position: absolute; left: 0; bottom: calc(var(--ts-casa) * var(--chao));
  width: calc(var(--ts-casa) * var(--colunas)); height: calc(var(--ts-casa) * var(--andares));
}

/* cada coisa da torre fica numa casa: --x é a coluna e --y o andar (de baixo para cima) */
.ts-casa {
  position: absolute; left: 0; bottom: 0; width: var(--ts-casa); height: var(--ts-casa);
  transform: translate(calc(var(--ts-casa) * var(--x)), calc(var(--ts-casa) * var(--y) * -1));
}
.ts-casa > svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ts-fixo { z-index: 2; }

.ts-trilho { z-index: 1; width: calc(var(--ts-casa) * var(--w)); height: calc(var(--ts-casa) * 0.36); bottom: calc(var(--ts-casa) * 0.32); }
.ts-trilho svg { width: 100%; height: 100%; display: block; }
.ts-poco {
  z-index: 1; height: calc(var(--ts-casa) * var(--w)); width: var(--ts-casa);
  background: linear-gradient(90deg, transparent 8%, var(--cor) 8% 12%, transparent 12% 88%, var(--cor) 88% 92%, transparent 92%);
  opacity: 0.55;
}
.ts-roldana { z-index: 3; height: calc(var(--ts-casa) * 0.72); }
.ts-roldana svg { width: 100%; height: 100%; display: block; }
/* o andar redondo: um prato de madeira embaixo dos blocos, com uma seta de volta em cada ponta */
.ts-base-redonda {
  z-index: 1; width: calc(var(--ts-casa) * var(--w)); height: calc(var(--ts-casa) * 0.3); bottom: calc(var(--ts-casa) * -0.12);
  border-radius: calc(var(--ts-casa) * 0.15); border: 3px solid var(--cor-escura);
  background: repeating-linear-gradient(90deg, #f3e2c3 0 calc(var(--ts-casa) * 0.42), var(--cor-clara) calc(var(--ts-casa) * 0.42) calc(var(--ts-casa) * 0.5));
}
.ts-volta { position: absolute; bottom: 70%; width: calc(var(--ts-casa) * 0.5); height: calc(var(--ts-casa) * 0.5); }
.ts-volta svg { width: 100%; height: 100%; display: block; }
.ts-volta-esq { left: calc(var(--ts-casa) * -0.42); transform: scaleX(-1); }
.ts-volta-dir { right: calc(var(--ts-casa) * -0.42); }

/* as peças que mexem */
.ts-peca { z-index: 3; transition: transform 0.26s ease-in-out, opacity 0.2s; }
.ts-deslizante { display: flex; width: calc(var(--ts-casa) * var(--w)); }
.ts-deslizante > svg { flex: 1 1 0; height: 100%; overflow: visible; }
.ts-corda {
  position: absolute; left: 20%; right: 20%; bottom: 88%; height: calc(var(--ts-casa) * (var(--corda) + 0.42));
  border-left: 3px solid #7a5230; border-right: 3px solid #7a5230; transition: height 0.26s ease-in-out; pointer-events: none;
}
.ts-por-tras { animation: ts-por-tras 0.36s ease-in-out; }
@keyframes ts-por-tras { 0% { opacity: 0; } 60% { opacity: 0.2; } 100% { opacity: 1; } }
.ts-brilha { filter: drop-shadow(0 0 6px #fff59d) drop-shadow(0 0 4px #ffd54f); }
.ts-peca.ts-brilha { animation: ts-respira 1.6s ease-in-out infinite; }
@keyframes ts-respira { 50% { filter: drop-shadow(0 0 10px #fff59d) drop-shadow(0 0 7px #ffb300); } }
.ts-treme { animation: ts-treme 0.3s ease-in-out; }
@keyframes ts-treme { 25% { margin-left: -4px; } 75% { margin-left: 4px; } }

/* o coração do topo */
.ts-coracao { z-index: 2; }
.ts-casa.ts-coracao > svg { width: 74%; height: 74%; margin: 13% auto 0; }
.ts-coracao-leve { animation: ts-leve 1.8s ease-in-out infinite alternate; }
@keyframes ts-leve { to { margin-bottom: calc(var(--ts-casa) * 0.25); } }
.ts-coracao-leve { z-index: 5; }

/* o Saltitão: o recorte, com transform; o pulinho é no recorte, o caminho na caixa */
.ts-saltitao { z-index: 4; pointer-events: none; transition: transform 0.36s ease-in-out; }
.ts-sem-transicao { transition: none; }
.ts-saltitao-img { position: absolute; left: 50%; bottom: 0; height: 128%; width: auto; transform: translateX(-50%); }
.ts-hop .ts-saltitao-img { animation: ts-hop 0.36s ease-out; }
.ts-hop-alto .ts-saltitao-img { animation: ts-hop-alto 0.36s ease-out; }
.ts-festa .ts-saltitao-img { animation: ts-hop 0.5s ease-out 3; }
@keyframes ts-hop { 50% { transform: translateX(-50%) translateY(-30%); } }
@keyframes ts-hop-alto { 50% { transform: translateX(-50%) translateY(-55%); } }
.ts-pausada * { animation-play-state: paused !important; }

/* ---------- os controles ---------- */
.ts-controles {
  flex: 0 0 var(--ts-painel); display: grid; grid-template-columns: repeat(3, var(--alvo)); grid-template-rows: repeat(3, var(--alvo));
  gap: 6px; align-content: safe center; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin;
}
.ts-mexer {
  position: relative; width: var(--alvo); height: var(--alvo); padding: 0; border: 0; border-radius: 18px;
  color: #fffdf7; font-size: 34px; font-weight: bold; box-shadow: var(--sombra); line-height: 1;
}
.ts-mexer:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12); }
.ts-cor-0 { background: var(--ts-laranja); }
.ts-cor-1 { background: var(--ts-verde); }
.ts-cor-2 { background: var(--ts-roxo); }
.ts-seta { display: block; width: 62%; height: 62%; margin: 0 auto; }
.ts-seta svg { width: 100%; height: 100%; display: block; }
.ts-simbolo { position: absolute; right: 6px; bottom: 6px; width: 20px; height: 20px; opacity: 0.9; }
.ts-simbolo svg { width: 100%; height: 100%; display: block; }
.ts-mexer.ts-brilha { outline: 5px solid #fff59d; outline-offset: 2px; animation: ts-respira 1.6s ease-in-out infinite; }
.ts-pula {
  grid-column: 3; grid-row: 1 / span 2; min-width: 0; width: var(--alvo); padding: 0 6px; border-radius: 22px;
  font-size: 19px; line-height: 1.15; background: var(--amarelo);
}
.ts-comeco { grid-column: 3; grid-row: 3; font-size: 38px; }
.ts-travado button { opacity: 0.55; }

/* o quadro do fim, no lugar dos controles */
.ts-controles-fim { display: flex; flex-direction: column; justify-content: safe center; }
.ts-fim { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; background: rgba(255, 253, 247, 0.92); border-radius: var(--raio); }
.ts-turma { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: clamp(40px, 12vh, 90px); }
.ts-amigo { height: 100%; display: block; }
.ts-amigo img { height: 100%; width: auto; }
.ts-amigo-1 img { height: 70%; }
.ts-amigo { animation: ts-pula-amigo 0.6s ease-in-out 4 alternate; }
.ts-amigo-1 { animation-delay: 0.2s; }
.ts-amigo-2 { animation-delay: 0.4s; }
@keyframes ts-pula-amigo { to { transform: translateY(-14%); } }
.ts-fim-texto { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; font-size: 16px; line-height: 1.2; text-align: center; }
.ts-fim-texto strong { font-size: 18px; color: var(--azul); }
.ts-fim-botoes { display: flex; justify-content: center; gap: 6px; }
.ts-fim-botoes button { flex: 0 0 var(--alvo); }

/* ---------- telas estreitas: o menu cabe numa linha por parte ---------- */
@media (max-width: 780px) {
  .ts-menu { gap: 6px; }
  .ts-partes { flex-shrink: 0; }
  .ts-parte { gap: 6px; padding: 4px 6px; }
  .ts-parte-fases { gap: 4px; flex-wrap: nowrap; }
  .ts-parte-nome { flex-basis: 76px; }
}
@media (max-width: 680px) {
  .ts-partes { flex-shrink: 1; }
  .ts-parte-fases { flex-wrap: wrap; }
  .ts-parte-nome span { display: none; }
  .ts-torre-nova { --tn: 14px; padding: 4px; }
}

/* ---------- telas baixas (celular deitado dentro do navegador) ---------- */
@media (max-height: 460px) {
  .ts-fase-botao { font-size: 28px; }
  .ts-fim-texto { font-size: 14px; }
  .ts-fim-texto strong { font-size: 16px; }
  .ts-contador { font-size: 13px; }
}
