.alchemy-puzzle {
  box-sizing: border-box;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 12px;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  color: #f4e1b8;
  background:
    linear-gradient(180deg, rgba(12, 8, 4, .14) 0%, rgba(12, 8, 4, .3) 58%, rgba(9, 6, 3, .68) 100%),
    url("alchemy-background.jpg") center / cover no-repeat;
  box-shadow: none;
  font: 16px/1.4 "Segoe UI", Arial, sans-serif;
  scrollbar-width: none;
}
.alchemy-puzzle * { box-sizing: border-box; }
.alchemy-puzzle::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(5px); }
.alchemy-puzzle::-webkit-scrollbar { display: none; }
.alchemy-puzzle h2 { margin: 58px 42px 8px; font-size: clamp(18px, 2.2dvh, 24px); line-height: 1.15; text-align: center; }
.alchemy-puzzle > h2,
.alchemy-work > .alchemy-stage,
.alchemy-work > .alchemy-status {
  visibility: hidden;
}
.alchemy-close {
  position: absolute;
  right: 14px;
  top: 10px;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #f4e1b8;
  font: 30px Arial, sans-serif;
  cursor: pointer;
}
.alchemy-stage-one {
  display: grid;
  grid-template-columns: minmax(260px, .42fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: calc(100% - 94px);
  gap: clamp(18px, 3vw, 54px);
  align-items: center;
}
.alchemy-stage-one[hidden],
.alchemy-assembly[hidden] { display: none; }
.alchemy-scene {
  position: relative;
  display: grid;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  width: min(100%, calc(82dvh * 1.276));
  aspect-ratio: 1633 / 1280;
  min-height: 0;
  height: auto;
  max-height: 100%;
  place-items: center;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  transform: translateY(clamp(12px, 2dvh, 22px));
}
.alchemy-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 230, 130, .95), rgba(255, 112, 42, .45) 18%, transparent 38%);
}
.alchemy-scene.is-exploding::after {
  animation: alchemy-explosion .65s ease-out;
}
.alchemy-cabinet {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, .42));
  pointer-events: none;
}
.alchemy-shelves-panel {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 4;
  width: 100%;
  aspect-ratio: 1633 / 1280;
  display: none;
  pointer-events: none;
}
.alchemy-scene.is-open .alchemy-shelves-panel {
  display: block;
}
.alchemy-shelf {
  position: absolute;
  width: 21.5%;
  height: 21.5%;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #f5ddb0;
  font: 600 14px/1.2 Georgia, "Times New Roman", serif;
  text-align: center;
  text-shadow: 0 1px 3px #000;
  cursor: pointer;
  pointer-events: auto;
}
.alchemy-shelf:nth-child(1) { left: 14.5%; top: 42%; }
.alchemy-shelf:nth-child(2) { left: 40.5%; top: 42%; }
.alchemy-shelf:nth-child(3) { left: 65.4%; top: 42%; }
.alchemy-shelf:nth-child(4) { left: 14.5%; top: 68%; }
.alchemy-shelf:nth-child(5) { left: 40.5%; top: 68%; }
.alchemy-shelf:nth-child(6) { left: 65.4%; top: 68%; }
.alchemy-shelf-object {
  position: absolute;
  inset: -3% 12% 17%;
  display: block;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  filter: drop-shadow(0 7px 7px rgba(0, 0, 0, .48));
  pointer-events: none;
}
.alchemy-shelf-staged-jar {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 15%;
  width: 38%;
  height: 78%;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .58));
  pointer-events: none;
}
.alchemy-shelf b {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: -5%;
  display: grid;
  min-height: 17%;
  place-items: center;
  color: #3a2113;
  font-family: "Segoe Print", "Monotype Corsiva", cursive;
  font-size: clamp(10px, .9vw, 15px);
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 1px rgba(255, 241, 203, .68);
  pointer-events: none;
}
.alchemy-shelf-result {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4%;
  bottom: 15%;
  display: none;
  place-items: center;
  gap: 3px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #d7ff9d;
  font: 600 clamp(9px, .75vw, 12px)/1.15 "Segoe UI", Arial, sans-serif;
}
.alchemy-shelf-result img {
  display: block;
  width: 72%;
  height: 76%;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .62));
}
.alchemy-shelf.is-revealed .alchemy-shelf-object { display: none; }
.alchemy-shelf.is-revealed .alchemy-shelf-result { display: grid; }
.alchemy-shelf.is-collected .alchemy-shelf-result { display: none; }
.alchemy-shelf:disabled {
  cursor: default;
  opacity: 1;
}
.alchemy-work {
  display: grid;
  gap: 8px 12px;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: start;
  min-width: 0;
}
.alchemy-stage {
  grid-column: 1 / -1;
  margin: 0;
  color: #f3d99f;
  font-weight: 700;
}
.alchemy-notes-stack {
  position: relative;
  justify-self: center;
  width: min(100%, 420px);
  height: min(70dvh, 630px);
  isolation: isolate;
}
.alchemy-note-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: url("puzzle-cursor-hand-active.png") 15 15, pointer;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .42));
  transform-origin: center;
  transition: transform .72s cubic-bezier(.22, .8, .22, 1), opacity .42s ease, filter .42s ease;
}
.alchemy-note-stage-one {
  z-index: 2;
  transform: rotate(-2deg);
}
.alchemy-note-stage-two {
  z-index: 1;
  transform: translate(30px, 20px) rotate(3deg);
  filter: brightness(.72) drop-shadow(0 8px 10px rgba(0, 0, 0, .42));
  pointer-events: none;
}
.alchemy-notes-stack.is-stage-two .alchemy-note-stage-one {
  z-index: 1;
  transform: translate(-24px, 18px) rotate(-4deg);
  filter: brightness(.68) drop-shadow(0 8px 10px rgba(0, 0, 0, .42));
  pointer-events: none;
}
.alchemy-notes-stack.is-stage-two .alchemy-note-stage-two {
  z-index: 2;
  transform: translate(0, 0) rotate(-1.2deg);
  filter: drop-shadow(0 10px 13px rgba(0, 0, 0, .48));
  pointer-events: auto;
}
.alchemy-note-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.alchemy-collected-preview {
  position: relative;
  width: min(100%, 310px);
  height: 92px;
}
.alchemy-collected-preview[hidden] { display: none; }
.alchemy-collected-preview img {
  position: absolute;
  left: calc(var(--collected-index) * 38px);
  top: 4px;
  width: 82px;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .62));
  transform: rotate(var(--collected-angle));
}
.alchemy-note-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(5, 3, 1, .86);
}
.alchemy-note-view[hidden] { display: none; }
.alchemy-note-view img {
  display: block;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  object-fit: contain;
  filter: drop-shadow(0 20px 34px rgba(0, 0, 0, .68));
}
.alchemy-note-close {
  position: fixed;
  z-index: 51;
  top: 12px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: rgba(25, 16, 8, .82);
  color: #f4e1b8;
  font: 30px/1 Arial, sans-serif;
  cursor: pointer;
}
.alchemy-held-jar {
  position: fixed;
  z-index: 40;
  width: 58px;
  height: 126px;
  pointer-events: none;
  transform: translate(-50%, -72%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 10px 9px rgba(0, 0, 0, .62));
}
.alchemy-held-jar[hidden] { display: none; }
.alchemy-danger-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #fff;
  color: #17130e;
  transition: background-color .85s ease, color .85s ease;
  animation: alchemy-whiteout .5s ease-out both;
}
.alchemy-danger-overlay[hidden] { display: none; }
.alchemy-danger-overlay.is-dark {
  background: #050403;
  color: #d6c79a;
}
.alchemy-danger-content {
  display: grid;
  width: min(92vw, 760px);
  gap: 28px;
  justify-items: center;
  text-align: center;
}
.alchemy-danger-message {
  min-height: 4.6em;
  margin: 0;
  white-space: pre-line;
  font: 400 clamp(24px, 3vw, 44px)/1.45 Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}
