/* Shape Puzzle styles */

:root {
  --wood-light: #fef3c7;
  --wood-base: #fde68a;
  --wood-dark: #d97706;
  --wood-border: #b45309;
  --board-bg: #fffbeb;
  --slot-bg: rgba(217, 119, 6, 0.08);
  --slot-border: rgba(180, 83, 9, 0.35);
}

.puzzle-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1rem;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

/* Theme Navigation */
.theme-nav {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.65rem;
  width: 100%;
  max-width: 600px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.theme-tab-btn {
  flex: 1;
  min-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #78350f;
  background: #ffffff;
  border: 2px solid #fde68a;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.theme-tab-btn:hover {
  transform: translateY(-2px);
  background: #fef3c7;
}

.theme-tab-btn.active {
  background: #f59e0b;
  border-color: #b45309;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.theme-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Wooden Puzzle Board */
.board-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.puzzle-board {
  position: relative;
  width: 100%;
  height: 270px;
  background: radial-gradient(circle at 50% 40%, #fffdf5 0%, #fef3c7 70%, #fde68a 100%);
  border: 8px solid #b45309;
  border-radius: 1.75rem;
  box-shadow: inset 0 3px 8px rgba(120, 53, 15, 0.25), 0 8px 24px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
  overflow: hidden;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.puzzle-board.is-solved {
  border-color: #10b981;
  box-shadow: inset 0 3px 8px rgba(16, 185, 129, 0.2), 0 0 25px rgba(16, 185, 129, 0.45);
}

/* Silhouette Slots Layer */
.silhouette-layer {
  position: absolute;
  inset: 0;
  display: block;
}

/* Puzzle Slot on Board */
.puzzle-slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--slot-bg);
  border: 2px dashed var(--slot-border);
  border-radius: 1.25rem;
  box-sizing: border-box;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  cursor: pointer;
}

.puzzle-slot.highlight {
  background: rgba(245, 158, 11, 0.25);
  border-color: #f59e0b;
  transform: scale(1.06);
}

.puzzle-slot.wobble {
  animation: slot-wobble 0.4s ease-in-out;
  border-color: #ef4444;
}

@keyframes slot-wobble {
  0%, 100% { transform: scale(1) translateX(0); }
  25% { transform: scale(1.04) translateX(-6px); }
  75% { transform: scale(1.04) translateX(6px); }
}

.puzzle-slot.is-filled {
  border-style: solid;
  border-color: transparent;
  background: transparent;
}

.slot-ghost-icon {
  font-size: 2.4rem;
  line-height: 1;
  opacity: 0.32;
  filter: grayscale(1);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.puzzle-slot.is-filled .slot-ghost-icon {
  display: none;
}

.slot-filled-icon {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.2));
  animation: snap-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

@keyframes snap-pop {
  0% { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Lively animation when board is solved */
.puzzle-board.is-solved .slot-filled-icon {
  animation: lively-float 2.5s ease-in-out infinite alternate;
}

@keyframes lively-float {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.03); }
  100% { transform: translateY(2px) scale(0.99); }
}

/* Smoke puff for train, flames for rocket */
.live-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.steam-puff {
  position: absolute;
  font-size: 1.8rem;
  animation: puff-up 1.6s ease-out forwards;
}

@keyframes puff-up {
  0% { transform: translateY(0) scale(0.6); opacity: 0.9; }
  100% { transform: translateY(-70px) scale(1.6); opacity: 0; }
}

/* Action Controls Bar */
.action-bar {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 0.6rem 0;
  min-height: 48px;
}

.action-pill-btn {
  padding: 0.65rem 1.6rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: pop-btn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-pill-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.action-pill-btn:active {
  transform: translateY(1px) scale(0.98);
}

.again-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

@keyframes pop-btn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Wooden Tray for Pieces */
.tray-section {
  width: 100%;
  max-width: 540px;
  background: #ffffff;
  border: 3px solid #fde68a;
  border-radius: 1.25rem;
  padding: 0.6rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.pieces-tray {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  justify-items: center;
}

.piece-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
  background: radial-gradient(circle at 40% 30%, #fffbeb 0%, #fef3c7 80%, #fde68a 100%);
  border: 2px solid #d97706;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(180, 83, 9, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  min-height: 72px;
}

.piece-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 10px rgba(180, 83, 9, 0.25);
}

.piece-btn:active {
  transform: translateY(1px) scale(0.96);
}

.piece-btn.is-placed {
  opacity: 0.25;
  pointer-events: none;
  filter: grayscale(0.8);
}

.piece-btn.dragging {
  cursor: grabbing !important;
  opacity: 0.95;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
  transform: scale(1.15) rotate(2deg);
  pointer-events: none;
}

.piece-btn.selected {
  outline: 4px solid #f59e0b;
  outline-offset: 3px;
  transform: translateY(-5px) scale(1.06);
  box-shadow: 0 10px 20px rgba(245, 158, 11, 0.45);
}

.piece-btn.shake {
  animation: shake 0.4s ease-in-out;
  border-color: #ef4444;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.piece-icon {
  font-size: 2.1rem;
  line-height: 1.1;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15));
}

.piece-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #78350f;
  margin-top: 0.25rem;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Sparks & Confetti Layer */
.sparks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.sparkle {
  position: absolute;
  font-size: 1.5rem;
  animation: burst 0.85s ease-out forwards;
}

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

/* Responsive adjustments */
@media (max-width: 480px) {
  .puzzle-board {
    height: 240px;
  }
  .slot-ghost-icon {
    font-size: 1.9rem;
  }
  .slot-filled-icon {
    font-size: 2.5rem;
  }
  .piece-icon {
    font-size: 1.7rem;
  }
  .piece-name {
    font-size: 0.65rem;
  }
  .piece-btn {
    min-height: 60px;
    padding: 0.35rem 0.2rem;
  }
  .theme-tab-btn {
    min-width: 65px;
    padding: 0.35rem 0.4rem;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-board.is-solved .slot-filled-icon,
  .action-pill-btn,
  .steam-puff,
  .puzzle-slot.wobble,
  .piece-btn.shake {
    animation: none;
  }
}
