/* Mercader Errante — AO clásico + medieval Survivor, ventana tamaño fijo */

#survivor-merchant-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.72);
}

#survivor-merchant-overlay .sv-merch-window {
  box-sizing: border-box;
  width: min(780px, 96vw);
  height: min(620px, 92vh);
  min-height: min(620px, 92vh);
  max-height: min(620px, 92vh);
  display: flex;
  flex-direction: column;
  color: var(--text-primary, #e8dcc8);
  font-family: Tahoma, "Segoe UI", Verdana, sans-serif;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.045) 2px,
      rgba(0, 0, 0, 0.045) 3px
    ),
    linear-gradient(180deg, #1a1510 0%, #14100b 55%, #0f0c08 100%);
  border: 3px solid var(--border-copper, #8b5a2b);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px #3d2a14,
    0 0 0 2px rgba(197, 160, 89, 0.28),
    0 18px 42px rgba(0, 0, 0, 0.78),
    inset 0 0 36px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.sv-merch-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 52px;
  padding: 8px 44px 8px 14px;
  background: linear-gradient(180deg, #3a2e22 0%, #2a221a 48%, #1a1510 100%);
  border-bottom: 2px solid var(--border-copper, #8b5a2b);
  box-shadow: inset 0 1px 0 rgba(255, 220, 140, 0.1);
}

.sv-merch-titlebar-ornament {
  width: 22px;
  height: 2px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent, var(--border-gold, #c5a059), transparent);
}

.sv-merch-titlebar-text {
  text-align: center;
  min-width: 0;
}

.sv-merch-titlebar h2,
#sv-merchant-title {
  margin: 0;
  font-family: Cinzel, Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-gold, #ffcc00);
  text-shadow: 1px 1px 0 #000;
}

.sv-merch-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #b8a57a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-merch-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  background: linear-gradient(180deg, #6a2222, #3a1010);
  color: #ffd0d0;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.sv-merch-close:hover {
  border-color: var(--border-gold, #c5a059);
  filter: brightness(1.1);
}

.sv-merch-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 8px;
  align-items: center;
  flex-shrink: 0;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  padding: 0 12px;
  box-sizing: border-box;
  overflow: hidden;
  background: #120e0a;
  border-bottom: 1px solid #3d2e1e;
}

.sv-merch-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.sv-merch-filters button {
  background: linear-gradient(180deg, #2a2218, #1a1510);
  border: 1px solid var(--border-copper, #8b5a2b);
  color: #d4c4a0;
  border-radius: 3px;
  padding: 4px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.sv-merch-filters button.is-active {
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  border-color: var(--border-gold-bright, #ffd700);
  color: #1a1008;
  text-shadow: none;
}

.sv-merch-search {
  width: 140px;
  min-width: 110px;
  background: #0a0806;
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  color: #f2e6c9;
  padding: 5px 8px;
  font-size: 0.8rem;
}

.sv-merch-search:focus {
  outline: none;
  border-color: var(--border-gold, #c5a059);
}

.sv-merch-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 12px 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.sv-merch-panel {
  background: #0d0a08;
  border: 2px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55);
}

.sv-merch-panel-title {
  color: var(--text-gold, #ffcc00);
  font-weight: 800;
  font-size: 0.8rem;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #3d2e1e;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-shadow: 1px 1px 0 #000;
}

.sv-merch-panel-title::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 1px;
  flex-shrink: 0;
}

.sv-merch-panel--shop .sv-merch-panel-title::before {
  background: #4caf50;
  box-shadow: 0 0 4px rgba(76, 175, 80, 0.45);
}

.sv-merch-panel--inv .sv-merch-panel-title::before {
  background: #2196f3;
  box-shadow: 0 0 4px rgba(33, 150, 243, 0.45);
}

.sv-merch-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b8a57a;
  text-shadow: none;
}

/* Grillas de altura fija: scroll interno, no redimensionan la ventana */
.sv-merch-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: 52px;
  align-content: start;
  gap: 5px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: #8b5a2b #140c08;
}

.sv-merch-grid::-webkit-scrollbar {
  width: 10px;
}
.sv-merch-grid::-webkit-scrollbar-track {
  background: #140c08;
  border-left: 1px solid #3d2e1e;
}
.sv-merch-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  border: 1px solid #3d2a14;
  border-radius: 2px;
}

.sv-merch-slot {
  box-sizing: border-box;
  width: 100%;
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  aspect-ratio: unset;
  background: linear-gradient(180deg, #1a1510, #0d0a07);
  border: 2px solid #3a3228;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  transform: none;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.sv-merch-slot:hover {
  z-index: 2;
  border-color: var(--border-gold, #c5a059);
}

.sv-merch-slot.is-selected {
  border-color: var(--border-gold-bright, #ffd700) !important;
  z-index: 3;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.35), inset 0 0 8px rgba(0, 0, 0, 0.45);
}

.sv-slot-icon,
.sv-merch-icon {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px;
  max-height: 32px;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

.sv-merch-slot canvas.sv-slot-icon,
.sv-merch-slot img.sv-slot-icon,
.sv-merch-slot canvas.sv-merch-icon,
.sv-merch-slot img.sv-merch-icon {
  width: 32px !important;
  height: 32px !important;
}

.sv-merch-icon--empty,
.sv-slot-icon--empty {
  color: #555;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sv-merch-amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: #e8c86a;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000;
  pointer-events: none;
}

.sv-merch-slot.tier-border-1 {
  border-color: #8a8278;
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.3);
}
.sv-merch-slot.tier-border-2 {
  border-color: #4a8a4a;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.35), inset 0 0 0 1px rgba(76, 175, 80, 0.2);
}
.sv-merch-slot.tier-border-3 {
  border-color: #3a6a9a;
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.35), inset 0 0 0 1px rgba(33, 150, 243, 0.22);
}
.sv-merch-slot.tier-border-4 {
  border-color: #7a4a8a;
  box-shadow: 0 0 8px rgba(171, 71, 188, 0.35), inset 0 0 0 1px rgba(171, 71, 188, 0.25);
}
.sv-merch-slot.tier-border-5 {
  border-color: #c9a227;
  box-shadow: 0 0 10px rgba(255, 179, 0, 0.4), inset 0 0 0 1px rgba(255, 179, 0, 0.3);
}

.sv-merch-slot.tier-border-1:hover { border-color: #cfcfcf; }
.sv-merch-slot.tier-border-2:hover { border-color: #81c784; }
.sv-merch-slot.tier-border-3:hover { border-color: #64b5f6; }
.sv-merch-slot.tier-border-4:hover { border-color: #ce93d8; }
.sv-merch-slot.tier-border-5:hover { border-color: #ffd54f; }

.sv-merch-slot.tier-border-1.is-selected,
.sv-merch-slot.tier-border-2.is-selected,
.sv-merch-slot.tier-border-3.is-selected,
.sv-merch-slot.tier-border-4.is-selected,
.sv-merch-slot.tier-border-5.is-selected {
  border-color: var(--border-gold-bright, #ffd700) !important;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.4), inset 0 0 8px rgba(0, 0, 0, 0.45);
}

.sv-merch-slot.is-equipped::after {
  content: "E";
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 1;
  font-size: 9px;
  font-weight: 800;
  color: var(--text-gold, #ffcc00);
  text-shadow: 0 0 2px #000;
  pointer-events: none;
}

.sv-merch-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #88785a;
  font-size: 0.82rem;
  padding: 36px 10px;
  line-height: 1.4;
}

.sv-merch-detail {
  flex-shrink: 0;
  margin: 10px 12px 0;
  padding: 10px 12px;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  box-sizing: border-box;
  overflow: hidden;
  background: linear-gradient(180deg, #1a1510, #0d0a07);
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.sv-merch-detail-text {
  min-width: 0;
  flex: 1;
}

.sv-merch-item-name {
  font-weight: 800;
  color: #fff;
  font-size: 0.9rem;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-merch-item-stats {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #b8a57a;
  line-height: 1.35;
  height: 2.7em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sv-merch-price {
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
  flex-shrink: 0;
  text-shadow: 1px 1px 0 #000;
  padding-top: 2px;
}

.sv-merch-price.is-buy { color: var(--text-gold, #ffcc00); }
.sv-merch-price.is-sell { color: #81c784; }

.sv-merch-footer {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 12px;
  box-sizing: border-box;
  border-top: 2px solid var(--border-copper, #8b5a2b);
  margin-top: 10px;
  background: linear-gradient(180deg, #16120e, #100d09);
  overflow: hidden;
}

.sv-merch-gold {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-gold, #ffcc00);
  font-weight: 800;
  min-width: 72px;
  text-shadow: 1px 1px 0 #000;
}

.sv-merch-gold img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.sv-merch-qty {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #cbb892;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.sv-merch-qty input {
  width: 56px;
  background: #0a0806;
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  color: #fff;
  padding: 5px 6px;
  font-size: 0.8rem;
}

.sv-merch-qty input:focus {
  outline: none;
  border-color: var(--border-gold, #c5a059);
}

.sv-merch-hint {
  flex: 1;
  font-size: 0.72rem;
  color: #88785a;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-merch-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.sv-merch-btn {
  border: 2px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  padding: 8px 12px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  min-width: 88px;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.sv-merch-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.sv-merch-btn--buy {
  border-color: var(--border-gold-bright, #ffd700);
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  color: #1a1008;
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, 0.25);
}

.sv-merch-btn--sell {
  border-color: #5a9a5a;
  background: linear-gradient(180deg, #3d8b40, #2a5e2c);
  color: #e8ffe8;
  box-shadow: inset 0 1px 0 rgba(180, 255, 180, 0.15);
}

.sv-merch-btn--buy:not(:disabled):hover,
.sv-merch-btn--sell:not(:disabled):hover {
  filter: brightness(1.08);
}

@media (max-width: 720px) {
  #survivor-merchant-overlay .sv-merch-window {
    width: min(96vw, 780px);
    height: min(88vh, 620px);
    min-height: min(88vh, 620px);
    max-height: min(88vh, 620px);
  }

  .sv-merch-toolbar {
    height: 72px;
    min-height: 72px;
    max-height: 72px;
    flex-wrap: wrap;
    padding: 6px 10px;
  }

  .sv-merch-filters {
    flex-wrap: wrap;
    width: 100%;
  }

  .sv-merch-search {
    width: 100px;
    min-width: 90px;
  }

  .sv-merch-body {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sv-merch-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: 46px;
  }

  .sv-merch-slot {
    height: 46px;
    min-height: 46px;
    max-height: 46px;
  }

  .sv-merch-detail {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
  }

  .sv-merch-footer {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    flex-wrap: wrap;
    padding: 6px 10px;
  }

  .sv-merch-btn {
    min-width: 76px;
    padding: 7px 10px;
  }
}

/* ========== Herrería Survivor (Yunque + Banco) — AO clásico + medieval, tamaño fijo ========== */

#survivor-smith-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.72);
}

/* Ventana de altura/ancho fijos: no crece con ítems ni al cambiar tabs */
#survivor-smith-overlay .sv-smith-window {
  box-sizing: border-box;
  width: min(720px, 96vw);
  height: min(620px, 92vh);
  min-height: min(620px, 92vh);
  max-height: min(620px, 92vh);
  display: flex;
  flex-direction: column;
  color: var(--text-primary, #e8dcc8);
  font-family: Tahoma, "Segoe UI", Verdana, sans-serif;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.045) 2px,
      rgba(0, 0, 0, 0.045) 3px
    ),
    linear-gradient(180deg, #1a1510 0%, #14100b 55%, #0f0c08 100%);
  border: 3px solid var(--border-copper, #8b5a2b);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px #3d2a14,
    0 0 0 2px rgba(197, 160, 89, 0.28),
    0 18px 42px rgba(0, 0, 0, 0.78),
    inset 0 0 36px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.sv-smith-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 52px;
  padding: 8px 44px 8px 14px;
  background: linear-gradient(180deg, #3a2e22 0%, #2a221a 48%, #1a1510 100%);
  border-bottom: 2px solid var(--border-copper, #8b5a2b);
  box-shadow: inset 0 1px 0 rgba(255, 220, 140, 0.1);
}

.sv-smith-titlebar-ornament {
  width: 22px;
  height: 2px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent, var(--border-gold, #c5a059), transparent);
}

.sv-smith-titlebar-text {
  text-align: center;
  min-width: 0;
}

.sv-smith-titlebar h2,
#sv-smith-title {
  margin: 0;
  font-family: Cinzel, Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-gold, #ffcc00);
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #b8a57a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-smith-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  background: linear-gradient(180deg, #6a2222, #3a1010);
  color: #ffd0d0;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-close:hover {
  border-color: var(--border-gold, #c5a059);
  filter: brightness(1.1);
}

.sv-smith-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  padding: 0 12px;
  background: #0d0a08;
  border-bottom: 1px solid var(--border-copper, #8b5a2b);
}

.sv-smith-tabs button {
  flex: 1;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0;
  background: transparent;
  color: #a89878;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-tabs button.is-active {
  background: linear-gradient(180deg, rgba(197, 160, 89, 0.22), rgba(139, 90, 43, 0.12));
  border-color: var(--border-gold, #c5a059);
  border-bottom: 2px solid var(--text-gold, #ffcc00);
  color: var(--text-gold, #ffcc00);
  margin-bottom: -1px;
}

.sv-smith-tabs button:not(.is-active):hover {
  color: #e8dcc8;
  background: rgba(255, 255, 255, 0.03);
}

/* Toolbar: altura fija siempre (en Mejorar queda invisible pero ocupa espacio) */
.sv-smith-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px 8px;
  align-items: center;
  flex-shrink: 0;
  height: 46px;
  min-height: 46px;
  max-height: 46px;
  padding: 0 12px;
  box-sizing: border-box;
  overflow: hidden;
  background: #120e0a;
  border-bottom: 1px solid #3d2e1e;
}

.sv-smith-toolbar.is-inert {
  visibility: hidden;
  pointer-events: none;
}

.sv-smith-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.sv-smith-filters button {
  background: linear-gradient(180deg, #2a2218, #1a1510);
  border: 1px solid var(--border-copper, #8b5a2b);
  color: #d4c4a0;
  border-radius: 3px;
  padding: 4px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-filters button.is-active {
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  border-color: var(--border-gold-bright, #ffd700);
  color: #1a1008;
  text-shadow: none;
}

.sv-smith-search {
  width: 132px;
  min-width: 110px;
  background: #0a0806;
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  color: #f2e6c9;
  padding: 5px 8px;
  font-size: 0.8rem;
}

.sv-smith-search:focus {
  outline: none;
  border-color: var(--border-gold, #c5a059);
}

.sv-smith-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #b8a57a;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sv-smith-resources {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 16px;
  flex-shrink: 0;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0 12px;
  box-sizing: border-box;
  overflow: hidden;
  font-size: 0.8rem;
  color: #d4c4a0;
  background: #0d0a08;
  border-bottom: 1px solid #2a2218;
}

.sv-smith-res {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.sv-smith-res--gold img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}

.sv-smith-res b {
  color: var(--text-gold, #ffcc00);
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 12px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Grilla de altura fija: scroll interno, no redimensiona la ventana */
.sv-smith-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: 54px;
  align-content: start;
  gap: 6px;
  height: 100%;
  min-height: 216px; /* 4 filas */
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px;
  background: #0d0a08;
  border: 2px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55);
  scrollbar-width: thin;
  scrollbar-color: #8b5a2b #140c08;
}

.sv-smith-grid::-webkit-scrollbar {
  width: 10px;
}
.sv-smith-grid::-webkit-scrollbar-track {
  background: #140c08;
  border-left: 1px solid #3d2e1e;
}
.sv-smith-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  border: 1px solid #3d2a14;
  border-radius: 2px;
}

.sv-smith-slot {
  box-sizing: border-box;
  width: 100%;
  height: 54px;
  min-height: 54px;
  max-height: 54px;
  aspect-ratio: unset;
  background: linear-gradient(180deg, #1a1510, #0d0a07);
  border: 2px solid #3a3228;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  transform: none;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.sv-smith-slot:hover {
  z-index: 2;
  border-color: var(--border-gold, #c5a059);
}

.sv-smith-slot.is-selected {
  border-color: var(--border-gold-bright, #ffd700) !important;
  z-index: 3;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.35), inset 0 0 8px rgba(0, 0, 0, 0.45);
}

.sv-smith-slot.is-locked {
  opacity: 0.42;
}

.sv-smith-slot.is-maxed {
  border-color: #a070b0;
}

.sv-smith-slot.tier-border-1 {
  border-color: #8a8278;
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.3);
}
.sv-smith-slot.tier-border-2 {
  border-color: #4a8a4a;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.35), inset 0 0 0 1px rgba(76, 175, 80, 0.2);
}
.sv-smith-slot.tier-border-3 {
  border-color: #3a6a9a;
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.35), inset 0 0 0 1px rgba(33, 150, 243, 0.22);
}
.sv-smith-slot.tier-border-4 {
  border-color: #7a4a8a;
  box-shadow: 0 0 8px rgba(171, 71, 188, 0.35), inset 0 0 0 1px rgba(171, 71, 188, 0.25);
}
.sv-smith-slot.tier-border-5 {
  border-color: #c9a227;
  box-shadow: 0 0 10px rgba(255, 179, 0, 0.4), inset 0 0 0 1px rgba(255, 179, 0, 0.3);
}

.sv-slot-icon,
.sv-smith-icon {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px;
  max-height: 32px;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
  flex-shrink: 0;
}

.sv-smith-slot canvas.sv-slot-icon,
.sv-smith-slot img.sv-slot-icon,
.sv-smith-slot canvas.sv-smith-icon,
.sv-smith-slot img.sv-smith-icon {
  width: 32px !important;
  height: 32px !important;
}

.sv-smith-icon--empty,
.sv-slot-icon--empty {
  color: #555;
  font-size: 1.15rem;
}

.sv-smith-amt {
  position: absolute;
  right: 3px;
  bottom: 2px;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: #e8c86a;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000;
  pointer-events: none;
}

.sv-smith-empty {
  grid-column: 1 / -1;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #88785a;
  font-size: 0.82rem;
  padding: 24px 10px;
  line-height: 1.4;
}

/* Detalle: altura fija (barra de progreso reserva espacio aunque esté inert) */
.sv-smith-detail {
  flex-shrink: 0;
  margin: 10px 12px 0;
  padding: 10px 12px;
  height: 108px;
  min-height: 108px;
  max-height: 108px;
  box-sizing: border-box;
  overflow: hidden;
  background: linear-gradient(180deg, #1a1510, #0d0a07);
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 3px;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.4);
  text-align: left;
}

.sv-smith-item-name {
  font-weight: 800;
  color: #fff;
  font-size: 0.9rem;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-smith-item-stats {
  margin-top: 4px;
  font-size: 0.75rem;
  color: #b8a57a;
  line-height: 1.35;
  height: 2.7em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sv-smith-progress-wrap {
  margin-top: 8px;
  height: 28px;
  min-height: 28px;
}

.sv-smith-progress-wrap.is-inert {
  visibility: hidden;
  pointer-events: none;
}

.sv-smith-progress-track {
  height: 9px;
  background: #0a0806;
  border: 1px solid var(--border-copper, #8b5a2b);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.55);
}

.sv-smith-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b5a2b, #c5a059 55%, #ffd700);
  transition: width 0.2s ease;
}

.sv-smith-progress-label {
  margin-top: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #cbb892;
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-footer {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 12px;
  box-sizing: border-box;
  border-top: 2px solid var(--border-copper, #8b5a2b);
  margin-top: 10px;
  background: linear-gradient(180deg, #16120e, #100d09);
  overflow: hidden;
}

.sv-smith-cost {
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 110px;
  text-shadow: 1px 1px 0 #000;
}

.sv-smith-cost.is-ok { color: #81c784; }
.sv-smith-cost.is-bad { color: #ef5350; }

.sv-smith-hint {
  flex: 1;
  font-size: 0.72rem;
  color: #88785a;
  min-width: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-smith-btn {
  border: 2px solid var(--border-gold-bright, #ffd700);
  border-radius: 3px;
  padding: 9px 16px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  min-width: 108px;
  background: linear-gradient(180deg, #c5a059, #8b5a2b);
  color: #1a1008;
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, 0.25);
}

.sv-smith-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.sv-smith-btn:not(:disabled):hover {
  filter: brightness(1.08);
}

@media (max-width: 720px) {
  #survivor-smith-overlay .sv-smith-window {
    width: min(96vw, 720px);
    height: min(88vh, 620px);
    min-height: min(88vh, 620px);
    max-height: min(88vh, 620px);
  }

  .sv-smith-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 50px;
    min-height: 200px;
  }

  .sv-smith-slot {
    height: 50px;
    min-height: 50px;
    max-height: 50px;
  }

  .sv-smith-toolbar {
    height: 72px;
    min-height: 72px;
    max-height: 72px;
    flex-wrap: wrap;
    padding: 6px 10px;
  }

  .sv-smith-filters {
    flex-wrap: wrap;
    width: 100%;
  }

  .sv-smith-search {
    width: 100px;
    min-width: 90px;
  }

  .sv-smith-subtitle {
    white-space: nowrap;
  }

  .sv-smith-detail {
    height: 100px;
    min-height: 100px;
    max-height: 100px;
  }

  .sv-smith-footer {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    flex-wrap: wrap;
    padding: 6px 10px;
  }
}
