/* ── 마을 대장장이(v5.0, SM-1): 같은 등급 장비 5개 → 한 단계 위 등급. 배경은 대장간 그림(assets/smith/forge.webp) ──
   v5.0.1: 16:9 큰 창(필드 높이에 맞춰 줄어듦), 대장간 그림이 창 대부분을 채우고 재료 칸·결과 칸을 키움 */
.smith-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(1240px, calc(100% - 24px), calc((100dvh - 200px) * 16 / 9));
  aspect-ratio: 16 / 9;
  max-height: calc(100% - 16px);
  overflow: hidden;
}
.smith-gold {
  margin-left: auto;
  margin-right: 12px;
  color: var(--gold);
  font-size: 15px;
}
.smith-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px 16px;
  background:
    linear-gradient(180deg, rgba(10, 6, 4, 0.15) 0%, rgba(10, 6, 4, 0.45) 55%, rgba(10, 6, 4, 0.9) 100%),
    url('../assets/smith/forge.webp') center 40% / cover no-repeat;
  border-bottom: 1px solid var(--inset-border);
  overflow: hidden;
}
.smith-forge {
  display: flex;
  align-items: center;
  gap: 24px;
}
.smith-slots {
  --smith-cell: 92px;
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: rgba(18, 12, 9, 0.78);
  border: 2px solid #7a5530;
  border-radius: 10px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.7), 0 0 22px rgba(255, 120, 30, 0.2);
}
.smith-item {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--smith-cell, 52px);
  height: var(--smith-cell, 52px);
  padding: 4px;
  color: var(--text-dim);
  font: 700 18px var(--font-serif);
  background: linear-gradient(180deg, #2a211a, #15100c);
  border: 2px solid #4a3a2c;
  border-radius: 8px;
  cursor: pointer;
}
.smith-item.is-empty {
  border-style: dashed;
  cursor: default;
  opacity: 0.75;
}
.smith-item.grade-common { border-color: var(--grade-common); }
.smith-item.grade-uncommon { border-color: var(--grade-uncommon); }
.smith-item.grade-rare { border-color: var(--grade-rare); }
.smith-item.grade-epic { border-color: var(--grade-epic); }
.smith-item.grade-legendary { border-color: var(--grade-legendary); box-shadow: 0 0 8px var(--grade-legendary); }
.smith-item:hover:not(.is-empty) { filter: brightness(1.25); }
.smith-item.is-picked { outline: 2px solid var(--gold); outline-offset: 1px; filter: brightness(0.55); }
.smith-item.is-other { opacity: 0.35; }
.smith-plus {
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: #ffd76a;
  font: 700 13px var(--font-sans);
  text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.smith-arrow {
  color: #ffb347;
  font-size: 44px;
  text-shadow: 0 0 12px rgba(255, 120, 30, 0.9);
}
.smith-result {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  padding: 12px;
  color: #ffdba0;
  font: 700 56px var(--font-serif);
  background: radial-gradient(circle, rgba(255, 150, 50, 0.35), rgba(20, 12, 8, 0.9) 70%);
  border: 3px solid #8a6438;
  border-radius: 12px;
  box-shadow: 0 0 22px rgba(255, 130, 40, 0.5);
}
.smith-result.grade-uncommon { border-color: var(--grade-uncommon); }
.smith-result.grade-rare { border-color: var(--grade-rare); }
.smith-result.grade-epic { border-color: var(--grade-epic); }
.smith-result.grade-legendary { border-color: var(--grade-legendary); box-shadow: 0 0 30px var(--grade-legendary); }
.smith-result.grade-mythic { border-color: var(--grade-mythic); box-shadow: 0 0 34px var(--grade-mythic); }
.smith-result.is-success { animation: smith-pop 0.6s ease-out; }
.smith-result.is-fail { color: #bbb; filter: grayscale(0.7); }
.smith-info {
  min-height: 48px;
  color: var(--text);
  font-size: 15px;
  text-align: center;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}
.smith-recipe { font: 700 23px var(--font-serif); }
.smith-odds { margin-top: 4px; color: #f3d9a8; font-size: 15px; }
.smith-actions { display: flex; gap: 12px; }
.smith-actions button {
  padding: 10px 24px;
  color: var(--text);
  font: 700 17px var(--font-serif);
  background: linear-gradient(180deg, #3a2c20, #1e1610);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
}
.smith-actions .smith-craft {
  color: #2a1606;
  background: linear-gradient(180deg, #ffcf7a, #e08a2e);
  border-color: #ffd98f;
  box-shadow: 0 0 16px rgba(255, 140, 40, 0.6);
}
.smith-actions button:disabled { filter: grayscale(0.8) brightness(0.6); cursor: default; box-shadow: none; }
.smith-message { min-height: 20px; margin: 0; color: var(--text-dim); font-size: 14px; text-shadow: 0 1px 3px #000; }
.smith-message[data-kind='ok'] { color: var(--ok); }
.smith-message[data-kind='bad'] { color: var(--bad); }
.smith-bag-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 4px;
  color: var(--text-dim);
  font-size: 14px;
}
.smith-filter { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.smith-chip {
  padding: 3px 10px;
  color: var(--text-dim);
  font-size: 13px;
  background: #1a140f;
  border: 1px solid #3b2f24;
  border-radius: 10px;
  cursor: pointer;
}
.smith-chip.is-on { background: #3a2c1e; border-color: var(--gold); }
.smith-bag {
  --smith-cell: 62px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 62px);
  gap: 8px;
  max-height: 150px;
  padding: 6px 16px 14px;
  overflow-y: auto;
}
.smith-empty { grid-column: 1 / -1; color: var(--text-dim); font-size: 14px; }
/* 망치질: 재료 칸이 떨리고 불꽃이 튄다 */
.smith-stage.is-forging .smith-slots { animation: smith-shake 0.18s linear infinite; }
.smith-stage.is-forging .smith-result { animation: smith-glow 0.5s ease-in-out infinite alternate; }
.smith-stage::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: '';
  opacity: 0;
}
.smith-stage.is-forging::after {
  background:
    radial-gradient(circle at 46% 40%, rgba(255, 210, 120, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 52% 34%, rgba(255, 170, 60, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 58% 44%, rgba(255, 230, 150, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 40% 30%, rgba(255, 150, 40, 0.8) 0 3px, transparent 4px),
    radial-gradient(circle at 62% 28%, rgba(255, 200, 90, 0.9) 0 3px, transparent 4px);
  animation: smith-sparks 0.35s steps(2) infinite;
}
.smith-stage.is-success::after { background: radial-gradient(circle at 72% 40%, rgba(255, 220, 120, 0.55), transparent 55%); animation: smith-flash 1.4s ease-out forwards; }
.smith-stage.is-fail::after { background: radial-gradient(circle at 72% 40%, rgba(120, 120, 120, 0.45), transparent 55%); animation: smith-flash 1.4s ease-out forwards; }
@keyframes smith-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  75% { transform: translate(2px, -1px); }
}
@keyframes smith-glow {
  from { box-shadow: 0 0 14px rgba(255, 130, 40, 0.5); }
  to { box-shadow: 0 0 46px rgba(255, 190, 80, 1); filter: brightness(1.3); }
}
@keyframes smith-sparks {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0.4; transform: translateY(-16px) scale(1.15); }
}
@keyframes smith-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes smith-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
/* 필드가 낮은 화면(1280×720 등)에서는 칸을 조금 줄인다 */
@media (max-height: 760px) {
  .smith-slots { --smith-cell: 72px; gap: 10px; padding: 12px 14px; }
  .smith-result { width: 100px; height: 100px; font-size: 44px; }
  .smith-stage { gap: 10px; padding: 14px 12px 10px; }
  .smith-bag { --smith-cell: 52px; grid-template-columns: repeat(auto-fill, 52px); max-height: 120px; }
}
