* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3a2414; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #3b2a18;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
[hidden] { display: none !important; }

#palco { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#tela { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }

/* --- placar ---------------------------------------------------------------------------- */
#hud { position: absolute; left: 8px; right: 8px; top: 8px; display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.hud-esq { display: flex; gap: 6px; flex-wrap: wrap; }
.hud-caixa {
  display: flex; align-items: center; gap: 5px; padding: 3px 9px 3px 6px; min-height: 34px;
  background: rgba(255, 246, 220, 0.92); border: 2px solid #5b3a1c; border-radius: 12px;
}
.hud-caixa b { font-size: 17px; }
.hud-caixa i { font-style: normal; font-size: 17px; }
.hud-caixa i.moeda { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0 0 22%, #f6c33b 24%); border: 2px solid #a8741a; }
.hud-caixa.ganhou { animation: pulsa 0.6s ease-out; }
@keyframes pulsa { 40% { transform: scale(1.25); } }
#objetivo {
  flex: 1 1 auto; margin: 0 auto; max-width: 470px; text-align: center; align-self: center;
  background: rgba(255, 246, 220, 0.94); border: 2px solid #5b3a1c; border-radius: 12px;
  padding: 4px 10px; font-weight: bold; font-size: 15px; line-height: 1.25;
}
#objetivo:empty { visibility: hidden; }
.hud-botoes { display: flex; gap: 6px; pointer-events: auto; }
.hud-botao {
  width: 38px; height: 34px; font: inherit; font-size: 17px; font-weight: bold; color: #3b2a18; cursor: pointer;
  background: #ffe7a6; border: 2px solid #5b3a1c; border-radius: 10px; box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
.hud-botao.dentro { background: #8bd35a; }

/* --- andar pelo mercado (no celular) ---------------------------------------------------- */
.toque { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.toque .seta {
  pointer-events: auto; touch-action: none; width: 66px; height: 60px; font: inherit; font-size: 26px; font-weight: bold; color: #3b2a18; cursor: pointer;
  background: rgba(255, 246, 220, 0.82); border: 3px solid #5b3a1c; border-radius: 16px; box-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.toque .seta.apertado { transform: translateY(3px); box-shadow: none; filter: brightness(0.92); }
@media (pointer: fine) { .toque { display: none; } }
@media (pointer: coarse) { .dica-teclado { display: none; } }

/* --- painéis ------------------------------------------------------------------------- */
.painel {
  position: absolute; inset: 0; display: flex; padding: 14px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  background: rgba(58, 36, 20, 0.35);
}
#carregando { align-items: center; justify-content: center; color: #fff6dc; font-size: 20px; font-weight: bold; background: #3a2414; }
#titulo { background: linear-gradient(90deg, rgba(58, 36, 20, 0.55), rgba(58, 36, 20, 0) 72%); }
.cartao {
  margin: auto; min-width: 0; max-width: 430px; width: 100%; text-align: center;
  background: #fff6dc; border: 4px solid #5b3a1c; border-radius: 20px; padding: 16px 18px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}
#titulo .cartao { margin-left: max(14px, 6vw); }
.cartao.pequeno { max-width: 370px; }
.cartao h1 { margin: 0; font-size: 32px; color: #a8401c; letter-spacing: 1px; text-shadow: 0 2px 0 #f2c14e; }
.cartao h2 { margin: 0 0 6px; font-size: 22px; color: #a8401c; }
.cartao .sobre { margin: 0; font-size: 12px; font-weight: bold; letter-spacing: 2px; text-transform: uppercase; color: #8a6a3c; }
.cartao .historia { margin: 6px 0 10px; font-size: 15px; line-height: 1.35; }
.cartao .explica { margin: 6px 0; font-size: 14px; line-height: 1.35; color: #5a4630; }
.cartao .resumo { margin: 6px 0; font-size: 14px; font-weight: bold; color: #4f7a2a; }
.fases, .niveis { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.fases { display: grid; grid-template-columns: 1fr 1fr; }
.fases button:last-child:nth-child(odd) { grid-column: span 2; }
.fases button, .niveis button {
  flex: 1 1 0; min-width: 0; font: inherit; font-size: 14px; font-weight: bold; color: #4a3218; cursor: pointer;
  background: #fff6dc; border: 3px solid #c9b088; border-radius: 12px; padding: 6px 4px;
}
.fases button b { display: block; font-size: 18px; color: #a8401c; }
.niveis button span { display: block; color: #e3a21a; font-size: 13px; letter-spacing: 1px; }
.fases button[aria-pressed="true"], .niveis button[aria-pressed="true"] { background: #8bd35a; border-color: #3f7a26; }
.fases button:disabled { opacity: 0.5; cursor: default; }
.fases button .cadeado { display: block; font-size: 12px; font-weight: normal; }
.partida { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.cartao button.principal, .cartao .botoes button, .cartao .icone {
  font: inherit; font-weight: bold; font-size: 18px; color: #3b2a18; cursor: pointer;
  background: #ffe7a6; border: 3px solid #5b3a1c; border-radius: 14px; padding: 9px 18px; box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}
.cartao button.principal { background: #8bd35a; font-size: 20px; padding: 10px 22px; }
.cartao .icone { padding: 6px 12px; font-size: 20px; min-width: 50px; }
.cartao .icone.dentro { background: #8bd35a; }
.cartao .botoes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cartao button:active { transform: translateY(2px); }

/* o fim */
#final { background: rgba(58, 36, 20, 0.55); }
.cartao.final { max-width: 520px; }
#final-cena { width: 100%; height: auto; border-radius: 12px; border: 3px solid #5b3a1c; display: block; }

/* telas bem estreitas (o iframe da Sessão num celular em pé) ou baixas (o celular deitado) */
@media (max-width: 420px), (max-height: 420px) {
  .cartao { padding: 10px 12px; border-width: 3px; }
  .cartao h1 { font-size: 25px; }
  .cartao .historia { font-size: 13px; margin: 4px 0 6px; }
  .fases button, .niveis button { font-size: 12px; padding: 4px 2px; }
  .cartao button.principal { font-size: 17px; padding: 8px 16px; }
  #objetivo { font-size: 12px; padding: 3px 6px; }
  .hud-caixa { min-height: 28px; padding: 2px 6px 2px 4px; }
  .hud-caixa b { font-size: 14px; }
  .hud-caixa i.moeda { width: 16px; height: 16px; }
  .hud-botao { width: 32px; height: 28px; font-size: 14px; }
}
@media (max-height: 420px) {
  .cartao.final { max-width: 640px; }
  #final-cena { max-height: 34vh; width: auto; margin: 0 auto; }
}
@media (max-width: 340px) {
  #titulo .cartao { margin-left: auto; }
  .painel { padding: 8px; }
  .partida { flex-wrap: wrap; }
  .cartao button.principal { flex: 1 1 100%; }
  .cartao .icone { flex: 1 1 0; }
  .cartao h1 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-caixa.ganhou { animation: none; }
}
