#damage-numbers-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 4;
}

.damage-number {
    position: absolute;
    transform: translate(-50%, -100%);
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    font-weight: normal;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #fffde7;
    text-shadow:
        -2px -2px 0 #3e2723,
        2px -2px 0 #3e2723,
        -2px 2px 0 #3e2723,
        2px 2px 0 #3e2723,
        -1px 0 0 #3e2723,
        1px 0 0 #3e2723,
        0 -1px 0 #3e2723,
        0 1px 0 #3e2723;
    pointer-events: none;
    white-space: nowrap;
    will-change: left, top, transform, opacity;
}

.damage-number--incoming {
    color: #ff8a80;
    text-shadow:
        -2px -2px 0 #4a0000,
        2px -2px 0 #4a0000,
        -2px 2px 0 #4a0000,
        2px 2px 0 #4a0000,
        -1px 0 0 #4a0000,
        1px 0 0 #4a0000,
        0 -1px 0 #4a0000,
        0 1px 0 #4a0000;
}

.damage-number--crit {
    font-size: 14px;
    color: #ffe082;
    letter-spacing: 0.04em;
    text-shadow:
        -2px -2px 0 #bf360c,
        2px -2px 0 #bf360c,
        -2px 2px 0 #bf360c,
        2px 2px 0 #bf360c,
        -1px 0 0 #bf360c,
        1px 0 0 #bf360c,
        0 -1px 0 #bf360c,
        0 1px 0 #bf360c,
        0 0 10px rgba(255, 193, 7, 0.55);
}

.damage-number--crit.damage-number--incoming {
    color: #ff5252;
    text-shadow:
        -2px -2px 0 #4a0000,
        2px -2px 0 #4a0000,
        -2px 2px 0 #4a0000,
        2px 2px 0 #4a0000,
        0 0 10px rgba(255, 82, 82, 0.5);
}

.damage-number--miss {
    font-size: 9px;
    color: #cfd8dc;
    letter-spacing: 0.08em;
    text-shadow:
        -1px -1px 0 #263238,
        1px -1px 0 #263238,
        -1px 1px 0 #263238,
        1px 1px 0 #263238;
}

.damage-number--label {
    font-size: 10px;
    color: #eceff1;
}

.loot-float {
    position: absolute;
    transform: translate(-50%, -100%);
    font-size: 14px;
    font-weight: bold;
    line-height: 1.2;
    color: #c8e6c9;
    text-shadow:
        -1px -1px 0 #1b5e20,
        1px -1px 0 #1b5e20,
        0 0 10px rgba(129, 199, 132, 0.5);
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}

.loot-float--gold {
    color: var(--px-gold);
    text-shadow:
        -1px -1px 0 #5d4037,
        1px -1px 0 #5d4037,
        0 0 10px var(--px-glow-gold);
}

.loot-float--exp {
    color: #ffe082;
    text-shadow:
        -1px -1px 0 #f57f17,
        1px -1px 0 #f57f17,
        0 0 10px rgba(255, 224, 130, 0.55);
}

/* เลเวลอัป — โทนทองสว่าง ขยายเด้ง */
.loot-float--level-up {
    font-size: clamp(15px, 4.2vw, 20px);
    letter-spacing: 0.04em;
    color: #fff59d;
    text-shadow:
        -2px -2px 0 #f9a825,
        2px -2px 0 #f9a825,
        -2px 2px 0 #f9a825,
        2px 2px 0 #f9a825,
        0 0 14px rgba(255, 241, 118, 0.95),
        0 0 24px rgba(255, 193, 7, 0.55);
    animation: loot-float-level-up 1.55s ease-out forwards;
}

@keyframes loot-float-level-up {
    0% {
        transform: translate(-50%, -80%) scale(0.35);
        opacity: 0;
    }
    18% {
        transform: translate(-50%, -118%) scale(1.32);
        opacity: 1;
    }
    35% {
        transform: translate(-50%, -128%) scale(1.08);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -168%) scale(0.92);
        opacity: 0;
    }
}

.loot-float--hp {
    color: #ff8a80;
    text-shadow:
        -1px -1px 0 #b71c1c,
        1px -1px 0 #b71c1c,
        0 0 10px rgba(255, 138, 128, 0.55);
}

