/* เมนูโต้ตอบผู้เล่น + ดูข้อมูล */
.player-interact-root,
.player-inspect-root {
    position: fixed;
    inset: 0;
    z-index: 9160;
    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;
}

.player-interact-root.open,
.player-inspect-root.open {
    pointer-events: auto;
    opacity: 1;
}

.player-interact-backdrop,
.player-inspect-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(20, 28, 36, 0.72) 0%, rgba(0, 0, 0, 0.78) 70%);
}

.player-interact-sheet {
    position: relative;
    width: min(92vw, 320px);
    padding: 16px;
    border-radius: 10px;
    background: linear-gradient(180deg, #3a2e24 0%, #1e1612 100%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.player-interact-title {
    margin: 0 0 14px;
    font-size: var(--text-lg);
    font-weight: bold;
    color: var(--px-gold);
}

.player-interact-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Modal ล้มรอช่วย / กลับเมือง */
.death-wait-root {
    position: fixed;
    inset: 0;
    z-index: 9170;
    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.22s ease;
}

.death-wait-root.open {
    pointer-events: auto;
    opacity: 1;
}

.death-wait-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(90, 18, 18, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 0, 0, 0.5) 0%, transparent 50%),
        rgba(4, 2, 2, 0.72);
}

.death-wait-sheet {
    position: relative;
    width: min(92vw, 340px);
    padding: 18px 16px 14px;
    border-radius: 12px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(72, 28, 24, 0.95) 0%, rgba(28, 14, 12, 0.98) 42%, rgba(14, 8, 8, 0.99) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 160, 100, 0.18),
        inset 0 0 0 1px rgba(120, 40, 30, 0.55),
        0 4px 0 #1a0806,
        0 16px 48px rgba(0, 0, 0, 0.65),
        0 0 40px rgba(160, 40, 20, 0.22);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    max-height: min(84vh, 520px);
    animation: death-wait-rise 0.32s ease-out;
}

@keyframes death-wait-rise {
    from {
        transform: translateY(14px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.death-wait-glow {
    position: absolute;
    left: 50%;
    top: -30%;
    width: 160%;
    height: 55%;
    transform: translateX(-50%);
    background: radial-gradient(
        ellipse at 50% 80%,
        rgba(220, 70, 40, 0.28) 0%,
        transparent 70%
    );
    pointer-events: none;
}

.death-wait-emblem {
    position: relative;
    font-size: 2.1rem;
    line-height: 1;
    margin: 2px 0 8px;
    filter: drop-shadow(0 0 10px rgba(220, 80, 40, 0.45));
    animation: death-wait-pulse 2.4s ease-in-out infinite;
}

@keyframes death-wait-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.92;
    }
    50% {
        transform: scale(1.06);
        opacity: 1;
    }
}

.death-wait-head {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.death-wait-eyebrow {
    margin: 0;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #c87868;
    text-shadow: 0 0 8px rgba(200, 60, 40, 0.35);
}

.death-wait-title {
    margin: 0;
    font-size: clamp(1.15rem, 4.2vw, 1.35rem);
    font-weight: bold;
    color: #f2d6a8;
    text-shadow:
        0 0 12px rgba(220, 90, 40, 0.35),
        1px 1px 0 #1a0806;
}

.death-wait-flavor {
    position: relative;
    margin: 0 0 12px;
    padding: 0 4px;
    color: #d8c8b8;
    font-size: var(--text-sm);
    line-height: 1.5;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45);
}

.death-wait-cost-block {
    position: relative;
    margin: 0 0 10px;
    padding: 10px 10px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(160, 70, 50, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 180, 120, 0.08);
    text-align: left;
}

.death-wait-cost-label {
    margin: 0 0 8px;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: #e0a070;
    text-align: center;
}

.death-wait-cost-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.death-wait-cost {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    color: #eadfd0;
    font-size: var(--text-sm);
    line-height: 1.4;
}

.death-wait-cost-icon {
    flex-shrink: 0;
    width: 1.25em;
    text-align: center;
    opacity: 0.9;
}

.death-wait-cost-text {
    min-width: 0;
}

.death-wait-hint {
    position: relative;
    margin: 0 0 12px;
    color: #9a8078;
    font-size: var(--text-xs);
    line-height: 1.4;
}

.death-wait-footer {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2px;
}

.death-wait-footer .pixel-btn {
    width: 100%;
    min-height: var(--touch-min, 44px);
}

.death-wait-btn-wait {
    border-color: #6a4a40 !important;
    background: linear-gradient(180deg, #3a2824 0%, #241816 100%) !important;
    color: #e8d8c8 !important;
}

.death-wait-btn-return {
    box-shadow: 0 0 14px rgba(200, 80, 40, 0.28);
}

/* เมนูสิ่งของบนช่องบ้าน */
.house-tile-root {
    position: fixed;
    inset: 0;
    z-index: 9160;
    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;
}

.house-tile-root.open {
    pointer-events: auto;
    opacity: 1;
}

.house-tile-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(20, 28, 36, 0.72) 0%, rgba(0, 0, 0, 0.78) 70%);
}

.house-tile-sheet {
    position: relative;
    width: min(92vw, 340px);
    padding: 16px;
    border-radius: 10px;
    background: linear-gradient(180deg, #3a2e24 0%, #1e1612 100%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.house-tile-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffe082;
    text-align: center;
}

.house-tile-list,
.house-tile-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.house-tile-layers {
    gap: 6px;
    padding: 4px 0;
}

.house-tile-layer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 2px solid rgba(255, 224, 130, 0.22);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
    color: #f3e6c8;
    font: inherit;
    text-align: left;
    box-sizing: border-box;
    min-height: 2.6rem;
}

