body.alchemy-active .main-view,
body.alchemy-active .main-actions {
  pointer-events: none;
}

.alchemy-layout {
  position: absolute;
  left: 0;
  right: var(--page-rail-space, 0px);
  top: var(--smithing-overlay-top, 0px);
  bottom: 0;
  z-index: 41;
  display: flex;
  margin-right: 0;
  background:
    linear-gradient(180deg, rgba(17, 33, 28, 0.94), rgba(11, 18, 20, 0.96)),
    rgba(0, 0, 0, 0.45);
  opacity: 1;
  transition: opacity 180ms ease-out;
  pointer-events: auto;
}

#alchemyView.hidden {
  display: none !important;
}

body:not(.alchemy-active) #alchemyView {
  opacity: 0;
  pointer-events: none;
}

.alchemy-panel {
  background: linear-gradient(180deg, #263f37 0%, #1e2d30 100%);
  border-color: #5e8d7b;
  box-shadow: inset 0 0 0 2px #142124;
}

.alchemy-panel h2,
.alchemy-panel h3 {
  color: #bff4d3;
}

.alchemy-card {
  background:
    radial-gradient(circle at 50% 0%, rgba(136, 239, 187, 0.14), transparent 34%),
    linear-gradient(180deg, #24423a 0%, #16282b 100%);
  border-color: #68a88f;
  box-shadow: inset 0 0 0 2px #102022;
  align-items: center;
}

.alchemy-card h1 {
  width: 100%;
  margin: 4px 0 12px;
  color: #d6ffe8;
  font-size: 20px;
}

.alchemy-card .pixel-btn {
  border-color: #73b99e;
  background: linear-gradient(180deg, #2f6858 0%, #1b3d42 100%);
  color: #eafff1;
  box-shadow: inset 0 0 0 2px #0d2427;
}

.alchemy-card .pixel-btn:hover {
  border-color: #c8ffde;
  background: linear-gradient(180deg, #3f806e 0%, #245259 100%);
}

.alchemy-card .pixel-btn:disabled {
  border-color: #4e756b;
  background: linear-gradient(180deg, #28483f 0%, #1a3033 100%);
  color: #8fb9a3;
  opacity: 0.62;
  filter: grayscale(0.35);
}

.alchemy-card .pixel-btn:disabled:hover {
  border-color: #4e756b;
  background: linear-gradient(180deg, #28483f 0%, #1a3033 100%);
}

.alchemy-unlock-box {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 2px dashed #79b79f;
  background: rgba(7, 20, 19, 0.55);
  padding: 8px;
  margin-bottom: 10px;
  color: #e7fff0;
}

.alchemy-unlock-box strong {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
}

.alchemy-unlock-box span {
  grid-column: 1 / -1;
  font-size: 22px;
  color: #c8efd9;
}

.alchemy-select-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.alchemy-select-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #d8ffe8;
  font-size: 10px;
}

.alchemy-recipe-select {
  width: 100%;
}

.alchemy-recipe-select .select-trigger {
  min-height: 42px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  font-size: 11px;
}

.alchemy-recipe-select .select-trigger img,
.alchemy-recipe-option img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  object-fit: contain;
}

.alchemy-recipe-menu {
  top: calc(100% + 6px);
  bottom: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border-color: #74b69b;
  background: #152b2d;
  box-shadow: inset 0 0 0 2px #0b1c1f;
  max-height: min(46vh, 360px);
}

.alchemy-recipe-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  border: 2px solid #3a7564;
  background: #1f423c;
  color: #e8fff2;
}

.alchemy-recipe-option:hover,
.alchemy-recipe-option.active {
  background: #2d6758;
  border-color: #ccffdf;
  color: #ffffff;
}

.alchemy-recipe-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alchemy-requirements {
  width: 100%;
  min-height: 54px;
  border: 2px dashed #79b79f;
  background: rgba(7, 20, 19, 0.55);
  color: #ddffea;
  padding: 8px;
  font-size: 22px;
}

.alchemy-craft-grid {
  position: relative;
  width: min(390px, 68vh, 100%);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  margin: 14px auto 10px;
}

.alchemy-craft-grid.crafting .alchemy-cell {
  pointer-events: none;
}

.alchemy-cell {
  position: relative;
  border: 3px solid #69a98e;
  background:
    linear-gradient(180deg, rgba(210, 255, 229, 0.08), rgba(0, 0, 0, 0.18)),
    #1c3a35;
  box-shadow: inset 0 0 0 2px #0e2022;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.alchemy-cell:hover,
.alchemy-cell.selected {
  border-color: #d8ffe8;
  background-color: #2b554b;
}

.alchemy-cell img {
  width: 74%;
  height: 74%;
  object-fit: contain;
  image-rendering: pixelated;
}

.alchemy-cell-amount {
  position: absolute;
  right: 4px;
  top: 4px;
  min-width: 22px;
  height: 22px;
  padding: 2px 4px;
  border: 2px solid #d8ffe8;
  background: rgba(7, 20, 19, 0.9);
  color: #f1fff6;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}

.alchemy-cell.empty::after {
  content: "";
  width: 20%;
  height: 20%;
  border: 2px solid #5f9b82;
  opacity: 0.75;
}

.alchemy-craft-ghost,
.alchemy-craft-result {
  position: fixed;
  width: 62px;
  height: 62px;
  object-fit: contain;
  image-rendering: pixelated;
  z-index: 160;
  pointer-events: none;
}

.alchemy-craft-result {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.2);
}

.alchemy-action-row {
  width: min(390px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.alchemy-action-row .pixel-btn {
  min-height: 42px;
}

.alchemy-event-feed {
  width: 100%;
  max-height: 132px;
  border-color: #5e9b82;
  background: rgba(6, 18, 17, 0.55);
  scrollbar-color: #9be6be #142527;
}

#alchemyItemRows .row {
  align-items: center;
}

.alchemy-locked .alchemy-select-row,
.alchemy-locked .alchemy-requirements,
.alchemy-locked .alchemy-craft-grid,
.alchemy-locked .alchemy-action-row {
  opacity: 0.42;
  pointer-events: none;
}

@media (max-width: 900px) {
  .alchemy-select-row {
    gap: 8px;
  }

  .alchemy-craft-grid {
    width: min(300px, 58vh, 100%);
    gap: 6px;
  }

  .alchemy-action-row {
    width: min(300px, 100%);
  }
}