.loot-float--mp {
    color: #82b1ff;
    text-shadow:
        -1px -1px 0 #0d47a1,
        1px -1px 0 #0d47a1,
        0 0 10px rgba(130, 177, 255, 0.55);
}

.loot-float--satiety {
    color: #ffe082;
    text-shadow:
        -1px -1px 0 #e65100,
        1px -1px 0 #e65100,
        0 0 10px rgba(255, 183, 77, 0.55);
}

/* ตีบวกสำเร็จ — โทนทองสว่าง ขยายเด้ง (แนว Ragnarok) */
.loot-float--enhance-ok {
    font-size: clamp(15px, 4.2vw, 20px);
    letter-spacing: 0.04em;
    color: #fff9c4;
    text-shadow:
        -2px -2px 0 #e65100,
        2px -2px 0 #e65100,
        -2px 2px 0 #e65100,
        2px 2px 0 #e65100,
        0 0 14px rgba(255, 213, 79, 0.95),
        0 0 28px rgba(255, 152, 0, 0.55);
    animation: loot-float-enhance-ok 1.5s ease-out forwards;
}

/* ตีบวกล้มเหลว — แดงสั่นเบา */
.loot-float--enhance-fail {
    font-size: clamp(14px, 3.8vw, 18px);
    letter-spacing: 0.02em;
    color: #ff8a80;
    text-shadow:
        -2px -2px 0 #b71c1c,
        2px -2px 0 #b71c1c,
        0 0 12px rgba(244, 67, 54, 0.75);
    animation: loot-float-enhance-fail 1.4s ease-out forwards;
}

@keyframes loot-float-enhance-ok {
    0% {
        transform: translate(-50%, -80%) scale(0.35);
        opacity: 0;
    }
    18% {
        transform: translate(-50%, -118%) scale(1.35);
        opacity: 1;
    }
    35% {
        transform: translate(-50%, -108%) scale(1.05);
    }
    100% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 0;
    }
}

@keyframes loot-float-enhance-fail {
    0% {
        transform: translate(-50%, -100%) scale(1);
        opacity: 1;
    }
    12% {
        transform: translate(calc(-50% - 4px), -100%) scale(1.05);
    }
    24% {
        transform: translate(calc(-50% + 4px), -100%) scale(1.05);
    }
    36% {
        transform: translate(calc(-50% - 3px), -100%) scale(1);
    }
    48% {
        transform: translate(calc(-50% + 3px), -100%) scale(1);
    }
    100% {
        transform: translate(-50%, -100%) scale(0.92);
        opacity: 0;
    }
}

