
/* ---------- Candy Claw Arcade ---------- */
.mini-game-board.candy-claw {
  min-height: clamp(430px, 64vh, 690px);
  padding: 0;
  border-color: rgba(255, 138, 192, 0.52);
  background: #33204b;
}
.candy-claw-stage {
  position: relative;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, 1.5vw, 14px);
  width: 100%;
  min-height: inherit;
  padding: clamp(10px, 2vw, 20px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.45), transparent 22%),
    linear-gradient(180deg, #ffe7f3 0%, #dff8f0 46%, #f7d5ff 100%);
  outline: none;
  isolation: isolate;
  --claw-drop: 300px;
  --claw-cable: 312px;
}
.candy-claw-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 10%, transparent 10% 22%),
    radial-gradient(circle at 16% 18%, rgba(255, 216, 107, 0.48) 0 5px, transparent 6px),
    radial-gradient(circle at 84% 20%, rgba(123, 224, 200, 0.44) 0 5px, transparent 6px);
  background-size: 120px 100%, auto, auto;
  opacity: 0.55;
  pointer-events: none;
}
.candy-claw-machine,
.candy-claw-controls {
  position: relative;
  z-index: 1;
}
.candy-claw-machine {
  align-self: stretch;
  justify-self: center;
  width: min(100%, 980px);
  min-height: 360px;
  border: 5px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 16%),
    linear-gradient(90deg, #ff8ac0 0 13%, #fff3fb 13% 15%, #8ee4d3 15% 85%, #fff3fb 85% 87%, #ffd86b 87% 100%),
    linear-gradient(135deg, #ff8ac0, #8ee4d3 52%, #ffd86b);
  box-shadow:
    0 18px 34px rgba(86, 37, 77, 0.24),
    inset 0 0 0 8px rgba(255, 255, 255, 0.3),
    inset 0 -86px 0 rgba(115, 64, 132, 0.2);
  overflow: hidden;
}
.candy-claw-machine::before,
.candy-claw-machine::after {
  content: "";
  position: absolute;
  top: 84px;
  bottom: 74px;
  width: clamp(16px, 2.4vw, 28px);
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 12%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 50% 42%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 50% 72%, #fff 0 4px, transparent 5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 138, 192, 0.5));
  opacity: 0.78;
}
.candy-claw-machine::before {
  left: clamp(8px, 1.4vw, 16px);
}
.candy-claw-machine::after {
  right: clamp(8px, 1.4vw, 16px);
}
.candy-claw-marquee {
  position: absolute;
  left: clamp(58px, 9vw, 104px);
  right: clamp(58px, 9vw, 104px);
  top: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 50%, rgba(255, 216, 107, 0.86) 0 5px, transparent 6px),
    radial-gradient(circle at 80% 50%, rgba(255, 216, 107, 0.86) 0 5px, transparent 6px),
    linear-gradient(180deg, #fff9d9, #ffd2eb);
  color: #7a2260;
  box-shadow:
    0 6px 14px rgba(86, 37, 77, 0.16),
    inset 0 0 0 3px rgba(255, 255, 255, 0.48);
}
.candy-claw-marquee span {
  font:
    900 clamp(17px, 2vw, 24px) / 1 "Georgia",
    serif;
  letter-spacing: 0;
}
.candy-claw-window {
  position: absolute;
  inset: 70px clamp(84px, 12vw, 132px) 94px clamp(30px, 5vw, 64px);
  border: 5px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.62) 0 12%, transparent 13% 48%, rgba(255, 255, 255, 0.24) 49% 55%, transparent 56%),
    repeating-linear-gradient(0deg, transparent 0 72px, rgba(255, 216, 107, 0.22) 72px 76px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(215, 247, 255, 0.34)),
    #f8f6ff;
  box-shadow:
    0 0 0 6px rgba(103, 56, 128, 0.16),
    inset 0 -26px 36px rgba(116, 54, 120, 0.18),
    inset 0 0 0 8px rgba(255, 255, 255, 0.24);
  overflow: hidden;
}
.candy-claw-rail {
  position: absolute;
  left: clamp(48px, 7vw, 84px);
  right: clamp(118px, 16vw, 174px);
  top: 65px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe896, #ffffff, #8ee4d3);
  box-shadow: 0 4px 10px rgba(90, 44, 96, 0.24);
}
.candy-claw-arm {
  position: absolute;
  left: 50%;
  top: 63px;
  z-index: 6;
  width: 78px;
  height: 130px;
  transform: translateX(-50%);
  transition: left 0.16s ease;
  pointer-events: none;
}
.candy-claw-cable {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 6px;
  height: 78px;
  border-radius: 999px;
  background: linear-gradient(180deg, #faf7ff, #9b7cb8);
  transform: translateX(-50%);
  transition: height 0.24s ease;
}
.candy-claw-hand {
  position: absolute;
  left: 50%;
  top: 72px;
  width: 62px;
  height: 54px;
  transform: translateX(-50%);
  transition: top 0.24s ease;
}
.candy-claw-hand::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 34px;
  height: 24px;
  border-radius: 16px 16px 10px 10px;
  background: linear-gradient(180deg, #ffffff, #ffd86b);
  box-shadow: 0 4px 10px rgba(85, 42, 85, 0.22);
  transform: translateX(-50%);
}
.candy-claw-hand i {
  position: absolute;
  top: 21px;
  width: 8px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #eaa7cf);
  transform-origin: 50% 0;
}
.candy-claw-hand i:nth-child(1) {
  left: 15px;
  transform: rotate(30deg);
}
.candy-claw-hand i:nth-child(2) {
  left: 27px;
  height: 38px;
}
.candy-claw-hand i:nth-child(3) {
  right: 15px;
  transform: rotate(-30deg);
}
.candy-claw-stage.dropping .candy-claw-cable {
  height: var(--claw-cable);
}
.candy-claw-stage.dropping .candy-claw-hand {
  top: var(--claw-drop);
}
.candy-claw-stage.grabbing .candy-claw-hand i:nth-child(1) {
  transform: rotate(12deg);
}
.candy-claw-stage.grabbing .candy-claw-hand i:nth-child(3) {
  transform: rotate(-12deg);
}
.candy-claw-stage.lifting .candy-claw-cable {
  height: 92px;
  transition-duration: 0.5s;
}
.candy-claw-stage.lifting .candy-claw-hand {
  top: 88px;
  transition-duration: 0.5s;
}
.candy-claw-stage.slipping .candy-claw-cable {
  height: var(--claw-cable);
  transition-duration: 0.26s;
}
.candy-claw-stage.slipping .candy-claw-hand {
  top: var(--claw-drop);
  transition-duration: 0.26s;
}
.candy-claw-carried {
  position: absolute;
  left: 50%;
  top: calc(var(--claw-drop) + 46px);
  width: clamp(36px, 5.2vw, 54px);
  aspect-ratio: 3 / 4;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transform-origin: 50% 10%;
  transition:
    top 0.5s ease,
    opacity 0.14s ease,
    transform 0.24s ease;
  filter: drop-shadow(0 8px 10px rgba(61, 31, 69, 0.2));
}
.candy-claw-stage.grabbing .candy-claw-carried,
.candy-claw-stage.lifting .candy-claw-carried {
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.58);
}
.candy-claw-stage.lifting .candy-claw-carried {
  top: 136px;
}
.candy-claw-stage.slipping .candy-claw-carried {
  top: calc(var(--claw-drop) + 82px);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.64) rotate(8deg);
  transition:
    top 0.34s ease-in,
    opacity 0.3s ease-in,
    transform 0.34s ease-in;
}
.candy-claw-prizes {
  position: absolute;
  inset: 0;
}
.candy-claw-prize {
  position: absolute;
  width: clamp(58px, 7.6vw, 86px);
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 8px 10px rgba(61, 31, 69, 0.18));
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    filter 0.16s ease;
}
.candy-claw-prize:hover,
.candy-claw-prize:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
  filter:
    drop-shadow(0 10px 12px rgba(61, 31, 69, 0.22))
    drop-shadow(0 0 12px rgba(255, 216, 107, 0.42));
}
.candy-claw-prize:focus-visible {
  outline: 4px solid rgba(255, 216, 107, 0.95);
  outline-offset: 3px;
  border-radius: 14px;
}
.candy-claw-prize.selected {
  filter:
    drop-shadow(0 10px 12px rgba(61, 31, 69, 0.22))
    drop-shadow(0 0 16px rgba(255, 216, 107, 0.68));
}
.candy-claw-prize.aligned {
  filter:
    drop-shadow(0 10px 12px rgba(61, 31, 69, 0.2))
    drop-shadow(0 0 18px rgba(123, 224, 200, 0.82));
}
.candy-claw-prize.collected {
  opacity: 0;
  transform: translate(-50%, -70%) scale(0.34);
  pointer-events: none;
}
.candy-claw-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background-image: url("../../data/claw_game/prize-sprites.png");
  background-repeat: no-repeat;
  background-size: 400% 300%;
}
.candy-claw-chute {
  position: absolute;
  right: clamp(22px, 4vw, 48px);
  bottom: 96px;
  display: grid;
  place-items: center;
  width: clamp(68px, 9vw, 92px);
  height: clamp(84px, 14vw, 126px);
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 28%),
    linear-gradient(180deg, #fff8d7, #f1b6df);
  box-shadow:
    0 10px 18px rgba(73, 36, 82, 0.18),
    inset 0 0 0 5px rgba(122, 68, 129, 0.12);
}
.candy-claw-chute span {
  display: block;
  width: 42px;
  aspect-ratio: 3 / 4;
}
.candy-claw-stage.complete .candy-claw-chute {
  box-shadow:
    inset 0 0 0 4px rgba(122, 68, 129, 0.12),
    0 0 28px rgba(255, 216, 107, 0.78);
}
.candy-claw-panel {
  position: absolute;
  right: clamp(18px, 3.4vw, 44px);
  top: clamp(210px, 34%, 280px);
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: clamp(68px, 9vw, 96px);
  padding: 12px 10px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 229, 246, 0.88)),
    #ffe6f3;
  box-shadow:
    0 12px 24px rgba(73, 36, 82, 0.2),
    inset 0 0 0 4px rgba(122, 68, 129, 0.08);
}
.candy-claw-coin {
  grid-column: 1 / -1;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #694a72, #2f2140, #694a72);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.28);
}
.candy-claw-button {
  justify-self: center;
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.48),
    0 4px 8px rgba(73, 36, 82, 0.2);
}
.candy-claw-button.red {
  background: linear-gradient(180deg, #ff8ac0, #c53e8a);
}
.candy-claw-button.mint {
  background: linear-gradient(180deg, #8ee4d3, #359e92);
}
.candy-claw-proof {
  position: relative;
  z-index: 3;
  width: min(560px, calc(100% - 28px));
  margin: -6px auto 8px;
  display: grid;
  gap: 4px;
  padding: 9px 13px;
  border: 3px solid rgba(255, 216, 107, 0.58);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  color: #6b2247;
  text-align: center;
  font:
    900 13px/1.2 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  box-shadow: 0 12px 22px rgba(107, 34, 71, 0.14);
}
.candy-claw-proof b {
  color: #b03579;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.candy-claw-controls {
  justify-self: center;
  display: grid;
  grid-template-columns: 64px minmax(92px, 140px) 64px;
  gap: 10px;
  width: min(100%, 320px);
}
.candy-claw-controls button {
  min-height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #ffe4f2);
  color: #5b2b6d;
  font:
    900 18px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  letter-spacing: 0;
  box-shadow: 0 8px 16px rgba(74, 36, 87, 0.18);
  cursor: pointer;
}
.candy-claw-controls button:hover,
.candy-claw-controls button:focus-visible {
  border-color: #ffd86b;
  outline: none;
  transform: translateY(-1px);
}
.candy-claw-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 680px) {
  .mini-game-board.candy-claw {
    min-height: min(620px, calc(100vh - 170px));
  }
  .candy-claw-stage {
    padding: 8px;
  }
  .candy-claw-machine {
    min-height: 390px;
  }
  .candy-claw-window {
    inset: 66px 68px 82px 12px;
  }
  .candy-claw-marquee {
    left: 58px;
    right: 58px;
    top: 12px;
    height: 38px;
  }
  .candy-claw-rail {
    left: 32px;
    right: 76px;
    top: 60px;
  }
  .candy-claw-arm {
    top: 58px;
  }
  .candy-claw-prize {
    width: clamp(44px, 13.4vw, 58px);
  }
  .candy-claw-arm {
    width: 64px;
  }
  .candy-claw-stage.dropping .candy-claw-hand {
    top: var(--claw-drop);
  }
  .candy-claw-stage.dropping .candy-claw-cable {
    height: var(--claw-cable);
  }
  .candy-claw-panel {
    right: 12px;
    top: 214px;
    width: 42px;
    gap: 6px;
    padding: 8px 7px;
  }
  .candy-claw-button {
    width: 16px;
  }
  .candy-claw-chute {
    right: 12px;
    bottom: 86px;
    width: 50px;
    height: 76px;
  }
  .candy-claw-chute span {
    width: 34px;
  }
  .candy-claw-controls {
    grid-template-columns: 58px minmax(92px, 1fr) 58px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .candy-claw-arm,
  .candy-claw-cable,
  .candy-claw-hand,
  .candy-claw-prize,
  .candy-claw-controls button {
    transition: none;
  }
}

/* ---------- Castle Mystery Trail ---------- */
.mini-game-board.mystery-trail {
  display: block;
  min-height: clamp(560px, 74vh, 760px);
  padding: 0;
  border-color: rgba(77, 195, 255, 0.42);
  background: #17364b;
}
.mystery-trail-stage {
  position: relative;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: minmax(360px, 58%) minmax(0, 1fr);
  gap: clamp(8px, 1.5vw, 14px);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(10px, 2vw, 20px);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 216, 107, 0.42), transparent 20%),
    radial-gradient(circle at 82% 24%, rgba(123, 224, 200, 0.36), transparent 22%),
    linear-gradient(145deg, #dff8ff 0%, #fff8dc 46%, #ffe4f2 100%);
  isolation: isolate;
}
.mystery-trail-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(rgba(74, 24, 52, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 24, 52, 0.05) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: 0.5;
  pointer-events: none;
}
.mystery-scene {
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
  border: 3px solid rgba(74, 24, 52, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 250, 221, 0.08), rgba(48, 23, 58, 0.18)),
    url("../../data/mini_game_worlds/castle_mystery_trail_story.png") center / cover no-repeat,
    linear-gradient(180deg, rgba(198, 235, 255, 0.92) 0%, rgba(255, 244, 210, 0.94) 48%, rgba(213, 176, 130, 0.95) 100%);
  box-shadow: 0 16px 34px rgba(23, 54, 75, 0.14);
  outline: none;
}
.mystery-scene:focus-visible {
  box-shadow:
    0 0 0 4px rgba(123, 224, 200, 0.42),
    0 16px 34px rgba(23, 54, 75, 0.14);
}
.mystery-story-card {
  position: absolute;
  z-index: 7;
  top: 12px;
  left: 12px;
  box-sizing: border-box;
  display: grid;
  gap: 3px;
  width: min(330px, calc(100% - 24px));
  min-height: 92px;
  padding: 10px 12px;
  border: 3px solid rgba(255, 216, 107, 0.74);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #4a1834;
  box-shadow: 0 10px 22px rgba(74, 24, 52, 0.14);
}
.mystery-story-kicker {
  color: #8f2f68;
  font:
    900 10px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}
