:root {
  --game-bg: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 50%, #ffcc80 100%);
  --slot-bg: #ffffff;
  --slot-border: #ff9800;
  --board-bg: #fff8e1;
  --board-shadow: 0 12px 32px rgba(230, 81, 0, 0.12);
}

.halves-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Sparkles & Confetti Container */
.particle-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.particle {
  position: absolute;
  font-size: 24px;
  pointer-events: none;
  animation: float-particle 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes float-particle {
  0% {
    transform: translate(0, 0) scale(0.6) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx, 0px), var(--ty, -80px)) scale(1.3) rotate(var(--rot, 30deg));
    opacity: 0;
  }
}

/* Puzzle Board / Top Frame */
.puzzle-board {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 220px;
}

.assembly-tray {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--board-bg);
  padding: 16px 20px;
  border-radius: 40px;
  border: 4px solid #ffe082;
  box-shadow: var(--board-shadow);
  transition: gap 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.assembly-tray.snap-together {
  gap: 0;
  border-color: #81c784;
}

.assembly-tray.snap-together .left-slot {
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.assembly-tray.snap-together .target-slot {
  border-left: none;
  border-style: solid;
  border-color: var(--slot-border);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: var(--slot-bg);
}

.puzzle-slot {
  width: 120px;
  height: 160px;
  background: var(--slot-bg);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.06);
}

.left-slot {
  border: 4px solid var(--slot-border);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

.target-slot {
  border: 4px dashed #ffb74d;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.target-slot.hover-near {
  background: #e8f5e9;
  border-color: #4caf50;
  border-style: solid;
  transform: scale(1.04);
}

.target-placeholder {
  font-size: 48px;
  font-weight: 900;
  color: #ffb74d;
  opacity: 0.7;
  animation: pulse-placeholder 2s infinite ease-in-out;
}

@keyframes pulse-placeholder {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.9; }
}

/* Half Icons */
.slot-icon,
.choice-icon {
  display: block;
  font-family: var(--font-emoji);
  font-size: 130px;
  line-height: 1;
  pointer-events: none;
}

.puzzle-slot .slot-icon {
  position: absolute;
  top: 50%;
}

.puzzle-slot .left-half-icon {
  right: 0;
  transform: translate(50%, -50%);
  clip-path: inset(0 50% 0 0);
}

.puzzle-slot .right-half-icon {
  left: 0;
  transform: translate(-50%, -50%);
  clip-path: inset(0 0 0 50%);
}

.choice-card .right-half-icon {
  clip-path: inset(0 0 0 50%);
  transform: translateX(-25%);
}

/* Solved Full Item Display */
.solved-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: pop-bounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.full-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.full-item-btn:hover,
.full-item-btn:active {
  transform: scale(1.15) rotate(5deg);
}

.full-item-btn:focus-visible {
  outline: 4px solid #ff9800;
  outline-offset: 4px;
}

.full-icon {
  font-size: 140px;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.18));
}

.item-title {
  font-size: 30px;
  font-weight: 800;
  color: #e65100;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 24px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(230, 81, 0, 0.1);
  margin-top: 10px;
}

.item-sound-text {
  font-size: 22px;
  font-weight: 700;
  color: #fb8c00;
  margin-top: 4px;
  min-height: 28px;
}

.next-btn {
  margin-top: 14px;
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
  color: #ffffff;
  border: 3px solid #a5d6a7;
  font-size: 22px;
  font-weight: 800;
  padding: 10px 36px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(46, 125, 50, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: pulse-next 1.6s infinite ease-in-out;
}

.next-btn:hover,
.next-btn:active {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(46, 125, 50, 0.4);
}

.next-btn:focus-visible {
  outline: 4px solid #ff9800;
  outline-offset: 4px;
}

@keyframes pulse-next {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes pop-bounce {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

/* Bottom choices section */
.choices-section {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-bottom: 8px;
}

.choices-tray {
  display: flex;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 380px;
}

.choice-card {
  flex: 1;
  max-width: 150px;
  height: 160px;
  background: #ffffff;
  border: 4px solid #ffb74d;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 152, 0, 0.15);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, border-color 0.2s;
  padding: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.choice-card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 12px 28px rgba(255, 152, 0, 0.25);
  border-color: #ffa726;
}

.choice-card:active {
  transform: scale(0.96);
}

.choice-card:focus-visible {
  outline: 4px solid #e65100;
  outline-offset: 4px;
}

.choice-icon {
  font-size: 130px;
  line-height: 1;
  pointer-events: none;
}

/* Dragging state */
.choice-card.is-dragging {
  opacity: 0.9;
  z-index: 100;
  cursor: grabbing;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  transition: none;
}

/* Friendly non-punitive wobble */
.choice-card.wobble {
  animation: friendly-wobble 0.5s ease-in-out;
}

@keyframes friendly-wobble {
  0% { transform: translateX(0); }
  20% { transform: translateX(-8px) rotate(-4deg); }
  40% { transform: translateX(8px) rotate(4deg); }
  60% { transform: translateX(-6px) rotate(-2deg); }
  80% { transform: translateX(4px) rotate(2deg); }
  100% { transform: translateX(0); }
}

/* Friendly guide pulse */
.choice-card.pulse-hint {
  animation: pulse-guide 0.8s 2 ease-in-out;
  border-color: #4caf50;
}

@keyframes pulse-guide {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 20px rgba(76, 175, 80, 0.2); }
  50% { transform: scale(1.08); box-shadow: 0 12px 28px rgba(76, 175, 80, 0.4); }
}

/* Flying match animation */
.flying-half {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.35s;
}

/* Responsiveness */
@media (max-height: 600px) {
  .assembly-tray { padding: 8px 14px; border-radius: 28px; }
  .puzzle-slot { width: 95px; height: 125px; border-radius: 20px; }
  .slot-icon, .choice-icon { font-size: 100px; }
  .choice-card { height: 125px; max-width: 125px; border-radius: 20px; }
  .full-icon { font-size: 105px; }
  .item-title { font-size: 24px; padding: 4px 18px; margin-top: 6px; }
  .item-sound-text { font-size: 18px; min-height: 22px; }
  .next-btn { font-size: 18px; padding: 6px 26px; margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .assembly-tray,
  .choice-card,
  .next-btn,
  .particle,
  .solved-card {
    animation: none !important;
    transition: none !important;
  }
}
