/* Botões, janelas de vitória e derrota, animações */

/* ---------- Botões ---------- */
.actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 22px; }

/* Ferramentas da partida (Dicas, Mostrar, Limpar): ícone num círculo e o nome embaixo */
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 64px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #fff4e6;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tool-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow), inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.1s;
}
.tool:active .tool-icon { transform: scale(0.93); }
.tool:focus-visible { outline: none; }
.tool:focus-visible .tool-icon { outline: 3px solid #ffe28a; outline-offset: 2px; }
.tool-icon .ico { width: 58%; height: 58%; }
.tool-icon .mark-cat { width: 72%; height: 72%; animation: none; }
.tool-label { font-size: 0.85rem; font-weight: 800; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.tool-cost.free { color: #8be59a; }
.tool-cost { margin-top: -4px; font-size: 0.72rem; font-weight: 700; color: #ff8a96; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.tool-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 0 0 2px var(--card);
}
.tool:disabled { cursor: not-allowed; opacity: 0.45; }
.tool:disabled:active .tool-icon { transform: none; }
.btn.small { padding: 7px 12px; font-size: 0.85rem; }

.btn {
  border: 0;
  font: inherit;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }

/* ---------- Vitória ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(122, 74, 79, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.overlay.show { opacity: 1; visibility: visible; }

.modal {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 340px;
  width: 100%;
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.overlay.show .modal { transform: scale(1); }
.modal-icon { font-size: 3.2rem; animation: celebrate 0.7s ease-in-out infinite alternate; }
.modal h2 { margin: 6px 0; }
.modal p { color: var(--muted); margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Animações ---------- */
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes appear { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10%); }
  75% { transform: translateX(10%); }
}
@keyframes wrong {
  0%, 100% { transform: translateX(0); box-shadow: none; }
  20% { transform: translateX(-8%); box-shadow: inset 0 0 0 100vmax rgba(214, 40, 57, 0.6); }
  40% { transform: translateX(8%); }
  60% { transform: translateX(-5%); box-shadow: inset 0 0 0 100vmax rgba(214, 40, 57, 0.4); }
  80% { transform: translateX(5%); }
}
@keyframes heart-break {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.5); color: #e0405a; }
}
@keyframes hint-pulse { from { transform: scale(0.85); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }
@keyframes reveal {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.95); }
  100% { box-shadow: 0 0 0 calc(var(--tile) * 0.5) rgba(255, 255, 255, 0); }
}
@keyframes celebrate { from { transform: translateY(0) scale(1); } to { transform: translateY(-8%) scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .actions .btn { padding: 10px 14px; font-size: 0.9rem; }
  .stats { gap: 16px; }
  .stat-label { font-size: 0.95rem; }
  .stat-value { font-size: 1.5rem; }
  .rule { flex-direction: column; text-align: center; gap: 4px; font-size: 0.68rem; padding: 6px 3px; }
  .mini { --m: 12px; }
}

/* Texto de ajuda conforme o dispositivo: mouse ou toque */
@media (pointer: coarse) { .hint-mouse { display: none; } }
@media (pointer: fine) { .hint-touch { display: none; } }

/* Cantos da partida: seta para voltar ao mapa e engrenagem das configurações.
   O botão de tema fica escondido aqui, pois o tema também está nas configurações. */
.game-back, .game-gear {
  position: fixed;
  z-index: 50;
  top: 12px;
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.game-back { left: 12px; }
.game-gear { right: 12px; }
.game-back:active, .game-gear:active { transform: scale(0.92); }
body[data-screen="game"] .game-back,
body[data-screen="game"] .game-gear { display: grid; }

/* Apoio nas fases difíceis (cheer.js): faixa escura atravessando o meio do tabuleiro, como no jogo de referência; não bloqueia toques */
.board-card { position: relative; }
.cheer {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 50%;
  padding: 12px 16px;
  background: rgba(36, 26, 30, 0.74);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translateY(-50%);
  animation: cheer-band 2.4s ease-in-out both;
}
.cheer b { color: #ffd23f; font-weight: 800; }
@keyframes cheer-band {
  0% { opacity: 0; }
  12%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Partida: sem rolagem e sem zoom (js/fit.js faz tudo caber na tela) */
html { touch-action: manipulation; }
html:has(body[data-screen="game"]) { overflow: hidden; overscroll-behavior: none; }
body[data-screen="game"] { position: fixed; inset: 0; width: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; }
body[data-screen="game"] #game { padding-bottom: 12px; }
#game.fit-no-hint .hint { display: none; }
#game.fit-no-rules .rules { display: none; }
