/* ====================== NHÂN VẬT ====================== */
.character-marker {
    z-index: 2;
    max-width: 75px;
    overflow: hidden;
}
.character-sprite {
    width: var(--frame-w);
    height: var(--frame-h);
    background: var(--sprite-url) 0 var(--y-pos) no-repeat;
    background-size: var(--sheet-w) var(--sheet-h);
    will-change: background-position-x;
    animation: character-idle-8 0.85s infinite steps(1);
}
/* ====================== PLAYER POPUP ====================== */
.player-popup {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%);
    width: max-content;
    min-width: 140px;
    background: linear-gradient(180deg, rgba(25, 62, 102, 0.75) 0%, rgba(14, 38, 64, 0.82) 50%, rgba(6, 17, 30, 0.92) 100%);
    border: 1px solid rgba(89, 210, 255, 0.55);
    border-radius: 5px;
    padding: 5px;
    color: #fff;
    font-size: 0.8em;
    opacity: 0;
    box-sizing: border-box;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    word-break: break-word;
    overflow-wrap: break-word;
    pointer-events: auto;
    white-space: nowrap;
    z-index: 1;
}
.player-popup::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-top: 15px solid rgba(14, 38, 64, 0.92);
    z-index: 1;
}
.player-popup::before {
    content: '';
    position: absolute;
    bottom: -17px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 17px solid rgba(89, 210, 255, 0.55);
    z-index: 1;
}
.player-popup.show {
    animation: bubblePop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.player-popup.hide {
    animation: bubblePop 0.35s cubic-bezier(0.4, 0, 1, 1) reverse forwards;
}
.player-actions {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.player-actions > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.player-actions > div.sent,
.player-actions > div.disabled {
    pointer-events: none;
    opacity: 0.55;
}
.character-marker.sim-marker {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}
.character-marker.sim-marker.fake-player {
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}
.character-marker.sim-marker.fake-player .character-sprite {
    pointer-events: auto;
    cursor: pointer;
}
.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8em;
}
.player-info .stamina-bar {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
    overflow: hidden;
    border: 1px solid rgba(120, 210, 255, 0.7);
}
.player-info .stamina-fill {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(76, 109, 145, .78) 0%, rgba(39, 63, 93, .90) 40%, rgb(0 110 255 / 96%) 100%);
    transition: width 0.12s linear;
}
.name-user {
    color:#ffaa00;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    opacity: 0.8;
}
.guest-clan {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.logo-clan {
    width: 20px;
    filter: brightness(1.5);
}
.guest-name,
.name-clan {
    color: #fff;
    white-space: nowrap;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
    opacity: 0.8;
}
/* ====================== GIAO TRANH ====================== */
@property --angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

@keyframes fireRotate {
    to { --angle: 360deg; }
}
.battle-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(102, 25, 25, 0.75) 0%, rgba(64, 14, 14, 0.82) 50%, rgba(30, 6, 6, 0.92) 100%);
    z-index: 29;
    pointer-events: none;
    opacity: 0;
    transition: opacity 400ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.battle-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.battle-panel {
    width: 100%;
    height: 100dvh;
    z-index: 1;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.15);
    transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.4s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: center center;
}
.battle-panel.show {
    opacity: 1;
    transform: scale(1);
}
.battle-panel.hide {
    opacity: 0;
    transform: scale(0.15);
    transition: transform 0.4s ease-in, opacity 0.35s ease-in;
}
.battle-left,
.battle-right {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.battle-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: url(/images/clan/editor/ui/frame.webp) center center / cover no-repeat;
    width: 100%;
    height: 60px;
    pointer-events: none;
    position: relative;
    overflow: visible;
}
.dialogue-frame.bottom {
    top: -15px;
    transform: scaleY(-1);
}
.battle-icon-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    z-index: 6;
}
.weapon-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center center;
}
.weapon-layer.sword {
    animation: swordSlashSimple 1.5s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
}
.weapon-layer.staff {
    animation: staffDefendSimple 1.5s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
}
.clan-war-clash {
    position: absolute;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 25;
    overflow: visible;
}
.clan-war-clash .weapon-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center center;
}
.clan-war-clash .weapon-layer.sword {
    animation: swordSlashSimple 1.5s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
}

