/* =========================
   VOCAB GAME: SHAPE MATCH
========================= */

.shape-match-game {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  font-family: "Fredoka", Arial, sans-serif;
  color: #000;
  overflow: hidden;
}

.shape-match-stage-wrap {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.shape-match-stage {
  height: 100%;
  min-height: 0;
  position: relative;
  border: 7px solid #000;
  border-radius: 26px;
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 79, 216, 0.25) 0 12%, transparent 13%),
    radial-gradient(circle at 86% 76%, rgba(211, 255, 0, 0.35) 0 16%, transparent 17%),
    #eaf8ff;
  box-shadow: inset -6px -6px 0 rgba(0,0,0,0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.shape-match-topline {
  flex: 0 0 auto;
  margin: 16px;
  padding: 12px 16px;
  border: 6px solid #000;
  border-radius: 18px;
  background: #fff0a8;
  box-shadow: 6px 6px 0 rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.shape-match-topline strong {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.shape-match-topline span {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  font-weight: 900;
}

.shape-match-next-btn {
  background: #23d8ff;
  font-size: 18px;
  white-space: nowrap;
}

.shape-match-workspace {
  flex: 1;
  min-height: 0;
  padding: 12px 22px 24px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.shape-match-drag-area,
.shape-match-slots-area {
  min-height: 0;
  border: 6px solid #000;
  border-radius: 24px;
  background: rgba(255,255,255,0.72);
  box-shadow: 8px 8px 0 rgba(0,0,0,0.22);
}

.shape-match-drag-area {
  height: min(520px, 100%);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.shape-match-slots-area {
  height: min(580px, 100%);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shape-match-label {
  align-self: flex-start;
  background: #ff7fcb;
  border: 5px solid #000;
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 17px;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.22);
}

.shape-drag-home {
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  border: 6px dashed #000;
  border-radius: 26px;
  background: #fff;
}

.shape-drag-item {
  width: 185px;
  height: 185px;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  cursor: grab;
  border-radius: 24px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.shape-drag-item:hover {
  transform: scale(1.05) rotate(-2deg);
}

.shape-drag-item.dragging {
  position: fixed !important;
  z-index: 99999 !important;
  pointer-events: none !important;
  cursor: grabbing;
  transform: scale(1.08) rotate(2deg) !important;
  filter: drop-shadow(10px 10px 0 rgba(0,0,0,0.28));
}

.shape-drag-item img,
.shape-match-silhouette,
.shape-match-placed-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.shape-match-word-pill,
.shape-match-target-name,
.shape-match-score {
  background: #d3ff00;
  border: 5px solid #000;
  border-radius: 16px;
  padding: 10px 14px;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.22);
}

.shape-match-slots {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 18px;
  align-items: center;
}

.shape-match-slot {
  height: min(340px, 44vh);
  min-height: 220px;
  border: 7px solid #000;
  border-radius: 26px;
  background: #fff;
  position: relative;
  display: grid;
  place-items: center;
  padding: 18px;
  box-shadow: 7px 8px 0 rgba(0,0,0,0.24);
  overflow: hidden;
}

.shape-match-slot::before {
  content: "DROP";
  position: absolute;
  left: 12px;
  top: 10px;
  background: #bff1ea;
  border: 4px solid #000;
  border-radius: 12px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 900;
  z-index: 2;
}

.shape-match-silhouette {
  width: 88%;
  height: 72%;
  filter: brightness(0) saturate(0);
  opacity: 0.25;
}

.shape-match-slot-name {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: #f7d3ff;
  border: 4px solid #000;
  border-radius: 14px;
  padding: 8px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  z-index: 3;
}

.shape-match-slot.correct {
  background: #d3ff00;
  animation: shapeCorrectPop 0.55s ease;
}

.shape-match-slot.correct::before {
  content: "CORRECT";
  background: #78ff4f;
}

.shape-match-slot.correct .shape-match-silhouette {
  opacity: 0.12;
}

.shape-match-placed-img {
  position: absolute;
  width: 72%;
  height: 68%;
  z-index: 2;
  filter: drop-shadow(6px 6px 0 rgba(0,0,0,0.25));
}

.shape-match-slot.wrong {
  background: #ff9b9b;
  animation: shapeWrongShake 0.38s linear;
}

.shape-match-side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.shape-match-card,
.shape-match-score-card {
  background: #bff1ea;
  border: 7px solid #000;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.25);
}

.shape-match-card h3,
.shape-match-score-card h3 {
  margin: 0 0 12px;
  font-size: 24px;
}

.shape-match-card p,
.shape-match-score-card p {
  margin: 12px 0 0;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.25;
}

.shape-match-score {
  font-size: 42px;
}

.shape-match-new-btn {
  margin-top: auto;
  background: #ff9b42;
  font-size: 20px;
  width: 100%;
}

.shape-match-celebration {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(430px, 80%);
  background: #fff0a8;
  border: 8px solid #000;
  border-radius: 26px;
  padding: 22px;
  text-align: center;
  box-shadow: 12px 12px 0 rgba(0,0,0,0.35);
  animation: celebrationPop 0.55s ease;
}

.shape-match-celebration h2 {
  margin: 8px 0;
  font-size: 40px;
}

.shape-match-celebration p {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
}

.shape-match-stars {
  font-size: 34px;
}

.shape-match-error-box {
  max-width: 560px;
  margin: 80px auto;
  background: #fff0a8;
  border: 7px solid #000;
  border-radius: 26px;
  padding: 28px;
  text-align: center;
  font-family: "Fredoka", Arial, sans-serif;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.25);
}

.shape-match-error-box h2 {
  font-size: 36px;
  margin-top: 0;
}

.shape-match-error-box p {
  font-size: 22px;
  font-weight: 800;
}

.shape-match-shake {
  animation: shapeWrongShake 0.38s linear;
}

@keyframes shapeCorrectPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06) rotate(2deg); }
  100% { transform: scale(1); }
}

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

@keyframes celebrationPop {
  0% { transform: translate(-50%, -50%) scale(0.6) rotate(-4deg); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
}

@media (max-width: 1000px) {
  .shape-match-game {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .shape-match-side-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    overflow: visible;
  }

  .shape-match-new-btn {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .shape-match-workspace {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .shape-match-slots {
    grid-template-columns: 1fr;
  }

  .shape-match-slot {
    min-height: 190px;
    height: 230px;
  }

  .shape-match-side-panel {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   FIX DRAG OFFSET
   Keeps the dragged picture under the cursor, even when UI Scale is not 100%.
========================================================= */

.shape-drag-item.dragging {
  position: fixed !important;
  z-index: 999999 !important;
  pointer-events: none !important;
  cursor: grabbing !important;

  /* No scale/rotate while dragging. This prevents visual cursor offset. */
  transform: none !important;

  filter: drop-shadow(10px 10px 0 rgba(0,0,0,0.28)) !important;
}

/* =========================================================
   FIX FROZEN DRAG IMAGE
   Prevents old dragged images from staying on screen after a lost pointer event.
========================================================= */

.shape-match-floating-drag {
  position: fixed !important;
  z-index: 999999 !important;
  pointer-events: none !important;
  margin: 0 !important;
  transform: none !important;
}

body > .shape-drag-item {
  position: fixed !important;
  z-index: 999999 !important;
}


/* =========================================================
   SHAPE MATCH TOP RESET BUTTON
   Removes bottom New Round button and places a reset icon next to Next Round.
========================================================= */

.shape-match-top-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  flex: 0 0 auto !important;
}

.shape-match-reset-btn {
  width: 54px !important;
  height: 54px !important;
  min-width: 54px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  background: #ff9b42 !important;
  border: 5px solid #000 !important;
  border-radius: 14px !important;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.25) !important;
  font-size: 30px !important;
  line-height: 1 !important;
  font-family: "Fredoka", Arial, sans-serif !important;
  font-weight: 900 !important;
}

.shape-match-next-btn {
  min-width: 170px !important;
  height: 54px !important;
  padding: 0 16px !important;
  display: grid !important;
  place-items: center !important;
}

/* In case an old bottom button still exists in cached HTML, hide it. */
.shape-match-side-panel > .shape-match-new-btn {
  display: none !important;
}

@media (max-width: 760px) {
  .shape-match-topline {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .shape-match-top-actions {
    justify-content: flex-start !important;
  }
}
