/* Estilos lúdicos infantis para "Encaixe as Formas" */
/* Importa fonte arredondada amigável */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

:root {
  --bg-sky-top: #74b9ff;
  --bg-sky-bottom: #a1e3f9;
  --surface-card: #ffffff;
  --text-main: #2d3436;
  --text-muted: #636e72;
  --color-primary: #ff4757;
  --color-secondary: #2e86de;
  --color-success: #10ac84;
  --color-warning: #ffa502;
  --color-purple: #9b59b6;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-chunky: 0 6px 0 rgba(0, 0, 0, 0.15);
  --shadow-piece: 0 8px 18px rgba(0, 0, 0, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-sky-top) 0%, var(--bg-sky-bottom) 55%, #b8e994 55%, #78e08f 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  color: var(--text-main);
}

/* Nuvens lúdicas em background */
.cloud-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 55%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 100px;
  filter: blur(1px);
  animation: floatCloud 45s linear infinite;
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 50%;
}

.cloud-1 {
  width: 140px;
  height: 45px;
  top: 15%;
  left: -150px;
}
.cloud-1::before {
  width: 55px;
  height: 55px;
  top: -24px;
  left: 20px;
}
.cloud-1::after {
  width: 75px;
  height: 75px;
  top: -36px;
  right: 25px;
}

.cloud-2 {
  width: 180px;
  height: 55px;
  top: 32%;
  left: -200px;
  animation-duration: 65s;
  animation-delay: -15s;
}
.cloud-2::before {
  width: 65px;
  height: 65px;
  top: -28px;
  left: 30px;
}
.cloud-2::after {
  width: 90px;
  height: 90px;
  top: -42px;
  right: 35px;
}

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 250px)); }
}

/* Container do Jogo */
.game-app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 20px;
}

/* Cabeçalho */
.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08), 0 3px 0 rgba(0, 0, 0, 0.06);
  border: 3px solid #ffffff;
  margin-bottom: 12px;
}

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

.logo-badge {
  background: linear-gradient(135deg, #ff9f43, #ee5253);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 0 #c23616;
}

.logo-badge svg {
  width: 28px;
  height: 28px;
}

.game-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #2f3542;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.game-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: #747d8c;
}

/* Placar de Progresso e Pontos */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.score-pill {
  background: #f1f2f6;
  border: 2px solid #dfe4ea;
  padding: 6px 14px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #2f3542;
}

.score-number {
  color: #ee5253;
  font-size: 1.15rem;
}

.stars-progress {
  display: flex;
  align-items: center;
  gap: 3px;
}

