/* ============================================
   LEVEL 3 — The Candy Village
   Styles for spot-the-difference, anagrams, recipe sequencing
   ============================================ */

/* ── SPOT THE DIFFERENCE ── */

#screen-spot-diff {
  /* position: absolute + inset: 0 inherited from .screen — fills viewport */
}

#screen-spot-diff .scene-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.spot-diff-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 0.5rem 0.5rem 0;
}

/* Tracker chip — small gold double-frame plaque */
.spot-diff-tracker {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.4vw, 0.65rem);
  color: #daba6a;
  background: rgba(12, 16, 22, 0.88);
  border: 2px solid #c5952e;
  box-shadow:
    inset 0 0 0 1px rgba(8, 10, 16, 0.8),
    inset 0 0 0 2px #8a6518,
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 6px rgba(160, 120, 40, 0.12);
  padding: 0.4em 1em;
  margin-bottom: 0.4rem;
  text-shadow: 0 0 8px rgba(218, 186, 106, 0.45);
}

.spot-diff-tracker .tracker-icon {
  margin-right: 0.3em;
}

.spot-diff-panels {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  width: 100%;
  max-height: calc(100% - 3rem);
  justify-content: center;
  align-items: center;
}

/* Shelf panels — framed like in-world gold picture frames */
.shelf-panel {
  position: relative;
  flex: 1;
  max-width: 48%;
  aspect-ratio: 1 / 1;
  border: 3px solid #c5952e;
  overflow: hidden;
  background: rgba(12, 16, 22, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(8, 10, 16, 0.8),
    inset 0 0 0 2px #8a6518,
    0 0 0 2px rgba(0, 0, 0, 0.7),
    0 0 10px rgba(160, 120, 40, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.4);
}

.shelf-bg-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.shelf-items {
  position: absolute;
  inset: 0;
}

.shelf-item {
  position: absolute;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  image-rendering: pixelated;
}

.shelf-item:hover {
  transform: scale(1.08);
  filter: brightness(1.2);
}

.diff-target {
  cursor: pointer;
}

.diff-found {
  filter: brightness(1.3) drop-shadow(0 0 6px #ffd700) !important;
  pointer-events: none;
}

.diff-sparkle {
  position: absolute;
  pointer-events: none;
  animation: sparkle-pop 1.5s ease-out forwards;
  z-index: 10;
  image-rendering: pixelated;
}

@keyframes sparkle-pop {
  0% { opacity: 0; transform: scale(0.5); }
  20% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.5); }
}


/* ── ANAGRAM PUZZLE ── */

#screen-anagram {
  /* position: absolute + inset: 0 inherited from .screen — fills viewport */
}

#screen-anagram .scene-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.anagram-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
}

.anagram-bowl-area {
  position: absolute;
  bottom: 4%;
  right: 4%;
  width: 18%;
  z-index: 2;
}

.anagram-bowl-area img {
  width: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

#anagram-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.anagram-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.3vw, 0.6rem);
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.anagram-slots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* Slots — recessed cuts in a wooden board */
.anagram-slot {
  width: clamp(36px, 8vw, 52px);
  height: clamp(42px, 9vw, 60px);
  border: 3px solid #5a3a1c;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(30, 18, 8, 0.92) 0%, rgba(46, 28, 12, 0.92) 100%);
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.65),
    inset 0 -1px 0 rgba(255, 220, 160, 0.08),
    0 1px 0 rgba(255, 220, 160, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  color: #f5e6c8;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.anagram-slot.filled {
  border-color: #daba6a;
  background: linear-gradient(180deg, rgba(74, 50, 20, 0.95) 0%, rgba(58, 38, 14, 0.95) 100%);
  color: #ffe79a;
  text-shadow: 0 0 8px rgba(218, 186, 106, 0.5);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.5),
    inset 0 0 10px rgba(218, 186, 106, 0.25);
}

