.gua {
    float: left;
    margin-right: 16px;
    text-align: center;
    font-size: 20px;
    font-weight: 900;
    color: gray;
    cursor: pointer;
}

.yao {
    font-size: 0px;
    margin-bottom: 6px;
}

.line {
    width: 36px;
    height: 12px;
    background: #000;
    display: inline-block;
}

.yin .change {
    width: 10px;
    height: 12px;
    background: transparent;
    display: inline-block;
}

.yang .change {
    width: 10px;
    height: 12px;
    background: #000;
    display: inline-block;
}

.south {
    position: absolute;
    top: 50px;
    left: 200px;
}

.north {
    position: absolute;
    top: 350px;
    left: 200px;
    transform: rotate(180deg)
}

.west {
    position: absolute;
    top: 200px;
    left: 350px;
    transform: rotate(90deg)
}

.east {
    position: absolute;
    top: 200px;
    left: 50px;
    transform: rotate(-90deg)
}

.southeast {
    position: absolute;
    top: 100px;
    left: 100px;
    transform: rotate(-45deg);
}

.northwest {
    position: absolute;
    top: 300px;
    left: 300px;
    transform: rotate(135deg)
}

.southwest {
    position: absolute;
    top: 100px;
    left: 300px;
    transform: rotate(45deg)
}

.northeast {
    position: absolute;
    top: 300px;
    left: 100px;
    transform: rotate(-135deg);
}

.position {
    font-size: 16px;
    color: gainsboro;
}

/* 乾 */
.south2northwest {
    animation: south2northwest 1s forwards ease;
}
@keyframes south2northwest {
    from {position: absolute;
    top: 50px;
    left: 200px;}
    to {position: absolute;
    top: 300px;
    left: 300px;
    transform: rotate(135deg)}
}
.northwest2south {
    animation: northwest2south 1s forwards ease;
}
@keyframes northwest2south {
    to {position: absolute;
    top: 50px;
    left: 200px;}
    from {position: absolute;
    top: 300px;
    left: 300px;
    transform: rotate(135deg)}
}

/* 坤 */
.north2southwest {
    animation: north2southwest 1s forwards ease;
}
@keyframes north2southwest {
    from {position: absolute;
    top: 350px;
    left: 200px;
    transform: rotate(180deg)}
    to {position: absolute;
    top: 100px;
    left: 300px;
    transform: rotate(45deg)}
}
.southwest2north {
    animation: southwest2north 1s forwards ease;
}
@keyframes southwest2north {
    to {position: absolute;
    top: 350px;
    left: 200px;
    transform: rotate(180deg)}
    from {position: absolute;
    top: 100px;
    left: 300px;
    transform: rotate(45deg)}
}

/* 兑 */
.southeast2west {
    animation: southeast2west 1s forwards ease;
}
@keyframes southeast2west {
    from {position: absolute;
    top: 100px;
    left: 100px;
    transform: rotate(-45deg);}
    to {position: absolute;
    top: 200px;
    left: 350px;
    transform: rotate(90deg)}
}
.west2southeast {
    animation: west2southeast 1s forwards ease;
}
@keyframes west2southeast {
    to {position: absolute;
    top: 100px;
    left: 100px;
    transform: rotate(-45deg);}
    from {position: absolute;
    top: 200px;
    left: 350px;
    transform: rotate(90deg)}
}

/* 艮 */
.northwest2northeast {
    animation: northwest2northeast 1s forwards ease;
}
@keyframes northwest2northeast {
    from {position: absolute;
    top: 300px;
    left: 300px;
    transform: rotate(135deg)}
    to {position: absolute;
    top: 300px;
    left: 100px;
    transform: rotate(-135deg);}
}
.northeast2northwest {
    animation: northeast2northwest 1s forwards ease;
}
@keyframes northeast2northwest {
    to {position: absolute;
    top: 300px;
    left: 300px;
    transform: rotate(135deg)}
    from {position: absolute;
    top: 300px;
    left: 100px;
    transform: rotate(-135deg);}
}

/* 巺 */
.southwest2southeast {
    animation: southwest2southeast 1s forwards ease;
}
@keyframes southwest2southeast {
    from {position: absolute;
    top: 100px;
    left: 300px;
    transform: rotate(45deg)}
    to {position: absolute;
    top: 100px;
    left: 100px;
    transform: rotate(-45deg);}
}
.southeast2southwest {
    animation: southeast2southwest 1s forwards ease;
}
@keyframes southeast2southwest {
    to {position: absolute;
    top: 100px;
    left: 300px;
    transform: rotate(45deg)}
    from {position: absolute;
    top: 100px;
    left: 100px;
    transform: rotate(-45deg);}
}

