/* --- หน้าต่างคราฟ NPC — ธีมเดียวกับขาย/ซื้อของ --- */
.npc-craft-root {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
        max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.npc-craft-root.open {
    pointer-events: auto;
    opacity: 1;
}

.npc-craft-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(20, 28, 36, 0.72) 0%, rgba(0, 0, 0, 0.78) 70%);
}

.npc-craft-sheet {
    position: relative;
    z-index: 1;
    width: min(96vw, 420px);
    max-height: min(88vh, 620px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 10px;
    padding: 0;
    background: linear-gradient(180deg, #3a2e24 0%, #1e1612 38%, #120e0a 100%);
    box-shadow:
        0 0 0 1px rgba(255, 213, 79, 0.12),
        0 12px 40px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(141, 110, 99, 0.25);
}

.npc-craft-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px 10px;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(0, 0, 0, 0.35);
    background: linear-gradient(180deg, rgba(74, 52, 36, 0.55) 0%, rgba(30, 22, 16, 0.2) 100%);
}

.npc-craft-head-text {
    flex: 1;
    min-width: 0;
}

.npc-craft-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: bold;
    color: var(--px-gold);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
    line-height: 1.3;
}

.npc-craft-subtitle {
    margin: 4px 0 0;
    font-size: var(--text-xs);
    color: #a89a8c;
    line-height: 1.35;
}

.npc-craft-close-btn {
    flex-shrink: 0;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: 0;
    font-size: var(--text-md);
    line-height: 1;
}

.npc-craft-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px 14px;
}

.npc-craft-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.npc-craft-empty {
    margin: 0;
    text-align: center;
    color: #a89a8c;
    font-size: var(--text-sm);
    padding: 24px 8px;
}

.npc-craft-card {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(141, 110, 99, 0.35);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
}

.npc-craft-card.disabled {
    opacity: 0.72;
}

.npc-craft-card-result {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.npc-craft-result-icon {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    padding: 4px;
    border-radius: 6px;
    background: linear-gradient(145deg, rgba(74, 52, 36, 0.95) 0%, rgba(24, 18, 14, 0.98) 100%);
    border: 2px solid rgba(141, 110, 99, 0.45);
    cursor: pointer;
    font-family: inherit;
}

.npc-craft-result-icon:hover {
    border-color: var(--px-gold-dim);
    box-shadow: 0 0 8px var(--px-glow-gold);
}

.npc-craft-result-icon img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    object-fit: contain;
}

.npc-craft-qty {
    position: absolute;
    right: 2px;
    bottom: 1px;
    font-size: 10px;
    font-weight: bold;
    color: #fff8e8;
    text-shadow: 0 1px 0 #000;
    background: rgba(0, 0, 0, 0.72);
    padding: 0 3px;
    border-radius: 3px;
}

.npc-craft-card-name {
    margin: 0 0 6px;
    font-size: var(--text-sm);
    font-weight: bold;
    color: #efebe9;
}

.npc-craft-card-reqs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.npc-craft-req {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 2px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 10px;
    color: #bcaaa4;
    border: 1px solid rgba(141, 110, 99, 0.25);
    cursor: pointer;
    font-family: inherit;
}

.npc-craft-req:hover {
    border-color: rgba(255, 213, 79, 0.35);
    color: #efebe9;
}

.npc-craft-req img {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
}

.npc-craft-req.lacking {
    color: #ef9a9a;
    border-color: rgba(239, 83, 80, 0.35);
}

.npc-craft-card-hint {
    margin: 6px 0 0;
    font-size: 10px;
    color: #ef9a9a;
}

.npc-craft-btn {
    flex-shrink: 0;
    align-self: center;
    min-width: 4.5em;
    min-height: var(--touch-min);
    padding: 8px 12px;
    font-size: var(--text-sm);
}

.npc-craft-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.npc-craft-root > .item-detail-root {
    position: absolute;
    inset: 0;
    z-index: 20;
}

.npc-craft-root > .item-detail-root .item-detail-panel {
    max-height: min(85vh, 520px);
}

.npc-craft-busy {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: auto;
}

.npc-craft-busy[hidden] {
    display: none !important;
}

.npc-craft-busy-panel {
    width: min(88vw, 280px);
    padding: 20px 18px 16px;
    text-align: center;
    border-radius: 10px;
}

.npc-craft-busy-label {
    margin: 0 0 8px;
    font-size: var(--text-md);
    color: #efebe9;
    font-weight: bold;
}

.npc-craft-busy-sec {
    margin: 0 0 14px;
    font-size: clamp(32px, 10vw, 44px);
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    color: var(--px-gold);
    text-shadow: 0 0 12px var(--px-glow-gold);
    line-height: 1;
}

.npc-craft-busy-bar {
    height: 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    overflow: hidden;
    border: 1px solid rgba(141, 110, 99, 0.45);
}

.npc-craft-busy-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--px-gold-dim), var(--px-gold));
    transition: width 0.95s linear;
    border-radius: 3px;
}

.npc-craft-root.is-crafting .npc-craft-close-btn {
    opacity: 0.4;
    pointer-events: none;
}

.npc-craft-item-preview {
    -webkit-tap-highlight-color: transparent;
}
