/* 仅768px以下手机屏幕生效，全部移动端优化 */
html {
    font-size: 55%;
}
body {
    max-width: 100%;
    padding: 0 1rem;
    margin: 1.5rem auto;
}
h2 {
    font-size: 2.6rem;
}

/* ========== 四个主按钮 ========== */
.btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 1rem 0.5rem;
}
.btns button {
    flex: 0 0 calc(50% - 0.5rem);
    font-size: 2.2rem !important;
    padding: 0.8rem 1.2rem;
    margin: 0 !important;
    text-align: left;
    box-sizing: border-box;
}

/* ========== 时间起卦子按钮 ========== */
.sub-tab {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    padding: 0;
    margin-bottom: 1.5rem;
}
.sub-tab button {
    flex: 1 1 100%;
    font-size: 1.8rem !important;
    color: #888 !important;
    padding: 1rem;
    margin: 0 !important;
    width: 100%;
    border-color: #bbb;
}

/* ========== 时间起卦表单项 ========== */
.time-item {
    display: block !important;
    margin: 1.5rem 0 !important;
    width: 100%;
    font-size: 2rem !important;
}
.time-item select,
.time-item input {
    font-size: 2rem !important;
    height: 4.2rem !important;
    padding: 0.5rem !important;
    min-width: 12rem;
}
.time-item input[type="number"] {
    width: 10rem !important;
}

/* ========== 数字起卦 ========== */
.num-tip-text {
    font-size: 1.4rem !important;
    color: #444;
}
.num-input-label {
    font-size: 2.2rem !important;
}
.num-input {
    font-size: 2.2rem !important;
    height: 4.2rem !important;
    width: 100% !important;
    max-width: 300px;
}