.mystery-story-card strong {
  font:
    900 clamp(14px, 1.7vw, 18px)/1.05 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-story-card em {
  color: #6b3552;
  font:
    800 clamp(12px, 1.3vw, 14px)/1.22 "Trebuchet MS",
    Arial,
    sans-serif;
  font-style: normal;
}
.mystery-castle-sky {
  position: absolute;
  inset: 0 0 44%;
  display: none;
  background:
    radial-gradient(circle at 16% 22%, rgba(255, 255, 255, 0.9) 0 22px, transparent 23px),
    radial-gradient(circle at 44% 18%, rgba(255, 255, 255, 0.72) 0 18px, transparent 19px),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.82) 0 24px, transparent 25px),
    linear-gradient(180deg, #beeaff 0%, #fff6d9 100%);
}
.mystery-castle-hall {
  position: absolute;
  inset: 25% 0 25%;
  display: none;
  background:
    repeating-linear-gradient(90deg, rgba(107, 34, 71, 0.1) 0 2px, transparent 2px 96px),
    linear-gradient(180deg, #f7d8b8 0%, #ffedf7 100%);
  border-top: 4px solid rgba(255, 255, 255, 0.72);
  border-bottom: 4px solid rgba(107, 34, 71, 0.14);
}
.mystery-arch {
  position: absolute;
  bottom: 0;
  width: 82px;
  height: 112px;
  translate: -50% 0;
  border: 5px solid rgba(107, 34, 71, 0.22);
  border-bottom: 0;
  border-radius: 44px 44px 0 0;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.64), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(123, 224, 200, 0.32));
}
.arch-kitchen {
  left: 22%;
}
.arch-library {
  left: 42%;
}
.arch-ballroom {
  left: 64%;
}
.arch-garden {
  left: 84%;
}
.mystery-path {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 10px;
  height: 58px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 10% 50%, rgba(255, 216, 107, 0.75) 0 7px, transparent 8px),
    radial-gradient(circle at 34% 48%, rgba(255, 216, 107, 0.75) 0 7px, transparent 8px),
    radial-gradient(circle at 58% 50%, rgba(255, 216, 107, 0.75) 0 7px, transparent 8px),
    radial-gradient(circle at 82% 48%, rgba(255, 216, 107, 0.75) 0 7px, transparent 8px),
    linear-gradient(180deg, rgba(166, 108, 68, 0.36), rgba(116, 74, 52, 0.22));
  filter: blur(0.1px);
}
.mystery-clue-stops {
  position: absolute;
  inset: 0;
}
.mystery-clue-stop {
  position: absolute;
  bottom: 44px;
  translate: -50% 0;
  display: grid;
  place-items: center;
  gap: 2px;
  min-width: 66px;
  min-height: 66px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #5b2142;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow:
    0 0 0 4px rgba(255, 216, 107, 0.32),
    0 9px 20px rgba(74, 24, 52, 0.18);
  animation: mystery-clue-glow 1.2s ease-in-out infinite alternate;
  scroll-margin-top: 240px;
}
.mystery-clue-stop span {
  display: grid;
  place-items: center;
  width: 34px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff8dc, #7be0c8);
  font-weight: 900;
}
.mystery-clue-stop em {
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6b3552;
  font:
    900 11px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  font-style: normal;
}
.mystery-clue-stop.visited {
  box-shadow:
    0 0 0 4px rgba(123, 224, 200, 0.32),
    0 9px 20px rgba(74, 24, 52, 0.14);
}
.mystery-clue-stop.selected {
  box-shadow:
    0 0 0 6px rgba(255, 216, 107, 0.36),
    0 0 26px rgba(255, 216, 107, 0.72),
    0 9px 20px rgba(74, 24, 52, 0.18);
}
.mystery-clue-stop.solved {
  opacity: 0.66;
  animation: none;
}
.mystery-doors {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.mystery-room-door {
  position: absolute;
  bottom: 84px;
  translate: -50% 0;
  display: grid;
  place-items: center;
  gap: 3px;
  width: clamp(76px, 8vw, 104px);
  min-height: 82px;
  padding: 8px;
  border: 3px solid rgba(255, 255, 255, 0.68);
  border-radius: 48px 48px 10px 10px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.76), transparent 26%),
    linear-gradient(180deg, rgba(80, 41, 93, 0.76), rgba(107, 34, 71, 0.56));
  color: #fff8dc;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  text-shadow: 0 2px 0 rgba(74, 24, 52, 0.34);
  box-shadow:
    inset 0 -9px 0 rgba(74, 24, 52, 0.16),
    0 10px 18px rgba(74, 24, 52, 0.18);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
  scroll-margin-top: 240px;
}
.mystery-room-door:hover,
.mystery-room-door:focus-visible {
  border-color: rgba(255, 216, 107, 0.92);
  box-shadow:
    inset 0 -9px 0 rgba(74, 24, 52, 0.16),
    0 0 0 5px rgba(255, 216, 107, 0.18),
    0 12px 22px rgba(74, 24, 52, 0.2);
  outline: none;
}
.mystery-room-door span {
  display: grid;
  place-items: center;
  width: 30px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 248, 220, 0.9);
  color: #6b2247;
  text-shadow: none;
  font-weight: 900;
}
.mystery-room-door strong {
  max-width: 86px;
  text-align: center;
  font:
    900 11px/1.05 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-room-door.matched {
  border-color: rgba(123, 224, 200, 0.94);
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.76), transparent 26%),
    linear-gradient(180deg, rgba(47, 118, 104, 0.76), rgba(66, 142, 128, 0.56));
}
.mystery-room-door.needs-helper {
  border-color: rgba(255, 138, 192, 0.94);
  animation: mystery-helper-pulse 0.42s ease;
}
.mystery-walk-controls {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 8px;
  translate: -50% 0;
  display: grid;
  grid-template-columns: 48px auto 48px;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 18px rgba(74, 24, 52, 0.16);
}
.mystery-walk-controls button {
  min-width: 48px;
  min-height: 44px;
  border: 2px solid rgba(107, 34, 71, 0.24);
  border-radius: 999px;
  background: rgba(255, 248, 220, 0.96);
  color: #6b2247;
  font:
    900 18px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.mystery-walk-controls .mystery-look {
  min-width: 74px;
  padding: 0 13px;
  font-size: 14px;
}
.mystery-prince {
  position: absolute;
  z-index: 6;
  left: 8%;
  bottom: 22px;
  width: clamp(78px, 9vw, 112px);
  height: clamp(104px, 12vw, 148px);
  translate: -50% 0;
  background: url("../../data/prince_rescue/human_prince_runtime.png") center bottom / contain no-repeat;
  filter:
    drop-shadow(0 9px 10px rgba(39, 29, 58, 0.26))
    drop-shadow(0 0 9px rgba(255, 238, 157, 0.22));
  transition: left 0.72s cubic-bezier(0.2, 0.72, 0.24, 1);
  pointer-events: none;
}
.mystery-prince.facing-left {
  scale: -1 1;
}
.mystery-prince.walking {
  animation: mystery-prince-walk 0.36s ease-in-out infinite alternate;
}
.mystery-speech {
  position: absolute;
  z-index: 8;
  left: 50% !important;
  bottom: clamp(126px, 17vw, 166px);
  box-sizing: border-box;
  width: min(380px, calc(100% - 34px));
  max-width: min(380px, calc(100% - 34px));
  min-height: 150px;
  padding: 10px 14px;
  border: 3px solid rgba(255, 216, 107, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #4a1834;
  font:
    900 clamp(13px, 1.6vw, 17px)/1.2 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  translate: -50% 6px;
  pointer-events: none;
  box-shadow: 0 12px 26px rgba(74, 24, 52, 0.16);
  transition:
    opacity 0.16s ease,
    left 0.72s cubic-bezier(0.2, 0.72, 0.24, 1),
    translate 0.16s ease;
}
.mystery-speech.show {
  opacity: 1;
  translate: -50% 0;
}
.mystery-speech::after {
  display: none;
}
.mystery-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.mystery-casebook {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(130px, 0.28fr) minmax(0, 1fr);
  gap: clamp(10px, 2vw, 18px);
  width: min(100%, 1040px);
  min-height: 0;
  margin: 0 auto;
}
.mystery-casebook-cover,
.mystery-casebook-pages {
  border: 3px solid rgba(74, 24, 52, 0.2);
  box-shadow: 0 18px 40px rgba(23, 54, 75, 0.16);
}
.mystery-casebook-cover {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  min-height: 100%;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(107, 34, 71, 0.95), rgba(56, 42, 88, 0.95)),
    linear-gradient(90deg, rgba(255, 216, 107, 0.28), transparent);
  color: #fff8dc;
  text-align: center;
}
.mystery-casebook-cover span {
  display: grid;
  place-items: center;
  width: 74px;
  aspect-ratio: 1;
  border: 3px solid rgba(255, 216, 107, 0.76);
  border-radius: 50%;
  font:
    900 42px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-casebook-cover strong {
  font:
    900 clamp(18px, 2.4vw, 30px)/1.05 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-casebook-pages {
  display: grid;
  grid-template-columns: minmax(230px, 0.78fr) minmax(260px, 1fr);
  gap: clamp(10px, 2vw, 18px);
  padding: clamp(10px, 2vw, 18px);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(74, 24, 52, 0.08) 0 2px, transparent 2px 50%),
    rgba(255, 255, 255, 0.88);
  min-height: 0;
}
.mystery-current-clue,
.mystery-notes {
  box-sizing: border-box;
  border: 3px solid rgba(123, 224, 200, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: #4a1834;
}
.mystery-current-clue {
  display: grid;
  align-content: center;
  gap: 7px;
  min-height: 116px;
  padding: 14px;
}
.mystery-current-clue strong {
  font:
    900 clamp(18px, 2.1vw, 28px)/1.04 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-current-clue em {
  color: #6b3552;
  font:
    800 14px/1.24 "Trebuchet MS",
    Arial,
    sans-serif;
  font-style: normal;
}
.mystery-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 116px;
  margin: 0;
  padding: 12px;
  list-style: none;
}
.mystery-notes li {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 8px 10px;
  border: 2px solid rgba(123, 224, 200, 0.42);
  border-radius: 8px;
  background: rgba(239, 255, 250, 0.9);
}
.mystery-notes strong {
  font:
    900 13px/1.05 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-notes span {
  color: #407065;
  font:
    800 12px/1.1 "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-clues,
.mystery-rooms {
  display: grid;
  gap: clamp(8px, 1.4vw, 12px);
}
.mystery-clues {
  grid-template-columns: 1fr;
  align-content: start;
}
.mystery-rooms {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mystery-clue-card,
.mystery-room-card {
  box-sizing: border-box;
  min-height: 104px;
  border: 3px solid rgba(176, 53, 121, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #4a1834;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}
.mystery-clue-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: 10px;
  padding: 12px;
}
.mystery-room-card {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  column-gap: 10px;
  row-gap: 5px;
  padding: 12px;
}
.mystery-clue-card:hover,
.mystery-clue-card:focus-visible,
.mystery-room-card:hover,
.mystery-room-card:focus-visible {
  border-color: rgba(77, 195, 255, 0.72);
  box-shadow: 0 10px 24px rgba(23, 54, 75, 0.14);
  transform: translateY(-2px);
  outline: none;
}
.mystery-clue-card.selected {
  border-color: rgba(255, 216, 107, 0.96);
  box-shadow:
    0 0 0 4px rgba(255, 216, 107, 0.24),
    0 12px 26px rgba(107, 34, 71, 0.16);
}
.mystery-clue-card.solved {
  opacity: 0.62;
  cursor: default;
  transform: none;
}
.mystery-room-card.matched {
  border-color: rgba(123, 224, 200, 0.9);
  background: rgba(239, 255, 250, 0.95);
}
.mystery-room-card.needs-helper {
  border-color: rgba(255, 138, 192, 0.9);
  animation: mystery-helper-pulse 0.42s ease;
}
.mystery-clue-icon,
.mystery-room-icon {
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.8), transparent 36%),
    linear-gradient(180deg, #ffd86b, #7be0c8);
  color: #5b2142;
  font:
    900 24px/1 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-clue-card strong,
.mystery-room-card strong {
  font:
    900 clamp(15px, 1.8vw, 20px)/1.08 "Arial Rounded MT Bold",
    "Trebuchet MS",
    Arial,
    sans-serif;
}
.mystery-clue-card em,
.mystery-room-card em {
  display: block;
  margin-top: 4px;
  color: #6b3552;
  font:
    800 13px/1.25 "Trebuchet MS",
    Arial,
    sans-serif;
  font-style: normal;
}
.mystery-room-slots {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin-top: 2px;
}
.mystery-room-slots span {
  display: grid;
  place-items: center;
  width: 28px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff8dc;
  color: #6b2247;
  border: 2px solid rgba(255, 216, 107, 0.78);
  font-weight: 900;
}
@keyframes mystery-helper-pulse {
  50% {
    transform: translateY(-2px) scale(1.02);
  }
}
@keyframes mystery-clue-glow {
  to {
    box-shadow:
      0 0 0 6px rgba(255, 216, 107, 0.18),
      0 0 24px rgba(255, 216, 107, 0.48),
      0 9px 20px rgba(74, 24, 52, 0.18);
  }
}
@keyframes mystery-prince-walk {
  to {
    translate: -50% -7px;
    rotate: 2deg;
  }
}
@media (max-width: 760px) {
  .mini-game-board.mystery-trail {
    min-height: min(720px, calc(100vh - 128px));
  }
  .mystery-trail-stage {
    grid-template-rows: 300px minmax(0, 1fr);
    padding: 8px;
  }
  .mystery-scene {
    min-height: 300px;
  }
  .mystery-story-card {
    display: none;
  }
  .mystery-clue-stop {
    bottom: 72px;
    min-width: 54px;
    min-height: 54px;
  }
  .mystery-clue-stop em {
    display: none;
  }
  .mystery-prince {
    bottom: 42px;
    width: 76px;
    height: 102px;
  }
  .mystery-room-door {
    bottom: 126px;
    width: 66px;
    min-height: 70px;
    padding: 6px;
  }
  .mystery-room-door span {
    width: 26px;
  }
  .mystery-room-door strong {
    display: none;
  }
  .mystery-walk-controls {
    bottom: 6px;
  }
  .mystery-speech {
    left: 50% !important;
    bottom: 98px;
    width: calc(100% - 22px);
    max-width: calc(100% - 22px);
    min-height: 66px;
    padding: 8px 10px;
    font-size: 12px;
    translate: -50% 6px;
  }
  .mystery-speech.show {
    translate: -50% 0;
  }
  .mystery-casebook {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
  }
  .mystery-casebook-cover {
    min-height: 78px;
    grid-template-columns: auto auto;
    place-content: center;
  }
  .mystery-casebook-cover span {
    width: 46px;
    font-size: 28px;
  }
  .mystery-casebook-pages {
    grid-template-columns: 1fr;
  }
  .mystery-current-clue,
  .mystery-notes {
    min-height: 84px;
  }
  .mystery-current-clue {
    padding: 10px;
  }
  .mystery-current-clue strong {
    font-size: 18px;
  }
  .mystery-current-clue em {
    font-size: 12px;
  }
  .mystery-notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }
}
@media (max-width: 430px) {
  .mystery-trail-stage {
    grid-template-rows: 292px minmax(0, 1fr);
  }
  .mystery-scene {
    min-height: 292px;
  }
  .mystery-castle-hall {
    inset: 24% 0 27%;
  }
  .mystery-arch {
    width: 58px;
    height: 88px;
  }
  .mystery-clue-stop {
    bottom: 68px;
    min-width: 46px;
    min-height: 46px;
    padding: 3px;
  }
  .mystery-clue-stop span {
    width: 30px;
  }
  .mystery-prince {
    bottom: 38px;
    width: 62px;
    height: 88px;
  }
  .mystery-room-door {
    bottom: 118px;
    width: 54px;
    min-height: 60px;
  }
  .mystery-speech {
    bottom: 92px;
    min-height: 58px;
    font-size: 11px;
    line-height: 1.16;
  }
  .mystery-walk-controls {
    grid-template-columns: 44px auto 44px;
  }
  .mystery-walk-controls button {
    min-width: 44px;
  }
  .mystery-walk-controls .mystery-look {
    min-width: 68px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mystery-clue-card,
  .mystery-room-card,
  .mystery-room-card.needs-helper,
  .mystery-room-door.needs-helper,
  .mystery-clue-stop,
  .mystery-prince.walking {
    animation: none;
    transition: none;
  }
}

/* ── Difficulty selector overlay ─────────────────────────────────────── */
.difficulty-selector-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 10, 40, 0.72);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.difficulty-selector-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.difficulty-selector-card {
  background: linear-gradient(160deg, #fff9fe 0%, #f0e8ff 100%);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(100, 0, 180, 0.28);
  padding: 28px 24px 20px;
  width: min(92vw, 380px);
  box-sizing: border-box;
  max-height: min(92dvh, 680px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.difficulty-selector-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #4a1880;
  text-align: center;
  margin: 0;
}
.difficulty-selector-note {
  margin: -8px 0 0;
  color: #6b477f;
  font: 700 0.88rem/1.3 "Trebuchet MS", Arial, sans-serif;
  text-align: center;
}
.difficulty-selector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.difficulty-tier-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  min-height: 72px;
  padding: 12px 16px;
  border: 2.5px solid transparent;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
  text-align: left;
}
.difficulty-tier-btn:hover,
.difficulty-tier-btn:focus-visible {
  border-color: var(--tier-color, #a78bfa);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  outline: none;
}
.difficulty-tier-btn.is-selected {
  border-color: var(--tier-color, #a78bfa);
  background: color-mix(in srgb, var(--tier-color, #a78bfa) 12%, #fff);
}
.difficulty-tier-emoji {
  grid-row: 1 / 3;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid color-mix(in srgb, var(--tier-color, #a78bfa) 55%, #fff);
  border-radius: 50%;
  background: color-mix(in srgb, var(--tier-color, #a78bfa) 13%, #fff);
  color: var(--tier-color, #a78bfa);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}
.difficulty-tier-label {
  font-weight: 700;
  font-size: 1rem;
  color: #2d1a5e;
}
.difficulty-tier-desc {
  font-size: 0.78rem;
  color: #6b5a8a;
}
.difficulty-selector-cancel {
  align-self: center;
  background: none;
  border: none;
  color: #9176b8;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
}
.difficulty-selector-cancel:hover {
  background: rgba(145, 118, 184, 0.12);
}

/* ── Difficulty badge (shown inside mini-game board) ─────────────────── */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--badge-color, #f5a623);
  background: color-mix(in srgb, var(--badge-color, #f5a623) 14%, #fff);
  border: 1.5px solid var(--badge-color, #f5a623);
  border-radius: 20px;
  padding: 2px 10px;
  margin: 4px auto 2px;
  pointer-events: none;
  user-select: none;
}
.mini-game-modal:has(.mini-game-board.tower-climb) .difficulty-badge {
  position: fixed;
  left: 50%;
  top: max(58px, calc(env(safe-area-inset-top) + 58px));
  z-index: 322;
  min-height: 32px;
  padding: 6px 12px;
  transform: translateX(-50%);
  box-sizing: border-box;
  box-shadow: 0 8px 18px rgba(44, 26, 58, 0.14);
  background: color-mix(in srgb, var(--badge-color, #f5a623) 14%, #fff);
}
@media (prefers-reduced-motion: reduce) {
  .difficulty-selector-overlay {
    transition: none;
  }
  .difficulty-tier-btn {
    transition: none;
  }
}
