/* 新香港官方弹窗（结构对齐参考站 #jinfang / .pop_body，视觉 1:1 还原） */

#jinfang {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 16px;
    padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
    background: rgba(18, 0, 0, 0.62);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: xhFadeInBg 0.3s ease-out;
}

body.xh-popup-open {
    overflow: hidden;
}

#jinfang .pop_body {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    margin: auto;
    width: min(430px, 92vw);
    max-width: 430px;
    max-height: 88vh;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background: linear-gradient(180deg, #fffdf6 0%, #fff3d9 100%);
    border: 2px solid #f0c96a;
    border-radius: 15px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), inset 0 0 0 4px rgba(255, 255, 255, 0.55);
    overflow: hidden;
    animation: xhPopIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 标题栏 */
#jinfang .xh-popup-head {
    position: relative;
    flex: 0 0 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #d32f2f 0%, #c2181f 50%, #9e1017 100%);
    box-shadow: 0 4px 15px rgba(180, 20, 30, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}

#jinfang .xh-popup-head span {
    font-family: "Microsoft YaHei", Arial, sans-serif;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

#jinfang .xh-popup-head button {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

#jinfang .xh-popup-head button:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* 内容滚动区 */
#jinfang .xh-popup-scroll {
    padding: 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 红金横幅 */
#cj-banner {
    position: relative;
    margin-bottom: 12px;
    padding: 14px 12px;
    text-align: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #b71c1c 0%, #c62828 40%, #d32f2f 100%);
    border: 2.5px solid transparent;
    background-clip: padding-box;
    overflow: hidden;
    perspective: 800px;
    animation: cjCardIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, cjGlow 3s 0.8s ease-in-out infinite;
}

#cj-banner .xh-banner-border {
    position: absolute;
    top: -2.5px;
    right: -2.5px;
    bottom: -2.5px;
    left: -2.5px;
    z-index: 0;
    border-radius: 14px;
    background: linear-gradient(90deg, #ffd54f, #ffab00, #ffd54f, #fff176, #ffd54f);
    background-size: 300% 100%;
    animation: cjBorderFlow 4s linear infinite;
}

#cj-banner .xh-banner-fill {
    position: absolute;
    top: 2.5px;
    right: 2.5px;
    bottom: 2.5px;
    left: 2.5px;
    z-index: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #b71c1c 0%, #c62828 40%, #d32f2f 100%);
}

#cj-banner .xh-banner-inner {
    position: relative;
    z-index: 2;
}

#cj-banner .xh-banner-sub {
    margin-bottom: 6px;
    font-size: 13px;
    letter-spacing: 2px;
    color: #ffd54f;
    opacity: 0.9;
}

#cj-banner .xh-banner-title {
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 3px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), 0 0 20px rgba(255, 213, 79, 0.3);
    animation: cjTitlePop 0.6s 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#cj-banner .xh-banner-desc {
    color: #ffcc80;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.7;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

#cj-banner .xh-tags {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

#cj-banner .xh-tags span {
    padding: 4px 12px;
    border: 1.5px solid #ffd54f;
    border-radius: 20px;
    background: rgba(139, 0, 0, 0.7);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    animation: cjTagSlide 0.5s ease-out both;
}

#cj-banner .xh-tags span:nth-child(1) { animation-delay: 0.6s; }
#cj-banner .xh-tags span:nth-child(2) { animation-delay: 0.75s; }
#cj-banner .xh-tags span:nth-child(3) { animation-delay: 0.9s; }

#cj-banner .cj-deco {
    display: inline-block;
    color: #ffd54f;
    text-shadow: 0 0 10px rgba(255, 213, 79, 0.7);
    animation: cjDecoSpin 3s ease-in-out infinite;
}

/* 金币粒子 */
#cj-banner .cj-fw {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(circle at 35% 35%, #fff176, #ffd54f 40%, #f9a825 100%);
    box-shadow: 0 0 4px rgba(255, 213, 79, 0.6);
}

