body.page-swipe #gameFrame {
  animation: pageSwipe 180ms ease-out;
}

@keyframes pageSwipe {
  0% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
  }
}

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

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

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

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

.smith-panel {
  background: linear-gradient(180deg, #3d3d3d 0%, #2d2d2d 100%);
  border-color: #656565;
  box-shadow: inset 0 0 0 2px #222;
}

.smith-panel h2,
.smith-panel h3 {
  color: #e2e2e2;
}

.smithing-card {
  background: linear-gradient(180deg, #363636 0%, #252525 100%);
  border-color: #656565;
  box-shadow: inset 0 0 0 2px #1c1c1c;
  align-items: center;
}

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

.smithing-card .pixel-btn {
  border-color: #8a8a8a;
  background: linear-gradient(180deg, #3d3d3d 0%, #242424 100%);
  color: #f2f2f2;
  box-shadow: inset 0 0 0 2px #171717;
}

.smithing-card .pixel-btn:hover {
  border-color: #d6d6d6;
  background: linear-gradient(180deg, #505050 0%, #303030 100%);
}

.smithing-card .pixel-btn:disabled {
  border-color: #626262;
  background: linear-gradient(180deg, #2e2e2e 0%, #202020 100%);
  color: #9b9b9b;
  opacity: 0.62;
  filter: grayscale(0.35);
}

.smithing-card .pixel-btn:disabled:hover {
  border-color: #626262;
  background: linear-gradient(180deg, #2e2e2e 0%, #202020 100%);
}

.smith-unlock-box {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 2px dashed #777;
  background: rgba(12, 12, 12, 0.45);
  padding: 8px;
  margin-bottom: 10px;
  color: #e7e7e7;
}

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

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

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

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

.smith-select {
  width: 100%;
  min-height: 38px;
  border: 2px solid #777;
  background: #242424;
  color: #f1f1f1;
  padding: 8px;
  font-family: "VT323", monospace;
  font-size: 24px;
}

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

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

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

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

.smith-recipe-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  min-width: 0;
  border: 2px solid #4f4f4f;
  background: #2d2d2d;
  color: #eeeeee;
}

.smith-recipe-option:hover,
.smith-recipe-option.active {
  background: #464646;
  border-color: #cfcfcf;
  color: #ffffff;
}

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

.smith-requirements {
  width: 100%;
  min-height: 54px;
  border: 2px dashed #777;
  background: rgba(14, 14, 14, 0.5);
  color: #dddddd;
  padding: 8px;
  font-size: 22px;
}

.smith-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;
}

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

.smith-cell {
  position: relative;
  border: 3px solid #797979;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.16)),
    #292929;
  box-shadow: inset 0 0 0 2px #171717;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.smith-cell:hover,
.smith-cell.selected {
  border-color: #dddddd;
  background-color: #363636;
}

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

.smith-cell-amount {
  position: absolute;
  right: 4px;
  top: 4px;
  min-width: 22px;
  height: 22px;
  padding: 2px 4px;
  border: 2px solid #d2d2d2;
  background: rgba(18, 18, 18, 0.88);
  color: #f6f6f6;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}

.smith-cell.empty::after {
  content: "";
  width: 20%;
  height: 20%;
  border: 2px solid #666;
  opacity: 0.7;
}

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

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

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

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

.smith-event-feed {
  width: 100%;
  max-height: 132px;
  border-color: #686868;
  background: rgba(10, 10, 10, 0.48);
  scrollbar-color: #9a9a9a #222;
}

.smith-event-feed::-webkit-scrollbar-track {
  background: #222;
}

.smith-event-feed::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #bdbdbd 0%, #777 100%);
  border: 2px solid #222;
}

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

#smithWeaponRows .row.hidden {
  display: none !important;
}

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

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

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

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