/* ---------- Overlay ---------- */
.popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 8;
    display: none;
    opacity: 0;
    transition: opacity .28s ease;
}
.popup-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 500px;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    overflow: hidden;
    z-index: 9;
    transition: opacity .28s ease;
    background: url(/images/clan/editor/ui/frame.webp) center center / cover no-repeat;
}
.popup-panel.show {
    opacity: 1;
}
.popup-system {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: url(/images/clan/editor/ui/frame.webp) center center / cover no-repeat;
    border: 1px solid rgba(89, 210, 255, 0.55);
    border-radius: 5px;
    padding: 12px 14px;
    color: #fff;
    font-size: 14.5px;
    line-height: 1.45;
    text-align: center;
    pointer-events: none;
    box-sizing: border-box;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    word-break: break-word;
    hyphens: auto;
    overflow-wrap: break-word;
    width: 90%;
    max-width: 500px;
    max-height: 90%;
    overflow: hidden;
}
.popup-system.confirm {
    pointer-events: all;
    z-index: 9;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity .28s ease;
}
.popup-system.confirm.show {
    opacity: 1;
}
.popup-system.confirm .accept,
.popup-system.confirm .decline {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
    z-index: 1;
}
.popup-system.confirm .item-img {
    height: 100%;
    aspect-ratio: auto;
}
.item-img {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
.item-img img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}
.popup-header {
    height: 52px;
    width: 100%;
    padding: 5px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
}
.popup-title {
    color: #fff;
    font-size: 1.3em;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 2px 5px black, 0 0 10px rgba(255, 255, 255, .25);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-phoenix-close {
    width: 46px;
    height: 46px;
    border: none;
    background: url(/images/index/close.webp) center / contain no-repeat;
    transition: .18s;
    position: absolute;
    top: 0px;
    right: 10px;
    z-index: 10;
    cursor: pointer;
    opacity: 0;
    transition: opacity .28s ease, transform .18s ease, filter .18s ease;
}
.btn-phoenix-close.show {
    opacity: 1;
}
.btn-phoenix-close:hover {
    transform: scale(1.12);
    filter: drop-shadow(0 0 10px orange);
}
.popup-tabs {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(7, 19, 35, .72);
    border-bottom: 1px solid rgba(90, 205, 255, .25);
}
.tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    font-size: 0.9em;
    font-weight: 600;
    color: #d7d7d7;
    cursor: pointer;
    position: relative;
    transition: .2s;
    height: 100%;
}
.tab-btn:hover { color: white; }
.tab-btn.active {
    color: white;
    background: rgba(0,170,255,.08);
}
.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2.5px;
    background: #5dd8ff;
}
.popup-body-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: calc(100% - 164px);
    overflow: hidden;
    padding: 10px;
    gap: 10px;
}
.search-friend {
    height: 38px;
    width: 100%;
    outline: none;
    border-radius: 4px;
    padding: 0 14px;
    color: white;
    background: rgba(15,24,38,.82);
    border: 1px solid rgba(120,220,255,.18);
    font-size: 14.5px;
}
.search-friend::placeholder {
    color: #9fa8b5;
}
.popup-scroll-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.popup-scroll-list::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
    display: none;
}
.friend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 5px;
    background: rgb(0 0 0 / 25%);
    border: 1px solid rgba(130,220,255,.15);
    transition: .15s;
    width: 100%;
}
.friend-item:hover {
    transform: translateY(-1px);
    border-color: rgba(90,210,255,.45);
}
.friend-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 60px;
}
.friend-avatar .frame {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.friend-avatar .img {
    position: absolute;
    border-radius: 50%;
    width: 80%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.friend-info { flex: 1; }
.friend-name {
    color: white;
    font-size: 1em;
    font-weight: 600;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.friend-send {
    font-size:13px;
    color:#ffdd88;
}
.friend-select {
    display: flex;
    align-items: center;
    gap: 5px;
}
.friend-level {
    margin-top: 2px;
    color: #8edcff;
    font-size: 12.5px;
}
.status-dot {
    position: absolute;
    bottom: 4px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.online { background: #00ff3a; }
.offline { background: #9a9a9a; }
.popup-bottom {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: transparent;
    border-top: 1px solid rgba(100, 180, 255, 0.18);
    position: relative;
}
.bottom-btn {
    background: transparent;
    border: none;
    font-weight: 600;
    color: #a8d4ff;
    cursor: pointer;
    transition: all 0.25s ease;
    text-shadow: 0 0 12px rgba(120, 210, 255, 0.7);
    letter-spacing: 0.6px;
    padding: 20px 10px;
}
.bottom-btn:hover {
    color: #fff;
    text-shadow: 0 0 20px rgba(160, 230, 255, 1);
    transform: scale(1.04);
}
.bottom-btn.primary {
    color: #ffe68a;
    text-shadow: 0 0 15px rgba(255, 220, 100, 0.8);
}
.bottom-btn.primary:hover {
    color: #fff7c2;
    text-shadow: 0 0 22px rgba(255, 230, 120, 1);
}
.no-empty {
    text-align:center;
    padding:40px 20px;
    color:#aaa;
}

/* ---------- Friend speech ---------- */
.friend-speech {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    width: auto;
    background: #00000066;
    border: 1px solid #0000004d;
    border-radius: 5px;
    padding: 12px 14px;
    color: #fff;
    font-size: 14.5px;
    text-align: center;
    pointer-events: none;
    box-sizing: border-box;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.friend-speech.confirm {
    pointer-events: all;
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.friend-speech.confirm .accept,
.friend-speech.confirm .decline {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 100%;
}

/* =========================================================
   CHAT
   ========================================================= */
.chat-popup {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    margin-right: auto;
}
.chat-body {
    display: grid;
    grid-template-columns: 4fr 1fr;
    gap: 5px;
    flex: 1;
    overflow: hidden;
}
.messages-area {
    color: #fff;
    padding: 5px 10px;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
}
.chat-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    border-left: 1px solid rgba(100, 180, 255, 0.18);
}
.chat-avatar {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
}
.webcam, .micro {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    color: #ccc;
    font-size: 10px;
}
.webcam img, .micro img {
    width: 40px;
    height: 40px;
    filter: opacity(0.5);
}
.chat-img {
    width: 100px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.yahoo-icons {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
}
.yahoo-icon {
    width: 24px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    cursor: pointer;
}
.chat-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border-top: 1px solid rgba(100, 180, 255, 0.18);
}
.input-group {
    display: flex;
    justify-content: space-between;
}
.chat-input {
    width: 100%;
    background: rgb(0 0 0 / 50%);
    border: none;
    color: #fff;
    font-size: 0.9em;
    border-radius: 4px;
    outline: none;
}
.chat-input::placeholder {
    color: #9fa8b5;
}
.chat-send {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .375rem .75rem;
    font-size: 1rem;
    color: #fff;
}
.shake-effect {
    animation: shake 0.5s ease-in-out;
}
/* =========================================================
   NPC DIALOGUE (hội thoại nhân vật)
   ========================================================= */
.npc-dialogue-panel {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.npc-dialogue-skip {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    /* 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%); */
    background: url(/images/clan/editor/ui/frame.webp) center center / cover no-repeat;
    border: 1px solid rgba(89, 210, 255, 0.55);
    color: #fff;
    border-radius: 5px;
    pointer-events: auto;
    padding: 10px;
    cursor: pointer;
}
.npc-dialogue-portrait {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: visible;
    min-height: 0;
    background: url(/images/ui/background/dialogue.webp) center center / cover no-repeat;
    position: relative;
    z-index: 2;
}
.npc-dialogue-portrait::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(5, 12, 20, 0.8) 0%, rgba(5, 12, 20, 0.5) 35%, rgba(5, 12, 20, 0.6) 65%, rgba(5, 12, 20, 0.8) 100%);
    pointer-events: none;
    z-index: 1;
}
.dialogue-npc {
    position: relative;
    z-index: 2;
    object-fit: contain;
    object-position: bottom center;
    pointer-events: none;
}
.dialogue-frame {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -15px;
    width: 100%;
    height: auto;
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(2px 4px 6px black);
}
.npc-dialogue-box {
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    background: url(/images/clan/editor/ui/frame.webp) center center / cover no-repeat;
    border-top: 1px solid rgba(120, 190, 255, 0.25);
    padding: 14px 16px 20px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.npc-dialogue-name {
    font-size: 1em;
    font-weight: 700;
    text-align: center;
    color: #ffe08a;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.npc-dialogue-real {
    font-weight: 400;
    font-size: 0.85em;
    color: #a8c4d8;
}
.npc-dialogue-text {
    font-size: 0.95em;
    line-height: 1.55;
    color: #f0f4f8;
    white-space: pre-wrap;
}

/* =========================================================
   EFFECTS
   ========================================================= */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-2px, -2px) rotate(-2deg); }
    20% { transform: translate(-4px, 2px) rotate(2deg); }
    30% { transform: translate(4px, -2px) rotate(0deg); }
    40% { transform: translate(2px, 2px) rotate(2deg); }
    50% { transform: translate(-2px, -2px) rotate(-2deg); }
    60% { transform: translate(-4px, 2px) rotate(0deg); }
    70% { transform: translate(4px, -2px) rotate(-2deg); }
    80% { transform: translate(-2px, 2px) rotate(2deg); }
    90% { transform: translate(2px, -2px) rotate(0deg); }
    100% { transform: translate(1px, 1px) rotate(-2deg); }
}
.kiss-effect-yahoo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #00000066;
    object-fit: cover;
    animation: stamp 5s ease-in-out forwards;
}
@keyframes stamp {
    0% { transform: scale(1.5); opacity: 0 }
    10% { transform: scale(1); opacity: 1 }
    80% { transform: scale(1); opacity: 1 }
    100% { transform: scale(1); opacity: 0 }
}