/* Ảnh nổi FAQ: Vòng quay, Chao Goblin, Cộng hưởng, Up Level Item */
/* Vòng quay nổi, nằm ngay trên nút TOP */
#sd-spin-fab {
    position: fixed;
    right: 23px; /* căn giữa với nút TOP (right 24px, rộng 48px) */
    bottom: 193px; /* TOP ở bottom 135px + cao 48px + khoảng cách */
    width: 50px;
    height: 50px;
    z-index: 9999;
    display: block;
    line-height: 0;
    text-decoration: none;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}
#sd-spin-fab img {
    width: 50px;
    height: 50px;
    display: block;
    border-radius: 50%;
    animation: sd-spin-wheel 8s linear infinite;
}
#sd-spin-fab:hover {
    filter: drop-shadow(0 6px 12px rgba(224, 52, 47, 0.55));
}
#sd-spin-fab:hover img {
    animation-duration: 1.1s;
}
@keyframes sd-spin-wheel {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Chao Goblin nổi, nằm ngay trên vòng quay */
#sd-chao-fab {
    position: fixed;
    right: 23px;
    bottom: 251px; /* vòng quay bottom 193px + cao 50px + khoảng cách */
    width: 50px;
    height: 50px;
    z-index: 9999;
    display: block;
    line-height: 0;
    text-decoration: none;
    overflow: visible;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}