/* กล่องเป้าหมาย — พื้นหลังเดียวกับกล่องสถานะตัวละคร */
#hud .hud-target.pixel-frame {
    background: linear-gradient(
        145deg,
        rgba(36, 28, 22, 0.88) 0%,
        rgba(18, 14, 10, 0.82) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(141, 110, 99, 0.4),
        inset 0 0 12px rgba(255, 213, 79, 0.04),
        0 4px 0 rgba(8, 6, 4, 0.5),
        0 0 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

.hud-target {
    position: relative;
    width: 100%;
    padding: 8px 10px 7px;
    box-sizing: border-box;
}

.hud-target-close {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(141, 110, 99, 0.55);
    border-radius: 3px;
    background: rgba(20, 14, 10, 0.75);
    color: #cbb9a8;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
}

.hud-target-close:hover {
    color: #fff8e1;
    border-color: #ffd54f;
    background: rgba(60, 40, 28, 0.9);
}

.hud-target[hidden] {
    display: none !important;
}

.hud-target-label {
    font-size: 8px;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a89a8c;
    text-align: center;
    margin-bottom: 3px;
    opacity: 0.9;
}

.hud-target-name {
    font-size: var(--text-sm);
    font-weight: bold;
    color: #fff;
    text-align: center;
    line-height: 1.2;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-target-meta {
    font-size: var(--text-xs);
    line-height: 1.35;
    color: #c8e6c9;
    text-align: center;
    margin: -2px 0 6px;
}

.hud-target-meta[hidden] {
    display: none;
}

.hud-target-hp-row {
    margin-bottom: 0;
    gap: 5px;
    font-size: var(--text-xs);
    color: #d7ccc8;
}

.hud-target-mp-row {
    margin-top: 4px;
    margin-bottom: 0;
    gap: 5px;
    font-size: var(--text-xs);
    color: #d7ccc8;
}

.hud-target-hp-row > span:first-child {
    width: 1.8em;
    flex-shrink: 0;
    color: #ef9a9a;
}

.hud-target-mp-row > span:first-child {
    width: 1.8em;
    flex-shrink: 0;
    color: #90caf9;
}

.hud-target .bar-track {
    position: relative;
    flex: 1;
    min-width: 0;
    height: clamp(12px, 3vw, 14px);
    overflow: hidden;
}

.hud-target-hp-fill {
    background: linear-gradient(180deg, #ef5350, #c62828);
}

.hud-target-mp-fill {
    background: linear-gradient(180deg, #42a5f5, #1565c0);
}

.hud-target .bar-value {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    z-index: 2;
    max-width: calc(100% - 6px);
    margin: 0;
    padding: 0;
    text-align: right;
    font-size: clamp(8px, 2.05vw, 10px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #fff;
    text-shadow:
        0 0 2px rgba(0, 0, 0, 0.95),
        1px 1px 0 rgba(0, 0, 0, 0.9),
        -1px 0 0 rgba(0, 0, 0, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.hud-target-plant-row {
    margin-bottom: 0;
    gap: 6px;
    font-size: var(--text-xs);
    color: #d7ccc8;
}

.hud-target-plant-row > span:first-child {
    width: 1.8em;
    color: #aed581;
}

.hud-target-plant-pips {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 3px;
    align-items: center;
}

.hud-target-player-row {
    display: flex;
    justify-content: center;
    margin-top: 6px;
    pointer-events: auto;
}

.hud-target-player-row[hidden] {
    display: none !important;
}

.hud-target-trade-btn {
    pointer-events: auto;
    min-height: 32px;
    padding: 4px 12px;
    font-size: var(--text-xs);
}

.hud-target-statuses {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
    pointer-events: auto;
}

.hud-target-statuses[hidden] {
    display: none !important;
}

.hud-target-status-btn {
    position: relative;
    pointer-events: auto;
    touch-action: manipulation;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-target-status-img {
    display: block;
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 3px rgba(255, 213, 79, 0.45));
}

.hud-target-status-stacks {
    position: absolute;
    right: -2px;
    bottom: -2px;
    min-width: 12px;
    padding: 0 2px;
    font-size: 8px;
    line-height: 12px;
    text-align: center;
    color: #fffde7;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 2px;
    pointer-events: none;
}

.hud-plant-pip {
    position: relative;
    flex: 0 0 auto;
    width: clamp(8px, 2.2vw, 11px);
    height: clamp(8px, 2.2vw, 11px);
    min-width: 0;
    border-radius: 2px;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.hud-plant-pip.empty {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.hud-plant-pip.filled {
    background: linear-gradient(180deg, #aed581 0%, #558b2f 100%);
    border: 1px solid rgba(27, 94, 32, 0.85);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 1px 0 rgba(0, 0, 0, 0.35),
        0 0 6px rgba(46, 125, 50, 0.22);
}

/* แถบเก็บเกี่ยวเหนือฝ้าย / แร่ / ต้นไม้ ในโลก */
.harvest-progress {
    position: absolute;
    display: none;
    transform: translate(-50%, -100%);
    pointer-events: none;
    z-index: 2;
    padding: 3px 5px;
    border-radius: 4px;
    background: rgba(8, 6, 4, 0.72);
    border: 1px solid rgba(174, 213, 129, 0.35);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.harvest-progress-pips {
    display: flex;
    flex-direction: row;
    gap: 3px;
    align-items: center;
}

.harvest-progress-pip {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    box-sizing: border-box;
}

.harvest-progress-pip.empty {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.harvest-progress-pip.filled {
    background: linear-gradient(180deg, #c5e1a5 0%, #7cb342 55%, #558b2f 100%);
    border: 1px solid rgba(27, 94, 32, 0.9);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 5px rgba(104, 159, 56, 0.35);
}

.name-tag.monster {
    color: #ce93d8;
    font-size: var(--text-sm);
}

.name-tag.monster-green {
    color: #c6ff00;
    text-shadow:
        -1px -1px 0 #1b5e20,
        1px -1px 0 #1b5e20,
        -1px 1px 0 #1b5e20,
        1px 1px 0 #1b5e20;
}