/* 震 */
.northeast2east {
    animation: northeast2east 1s forwards ease;
}
@keyframes northeast2east {
    from {position: absolute;
    top: 300px;
    left: 100px;
    transform: rotate(-135deg);}
    to {position: absolute;
    top: 200px;
    left: 50px;
    transform: rotate(-90deg)}
}
.east2northeast {
    animation: east2northeast 1s forwards ease;
}
@keyframes east2northeast {
    to {position: absolute;
    top: 300px;
    left: 100px;
    transform: rotate(-135deg);}
    from {position: absolute;
    top: 200px;
    left: 50px;
    transform: rotate(-90deg)}
}

/* 离 */
.east2south {
    animation: east2south 1s forwards ease;
}
@keyframes east2south {
    from {position: absolute;
    top: 200px;
    left: 50px;
    transform: rotate(-90deg)}
    to {position: absolute;
    top: 50px;
    left: 200px;
    transform: rotate(0deg)}
}
.south2east {
    animation: south2east 1s forwards ease;
}
@keyframes south2east {
    to {position: absolute;
    top: 200px;
    left: 50px;
    transform: rotate(-90deg)}
    from {position: absolute;
    top: 50px;
    left: 200px;
    transform: rotate(0deg)}
}

/* 坎 */
.west2north {
    animation: west2north 1s forwards ease;
}
@keyframes west2north {
    from {position: absolute;
    top: 200px;
    left: 350px;
    transform: rotate(90deg)}
    to {position: absolute;
    top: 350px;
    left: 200px;
    transform: rotate(180deg)}
}
.north2west {
    animation: north2west 1s forwards ease;
}
@keyframes north2west {
    to {position: absolute;
    top: 200px;
    left: 350px;
    transform: rotate(90deg)}
    from {position: absolute;
    top: 350px;
    left: 200px;
    transform: rotate(180deg)}
}

.yanbtn {
    position: absolute;
    left: 0px;
    top: 540px;
    font-size: 40px;
    text-decoration: none;
    background: #000;
    color: #fff;
    padding: 0px 6px 2px 6px;
    box-shadow:-2px 0px 8px #f00,0px -2px 8px #000,0px 2px 8px #9e038a,2px 0px 8px #0f0;
    border-radius: 20%;
}

.yanbtn2 {
    position: absolute;
    left: 230px;
    top: 230px;
    font-size: 20px;
    text-decoration: none;
    background: #000;
    color: #fff;
    padding: 0px 6px 2px 6px;
    box-shadow:-4px 0px 8px #f00,0px -2px 8px #000,0px 2px 8px #9e038a,2px 0px 8px #0f0;
    border-radius: 20%;
}

/* new layout: top button row and responsive handling */
.btn-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
}
.btn-left {
    display: flex;
    align-items: center;
}
.btn-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}
.yanbtn, .yanbtn2, .meihua-btn {
    position: relative;
    margin: 0;
}
.meihua-btn {
    font-size: 16px;
    text-decoration: none;
    background: #333;
    color: #fff;
    padding: 6px 8px 8px 9px;
    border-radius: 8px;
    margin: 4px 0px 3px 8px;
}

/* First row: make xt8gua full width and responsive */
#xt8gua {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}
#xt8gua {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    display: block;
    height: 0px;
    background: linear-gradient(180deg,#fff,#f6f6f6);
    position: relative;
}

/* ensure individual gua render well in the responsive container */
#xt8gua .gua {
    float: none;
    display: inline-block;
    margin-right: 16px;
}

/* Second row: bubtn left (absolute), bubtn2 centered */

    .row2 {
        position: relative;
        width: 100%;
        display: flex;
        justify-content: left;
        align-items: left;
        padding: 12px 24px;
        box-sizing: border-box;
        gap: 30px;
    }
    .row2 > a {
        flex: 0 0 auto;
        padding: 4px 12px;
        border-radius: 8px;
        text-decoration: none;
        background: #fff;
        color: #111;
        border: 2px solid #ddd;
        
    } 