.alchemy-danger-timer-panel {
  display: grid;
  min-width: min(92vw, 390px);
  gap: 16px;
  justify-items: center;
  padding: 26px 30px;
  border: 1px solid rgba(183, 157, 96, .42);
  background: rgba(25, 20, 12, .82);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .48);
}
.alchemy-danger-timer-panel[hidden] { display: none; }
.alchemy-danger-timer-label {
  margin: 0;
  color: #b79d60;
  font: 600 clamp(18px, 2vw, 25px)/1.25 "Segoe UI", Arial, sans-serif;
}
.alchemy-danger-time {
  display: block;
  color: #b79d60;
  font: 700 clamp(30px, 5vw, 64px)/1 "Segoe UI", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.alchemy-danger-continue {
  min-width: 180px;
  min-height: 48px;
  border: 1px solid #8f7947;
  background: #3b3020;
  color: #e1cd98;
  padding: 8px 20px;
  font: 600 17px "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}
.alchemy-danger-continue:disabled {
  opacity: .32;
  cursor: not-allowed;
}
.alchemy-assembly {
  display: grid;
  grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
  height: calc(100% - 94px);
  gap: clamp(20px, 4vw, 68px);
  align-items: center;
  max-width: 1320px;
  margin: 0 auto;
}
.alchemy-parts-area {
  display: grid;
  gap: 14px;
  align-content: center;
  min-width: 0;
}
.alchemy-parts-area > .alchemy-stage,
.alchemy-assembly-status {
  display: none !important;
}
.alchemy-piece-pile {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 430px;
  padding: 10px;
  align-content: center;
}
.alchemy-loose-part {
  position: relative;
  width: 100%;
  height: 132px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: url("puzzle-cursor-hand.png") 15 15, grab;
  transform: rotate(var(--pile-angle));
}
.alchemy-loose-part img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .58));
}
.alchemy-loose-part:hover {
  z-index: 3;
  transform: translateY(-5px) scale(1.06);
  filter: drop-shadow(0 0 12px rgba(255, 218, 126, .72));
}
.alchemy-assembly-status {
  min-height: 42px;
  margin: 0;
  color: #f3d99f;
}
.alchemy-board-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  justify-items: center;
  min-height: 0;
}
.alchemy-board {
  position: relative;
  width: min(72dvh, 62vw, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(25, 16, 8, .48);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .76), 0 16px 30px rgba(0, 0, 0, .42);
}
.alchemy-board-pieces {
  position: absolute;
  inset: 0;
}
.alchemy-free-part {
  position: absolute;
  width: 44%;
  height: 48%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: url("puzzle-cursor-hand.png") 15 15, grab;
  touch-action: none;
  transform: translate(-50%, -50%);
}
.alchemy-free-part img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .55));
  pointer-events: none;
}
.alchemy-loose-part,
.alchemy-free-part { touch-action: none; }
.alchemy-loose-part.is-dragging,
.alchemy-free-part.is-dragging {
  position: fixed !important;
  z-index: 100;
  width: var(--drag-width);
  height: var(--drag-height);
  transform: translate(-50%, -50%) !important;
  filter: drop-shadow(0 0 16px rgba(255, 218, 126, .76));
  cursor: url("puzzle-cursor-hand-closed.png") 15 15, grabbing;
}
.alchemy-code-form {
  display: grid;
  gap: 6px;
  justify-items: center;
  color: #f3d99f;
  font: 400 16px/1.35 Arial, Helvetica, sans-serif;
}
.alchemy-code-form[hidden] { display: none; }
.alchemy-code-form div { display: flex; gap: 8px; }
.alchemy-code-form input {
  width: min(42vw, 280px);
  height: 42px;
  border: 1px solid #9f7134;
  background: rgba(24, 15, 7, .88);
  color: #f4e1b8;
  padding: 6px 10px;
  font: 400 18px/1.2 Arial, Helvetica, sans-serif;
  text-align: center;
}
.alchemy-code-form button {
  min-height: 42px;
  border: 1px solid #9f7134;
  background: linear-gradient(145deg, #67512a, #2b2013);
  color: #f4e1b8;
  padding: 7px 14px;
  font: 600 16px/1.2 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.alchemy-jars {
  position: absolute;
  z-index: 3;
  top: 7%;
  left: 14%;
  right: 14%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(2px, .6vw, 10px);
  align-items: start;
}
.alchemy-jar {
  position: relative;
  justify-self: center;
  width: min(100%, 158px);
  aspect-ratio: 3 / 5;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  cursor: url("puzzle-cursor-hand.png") 15 15, grab;
}
.alchemy-jar:hover {
  cursor: url("puzzle-cursor-hand-active.png") 15 15, pointer;
}
.alchemy-jar.is-staged {
  visibility: hidden;
  pointer-events: none;
}
.alchemy-jar:active,
.alchemy-puzzle.is-dragging-jar,
.alchemy-puzzle.is-dragging-jar * {
  cursor: url("puzzle-cursor-hand-closed.png") 15 15, grabbing !important;
}
.alchemy-puzzle.has-selected-jar .alchemy-shelf:not(:disabled) {
  cursor: url("puzzle-cursor-hand-active.png") 15 15, pointer;
}
.alchemy-jar-image {
  position: absolute;
  z-index: 2;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: auto 100%;
  background-position: center bottom;
}
.alchemy-jar[data-jar="oil"] .alchemy-jar-image {
  background-size: auto 107%;
}
.alchemy-jar-place {
  position: absolute;
  z-index: 3;
  left: 6%;
  bottom: 4%;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226, 183, 96, .68);
  border-radius: 50%;
  background: rgba(18, 14, 9, .82);
  color: #f3d99f;
  font-weight: 700;
  font-size: 12px;
}
.alchemy-jar:hover,
.alchemy-action:hover { filter: brightness(1.12); }
.alchemy-jar[aria-pressed="true"] {
  filter: drop-shadow(0 0 18px rgba(199, 255, 114, .52));
}
.alchemy-action {
  grid-column: auto;
  justify-self: start;
  min-height: 38px;
  padding: 7px 15px;
  border: 1px solid #8c6a34;
  border-radius: 8px;
  background: linear-gradient(145deg, #67512a, #2b2013);
  color: #f4e1b8;
  font: inherit;
  cursor: pointer;
}
.alchemy-status {
  grid-column: auto;
  min-height: 28px;
  margin: 0;
  font-size: 14px;
  color: #d8c29b;
}
.alchemy-status.is-error { color: #ffb3a8; }
.alchemy-status.is-success { color: #d7ff9d; }
.alchemy-status.is-danger { color: #ffd36d; }
.alchemy-close:focus-visible,
.alchemy-note-preview:focus-visible,
.alchemy-note-close:focus-visible,
.alchemy-jar:focus-visible,
.alchemy-action:focus-visible,
.alchemy-shelf:focus-visible { outline: 2px solid #ffe1a1; outline-offset: 3px; }
@keyframes alchemy-explosion {
  0% { opacity: 0; transform: scale(.94); }
  25% { opacity: 1; transform: scale(1.01); }
  100% { opacity: 0; transform: scale(1.12); }
}
@keyframes alchemy-danger-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-14px, 8px) rotate(-.35deg); }
  20% { transform: translate(12px, -9px) rotate(.3deg); }
  30% { transform: translate(-10px, -6px) rotate(-.25deg); }
  40% { transform: translate(13px, 7px) rotate(.3deg); }
  50% { transform: translate(-9px, 5px) rotate(-.2deg); }
  60% { transform: translate(8px, -6px) rotate(.18deg); }
  70% { transform: translate(-6px, -4px); }
  80% { transform: translate(5px, 3px); }
  90% { transform: translate(-2px, 1px); }
}
@keyframes alchemy-whiteout {
  from { opacity: 0; }
  to { opacity: 1; }
}
.alchemy-puzzle.is-danger-shaking { animation: alchemy-danger-shake .72s linear; }
@media (prefers-reduced-motion: reduce) {
  .alchemy-puzzle.is-danger-shaking { animation: none; }
  .alchemy-danger-overlay { animation-duration: .01ms; }
}
@media (max-width: 760px) {
  .alchemy-puzzle { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .alchemy-stage-one {
    display: flex;
    flex-direction: column;
    height: calc(100% - 88px);
    gap: 0;
    align-items: center;
    justify-content: flex-start;
  }
  .alchemy-scene {
    flex: 0 0 auto;
    width: min(100%, calc(43dvh * 1.276));
    min-height: 0;
    margin-top: clamp(10px, 1.8dvh, 18px);
    transform: none;
  }
  .alchemy-work {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;
  }
  .alchemy-stage {
    align-self: flex-start;
  }
  .alchemy-action,
  .alchemy-status {
    align-self: center;
    text-align: center;
  }
  .alchemy-notes-stack {
    flex: 1 1 auto;
    width: min(calc(100vw - 46px), 400px);
    min-height: 220px;
    height: min(38dvh, 360px);
    max-height: min(38dvh, 360px);
  }
  .alchemy-note-stage-two { transform: translate(18px, 13px) rotate(2.4deg); }
  .alchemy-notes-stack.is-stage-two .alchemy-note-stage-one { transform: translate(-16px, 12px) rotate(-3deg); }
  .alchemy-collected-preview {
    flex: 0 0 auto;
    width: min(100%, 250px);
    height: 58px;
  }
  .alchemy-collected-preview img {
    left: calc(var(--collected-index) * 29px);
    width: 54px;
    height: 54px;
  }
  .alchemy-assembly {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 4px;
    align-items: start;
  }
  .alchemy-board-area { grid-row: 1; }
  .alchemy-board { width: min(58dvh, 94vw); }
  .alchemy-parts-area { grid-row: 2; gap: 3px; }
  .alchemy-parts-area .alchemy-stage { display: none; }
  .alchemy-piece-pile {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 78px;
    padding: 0;
    gap: 2px;
  }
  .alchemy-loose-part { height: 74px; }
  .alchemy-assembly-status { min-height: 30px; font-size: 12px; }
}
@media (max-width: 560px) {
  .alchemy-puzzle { padding: 8px; }
  .alchemy-puzzle h2 { margin: 52px 38px 6px; font-size: 18px; }
  .alchemy-stage-one { height: calc(100% - 80px); }
  .alchemy-stage { font-size: 14px; }
  .alchemy-scene { width: min(100%, calc(37dvh * 1.276)); }
  .alchemy-notes-stack {
    width: min(calc(100vw - 46px), 400px);
    min-height: 220px;
    height: min(37dvh, 350px);
    max-height: min(37dvh, 350px);
  }
  .alchemy-jars {
    left: 12%;
    right: 12%;
    gap: 2px;
  }
  .alchemy-action { min-height: 34px; padding: 6px 12px; font-size: 14px; }
  .alchemy-status { min-height: 22px; font-size: 12px; }
  .alchemy-shelf b { font-size: 9px; }
  .alchemy-shelf-result { font-size: 8px; }
}

/* Match the established puzzle cursors while keeping movable objects tactile. */
.alchemy-puzzle,
.alchemy-puzzle * { cursor: url("puzzle-cursor-magnifier.png") 8 8, auto; }
.alchemy-puzzle button:not(:disabled):hover { cursor: url("puzzle-cursor-magnifier-active.png") 12 12, pointer; }
.alchemy-note-preview:hover { cursor: url("puzzle-cursor-magnifier-active.png") 12 12, pointer !important; }
.alchemy-jar,
.alchemy-loose-part,
.alchemy-free-part { cursor: url("puzzle-cursor-hand.png") 15 15, grab !important; }
.alchemy-jar:hover { cursor: url("puzzle-cursor-hand.png") 15 15, grab !important; }
.alchemy-jar:active,
.alchemy-loose-part.is-dragging,
.alchemy-free-part.is-dragging { cursor: url("puzzle-cursor-hand-closed.png") 15 15, grabbing !important; }