/* ========== 六十四卦自选 ========== */
.dong-select {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 0.5rem;
    margin: 1rem 0;
}
.dong-select .dong-title {
    width: 100%;
    font-size: 2.4rem !important;
    font-weight: bold;
    margin-bottom: 0.5rem;
}
.dong-select label {
    flex: 0 0 calc(33.33% - 0.5rem);
    font-size: 2rem !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dong-select label input[type="radio"] {
    width: 1.8rem !important;
    height: 1.8rem !important;
}

/* ========== 上下卦自选 ========== */
.form-updown {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 1rem;
}
.form-updown .updown-group {
    flex: 1 1 33%;
    max-width: 33%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f9f9f9;
    box-sizing: border-box;
}
.form-updown .updown-label {
    font-size: 2.2rem !important;
    font-weight: bold;
    margin-bottom: 0.8rem;
    width: 100%;
    text-align: center;
}
.form-updown .updown-group label {
    font-size: 2.1rem !important;
    display: flex !important;
    align-items: center;
    gap: 0.8rem;
    margin: 0.4rem 0 !important;
    padding: 0.2rem 0;
    width: 100%;
}
.form-updown .updown-group label input[type="radio"] {
    width: 2.1rem !important;
    height: 2.1rem !important;
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .form-updown {
        flex-wrap: wrap;
    }
    .form-updown .updown-group {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* ========== 其他通用 ========== */
input[type="number"],
input[type="text"],
select {
    font-size: 1.8rem;
    height: 4rem !important;
    padding: 0.6rem !important;
}
input[type="radio"] {
    width: 1.8rem !important;
    height: 1.8rem !important;
}
table {
    font-size: 1.6rem;
}
input[type="submit"] {
    font-size: 2.2rem !important;
    padding: 1.2rem 0 !important;
    width: 100%;
    height: auto !important;
}

/* 六十四卦表格横向滚动 */
.gua-table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid #aaa;
}
.gua-table-wrap table {
    min-width: 1200px;
    width: auto;
}
td {
    padding: 0.6rem 0.4rem;
}

/* ========== 手机端排盘结果：动爻可见，整体居中 ========== */
.gua-wrap {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 0.48rem !important;
    margin: 1.8rem 0 !important;
    justify-content: space-between !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.single-gua-card {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 1rem 1rem !important;      /* 增加左右内边距，确保动爻标记不溢出 */
    background: #fefbe8 !important;
    border-radius: 8px !important;
    border: 1px solid #f0e8d0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
}

.col-name {
    display: none !important;
}

.gua-title {
    font-size: 1.68rem !important;
    margin: 0 0 0.24rem 0 !important;
    color: #8020a0 !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    font-weight: bold !important;
    word-break: break-word !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
}
.gua-title span {
    font-size: 1.56rem !important;
    color: #0044cc !important;
    font-weight: normal !important;
    display: block !important;
    text-align: center !important;
    word-break: break-word !important;
    margin-top: 0.12rem !important;
    max-width: 100% !important;
}
.gua-bottom-text {
    display: none !important;
}

/* 每一爻行：使用 flex，整体居中 */
.yao-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.68rem !important;
    min-height: 2.64rem !important;
    margin: 0.12rem 0 !important;
    gap: 0.24rem !important;
    flex-shrink: 0 !important;
    width: 100% !important;
}

/* 爻线容器：固定宽度，内部居中 */
.col-line {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 8rem !important;            /* 固定宽度，防止挤压动爻标记 */
}

/* 阳爻线条 */
.yang-full {
    width: 100% !important;
    height: 0.6rem !important;
    background: #000 !important;
    border-radius: 3px !important;
}

/* 阴爻两段 */
.yin-split {
    width: 100% !important;
    gap: 0.8rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.yin-split span {
    flex: 1 1 0 !important;
    height: 0.6rem !important;
    background: #000 !important;
    border-radius: 3px !important;
}

/* 动爻标记：固定宽度，紧跟在爻线右侧 */
.col-dong {
    flex: 0 0 auto !important;
    width: 2.4rem !important;
    font-size: 1.68rem !important;
    text-align: center !important;
    color: #d82828 !important;
    font-weight: bold !important;
    line-height: 1 !important;
}

/* 确保卡片内容不溢出 */
.single-gua-card {
    overflow: hidden !important;
}

/* ========== 手机端外框统一 ========== */
.result-box,
.gua-yao-wrapper,
.xiang-duan-wrapper {
    padding: 1.2rem 1.2rem !important;
    margin: 1.5rem auto 0 !important;
    border: 1px solid #d0d0d0 !important;
    background: #8ef638 !important;
    border-radius: 12px !important;
}

.result-box h3,
.gua-yao-wrapper h3 {
    font-size: 2.4rem !important;
    margin-bottom: 1.2rem !important;
    text-align: center !important;
    color: #c82423 !important;
}

/* 手机端 detail-text */
.detail-text {
    font-size: 1.6rem !important;
    padding: 1.2rem !important;
    line-height: 1.8 !important;
    border: 1px solid #ccc !important;
    background: #8ef638 !important;
    border-radius: 6px !important;
    margin-bottom: 1.5rem !important;
}
.detail-text .dong-info {
    display: block;
    margin-top: 0.3rem;
}
.detail-text .ti-yong-item span,
.detail-text .ce-gui-item span {
    margin-right: 1.5rem !important;
}

.result-box .auto-tip {
    font-size: 1.6rem !important;
    display: block;
    margin-top: 0.2rem;
}

/* 卦爻辞内部容器 */
.gua-yao-container {
    background: #f0f0f0 !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 1.5rem !important;
    gap: 1.5rem !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}
.gua-yao-card {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    padding: 1.5rem !important;
}
.gua-yao-title {
    font-size: 2.2rem !important;
}
.gua-yao-gua,
.gua-yao-yao ul {
    font-size: 1.6rem !important;
}

/* 断法内部容器 */
.xiang-duan-container {
    background: #f0f0f0 !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 1.5rem !important;
    gap: 1.5rem !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
}
.xiang-duan-card {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    padding: 1.5rem !important;
}
.xiang-duan-title {
    font-size: 2.0rem !important;
}
.xiang-duan-content p {
    font-size: 1.6rem !important;
    margin-bottom: 1.2em !important;
}
.gua-name {
    font-size: 1.6rem !important;
}