:root {
  --bg: #7ec8e3;
  --bg-deep: #4a90c4;
  --panel: #ffffffee;
  --accent: #4caf50;
  --accent-dark: #388e3c;
  --purple: #9c6ade;
  --yellow: #ffca28;
  --text: #2b2b2b;
  --card-bg: #ffffff;
  --card-border: #e0e0e0;
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
}

/* ---------- Top bar ---------- */

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}

.title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-emoji {
  font-size: 2.2rem;
}

.title h1 {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
  margin: 0;
}

.version-switch {
  display: flex;
  gap: 10px;
}

.version-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  background: #ffffffcc;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}

.version-btn:hover {
  transform: translateY(-2px);
}

.version-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.version-btn.active {
  background: var(--yellow);
  box-shadow: 0 3px 0 #c98f00;
}

.v-emoji {
  margin-right: 4px;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 18px 12px 4px;
}

.tab-btn {
  border: none;
  border-radius: 18px;
  padding: 14px 26px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  background: #ffffffaa;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.tab-btn:hover {
  transform: translateY(-2px);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-dark);
}

.tab-emoji {
  margin-right: 6px;
}

/* ---------- Layout ---------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px;
}

.panel.hidden {
  display: none;
}

.section-label {
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
  font-size: 1.3rem;
  margin: 24px 4px 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
}

.small-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

/* ---------- Cards (botões gigantes de imagem) ---------- */

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 4px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  min-height: 150px;
}

.card:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--yellow);
}

.card:active {
  transform: translateY(1px) scale(0.98);
}

.card.selected {
  border-color: var(--accent);
  box-shadow: 0 5px 0 var(--accent-dark);
}

.card.small {
  min-height: 110px;
  padding: 10px 8px;
}

.card-icon {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.small .card-icon {
  width: 64px;
  height: 64px;
}

.icon-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  image-rendering: pixelated;
}

.icon-wrap img {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
}

.icon-wrap.icon-fallback img {
  display: none;
}

.card-label {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  line-height: 1.15;
}

/* Efeitos divertidos nos ícones */

.fx-rainbow .icon-wrap img {
  animation: hueSpin 3s linear infinite;
}

@keyframes hueSpin {
  from { filter: hue-rotate(0deg) saturate(1.6); }
  to { filter: hue-rotate(360deg) saturate(1.6); }
}

.fx-invisible .icon-wrap {
  opacity: 0.35;
}

.fx-flip .icon-wrap img {
  transform: rotate(180deg);
}

/* Badge (pequeno ícone sobreposto no canto, ex: botão de pedra na cabeça) */

.badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 34px;
  height: 34px;
  background: #fff;
  border-radius: 50%;
  border: 3px solid var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.badge img {
  max-width: 80%;
  max-height: 80%;
  image-rendering: pixelated;
}

.badge-text {
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text);
}

/* Animação de "clicado" */

@keyframes bounceCard {
  0% { transform: scale(1); }
  35% { transform: scale(1.15) rotate(-2deg); }
  60% { transform: scale(0.95) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}

.card.bounce {
  animation: bounceCard 0.4s ease;
}

@keyframes shakeCard {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.card.shake {
  animation: shakeCard 0.4s ease;
}

/* Poderes (toggle) usam roxo pra ficar visualmente diferente da
   seleção verde de montaria/cavaleiro. */
.card.toggle.selected {
  border-color: var(--purple);
  box-shadow: 0 5px 0 #6b3fa0;
}

/* Cartão de comando que só existe numa versão específica do jogo */
.version-lock {
  font-size: 0.7rem;
  font-weight: 700;
  color: #b45309;
  background: #fff3cd;
  border-radius: 999px;
  padding: 2px 8px;
}

.card.locked {
  opacity: 0.4;
  filter: grayscale(0.6);
}

/* Aviso: comando grande demais pro chat (limite de 256 caracteres do
   Minecraft) — precisa ser colado dentro de um Bloco de Comando. */
.cmd-length-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  color: #7a3b00;
  background: #ffe0b2;
  border-radius: 999px;
  padding: 3px 8px 3px 4px;
  text-align: center;
}

.cmd-length-warning img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.cmd-length-warning.hidden-warning {
  display: none;
}

/* Cabeçalho de grupo (Mundo & Tempo, Poderes) */
.group-label {
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
  font-size: 1.2rem;
  margin: 26px 4px 12px;
}

.group-label:first-child {
  margin-top: 4px;
}

/* ---------- Fábrica de Monstros: resultado ---------- */

.stacker-result {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.stacker-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  min-height: 160px;
  min-width: 140px;
}

/* O Aldeão encadeia 4 peças (bioma + profissão + nível) — fica melhor em
   linha, quebrando conforme o espaço, do que empilhado verticalmente. */
#villager-preview {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 420px;
}

.stacker-preview .icon-wrap {
  width: 84px;
  height: 84px;
}

.stacker-preview.empty {
  opacity: 0.5;
}

.stacker-preview.empty::after {
  content: "Escolha os dois acima ☝️";
  font-weight: 700;
  color: #777;
}

#villager-preview.empty::after {
  content: "Escolha os três acima ☝️";
}

.stack-arrow {
  font-size: 1.6rem;
}

.big-copy-btn {
  border: none;
  border-radius: 999px;
  padding: 18px 34px;
  font-family: inherit;
  font-weight: 800;
  font-size: 1.3rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--accent-dark);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.big-copy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.big-copy-btn:not(:disabled):hover {
  transform: translateY(-2px);
}

.big-copy-btn:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--accent-dark);
}

/* ---------- Overlay de sucesso (substitui alert()) ---------- */

.success-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

.success-overlay.hidden {
  display: none;
}

.success-check {
  font-size: 5rem;
  color: var(--accent);
  background: #fff;
  border-radius: 50%;
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.particle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  animation: burst 0.8s ease-out forwards;
}

@keyframes burst {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

/* ---------- Responsividade ---------- */

@media (max-width: 480px) {
  .title h1 {
    font-size: 1.2rem;
  }
  .version-btn, .tab-btn {
    font-size: 0.85rem;
    padding: 10px 14px;
  }
  .card-icon {
    width: 68px;
    height: 68px;
  }
}