/* Third row: action buttons centered */
.row3 {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    padding: 12px 24px 20px 24px;
    box-sizing: border-box;
}
.row3 > a {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
}
.row3 > a:first-child {
    background: #111;
    color: #fff;
}
.row3 > a:last-child {
    background: #fff;
    color: #111;
    border: 2px solid #ddd;
}

@media (max-width:600px) {
    .row2, .row3 {
        flex-direction: column;
        gap: 12px;
        padding: 10px 16px;
    }
    .row2 > a, .row3 > a {
        width: 100%;
        text-align: center;
    }
}
    .row3 {
        width: 100%;
        display: flex;
        justify-content: center;
        gap: 12px;
        padding: 8px 16px 20px 16px;
        box-sizing: border-box;
    }

    .row4 {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        padding: 8px 16px 24px 16px;
        box-sizing: border-box;
    }

    /* ensure bubtn2 in row3 looks appropriate */
    .row3 .yanbtn2 {
        position: static;
        font-size: 20px;
    }

#yantitle {
    writing-mode: tb-rl;
    position: absolute;
    left: 450px;
    top: 200px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 6px;
    padding: 6px 4px 0px 4px;
    background: #e7e7e7;
    color: #000;
}

footer {
    position: fixed;
    bottom: 6px;
    /* text-align: center; */
    /* width: 100%; */
    color: gray;
    font-size: 14px;
}

/* ——— 64 卦列表：每行 2 卦，放大卦体与按钮 ——— */
#zy64gua {
    clear: both;
    width: 100%;
    max-width: 720px;
    margin: 10px auto 28px;
    padding: 12px 12px 40px;
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    overflow: visible;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 12px;
    justify-items: center;
    align-items: start;
}

.gua64 {
    float: none;
    text-align: center;
    font-size: 20px;
    font-weight: 900;
    color: #444;
    cursor: pointer;
    width: 100%;
    max-width: 168px;
    margin: 0;
    padding: 14px 8px 12px;
    box-sizing: border-box;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
    touch-action: manipulation;
    user-select: none;
}

.gua64:active {
    transform: scale(0.97);
}

.gua64:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.yao64 {
    font-size: 0;
    margin: 6px auto;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.line64 {
    width: 42px;
    height: 12px;
    background: #1a1a1a;
    display: inline-block;
    border: 0 solid #fff !important;
    border-radius: 1px;
}

.yin64 .change {
    width: 10px;
    height: 12px;
    background: transparent;
    display: inline-block;
    border: 0 solid transparent !important;
}

.yang64 .change {
    width: 10px;
    height: 12px;
    background: #1a1a1a;
    display: inline-block;
    border: 0 solid #fff !important;
}

.name64 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #4a4a4a;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 16px;
    min-height: 44px;
    min-width: 72px;
    margin-top: 10px;
    border-radius: 10px;
    box-sizing: border-box;
    line-height: 1.2;
}

.name64 a {
    color: inherit;
    text-decoration: none;
    display: block;
    width: 100%;
    padding: 0;
    /* expand hit area for mobile */
    line-height: inherit;
}

/* 64 卦页顶栏 */
.zy64-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.zy64-header .title {
    font-size: 18px;
    font-weight: 700;
}

/* 通用移动端触控与排版 */
html {
    -webkit-text-size-adjust: 100%;
}

a, button {
    touch-action: manipulation;
}

.meihua-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    font-size: 15px;
}

/* 首页按钮触控加大 */
.btn-row a {
    min-height: 48px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    #zy64gua {
        max-width: 100%;
        padding: 10px 10px 48px;
        gap: 14px 10px;
    }

    .gua64 {
        max-width: none;
        padding: 12px 6px 10px;
    }

    .line64 {
        width: 38px;
        height: 11px;
    }

    .yin64 .change,
    .yang64 .change {
        width: 9px;
        height: 11px;
    }

    .name64 {
        font-size: 15px;
        padding: 9px 12px;
        min-width: 64px;
    }

    footer {
        flex-wrap: wrap;
        gap: 6px 10px !important;
        padding: 8px 10px !important;
        font-size: 12px;
        line-height: 1.4;
        text-align: center;
    }
}

@media (min-width: 601px) {
    .line64 {
        width: 48px;
        height: 13px;
    }

    .yin64 .change,
    .yang64 .change {
        width: 12px;
        height: 13px;
    }

    .name64 {
        font-size: 17px;
        padding: 11px 18px;
    }
}