:root {
    --coin-size: 80px;
    --coin-color: #b8860b;
    --coin-inner: #f5e6c8;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

/* 铜钱容器 */
.coins-container {
    display: flex;
    gap: 24px;
    padding: 16px;
    perspective: 800px;
}

.coin-wrapper {
    width: var(--coin-size);
    height: var(--coin-size);
    perspective: 400px;
}

.coin {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease-out;
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* 铜钱实物图（与小程序同源：images/coin-front|back.png） */
.coin-img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

.coin-back {
    transform: rotateY(180deg);
}

.coin-text {
    font-size: 28px;
    font-weight: bold;
    font-family: "KaiTi", "STKaiti", serif;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);
}

.coin-text.manchu {
    font-family: "Noto Sans Mongolian", "Mongolian Baiti", "Mongolian White", sans-serif;
    font-size: 22px;
    letter-spacing: 1px;
    line-height: 1;
}

/* 铜钱边框装饰 */
.coin-face::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    border-radius: 50%;
    border: 1px dashed rgba(139, 69, 19, 0.3);
}

/* 摇动动画 */
.coin-wrapper.shaking .coin {
    animation: coin-shake 0.18s linear infinite;
}

@keyframes coin-shake {
    0% {
        transform: rotateY(0deg) translateY(0);
    }
    25% {
        transform: rotateY(180deg) translateY(-10px);
    }
    50% {
        transform: rotateY(360deg) translateY(0);
    }
    75% {
        transform: rotateY(540deg) translateY(-6px);
    }
    100% {
        transform: rotateY(720deg) translateY(0);
    }
}

.coin-wrapper.tossing {
    animation: coin-toss 0.4s ease-out;
}

@keyframes coin-toss {
    0% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-40px) scale(1.1);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

/* 铜钱状态提示 */
.coin-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #78716c;
    text-align: center;
}

/* 禁用按钮 */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 爻图 */
.yao-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px;
}

.yao-row {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 24px;
}

.yao {
    width: 80px;
    height: 10px;
    background: #1c1917;
    border-radius: 2px;
    position: relative;
}

.yao.yin {
    background: transparent;
    display: flex;
    justify-content: space-between;
}

.yao.yin::before,
.yao.yin::after {
    content: "";
    width: 36px;
    height: 10px;
    background: #1c1917;
    border-radius: 2px;
}

.yao.dong {
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.2);
}

.yao.yin.dong::before,
.yao.yin.dong::after {
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.2);
}

.yao-mark {
    width: 20px;
    text-align: center;
    color: #b91c1c;
    font-weight: bold;
    font-size: 16px;
}

/* 合并排盘 */
.gua-pan {
    background: #fafaf9;
    border: 1px solid #e7e5e4;
    border-radius: 12px;
    padding: 16px 20px;
    overflow-x: auto;
    display: inline-block;
    width: auto;
    min-width: min-content;
    max-width: 100%;
    vertical-align: top;
    text-align: left;
}

.gua-pan-row {
    display: grid;
    grid-template-columns: 32px 54px 66px 32px 68px 40px 60px 60px 40px 32px 66px 54px;
    align-items: center;
    gap: 8px;
    padding: 14px 0;
    border-bottom: 1px solid #e7e5e4;
    font-size: 15px;
    min-width: 660px;
}

.gua-pan-row:last-child {
    border-bottom: none;
}

.gua-pan-row:hover {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
}

.pan-liushen {
    color: #57534e;
    text-align: center;
    font-weight: 500;
}

.pan-liuqin {
    font-weight: 600;
    text-align: center;
}

.pan-dizhi {
    color: #44403c;
    font-weight: 500;
    text-align: center;
}

.pan-tiang {
    color: #57534e;
    text-align: center;
}

.pan-ganzhi {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.pan-shiying {
    text-align: center;
}

/* 伏神简写 */
.pan-fushen {
    font-size: 11px;
    color: #78716c;
    white-space: nowrap;
    text-align: left;
}

/* 无伏神时收起伏神列 */
.gua-pan.no-fushen .pan-fushen {
    display: none;
}

.gua-pan.no-fushen .gua-pan-row {
    grid-template-columns: 32px 54px 66px 32px 40px 60px 60px 40px 32px 66px 54px;
    min-width: 600px;
}

.pan-fushen .fu-mark {
    color: #a8a29e;
    margin-right: 1px;
}

.pan-fushen .liu-qin {
    font-weight: 600;
}

.pan-fushen .fu-ganzhi {
    margin-left: 1px;
}

.pan-shiying .tag-shi,
.pan-shiying .tag-ying {
    margin-left: 0;
}

.pan-extra {
    font-size: 10px;
    color: #b45309;
    margin-left: 2px;
}

.pan-yao-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 24px;
}

.pan-yao {
    width: 44px;
    height: 2px;
    background: #1c1917;
    border-radius: 1px;
}

.pan-yao.yin {
    background: transparent;
    display: flex;
    justify-content: space-between;
}

.pan-yao.yin::before,
.pan-yao.yin::after {
    content: "";
    width: 18px;
    height: 2px;
    background: #1c1917;
    border-radius: 1px;
}

.pan-yao.dong {
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.25);
}

.pan-yao.yin.dong::before,
.pan-yao.yin.dong::after {
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.25);
}

.pan-mark {
    width: 14px;
    text-align: left;
    color: #b91c1c;
    font-weight: bold;
    font-size: 13px;
}
.cast-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
    padding: 10px;
    border-radius: 12px;
    background: #fafaf9;
    border: 1px solid #e7e5e4;
}