#cj-banner .cj-fw:nth-child(3) { top: 10%; left: 10%; animation: coinFall 2.2s ease-in infinite; }
#cj-banner .cj-fw:nth-child(4) { top: 5%; left: 30%; animation: coinFall 2.6s ease-in 0.4s infinite; }
#cj-banner .cj-fw:nth-child(5) { top: 8%; right: 25%; animation: coinFall 2s ease-in 0.8s infinite; }
#cj-banner .cj-fw:nth-child(6) { top: 12%; right: 10%; animation: coinFall 2.4s ease-in 0.2s infinite; }
#cj-banner .cj-fw:nth-child(7) { top: 3%; left: 20%; animation: coinFall 2.8s ease-in 1s infinite; }
#cj-banner .cj-fw:nth-child(8) { top: 6%; right: 18%; animation: coinFall 2.1s ease-in 0.6s infinite; }
#cj-banner .cj-fw:nth-child(9) { top: 15%; right: 35%; animation: coinFall 2.5s ease-in 1.2s infinite; }
#cj-banner .cj-fw:nth-child(10) { top: 2%; left: 40%; animation: coinFall 2.3s ease-in 0.3s infinite; }
#cj-banner .cj-fw:nth-child(11) { top: 9%; left: 48%; animation: coinFall 2.15s ease-in 0.9s infinite; }
#cj-banner .cj-fw:nth-child(12) { top: 4%; left: 62%; animation: coinFall 2.45s ease-in 0.15s infinite; }
#cj-banner .cj-fw:nth-child(13) { top: 11%; right: 42%; animation: coinFall 2.05s ease-in 0.55s infinite; }
#cj-banner .cj-fw:nth-child(14) { top: 7%; right: 6%; animation: coinFall 2.35s ease-in 1.05s infinite; }

/* 时间/口号 */
#jinfang .xh-info {
    margin: 10px 0 6px;
    text-align: center;
    line-height: 1.75;
}

#jinfang .xh-draw {
    color: #1e67f9;
    font-size: 17px;
    font-weight: 900;
}

#jinfang .xh-draw-sub {
    color: #1e67f9;
    font-size: 15px;
    font-weight: 700;
}

#jinfang .xh-slogan {
    color: #111;
    font-size: 14px;
    font-weight: 700;
}

/* 官方网址 */
#jinfang .xh-domains {
    margin: 12px 0 4px;
    text-align: center;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.7;
}

#jinfang .xh-domains .xh-domains-label {
    color: #b71c1c;
}

#jinfang .xh-domains a {
    display: block;
    color: #d32f2f;
    text-decoration: none;
    word-break: break-all;
}

#jinfang .xh-domains a:hover {
    text-decoration: underline;
}

/* 关闭按钮 */
#jinfang .tk_btn {
    flex: 0 0 auto;
    padding: 6px 12px 16px;
    text-align: center;
}

#jinfang .tk_btn .confirm {
    min-width: 150px;
    padding: 11px 34px;
    border: 2px solid #ffd54f;
    border-radius: 10px;
    background: linear-gradient(145deg, #cf1322, #a8071a);
    color: #fadb14;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(168, 7, 26, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#jinfang .tk_btn .confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 9px 22px rgba(168, 7, 26, 0.5);
}

#jinfang .tk_btn .confirm:active {
    transform: translateY(0) scale(0.98);
}

/* 动画 */
@keyframes xhFadeInBg {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes xhPopIn {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes coinFall {
    0% { transform: translateY(-20px) rotateY(0deg); opacity: 1; }
    100% { transform: translateY(95px) rotateY(720deg); opacity: 0; }
}

@keyframes cjCardIn {
    0% { transform: rotateY(90deg) scale(0.8); opacity: 0; }
    60% { transform: rotateY(-5deg) scale(1.02); opacity: 1; }
    100% { transform: rotateY(0) scale(1); opacity: 1; }
}

@keyframes cjBorderFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes cjTitlePop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes cjTagSlide {
    0% { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes cjGlow {
    0%, 100% { box-shadow: 0 6px 20px rgba(183, 28, 28, 0.4), 0 0 12px rgba(255, 213, 79, 0.15); }
    50% { box-shadow: 0 8px 28px rgba(183, 28, 28, 0.5), 0 0 25px rgba(255, 213, 79, 0.35); }
}

@keyframes cjDecoSpin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(15deg) scale(1.2); }
    75% { transform: rotate(-15deg) scale(1.2); }
}

/* 移动端：去掉可能引起 fixed 合成层偏移的模糊，高度按动态视口算，避开刘海/手势区 */
@media screen and (max-width: 768px) {
    #jinfang {
        padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    #jinfang .pop_body {
        width: 94vw;
        max-width: 430px;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
    }
}

/* 小屏优化 */
@media screen and (max-width: 375px) {
    #jinfang .pop_body { width: 95%; max-height: 90vh; max-height: calc(100dvh - 24px); }
    #cj-banner .xh-banner-title { font-size: 20px; letter-spacing: 2px; }
    #jinfang .tk_btn .confirm { padding: 10px 26px; font-size: 15px; }
    #jinfang .xh-draw { font-size: 16px; }
    #jinfang .xh-domains { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    #jinfang,
    #jinfang .pop_body,
    #cj-banner,
    #cj-banner .xh-banner-title,
    #cj-banner .xh-tags span,
    #cj-banner .cj-fw {
        animation: none !important;
    }
}