.clan-war-clash .weapon-layer.staff {
    animation: staffDefendSimple 1.5s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
}
.battle-text {
    color: #fff;
    font-size: 1.4em;
    font-weight: 800;
    letter-spacing: 1.5px;
    font-style: italic;
    animation: battleTextPulseAAA 1.5s cubic-bezier(0.15, 0.85, 0.35, 1) infinite;
    z-index: 1;
}
.particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}
.firefly {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #ffb347;
    box-shadow: 0 0 5px #ff9d00, 0 0 10px #ff6a00, 0 0 20px #ff6a00;
    animation: floatUp linear infinite;
}
.character-detail {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 6fr 1fr;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.user-battle-item {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 5px;
    height: 100%;
    overflow: hidden;
}
.character-skill {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 5px;
    height: 100%;
    overflow: hidden;
}
.skill-item {
    position: relative;
    width: 50px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
.skill-item .skill-equipped {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    padding: 5px;
    z-index: 1;
    transition: opacity 0.25s ease, filter 0.25s ease;
}
.skill-item .frame {
    position: absolute;
    inset: 0;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    pointer-events: none;
    filter: brightness(0.5) grayscale(1);
    transition: filter 0.25s ease;
}
.skill-item .is-gray {
    filter: grayscale(1) !important;
    opacity: 0.8;
}
.skill-item.is-equipped::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: conic-gradient(from var(--angle, 0deg), transparent 0%, #a8d4ff 6%, #7ec8ff 13%, #5bb8ff 20%, transparent 28%, transparent 72%, #a8d4ff 80%, #7ec8ff 87%, #5bb8ff 94%, transparent 100%);
    animation: fireRotate 4s linear infinite;
    opacity: 1;
    pointer-events: none;
    border-radius: 2px;
}
.skill-item .skill-empty-icon {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    opacity: 0.5;
    z-index: 1;
}
.character-body {
    grid-row: 1 / 2;
    z-index: 2;
    filter: drop-shadow(0 0 10px rgba(255, 140, 0, .3)) drop-shadow(0 0 25px rgba(255, 120, 0, .2));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}
.battle-img {
    height: 100%;
    object-fit: cover;
}
.pedestal {
    grid-row: 2 / 3;
    z-index: 1;
    position: relative;
    min-height: 24px;
}
.magic-circle {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    max-width: 100%;
    width: auto;
    height: auto;
    animation: magicGlow 1.8s ease-in-out infinite;
}
/* ====================== TREASURE ====================== */
.chukubu-popup {
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(25, 62, 102, 0.75) 0%, rgba(14, 38, 64, 0.82) 50%, rgba(6, 17, 30, 0.92) 100%);
    border: 1px solid rgba(89, 210, 255, 0.55);
    border-radius: 5px;
    padding: 5px;
    color: #fff;
    font-size: 0.8em;
    opacity: 0;
    box-sizing: border-box;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    word-break: break-word;
    overflow-wrap: break-word;
    pointer-events: auto;
    white-space: nowrap;
    z-index: 1;
}
.chukubu-popup.show {
    animation: bubblePop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.chukubu-popup.hide {
    animation: bubblePop 0.35s cubic-bezier(0.4, 0, 1, 1) reverse forwards;
}
.chukubu-kweh-marker {
    width: 40px;
    overflow: visible;
    transform: translate(-50%, -100%);
}
.chukubu-kweh-marker img {
    filter: drop-shadow(0 0 3px #ff9800);
    width: 100%;
    object-fit: cover;
    display: block;
    transform-origin: center bottom;
}
.chukubu-hunt .chukubu-fly {
    width: 40px;
    height: 100%;
    object-fit: cover;
    display: block;
    transform-origin: center bottom;
}
.reward-container .chukubu-fly {
    filter: drop-shadow(0 0 4px #ff9800);
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    transform-origin: center bottom;
}
.reward-container.chukubu {
    flex-direction: column;
    gap: 0;
    text-align: center;
}
.chukubu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chukubu-btn .btn-train {
    color: #FF9800;
    cursor: default;
    filter: drop-shadow(0 0 1px #FF9800);
}
.chukubu-mini-panel {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.chukubu-mini-title {
    font-size: 1.2rem;
    font-weight: 700;
}
.chukubu-mini-hint { font-size: 0.85rem; opacity: 0.85; margin-bottom: 12px; }
.chukubu-mini-stage {
    position: relative;
    width: 100%;
    height: 120px;
    overflow: hidden;
}
.chukubu-mini-net {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    object-fit: contain;
    display: block;
    pointer-events: none;
    z-index: 2;
}
.chukubu-mini-bird {
    position: absolute;
    top: 50%;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
    object-fit: contain;
    pointer-events: none;
}
.chukubu-mini-bird.is-flip {
    transform: translate(-50%, -50%) scaleX(-1);
}
.chukubu-mini-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}
.chukubu-stats {
    display: flex;
    align-items: center;
}
.chukubu-stats .avatar {
    max-width: 130px;
}
.chukubu-stats canvas {
    width: 100%;
    aspect-ratio: 1;
    display: block;
}
.chukubu-edge-indicator {
    position: absolute;
    z-index: 15;
    pointer-events: auto;
    cursor: pointer;
    background: rgb(0 0 0 / 50%);
    border-radius: 50%;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.chukubu-edge-indicator .img {
    width: 28px;
    aspect-ratio: 1;
    object-fit: contain;
}
.chukubu-edge-indicator .menu-text {
    font-size: 0.7em;
    color: #ff9800;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.treasure .treasure-img {
    width: 40px;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    display: block;
    transform-origin: center bottom;
    animation: treasure-wait 2.4s ease-in-out infinite;
}
.treasure.claimed .treasure-img,
.treasure-img.grayscale {
    animation: none;
}
.reward-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 20px;
    color: #fff;
}
.reward-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.reward-overlay.has-content {
    background: rgba(0,0,0,0.78);
}
.reward-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
}
.reward-container .bar {
    content: '';
    position: absolute;
    top: 45%;
    left: 60%;
    width: 100px;
    height: 10px;
    background: linear-gradient(90deg, transparent, #a8d4ff, transparent);
    background-size: 200% 100%;
    animation: flow 3s linear infinite;
    transform: translate(-50%, -50%);
    z-index: -1;
}
.pet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap:10px;
    position: relative;
    animation-delay: var(--delay, 0s);
    transform-origin: center center;
}
.pet-card {
    width: 150px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    box-shadow: rgba(89, 210, 255, 0.55) 0px 0px 10px;
}
.pet-level {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #a8d4ff;
    color: #ffe68a;
    padding: 4px 10px;
    border-radius: 5px;
    font-weight: bold;
}
.pet-level-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(120, 210, 255, 0.7);
    position: relative;
}
.pet-level-bar-exp {
    width:0%;
    height:100%;
    background: linear-gradient(180deg, rgba(76, 109, 145, .78) 0%, rgba(39, 63, 93, .90) 40%, rgb(0 110 255 / 96%) 100%);
    transition:width 1.8s cubic-bezier(0.25,0.46,0.45,0.94);
}
.pet-level-bar-text {
    position:absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size:20px;
    color: #ffe68a;
    font-weight:bold;
    opacity:0;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    pointer-events:none;
    width: 100%;
    text-align: center;
}
.pet-item .item-name {
    color: #a8d4ff;
    max-height: 60px;
    max-width: 300px;
    font-size: 0.8em;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}
.pet-item.anim-pop {
    animation: petPop 0.6s ease;
}
.pet-level-bar-exp.is-fill {
    transition: width 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.pet-level-bar-text.is-float {
    animation: expFloat 2s ease-out forwards;
}
.pet-exp-text {
    font-size: 0.9em;
    font-weight: 500;
    color: #ffe68a;
}
.item-image {
    position: relative;
    width: 100px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
.item-image .frame {
    position: absolute;
    inset: 0;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    pointer-events: none;
    transition: filter 0.25s ease;
}
.item-image .img {
    width: 90%;
    aspect-ratio: 1;
    object-fit: cover;
    padding: 5px;
    z-index: 1;
    transition: opacity 0.25s ease, filter 0.25s ease;
    filter: drop-shadow(-6px 8px 12px rgba(0, 4, 16, 0.6));
}
.item-image::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: conic-gradient(from var(--angle, 0deg), transparent 0%, #a8d4ff 6%, #7ec8ff 13%, #5bb8ff 20%, transparent 28%, transparent 72%, #a8d4ff 80%, #7ec8ff 87%, #5bb8ff 94%, transparent 100%);
    animation: fireRotate 4s linear infinite;
    opacity: 1;
    pointer-events: none;
    border-radius: 2px;
}
.clan-viewer-tile {
    position: absolute;
    cursor: pointer;
    background-size: cover;
    background-position: center;
}
.clan-info-popup {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) scale(0.85);
    min-width: 120px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(25, 62, 102, 0.9) 0%, rgba(6, 17, 30, 0.95) 100%);
    border: 1px solid rgba(89, 210, 255, 0.55);
    border-radius: 6px;
    color: #fff;
    text-align: center;
    opacity: 0;
    pointer-events: auto;
    z-index: 20;
    transition: opacity 0.25s, transform 0.25s;
}
.clan-info-popup.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
.clan-popup-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 4px;
}
.clan-popup-name {
    font-size: 0.85em;
    font-weight: 600;
    text-shadow: 0 1px 2px #000;
    white-space: nowrap;
}
.clan-popup-level {
    font-size: 0.75em;
    color: #a8d4ff;
    margin-top: 2px;
}
.treasure-edge-indicator {
    position: absolute;
    z-index: 15;
    pointer-events: auto;
    cursor: pointer;
    background: rgb(0 0 0 / 50%);
    border-radius: 50%;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.treasure-edge-indicator .img {
    width: 26px;
    aspect-ratio: 1;
    object-fit: contain;
    animation: treasure-wait 2.4s ease-in-out infinite;
}