#sd-chao-fab img {
    width: 50px;
    height: 50px;
    display: block;
    object-fit: contain;
}
#sd-chao-fab .sd-chao-body {
    animation: sd-chao-glow 1.8s ease-in-out infinite;
}
/* Hòn đá trên tay goblin: tung lên rồi rơi xuống */
#sd-chao-fab .sd-chao-stone {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    pointer-events: none;
    animation: sd-chao-toss 1.15s linear infinite;
}
#sd-chao-fab:hover .sd-chao-body {
    animation: none;
    filter: brightness(1.75) contrast(1.25) saturate(1.5) drop-shadow(0 0 6px #ffe08a) drop-shadow(0 0 12px rgba(255, 210, 80, 0.9));
}
@keyframes sd-chao-toss {
    0%, 14% { transform: translate(0, 0); }
    42% { transform: translate(4px, -14px); }
    54% { transform: translate(5px, -16px); }
    76% { transform: translate(2px, -5px); }
    100% { transform: translate(0, 0); }
}
@keyframes sd-chao-glow {
    0%, 100% {
        filter: brightness(1.4) contrast(1.2) saturate(1.4) drop-shadow(0 0 4px #9ad7ff) drop-shadow(0 0 8px rgba(90, 190, 255, 0.75));
    }
    50% {
        filter: brightness(1.7) contrast(1.28) saturate(1.55) drop-shadow(0 0 6px #ffe08a) drop-shadow(0 0 12px rgba(255, 210, 80, 0.85));
    }
}

/* Cộng hưởng nổi, nằm ngay trên Up Level Item. bottom do PHP xếp theo ảnh đang bật */
#sd-cong-fab {
    position: fixed;
    right: 23px;
    width: 50px;
    height: 50px;
    z-index: 9999;
    display: block;
    line-height: 0;
    text-decoration: none;
    overflow: visible;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}
#sd-cong-fab img {
    width: 50px;
    height: 50px;
    display: block;
    object-fit: contain;
    position: absolute;
    left: 0;
    top: 0;
    transform: scale(0.9);
}
/* Một vòng = 244 giây: hiệu ứng gộp ~2.4 giây, đứng yên 2 phút, rồi đổi bên */
#sd-cong-fab .sd-cong-gold { z-index: 1; animation: sd-cong-gold 244s linear infinite; }
#sd-cong-fab .sd-cong-red { z-index: 2; animation: sd-cong-red 244s linear infinite; }
#sd-cong-fab .sd-cong-flash {
    z-index: 3;
    pointer-events: none;
    animation: sd-cong-flash 244s linear infinite;
}
#sd-cong-fab:hover .sd-cong-gold,
#sd-cong-fab:hover .sd-cong-red {
    filter: brightness(1.2) drop-shadow(0 0 6px #ffe08a);
}
/* Kiếm vàng (bên trái) từ từ hiện và gộp. Kiếm đỏ đứng yên đúng vị trí */
@keyframes sd-cong-gold {
    0% { opacity: 0; transform: translate(-18px, 0) scale(0.9); }
    0.55% { opacity: 1; transform: translate(0, 0) scale(0.9); filter: brightness(1.35) drop-shadow(0 0 6px #ffe08a); }
    1%, 100% { opacity: 1; transform: translate(0, 0) scale(0.9); }
}
/* Sau 2 phút: kiếm vàng đứng yên, kiếm đỏ từ từ hiện và gộp */
@keyframes sd-cong-red {
    0%, 49.9% { opacity: 1; transform: translate(0, 0) scale(0.9); }
    50% { opacity: 0; transform: translate(18px, 0) scale(0.9); }
    50.55% { opacity: 1; transform: translate(0, 0) scale(0.9); filter: brightness(1.35) drop-shadow(0 0 6px #ffb040); }
    51%, 100% { opacity: 1; transform: translate(0, 0) scale(0.9); }
}
@keyframes sd-cong-flash {
    0%, 0.35% { opacity: 0; }
    0.55% { opacity: 1; }
    1%, 50.3% { opacity: 0; }
    50.55% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
/* Nửa vòng sáng đuổi quanh ảnh, cùng màu vệt của khung Tải game */
#sd-cong-fab.sd-cong-ring::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        transparent 180deg,
        rgba(3, 233, 244, 0.05) 200deg,
        #03e9f4 320deg,
        #ffffff 348deg,
        transparent 360deg
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 1px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 1px));
    animation: sd-cong-chase 2s linear infinite;
    pointer-events: none;
    z-index: 4;
}
@keyframes sd-cong-chase {
    to { transform: rotate(360deg); }
}

/* Up Level Item nổi, nằm ngay trên Chao Goblin. bottom do PHP xếp theo ảnh đang bật */
#sd-uplv-fab {
    position: fixed;
    right: 23px;
    width: 50px;
    height: 50px;
    z-index: 9999;
    display: block;
    line-height: 0;
    text-decoration: none;
    overflow: visible;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}
#sd-uplv-fab img {
    width: 50px;
    height: 50px;
    display: block;
    object-fit: contain;
    position: relative;
    z-index: 1;
}
#sd-uplv-fab .sd-uplv-body {
    animation: sd-uplv-forge 1.2s linear infinite;
}
/* Búa tách riêng: giơ lên (ra) rồi đập xuống lò (vào) */
#sd-uplv-fab .sd-uplv-hammer {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    transform-origin: 29% 17%;
    animation: sd-uplv-hammer 1.2s linear infinite;
}
#sd-uplv-fab:hover .sd-uplv-body,
#sd-uplv-fab:hover .sd-uplv-hammer {
    filter: brightness(1.15) drop-shadow(0 0 6px #ffe08a);
}
/* Lửa miệng lò, bùng lúc búa chạm */
#sd-uplv-fab::before {
    content: "";
    position: absolute;
    left: 58%;
    top: 18%;
    width: 14px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 248, 210, 0.95) 0%, rgba(255, 150, 20, 0.7) 38%, rgba(255, 60, 0, 0) 72%);
    pointer-events: none;
    z-index: 4;
    mix-blend-mode: screen;
    animation: sd-uplv-ember 1.2s linear infinite;
}
@keyframes sd-uplv-hammer {
    0%, 46% { transform: rotate(-42deg); }
    64% { transform: rotate(4deg); }
    70% { transform: rotate(-6deg); }
    86%, 100% { transform: rotate(-42deg); }
}
@keyframes sd-uplv-forge {
    0%, 60%, 100% { filter: drop-shadow(0 0 3px rgba(255, 160, 40, 0.65)); }
    66% { filter: brightness(1.45) drop-shadow(0 0 5px #ffd27a) drop-shadow(0 0 9px rgba(255, 70, 0, 0.85)); }
}
@keyframes sd-uplv-ember {
    0%, 58%, 100% { opacity: 0.4; transform: scale(0.7); }
    66% { opacity: 1; transform: scale(1.35); }
}
/* Tia lửa nhỏ bắn ra đúng nhịp búa đập */
.sd-uplv-spark {
    position: absolute;
    left: 70%;
    top: 28%;
    width: 2px;
    height: 5px;
    border-radius: 2px;
    background: linear-gradient(#fff8d8, #ff9a1a 50%, #ff3a00);
    box-shadow: 0 0 4px #ff6a00;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transform-origin: center bottom;
    animation: sd-uplv-spark 1.2s ease-out infinite;
}
#sd-uplv-fab .sd-uplv-spark:nth-child(3) { --dx: -9px; --dy: -16px; --rot: -28deg; animation-delay: 0.76s; }
#sd-uplv-fab .sd-uplv-spark:nth-child(4) { --dx: 1px; --dy: -18px; --rot: 6deg; animation-delay: 0.8s; }
#sd-uplv-fab .sd-uplv-spark:nth-child(5) { --dx: 11px; --dy: -12px; --rot: 32deg; animation-delay: 0.84s; }
#sd-uplv-fab .sd-uplv-spark:nth-child(6) { --dx: -5px; --dy: -11px; --rot: -12deg; animation-delay: 0.78s; height: 4px; }
#sd-uplv-fab .sd-uplv-spark:nth-child(7) { --dx: 8px; --dy: -8px; --rot: 48deg; animation-delay: 0.86s; height: 4px; }
@keyframes sd-uplv-spark {
    0% { opacity: 0; transform: translate(0, 2px) rotate(var(--rot)) scale(0.4); }
    12% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.55); }
}
