/* ========== 测名结果弹窗 遮罩 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

/* ========== 弹窗主体 ========== */
/*
 * aspect-ratio 锁住 3000:1960 比例，背景图永远不变形
 * 所有 % 尺寸均相对于 modal 宽度，随视口等比缩放
 */
.measure-modal {
    width: min(88vw, 1480px);
    aspect-ratio: 3000 / 1960;
    max-height: 92vh;
    position: relative;
    background-image: url('../images/popupwindow.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
}

/* 关闭按钮 */
.modal-close {
    position: absolute;
    top: 4%;
    right: 9%;
    width: clamp(26px, 2.4vw, 34px);
    height: clamp(26px, 2.4vw, 34px);
    border-radius: 50%;
    background: linear-gradient(to bottom, #f0c84a, #c09008);
    border: 2px solid #8a6000;
    color: #3a1000;
    font-size: clamp(12px, 1.1vw, 16px);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.8;
}

/* ========== 内容区 ========== */
.modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 18% 9% 18%;
    overflow: hidden;
}

/* 弹窗大标题 */
.modal-title {
    text-align: center;
    font-size: clamp(16px, 1.9vw, 28px);
    font-family: "楷体", "KaiTi", "STKaiti", serif;
    font-weight: 700;
    letter-spacing: 6px;
    color: #e8c060;
    -webkit-text-fill-color: #e8c060;
    text-shadow: 0 0 10px rgba(232, 180, 60, 0.8), 2px 2px 0 rgba(0, 0, 0, 0.85);
    padding-top: 6.5%;
    margin-bottom: 1%;
    flex-shrink: 0;
}

/* ========== 顶部信息条 ========== */
.modal-info-bar {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 2%;
    background: transparent;
    border: none;
    padding: 1% 2%;
    margin-top: 5.5%;
    margin-bottom: 0;
    margin-left: 4%;
    margin-right: 3%;
    flex-shrink: 0;
}

/* 评分圆 */
.score-circle {
    width: clamp(60px, 6vw, 88px);
    height: clamp(60px, 6vw, 88px);
    flex-shrink: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #c0281a, #6a0808);
    border: 3px solid #c9a227;
    box-shadow: 0 0 16px rgba(200, 140, 0, 0.5), inset 0 0 12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-circle .score-num {
    font-size: clamp(20px, 2.2vw, 32px);
    font-weight: 900;
    color: #ffd890;
    line-height: 1;
    font-family: "STKaiti", serif;
    text-shadow: 0 0 10px rgba(255, 200, 60, 0.8);
}

.score-circle .score-unit {
    font-size: clamp(9px, 0.9vw, 13px);
    color: #ffd890;
    letter-spacing: 1px;
}

.score-circle .score-grade {
    font-size: clamp(8px, 0.85vw, 12px);
    color: #f5d878;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* 中栏：姓名 + 标签 + 评级 */
.modal-basic-info {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.2vw, 18px);
    flex-shrink: 0;
    min-width: 120px;
}

.modal-basic-info h3 {
    font-size: clamp(18px, 2.1vw, 30px);
    font-family: "STKaiti", "KaiTi", serif;
    color: #5c1800;
    letter-spacing: 5px;
    margin: 0;
}

.modal-basic-info .info-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.info-tag {
    padding: 2px 8px;
    border: 1px solid rgba(180, 130, 30, 0.5);
    border-radius: 20px;
    font-size: clamp(10px, 0.9vw, 13px);
    color: #6b3010;
    background: rgba(255, 255, 255, 0.55);
    font-family: "STKaiti", serif;
    letter-spacing: 1px;
}

.grade-badge {
    display: inline-block;
    width: fit-content;
    align-self: flex-start;
    padding: clamp(3px, 0.4vw, 5px) clamp(10px, 1.3vw, 18px);
    background: linear-gradient(135deg, #c0281a, #8a1008);
    border-radius: 4px;
    color: #ffd890;
    font-size: clamp(11px, 1.05vw, 15px);
    font-weight: bold;
    font-family: "STKaiti", "KaiTi", serif;
    letter-spacing: 4px;
    box-shadow: 0 2px 10px rgba(120, 0, 0, 0.45), inset 0 1px 0 rgba(255, 200, 80, 0.3);
    border: 1px solid rgba(200, 162, 50, 0.7);
    border-top: 1px solid rgba(245, 216, 120, 0.6);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.grade-badge::before,
.grade-badge::after {
    content: "◆";
    font-size: 8px;
    color: #c9a227;
    vertical-align: middle;
    margin: 0 4px;
}

/* 右栏：运势总览 */
.modal-fortune-inline {
    flex: 1;
    border-left: 2px solid rgba(180, 130, 30, 0.4);
    padding-left: clamp(8px, 1vw, 14px);
}

.modal-fortune-inline h4 {
    font-size: clamp(11px, 1vw, 14px);
    font-family: "STKaiti", serif;
    color: #6b1a00;
    letter-spacing: 3px;
    margin-bottom: 4px;
}

.modal-fortune-inline p {
    font-size: clamp(10px, 0.95vw, 13.5px);
    line-height: 1.8;
    color: #3a1a00;
    font-family: "STSong", "SimSun", serif;
    letter-spacing: 0.3px;
}

/* ========== 区块分隔标题 ========== */
.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1% 0 0.8%;
    flex-shrink: 0;
}

.section-divider::before,
.section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #b8943a 60%);
}

.section-divider::after {
    background: linear-gradient(to left, transparent, #b8943a 60%);
}

.section-divider span {
    font-size: clamp(12px, 1.1vw, 16px);
    font-family: "STKaiti", "KaiTi", serif;
    color: #6b1a00;
    letter-spacing: 4px;
    font-weight: bold;
    white-space: nowrap;
}

/* ========== 五格数理 ========== */
.wuge-grid {
    display: flex;
    gap: clamp(6px, 0.7vw, 10px);
    flex-shrink: 0;
    margin-left: 6%;
    margin-right: 5%;
}

.wuge-card {
    flex: 1;
    background: linear-gradient(to bottom, rgba(255, 252, 235, 0.85), rgba(255, 244, 200, 0.6));
    border: 1px solid rgba(180, 130, 30, 0.5);
    border-top: 2px solid rgba(200, 162, 50, 0.8);
    border-radius: 6px;
    padding: calc(6px + 1%) 4%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(2px, 0.3vw, 4px);
    min-height: 140px;
}

.wuge-card .wuge-name {
    font-size: clamp(13px, 1.25vw, 18px);
    font-family: "STKaiti", "KaiTi", serif;
    color: #5c1000;
    letter-spacing: 6px;
    font-weight: bold;
    margin-bottom: clamp(3px, 0.4vw, 6px);
    text-shadow: 0 1px 2px rgba(180, 100, 0, 0.25);
    border-bottom: 1px solid rgba(180, 130, 30, 0.3);
    padding-bottom: 3px;
    width: 100%;
}

.wuge-card .wuge-score {
    font-size: clamp(20px, 2.1vw, 30px);
    font-weight: 900;
    color: #8a1008;
    font-family: "STKaiti", serif;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(138, 16, 8, 0.2);
}

.wuge-card .wuge-score span {
    font-size: clamp(11px, 1.05vw, 15px);
    font-weight: normal;
    color: #a03010;
}

.wuge-card .wuge-ji {
    font-size: clamp(9px, 0.85vw, 12px);
    color: #b8860b;
    letter-spacing: 2px;
    font-family: "STKaiti", serif;
    background: rgba(200, 162, 50, 0.12);
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid rgba(200, 162, 50, 0.3);
}

.wuge-card .wuge-role {
    font-size: clamp(8px, 0.7vw, 10px);
    color: #8b5a2b;
    letter-spacing: 1px;
    font-family: "STSong", serif;
    margin-top: 2px;
    opacity: 0.85;
    font-style: italic;
}

.wuge-card .wuge-desc {
    font-size: clamp(9px, 0.8vw, 11px);
    color: #6b3a10;
    line-height: 1.5;
    font-family: "STSong", "SimSun", serif;
    letter-spacing: 0.5px;
    white-space: normal;
    word-break: break-all;
    overflow: visible;
    text-align: center;
}

.wuge-card.auspicious {
    background: linear-gradient(to bottom, rgba(255, 252, 220, 0.9), rgba(255, 240, 170, 0.65));
    border-color: rgba(200, 162, 50, 0.7);
    border-top-color: #c9a227;
}

/* 总格：深红金渐变 */
.wuge-card.total {
    background: linear-gradient(to bottom, rgba(140, 10, 10, 0.88), rgba(100, 5, 5, 0.75));
    border-color: #c9a227;
    border-top: 3px solid #f5d878;
}

.wuge-card.total .wuge-name {
    color: #f5d878;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    border-bottom-color: rgba(245, 216, 120, 0.35);
}

.wuge-card.total .wuge-score {
    color: #ffd890;
    text-shadow: 0 0 10px rgba(255, 200, 60, 0.5);
}

.wuge-card.total .wuge-score span {
    color: #f5c060;
}

.wuge-card.total .wuge-ji {
    color: #f5d878;
    background: rgba(255, 200, 60, 0.15);
    border-color: rgba(245, 216, 120, 0.4);
}

.wuge-card.total .wuge-desc {
    color: #f0d0a0;
}

/* ========== 事格与财理 ========== */
.detail-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(6px, 0.7vw, 10px);
    flex: 1;
    min-height: 0;
    margin-left: 6%;
    margin-right: 5%;
}

.detail-col {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(180, 130, 30, 0.3);
    border-radius: 6px;
    padding: clamp(8px, 0.9vw, 12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail-col h4 {
    font-size: clamp(10px, 0.85vw, 12px);
    font-family: "STKaiti", serif;
    color: #6b1a00;
    letter-spacing: 3px;
    margin-bottom: clamp(4px, 0.5vw, 8px);
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(180, 130, 30, 0.3);
    flex-shrink: 0;
}

.detail-col p {
    font-size: clamp(9px, 0.8vw, 11px);
    line-height: 1.8;
    color: #3a1a00;
    font-family: "STSong", "SimSun", serif;
    flex: 1;
    overflow: hidden;
}

/* 底部留白 */
.modal-bottom-bar {
    height: 0;
}

/* ========== 小屏适配（< 768px，手机竖屏） ========== */
@media (max-width: 768px) {
    .measure-modal {
        width: 96vw;
        aspect-ratio: unset;
        max-height: 95vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 0 14% 8% 14%;
    }

    .modal-info-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-top: 10%;
    }

    .modal-fortune-inline {
        border-left: none;
        border-top: 1px solid rgba(180, 130, 30, 0.4);
        padding-left: 0;
        padding-top: 10px;
        width: 100%;
    }

    .wuge-grid {
        flex-wrap: wrap;
        margin-left: 2%;
        margin-right: 2%;
    }

    .wuge-card {
        flex: 0 0 calc(33% - 6px);
    }

    .detail-columns {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        margin-left: 2%;
        margin-right: 2%;
    }
}

/* ========== 横屏矮视口（高度 < 600px） ========== */
@media (max-height: 600px) {
    .measure-modal {
        aspect-ratio: unset;
        width: min(95vw, 1480px);
        height: 96vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 0 18% 3% 18%;
    }

    .modal-title {
        padding-top: 2%;
        margin-bottom: 0.5%;
    }

    .modal-info-bar {
        margin-top: 2%;
    }
}

/* ========== measure-modal 高度补丁（600–768px 高度设备） ========== */
@media (max-height: 768px) and (min-height: 601px) {
    .measure-modal {
        max-height: 96vh;
        overflow-y: auto;
    }
}

/* ========== 手机端五格卡片对称布局 ========== */
@media (max-width: 768px) {
    .wuge-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .wuge-card {
        flex: 0 0 calc(33% - 6px);
        min-width: 80px;
    }

    /* 最后一张总格独占一行居中 */
    .wuge-card.total {
        flex: 0 0 calc(50% - 6px);
    }

    /* 正文字号保底 */
    .detail-col h4 {
        font-size: clamp(12px, 1.2vw, 14px);
    }

    .detail-col p {
        font-size: clamp(11px, 1vw, 13px);
    }
}