.npc-card {
    position: relative;
    box-sizing: border-box;
    --npc-frame-height: 115px;
    --npc-text-height: 65px;
    --npc-portrait-width: 150px;
    --npc-avatar-width: 170px;
    --npc-avatar-height: 176px;
    --npc-content-top: 10px;
    --npc-actions-padding-y: 5px;
    background:
            radial-gradient(circle at 96% 11%, rgba(255, 232, 133, 0.34), transparent 8%),
            radial-gradient(circle at 91% 68%, rgba(118, 210, 50, 0.12), transparent 16%),
            linear-gradient(180deg, #171210 0%, #0d0d0f 100%);
    border-top: 1px solid #4b371d;
    border-bottom: 1px solid #070707;
}
.npc-dialog-popup {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    box-sizing: border-box;
    background-color: transparent;
    opacity: 1;
    transition: opacity 0.22s ease, background-color 0.28s ease;
    user-select: none;
}
.npc-dialog-popup--top {
    top: 0;
    bottom: auto;
    align-items: flex-start;
}
.npc-dialog-popup--bottom {
    top: auto;
    bottom: 0;
    align-items: flex-end;
}
.npc-dialog-popup--shade {
    top: 0;
    bottom: 0;
    background-color: rgba(25, 25, 25, 0.5);
}
.npc-dialog-popup--shade.npc-dialog-popup--top {
    align-items: flex-start;
}
.npc-dialog-popup--shade.npc-dialog-popup--bottom {
    align-items: flex-end;
}
.npc-dialog-popup--no-shade {
    background-color: transparent;
    pointer-events: none;
}
.npc-dialog-popup--no-shade .npc-dialog-popup__panel {
    pointer-events: auto;
}
.npc-dialog-popup--shade-out {
    top: 0;
    bottom: 0;
    background-color: transparent;
    pointer-events: none;
}
.npc-dialog-popup--shade-out .npc-dialog-popup__panel {
    pointer-events: auto;
}
.npc-dialog-popup__panel {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    box-sizing: border-box;
    transform: translateY(0);
    transition: transform 0.22s ease;
}
.npc-dialog-popup .npc-card {
    background: transparent;
    border-top: none;
    border-bottom: none;
}
.npc-dialog-popup--closing {
    opacity: 0;
    pointer-events: none;
}
.npc-dialog-popup--closing .npc-dialog-popup__panel {
    transform: translateY(18px);
}
.npc-dialog-popup__close {
    position: absolute;
    top: 4px;
    right: 9px;
    z-index: 5;
    width: 26px;
    height: 26px;
    padding: 0;
    color: #f0cf8f;
    font-size: 22px;
    line-height: 24px;
    text-align: center;
    background: rgba(24, 18, 13, 0.86);
    border: 1px solid rgba(236, 190, 99, 0.64);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    cursor: pointer;
}
.npc-card__frame {
    position: relative;
    display: flex;
    min-height: var(--npc-frame-height);
    overflow: visible;
    gap: 20px;
    background:
            linear-gradient(90deg, rgba(13, 12, 13, 0.55) 0%, rgba(13, 12, 13, 0.08) 20%, rgba(13, 12, 13, 0.45) 100%),
            radial-gradient(circle at 94% 22%, rgba(255, 221, 104, 0.18), transparent 18%),
            repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 5px),
            linear-gradient(180deg, rgba(54, 42, 32, 0.96) 0%, rgba(27, 23, 22, 0.98) 100%);
    border: 2px solid #8b6129;
    border-radius: 4px;
    box-shadow:
            inset 0 3px 0 rgba(255, 226, 145, 0.4),
            inset 0 -3px 0 rgba(89, 58, 25, 0.72),
            inset 0 0 0 1px rgba(250, 211, 125, 0.35),
            inset 0 0 34px rgba(0, 0, 0, 0.64),
            0 2px 0 rgba(0, 0, 0, 0.72);
}
.npc-card__frame::before,
.npc-card__frame::after {
    content: "";
    position: absolute;
    top: 5px;
    width: 38px;
    height: 38px;
    z-index: 3;
    border-top: 3px solid rgba(236, 190, 99, 0.9);
}
.npc-card__frame::before {
    left: 5px;
    border-left: 3px solid rgba(236, 190, 99, 0.9);
    box-shadow: inset 10px 10px 0 -7px rgba(255, 241, 175, 0.52);
}
.npc-card__frame::after {
    right: 5px;
    border-right: 3px solid rgba(236, 190, 99, 0.9);
    box-shadow: inset -10px 10px 0 -7px rgba(255, 241, 175, 0.52);
}
.npc-card__portrait {
    position: relative;
    flex: 0 0 var(--npc-portrait-width);
}
.npc-card__avatar {
    position: absolute;
    left: -10px;
    bottom: -1px;
    width: var(--npc-avatar-width);
    height: var(--npc-avatar-height);
    max-width: none;
    object-fit: contain;
    object-position: left bottom;
    z-index: 1000;
    pointer-events: none;
}
.npc-card__content {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    margin-top: var(--npc-content-top);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto var(--npc-text-height) auto;
    grid-template-areas:
        "name"
        "text"
        "action";
    align-content: start;
    align-items: start;
    text-align: left;
    z-index: 1000;
}
.npc-card__name {
    position: relative;
    grid-area: name;
    padding-bottom: 5px;
    color: #f0cf8f;
    font-size: clamp(18px, 2vw, 20px);
    font-weight: bold;
    line-height: 1.1;
    text-shadow: 0 2px 3px #000, 0 0 9px rgba(255, 210, 132, 0.22);
}
.npc-card__name::after {
    content: "";
    position: absolute;
    left: 0;
    right: 8%;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, #9b7440 0%, #74552f 68%, rgba(116, 85, 47, 0) 100%);
    box-shadow:
            0 1px 0 rgba(0, 0, 0, 0.72),
            inset 0 1px 0 rgba(255, 223, 144, 0.42);
}
.npc-card .npc-card__text {
    grid-area: text;
    align-self: start;
    margin: 0;
    padding: 5px 0 0;
    width: 95%;

    height: var(--npc-text-height);
    max-height: var(--npc-text-height);

    color: #ded8d4;
    font-size: clamp(14px, 1.8vw, 18px);
    line-height: 1.3;
    text-shadow: 0 2px 3px #000;
    overflow-wrap: anywhere;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.npc-card .npc-card__text::-webkit-scrollbar {
    width: 0;
    height: 0;
}
.npc-card .npc-card__text img {
    display: inline-block;
    width: auto;
    height: 1.25em;
    max-width: 100%;
    margin: 0 2px;
    vertical-align: -0.25em;
}
.npc-card__task {
    padding: 6px 8px 1px;
    font-size: small;
}
.npc-card__actions {
    grid-area: action;
    align-self: end;
    justify-content: center;
    padding: var(--npc-actions-padding-y) 0 var(--npc-actions-padding-y);
}
.npc-card__actions .btn {
    box-sizing: border-box;
    margin: 0;
    border-radius: 8px;
    font-size: large;
    line-height: 38px;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.72);
    box-shadow:
            0 0 18px rgba(99, 218, 59, 0.32),
            0 0 14px rgba(255, 228, 73, 0.24),
            inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.npc-card--compact {
    --npc-frame-height: 82px;
    --npc-text-height: 48px;
    --npc-portrait-width: 104px;
    --npc-avatar-width: 122px;
    --npc-avatar-height: 132px;
    --npc-content-top: 7px;
}
.npc-card--compact .npc-card__portrait {
    min-height: 82px;
}

.npc-card--compact .npc-card__name {
    font-size: clamp(15px, 1.8vw, 18px);
}
.npc-card--compact .npc-card__text {
    font-size: clamp(13px, 1.8vw, 15px);
}

@media (max-width: 460px) {
    .npc-card {
        --npc-frame-height: 105px;
        --npc-text-height: 60px;
        --npc-portrait-width: 118px;
        --npc-avatar-width: 134px;
        --npc-avatar-height: 142px;
        --npc-content-top: 8px;
    }
    .npc-card__frame {
        gap: 5px;
    }
}

@media (max-height: 560px) {
    .npc-card {
        --npc-frame-height: 88px;
        --npc-text-height: 48px;
        --npc-portrait-width: 98px;
        --npc-avatar-width: 114px;
        --npc-avatar-height: 124px;
        --npc-content-top: 6px;
        --npc-actions-padding-y: 5px;
    }
    .npc-card__name {
        padding-bottom: 3px;
        font-size: clamp(15px, 1.8vw, 17px);
    }
    .npc-card .npc-card__text {
        padding-top: 5px;
        font-size: clamp(13px, 1.8vw, 14px);
    }
    .npc-card__actions .btn {
        height: 34px;
        line-height: 34px;
        font-size: medium;
    }
}

@media (min-height: 561px) and (max-height: 680px) {
    .npc-card {
        --npc-frame-height: 98px;
        --npc-text-height: 52px;
        --npc-portrait-width: 108px;
        --npc-avatar-width: 126px;
        --npc-avatar-height: 136px;
        --npc-content-top: 7px;
        --npc-actions-padding-y: 5px;
    }
}

@media (min-height: 681px) and (max-height: 820px) {
    .npc-card {
        --npc-frame-height: 115px;
        --npc-text-height: 70px;
        --npc-portrait-width: 132px;
        --npc-avatar-width: 154px;
        --npc-avatar-height: 164px;
        --npc-content-top: 8px;
    }
}

@media (min-height: 821px) {
    .npc-card {
        --npc-frame-height: 128px;
        --npc-text-height: 80px;
        --npc-portrait-width: 150px;
        --npc-avatar-width: 172px;
        --npc-avatar-height: 184px;
        --npc-content-top: 10px;
    }
}

@media (min-width: 520px) and (min-height: 760px) {
    .npc-card {
        --npc-frame-height: 138px;
        --npc-text-height: 88px;
        --npc-portrait-width: 166px;
        --npc-avatar-width: 188px;
        --npc-avatar-height: 194px;
    }
}

@media (max-width: 360px) {
    .npc-card {
        --npc-portrait-width: 98px;
        --npc-avatar-width: 112px;
    }
    .npc-card__frame {
        gap: 2px;
    }
    .npc-card .npc-card__text {
        width: 97%;
    }
}

.npc-card--button-compact {
    --npc-frame-height: 104px;
    --npc-text-height: 40px;
    --npc-actions-padding-y: 5px;
    --npc-content-top: 7px;
}
.npc-card--button-compact .npc-card__content {
    grid-template-rows: auto minmax(0, var(--npc-text-height)) auto;
}
.npc-card--button-compact .npc-card__actions {
    align-self: start;
    padding: var(--npc-actions-padding-y) 0;
}
.npc-card--with-button .npc-card__actions .btn {
    height: auto;
    min-height: 44px;
    padding-top: 5px;
    padding-bottom: 5px;
    line-height: 1.15;
}

@media (max-height: 560px) {
    .npc-card--button-compact {
        --npc-frame-height: 86px;
        --npc-text-height: 30px;
        --npc-actions-padding-y: 5px;
    }
    .npc-card--with-button .npc-card__actions .btn {
        min-height: 42px;
    }
}

@media (min-height: 561px) and (max-height: 680px) {
    .npc-card--button-compact {
        --npc-frame-height: 94px;
        --npc-text-height: 34px;
    }
}

@media (min-height: 821px) {
    .npc-card--button-compact {
        --npc-frame-height: 112px;
        --npc-text-height: 44px;
    }
}