.star-icon {
  width: 24px;
  height: 24px;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star-icon.active {
  animation: starPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes starPop {
  0% { transform: scale(0.5); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* Botões de Ação do Topo */
.actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-chunky {
  appearance: none;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: all 0.1s ease-in-out;
  touch-action: manipulation;
}

.btn-chunky:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
}

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

.btn-sound, .btn-speech {
  background: #f1f2f6;
  color: #57606f;
  border: 2px solid #ced6e0;
}

.btn-sound.active, .btn-speech.active {
  background: #2ed573;
  color: #ffffff;
  border-color: #26af5f;
  box-shadow: 0 4px 0 #1b8a47;
}

.btn-restart {
  background: linear-gradient(135deg, #ff9f43, #ee5253);
  color: #ffffff;
  border: 2px solid #ff793f;
  box-shadow: 0 4px 0 #b33939;
}

/* Área Principal do Jogo */
.game-play-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  justify-content: space-around;
}

/* Faixa de Mensagem Encorajadora */
.banner-message {
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 100px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #3742fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 2px solid #ffffff;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.banner-message.highlight {
  background: #fff200;
  color: #2f3542;
  transform: scale(1.03);
}

/* Seção dos Espaços para Encaixar (Slots) */
.section-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
  border: 3px solid #ffffff;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #57606f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.slots-grid, .pieces-tray {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  align-items: center;
  justify-items: center;
}

/* Slot individual */
.shape-slot {
  width: 100%;
  max-width: 140px;
  aspect-ratio: 1;
  background: #f8f9fa;
  border-radius: var(--radius-md);
  border: 3px dashed #ced6e0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 8px;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.shape-slot .slot-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.shape-slot .slot-name {
  position: absolute;
  bottom: -10px;
  background: #ffffff;
  border: 2px solid #ced6e0;
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #57606f;
  text-transform: uppercase;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  pointer-events: none;
  transition: all 0.2s ease;
}

/* Hover e estados dos slots */
.shape-slot.drag-over {
  transform: scale(1.08);
  background: rgba(46, 213, 115, 0.12);
  border-color: #2ed573;
  border-style: solid;
  box-shadow: 0 0 20px rgba(46, 213, 115, 0.4);
}

.shape-slot.drag-wrong {
  animation: slotShake 0.4s ease-in-out;
  border-color: #ff4757;
}

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

.shape-slot.filled {
  border-style: solid;
  border-color: #2ed573;
  background: rgba(46, 213, 115, 0.08);
}

.shape-slot.filled .slot-name {
  background: #2ed573;
  color: #ffffff;
  border-color: #26af5f;
}

/* Check de acerto sobre o slot */
.slot-check-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 10;
  animation: badgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
  0% { transform: scale(0) rotate(-30deg); }
  70% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Bandeja de Peças (Área inferior onde ficam as peças soltas) */
.tray-card {
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), inset 0 2px 6px rgba(0, 0, 0, 0.04);
}

.tray-hint {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #747d8c;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Peças Arrastáveis */
.shape-piece-wrapper {
  width: 100%;
  max-width: 135px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.shape-piece {
  width: 100%;
  max-width: 130px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  position: relative;
  z-index: 2;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
}

.shape-piece:hover {
  transform: translateY(-4px) scale(1.05);
}

.shape-piece.selected {
  transform: scale(1.1);
  filter: drop-shadow(0 0 14px #ff9f43);
  animation: pulseSelect 1s infinite alternate;
}

@keyframes pulseSelect {
  0% { transform: scale(1.06); }
  100% { transform: scale(1.14); }
}

.shape-piece.dragging {
  cursor: grabbing;
  z-index: 999;
  transform: scale(1.15);
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.35));
  transition: none !important;
}

.shape-piece.snapping {
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.shape-piece.returning {
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.shape-piece.locked {
  cursor: default;
  pointer-events: none;
}

/* Animação comemorativa quando a forma encaixa */
.shape-piece.just-snapped {
  animation: pieceCelebrate 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pieceCelebrate {
  0% { transform: scale(1); }
  35% { transform: scale(1.22) rotate(-6deg); }
  65% { transform: scale(1.18) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Canvas dos Confetes */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2000;
}

/* Modal de Vitória */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(47, 53, 66, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.victory-card {
  background: #ffffff;
  border-radius: 32px;
  padding: 32px 28px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 6px solid #fffa65;
  transform: scale(0.8) translateY(30px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.modal-overlay.active .victory-card {
  transform: scale(1) translateY(0);
}

.trophy-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  animation: bounceTrophy 1.4s ease-in-out infinite alternate;
}

@keyframes bounceTrophy {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-12px) scale(1.08); }
}

.victory-title {
  font-size: 2rem;
  font-weight: 700;
  color: #ff4757;
  margin-bottom: 6px;
  line-height: 1.2;
}

.victory-subtitle {
  font-size: 1.15rem;
  color: #2f3542;
  font-weight: 600;
  margin-bottom: 18px;
}

.stars-celebration {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.stars-celebration .star-icon {
  width: 48px;
  height: 48px;
  animation: starDance 1.2s ease-in-out infinite alternate;
}

.stars-celebration .star-icon:nth-child(2) {
  animation-delay: 0.2s;
  transform: translateY(-8px);
}
.stars-celebration .star-icon:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes starDance {
  0% { transform: rotate(-8deg) scale(1); }
  100% { transform: rotate(8deg) scale(1.15); }
}

.victory-stats {
  background: #f1f2f6;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 24px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #57606f;
}

.victory-score {
  color: #2ed573;
  font-size: 1.6rem;
  display: block;
  margin-top: 4px;
}

.btn-play-again {
  background: linear-gradient(135deg, #2ed573, #10ac84);
  color: #ffffff;
  font-size: 1.25rem;
  padding: 14px 28px;
  border-radius: 100px;
  border: 3px solid #7bed9f;
  box-shadow: 0 8px 0 #009432, 0 12px 20px rgba(16, 172, 132, 0.35);
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.15s ease;
}

.btn-play-again:hover {
  transform: translateY(-3px);
  box-shadow: 0 11px 0 #009432, 0 16px 24px rgba(16, 172, 132, 0.4);
}

.btn-play-again:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #009432;
}

/* Responsividade */
@media (max-width: 768px) {
  .game-app {
    padding: 8px 10px 16px;
  }

  .game-header {
    padding: 8px 12px;
  }

  .game-title {
    font-size: 1.2rem;
  }

  .slots-grid, .pieces-tray {
    gap: 8px;
  }

  .shape-slot {
    padding: 4px;
  }

  .shape-slot .slot-name {
    font-size: 0.68rem;
    padding: 1px 6px;
    bottom: -8px;
  }

  .banner-message {
    font-size: 0.95rem;
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {
  /* No celular portrait pequeno, divide em 3 + 2 ou mantém flex adaptável */
  .slots-grid, .pieces-tray {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .score-pill {
    padding: 4px 8px;
    font-size: 0.85rem;
  }

  .game-header {
    justify-content: center;
  }

  .stats-bar {
    width: 100%;
    justify-content: space-between;
  }

  .actions-bar {
    width: 100%;
    justify-content: center;
  }
}