/* 已摇结果条目 */
.cast-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: white;
    border: 1px solid #e7e5e4;
    font-size: 13px;
}

.cast-tag .cast-num {
    color: #78716c;
    white-space: nowrap;
}

.cast-tag .cast-symbol {
    font-size: 16px;
    font-weight: bold;
    color: #1c1917;
}

.cast-tag .cast-name {
    font-size: 11px;
    color: #78716c;
}

/* 表格样式 */
table th,
table td {
    border: 1px solid #e7e5e4;
}

table tbody tr:nth-child(even) {
    background: #fafaf9;
}

/* 信息汇总表 */
.info-summary {
    table-layout: fixed;
    width: auto;
    margin: 0 auto;
    border: 1px solid #e7e5e4;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    font-size: 13px;
}

/* 列宽按内容定制：标签列与干支列收窄，公历列最宽 */
.info-summary col.col-label {
    width: 68px;
}

.info-summary col.col-v1 {
    width: 140px;
}

.info-summary col.col-v2 {
    width: 92px;
}

.info-summary col.col-v3,
.info-summary col.col-v4 {
    width: 72px;
}

.info-summary th,
.info-summary td {
    border: 1px solid #e7e5e4;
    padding: 6px 8px;
    vertical-align: middle;
    line-height: 1.5;
    white-space: nowrap;
}

.info-summary th {
    background: #f5f5f4;
    color: #57534e;
    font-weight: 600;
    text-align: center;
}

.info-summary td {
    color: #292524;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-summary td.text-left {
    text-align: left;
    white-space: normal;
    overflow: visible;
}

.info-summary .shensha-cell {
    text-align: left;
}

.info-summary .shensha-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px 12px;
}

.info-summary .shensha-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 默认折叠为两行，超出部分裁切 */
.info-summary .shensha-collapsed {
    max-height: 3.3em;
    overflow: hidden;
}

.info-summary .shensha-toggle {
    float: right;
    margin-top: 2px;
    padding: 0 6px;
    font-size: 11px;
    color: #0d9488;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.6;
}

.info-summary tr:nth-child(even) {
    background: #fafaf9;
}

/* 世应标记 */
.tag-shi,
.tag-ying {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 4px;
    line-height: 1.2;
}

.tag-shi {
    background: #b91c1c;
    color: white;
}

.tag-ying {
    background: #1d4ed8;
    color: white;
}

/* 六亲颜色 */
.liu-qin {
    font-weight: 600;
}

.liu-qin-fumu {
    color: #1d4ed8;
}

.liu-qin-zi {
    color: #16a34a;
}

.liu-qin-guan {
    color: #b91c1c;
}

.liu-qin-cai {
    color: #d97706;
}

.liu-qin-xiong {
    color: #7c3aed;
}

/* 响应式 */
@media (max-width: 640px) {
    :root {
        --coin-size: 60px;
    }

    .coin-text {
        font-size: 22px;
    }

    .coin-text.manchu {
        font-size: 18px;
    }

    .coins-container {
        gap: 16px;
        padding: 10px;
    }

    .cast-results {
        min-width: 130px;
    }

    .gua-pan {
        padding: 12px 14px;
        /* 关键：宽度收回到容器内，让 overflow-x 生效，排盘可左右滑动 */
        width: 100%;
        min-width: 0;
        display: block;
        -webkit-overflow-scrolling: touch;
    }

    .gua-pan-row {
        /* 手机端紧凑列宽：六神/六亲/地支/天干/伏神/世应/爻/爻/世应/天干/地支/六亲 */
        grid-template-columns: 20px 36px 44px 20px 50px 26px 38px 38px 26px 20px 44px 36px;
        gap: 3px;
        padding: 10px 0;
        font-size: 11px;
        min-width: 452px;
    }

    .pan-fushen {
        font-size: 9px;
    }

    /* 手机端无伏神时收起伏神列 */
    .gua-pan.no-fushen .gua-pan-row {
        grid-template-columns: 20px 36px 44px 20px 26px 38px 38px 26px 20px 44px 36px;
        min-width: 384px;
    }

    /* 手机端爻线：线长、线宽、间隔整体收窄 */
    .pan-yao {
        width: 30px;
        height: 2px;
    }

    .pan-yao.yin::before,
    .pan-yao.yin::after {
        width: 12px;
        height: 2px;
    }

    .pan-yao-area {
        height: 18px;
        gap: 3px;
    }

    .pan-yao.dong {
        box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.25);
    }

    .pan-yao.yin.dong::before,
    .pan-yao.yin.dong::after {
        box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.25);
    }

    .pan-mark {
        font-size: 10px;
        width: 10px;
    }

    .tag-shi,
    .tag-ying {
        padding: 1px 5px;
        font-size: 10px;
    }

    .yao {
        width: 60px;
    }

    .yao.yin::before,
    .yao.yin::after {
        width: 26px;
    }
}

/* 高频问题快捷按钮 */
.quick-chip {
    padding: 4px 12px;
    font-size: 13px;
    color: #57534e;
    background: white;
    border: 1px solid #d6d3d1;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.6;
}

.quick-chip:hover {
    border-color: #991b1b;
    color: #991b1b;
}

.quick-chip.active {
    background: #991b1b;
    border-color: #991b1b;
    color: white;
}

@media (max-width: 640px) {
    .quick-chip {
        padding: 3px 10px;
        font-size: 12px;
    }
}