.anagram-tiles {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Tiles — little wooden letter blocks with subtle grain.
   Press physics (translateY + scale) comes from the global .game-btn class;
   only colour/shadow/filter transitions here. */
.anagram-tile {
  width: clamp(36px, 8vw, 52px);
  height: clamp(42px, 9vw, 60px);
  border: 2px solid #a9743c;
  border-bottom-color: #4a2e12;
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255, 230, 190, 0.05) 0 2px,
      rgba(40, 22, 8, 0.06) 2px 5px
    ),
    linear-gradient(180deg, #8a5a2a 0%, #6a421e 100%);
  color: #f5e6c8;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 2.5vw, 1.1rem);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, box-shadow 0.15s, border-color 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.3),
    inset 0 0 0 1px rgba(40, 22, 8, 0.4),
    0 3px 0 #4a2e12,
    0 4px 8px rgba(0, 0, 0, 0.35);
  text-shadow: 0 2px 0 rgba(40, 22, 8, 0.7);
}

.anagram-tile:hover:not(.tile-used) {
  border-color: #daba6a;
  border-bottom-color: #4a2e12;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.4),
    inset 0 0 0 1px rgba(40, 22, 8, 0.4),
    0 3px 0 #4a2e12,
    0 0 10px rgba(255, 200, 110, 0.3),
    0 5px 10px rgba(0, 0, 0, 0.4);
}

.anagram-tile:active:not(.tile-used),
.anagram-tile.pressed:not(.tile-used) {
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.2),
    inset 0 0 0 1px rgba(40, 22, 8, 0.4),
    0 1px 0 #4a2e12,
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.anagram-tile.tile-used {
  opacity: 0.3;
  transform: scale(0.9);
  pointer-events: none;
}

.anagram-correct .anagram-slot {
  border-color: #58a248;
  color: #58a248;
  animation: slot-glow 0.6s ease;
}

@keyframes slot-glow {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50% { box-shadow: 0 0 15px rgba(88, 162, 72, 0.6); }
}

.ingredient-animation {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  max-width: 60%;
  image-rendering: pixelated;
  animation: ingredient-pop 1.2s ease forwards;
  z-index: 10;
  pointer-events: none;
}

@keyframes ingredient-pop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.5); opacity: 0; }
}


/* ── RECIPE SEQUENCING ── */

#screen-recipe-seq {
  /* position: absolute + inset: 0 inherited from .screen — fills viewport */
}

#screen-recipe-seq .scene-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.recipe-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 1rem 2rem;
  gap: 0.6rem;
}

#recipe-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
}

.recipe-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.4vw, 0.65rem);
  color: #ffd700;
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
  margin-top: 0.5rem;
}

/* ── Slots: compact numbered row across the top ── */

/* The slot list reads as a wooden recipe board hung in the bakery */
.recipe-slots {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  max-width: 680px;
  padding: 0.45rem 0.55rem;
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255, 230, 190, 0.04) 0 3px,
      rgba(30, 16, 6, 0.05) 3px 7px
    ),
    linear-gradient(180deg, rgba(96, 62, 30, 0.92) 0%, rgba(70, 44, 20, 0.92) 100%);
  border: 3px solid #c5952e;
  box-shadow:
    inset 0 0 0 1px rgba(8, 10, 16, 0.8),
    inset 0 0 0 2px #8a6518,
    0 0 0 2px rgba(0, 0, 0, 0.7),
    0 0 10px rgba(160, 120, 40, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Numbered card-holders — recessed cuts; cream dashes turn solid gold when filled */
.recipe-slot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(28, 16, 6, 0.7);
  border: 2px dashed rgba(245, 230, 200, 0.45);
  border-radius: 6px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55);
  padding: 0.35rem 0.7rem;
  min-height: clamp(28px, 4vh, 38px);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.recipe-slot:hover {
  border-color: rgba(218, 186, 106, 0.85);
}

.recipe-slot.slot-filled {
  border-style: solid;
  border-color: #daba6a;
  background: rgba(74, 50, 20, 0.75);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 0 10px rgba(218, 186, 106, 0.18);
}