.house-tile-layer-row.is-filled {
    cursor: pointer;
    border-color: rgba(255, 224, 130, 0.45);
    background: linear-gradient(180deg, rgba(72, 56, 40, 0.95) 0%, rgba(36, 26, 18, 0.98) 100%);
    transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}

.house-tile-layer-row.is-filled:hover,
.house-tile-layer-row.is-filled:focus-visible {
    border-color: #ffe082;
    outline: none;
    transform: translateY(-1px);
}

.house-tile-layer-row.is-empty {
    display: grid;
    grid-template-columns: 6.25rem minmax(0, 1fr);
    opacity: 0.55;
    border-style: dashed;
    border-color: rgba(243, 230, 200, 0.18);
}

.house-tile-layer-row.is-blocked {
    opacity: 0.72;
    border-style: solid;
    border-color: rgba(229, 115, 115, 0.45);
    background: rgba(80, 20, 20, 0.35);
    color: #ffcdd2;
    cursor: not-allowed;
}

.house-tile-layer-row.is-blocked .house-tile-layer-text {
    color: #ffcdd2;
}

.house-tile-layer-label {
    font-weight: 700;
    color: #ffe082;
    white-space: nowrap;
}

.house-tile-layer-text {
    font-weight: 700;
    color: #fff8e7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.house-tile-layer-value {
    min-height: 1.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff8e7;
}

.house-tile-actions .pixel-btn {
    width: 100%;
}

.house-tile-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.player-inspect-sheet {
    position: relative;
    width: min(96vw, 420px);
    max-height: min(90vh, 680px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(180deg, #3a2e24 0%, #1e1612 38%, #120e0a 100%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    /* ใช้ขนาดช่องเดียวกับกระเป๋า */
    --inv-slot-size: 46px;
    --inv-slot-gap: 5px;
}

@media (min-width: 420px) {
    .player-inspect-sheet {
        --inv-slot-size: 52px;
    }
}

.player-inspect-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px 8px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.35);
}

.player-inspect-title {
    margin: 0;
    font-size: var(--text-md);
    font-weight: bold;
    color: var(--px-gold);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-inspect-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
}

.player-inspect-root .player-inspect-tabs .status-tab {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
    font-size: var(--text-sm);
    white-space: nowrap;
}

.player-inspect-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 12px;
}

.player-inspect-page[hidden] {
    display: none !important;
}

/* ใช้เลย์เอาต์เดียวกับกระเป๋า (.inv-equip-*) — ขยายให้เต็มแผงดูข้อมูล */
.player-inspect-equip-layout.inv-equip-layout {
    margin-bottom: 0;
    min-height: clamp(240px, 42vh, 320px);
}

/* แถวสกิล 8 ช่อง ใต้ชุดสวมใส่ */
.player-inspect-skills {
    margin-top: 10px;
    padding: 8px 6px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(141, 110, 99, 0.28);
}

.player-inspect-skills-title {
    margin: 0 0 6px;
    font-size: var(--text-xs);
    font-weight: bold;
    color: var(--px-gold);
    letter-spacing: 0.04em;
}

.player-inspect-skill-row {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
}

.player-inspect-skill-slot {
    position: relative;
    aspect-ratio: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(42, 34, 26, 0.95) 0%, rgba(14, 10, 8, 0.92) 100%);
    box-shadow:
        inset 0 1px 0 rgba(141, 110, 99, 0.25),
        0 2px 0 rgba(8, 6, 4, 0.45);
    cursor: default;
}

.player-inspect-skill-slot.filled {
    cursor: pointer;
    background: linear-gradient(165deg, #4a6a7e 0%, #2c3e50 55%, #1a2830 100%);
    border-color: #64b5f6;
    box-shadow:
        inset 0 1px 0 rgba(144, 202, 249, 0.35),
        0 2px 0 rgba(8, 6, 4, 0.45),
        0 0 8px rgba(100, 181, 246, 0.18);
}

.player-inspect-skill-slot.empty {
    opacity: 0.45;
}

.player-inspect-skill-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    image-rendering: pixelated;
    pointer-events: none;
}

.player-inspect-skill-num {
    position: absolute;
    left: 2px;
    top: 1px;
    font-size: 8px;
    font-weight: bold;
    line-height: 1;
    color: rgba(255, 248, 232, 0.75);
    text-shadow: 0 1px 0 #000;
    pointer-events: none;
}

.player-inspect-skill-slot.filled .player-inspect-skill-num {
    color: #bbdefb;
}

.player-inspect-vitals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.player-inspect-vital {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(141, 110, 99, 0.35);
}

.player-inspect-vital span {
    font-size: 9px;
    color: #a89a8c;
}

.player-inspect-vital b {
    font-size: var(--text-sm);
    color: #efebe9;
}

.player-inspect-section-title {
    margin: 10px 0 6px;
    font-size: var(--text-xs);
    color: var(--px-gold);
    font-weight: bold;
}

.player-inspect-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.player-inspect-stat-grid--derived {
    grid-template-columns: 1fr 1fr;
}

.player-inspect-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.22);
}

.player-inspect-stat-label {
    font-size: 10px;
    color: #bcaaa4;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-inspect-stat-val {
    font-size: 11px;
    font-weight: bold;
    color: #efebe9;
    flex-shrink: 0;
}

.player-inspect-hint {
    margin: 8px 0 0;
    font-size: var(--text-xs);
    color: #a89a8c;
}