.recipe-slot-number {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.3vw, 0.6rem);
  color: #daba6a;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
  min-width: 1.5em;
}

.recipe-card-holder {
  flex: 1;
}

.recipe-slot-card {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.35rem, 1vw, 0.45rem);
  color: #ffe0b0;
  line-height: 1.6;
}

.recipe-slot-card .first-letter {
  color: #ffd700;
  font-size: 1.3em;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}

/* ── Cards: large row across the bottom ── */

.recipe-cards-source {
  display: flex;
  gap: clamp(0.4rem, 1.5vw, 1rem);
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  flex: 1;
  padding: 0.5rem 0;
}

/* Cards — wooden recipe cards with grain and block depth.
   Press physics from .game-btn; only colour/shadow/filter transitions here. */
.recipe-card {
  width: clamp(100px, 16vw, 170px);
  cursor: pointer;
  border: 2px solid #a9743c;
  border-bottom-color: #4a2e12;
  border-radius: 8px;
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255, 230, 190, 0.04) 0 3px,
      rgba(30, 16, 6, 0.05) 3px 7px
    ),
    linear-gradient(180deg, #6e451f 0%, #532f12 100%);
  padding: 0.3rem;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s, filter 0.15s;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.18),
    inset 0 0 0 1px rgba(30, 16, 6, 0.4),
    0 3px 0 #3a2410,
    0 4px 8px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.recipe-card:hover:not(.card-placed) {
  border-color: #daba6a;
  border-bottom-color: #3a2410;
  filter: brightness(1.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.25),
    inset 0 0 0 1px rgba(30, 16, 6, 0.4),
    0 3px 0 #3a2410,
    0 0 14px rgba(255, 200, 110, 0.3),
    0 5px 10px rgba(0, 0, 0, 0.4);
}

.recipe-card.card-selected {
  border-color: #ffd700;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.25),
    inset 0 0 0 1px rgba(30, 16, 6, 0.4),
    0 3px 0 #3a2410,
    0 0 16px rgba(255, 215, 0, 0.6);
  transform: scale(1.06);
}

.recipe-card.card-placed {
  opacity: 0.3;
  pointer-events: none;
  transform: scale(0.9);
}

.recipe-card-img {
  width: 100%;
  border-radius: 5px;
  image-rendering: pixelated;
}

.recipe-card-label {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.45rem, 1.1vw, 0.65rem);
  color: #e8d4a8;
  text-shadow: 0 1px 0 rgba(30, 16, 6, 0.7);
  margin-top: 0.3rem;
  line-height: 1.5;
}

.recipe-card-label .first-letter {
  color: #ffd700;
  font-size: 1.4em;
}


/* ── BAKING ANIMATION ── */

.baking-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.baking-oven {
  text-align: center;
}

.oven-glow-img {
  max-width: 60%;
  max-height: 50vh;
  image-rendering: pixelated;
  animation: oven-pulse 1s ease-in-out infinite;
}

@keyframes oven-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

/* Layered glow frames: two stacked imgs crossfade via opacity instead of
   hard src swaps (which read as flicker) */
.oven-glow-stack {
  position: relative;
  display: inline-block;
}

.oven-glow-layer {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

/* Second layer sits on top of the first, which defines the stack's size */
.oven-glow-layer:nth-child(2) {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.oven-glow-layer.is-visible {
  opacity: 1;
}

.baking-text {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.5rem, 1.5vw, 0.7rem);
  color: #ffd700;
  margin-top: 1rem;
  animation: baking-dots 1.5s ease infinite;
}

@keyframes baking-dots {
  0%, 20% { opacity: 1; }
  50% { opacity: 0.4; }
  80%, 100% { opacity: 1; }
}

.cake-reveal {
  text-align: center;
  animation: cake-appear 0.8s ease forwards;
}

@keyframes cake-appear {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.celebration-cake-img {
  max-width: 70%;
  max-height: 60vh;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 16px rgba(255, 180, 50, 0.4));
}


/* ── SHARED ── */

.shake {
  animation: puzzle-shake 0.4s ease;
}

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