/* 移动端响应式设计 */

/* 平板设备 (768px 以下) */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 25px 20px;
        border-radius: 12px;
    }
    
    /* 头部按钮布局 - 保持横排 */
    .header-layout {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important;
        align-items: center !important;
        gap: 8px !important;
        margin-bottom: 15px !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    .theme-button-wrapper {
        justify-self: start !important;
        position: relative !important;
        z-index: 100 !important;
    }
    
    .theme-toggle-btn,
    .history-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
        position: relative !important;
        z-index: 100 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    .history-btn {
        justify-self: end !important;
        z-index: 100 !important;
    }
    
    h1 {
        font-size: 22px !important;
        letter-spacing: 8px !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    .history-btn {
        justify-self: end !important;
    }
    
    .subtitle {
        font-size: 12px !important;
        margin-bottom: 25px !important;
    }
    
    /* 风格切换器 */
    .theme-switcher {
        top: 10px;
        right: 10px;
        gap: 8px;
    }
    
    .theme-label {
        display: none;
    }
    
    .theme-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .theme-menu {
        right: 0;
        min-width: 160px;
    }
    
    /* 输入区域 */
    .input-section {
        padding: 12px 15px;
        margin-bottom: 12px;
    }
    
    .radio-group {
        margin-bottom: 10px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .radio-group label {
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
        font-size: 14px;
    }
    
    .radio-group label input[type="radio"] {
        margin-right: 10px !important;
        flex-shrink: 0 !important;
    }
    
    .radio-group label .radio-text {
        flex: 1 !important;
    }
    
    .datetime-input input {
        display: block;
        width: 100%;
        margin: 8px 0;
        padding: 10px;
        font-size: 15px;
    }
    
    .question-input-wrapper {
        margin-top: 10px !important;
    }
    
    .question-input-inline {
        padding: 10px 12px !important;
        font-size: 14px !important;
    }
    
    .btn {
        width: 100%;
        padding: 12px 25px;
        font-size: 15px;
        letter-spacing: 2px;
        margin-top: 12px !important;
    }
    
    /* 信息表格 */
    .info-table {
        margin-bottom: 15px !important;
        font-size: 12px;
    }
    
    .info-table td {
        padding: 8px 6px;
        font-size: 12px;
        line-height: 1.4;
    }
    
    .info-table td:first-child {
        width: 70px;
        min-width: 70px;
        font-size: 12px !important;
        padding: 8px 4px;
    }
    
    /* 确保"问题"标签和内容字体大小一致 */
    .info-table tr:first-child td:first-child {
        font-size: 12px !important;
    }
    
    .info-table tr:first-child td:nth-child(2) {
        font-size: 12px !important;
    }
    
    /* 四柱和旬空行的单元格 */
    .info-table tr:nth-child(4) td,
    .info-table tr:nth-child(5) td {
        padding: 8px 4px;
        font-size: 12px;
        white-space: nowrap;
        text-decoration: none !important;
    }
    
    /* 四柱和旬空的标签列 */
    .info-table tr:nth-child(4) td:first-child,
    .info-table tr:nth-child(5) td:first-child {
        width: 70px;
        min-width: 70px;
    }
    
    /* 移除旬空高亮的下划线 */
    .info-table td.highlight {
        text-decoration: none !important;
        border-bottom: none !important;
    }
    
    /* 卦符显示 - 自适应同排 */
    .gua-display {
        flex-wrap: nowrap;
        gap: 4px;
        padding: 12px 4px 15px;
        margin: 10px 0;
        justify-content: space-between;
        overflow: visible;
        min-height: 200px;
    }
    
    .gua-item {
        flex: 1 1 0;
        min-width: 0;
    }
    
    .yao-gap {
        margin-bottom: 4px !important;
    }
    
    .gua-name {
        font-size: 11px !important;
        margin-bottom: 6px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0px;
    }
    
    .gua-symbols {
        font-size: 9px;
        line-height: 1.0;
        font-weight: 900;
        letter-spacing: -0.5px;
        margin-top: 2px;
    }
    
    .yao-line {
        font-size: 9px;
        line-height: 1.5;
        font-weight: 900;
        height: 14px;
        margin: 3px 0;
    }
    
    .yao-yang {
        width: 60px;
        height: 9px;
    }
    
    .yao-yin {
        width: 60px;
        gap: 7px;
    }
    
    .yin-left,
    .yin-right {
        width: 26.5px;
        height: 9px;
    }
    
    .yao-gap {
        margin-bottom: 6px !important;
    }
}

/* 小屏手机 (480px 以下) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 20px 15px;
        border-radius: 10px;
    }
    
    /* 头部按钮布局 */
    .header-layout {
        gap: 6px !important;
        margin-bottom: 12px !important;
        z-index: 10 !important;
    }
    
    .theme-button-wrapper {
        z-index: 100 !important;
    }
    
    .theme-toggle-btn,
    .history-btn {
        padding: 5px 8px !important;
        font-size: 11px !important;
        z-index: 100 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    h1 {
        font-size: 20px !important;
        letter-spacing: 6px !important;
        margin-bottom: 0 !important;
    }
    
    .subtitle {
        font-size: 11px !important;
        margin-bottom: 20px !important;
    }
    
    /* 风格切换器 */
    .theme-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .theme-menu {
        min-width: 140px;
        padding: 6px;
    }
    
    .theme-option {
        padding: 10px 12px;
        font-size: 13px;
        gap: 10px;
    }
    
    .theme-preview {
        width: 28px;
        height: 28px;
    }
    
    /* 输入区域 */
    .input-section {
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    
    .radio-group {
        margin-bottom: 8px !important;
        gap: 10px !important;
    }
    
    .radio-group label {
        font-size: 13px;
    }
    
    .question-input-inline {
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
        letter-spacing: 2px;
        margin-top: 10px !important;
    }
    
    /* 信息表格 */
    .info-table {
        margin-bottom: 12px !important;
        font-size: 11px;
    }
    
    .info-table td {
        padding: 6px 4px;
        font-size: 11px;
        line-height: 1.3;
    }
    
    .info-table td:first-child {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
        font-size: 11px !important;
        padding: 6px 2px;
    }
    
    /* 确保"问题"标签和内容字体大小一致 */
    .info-table tr:first-child td:first-child {
        font-size: 11px !important;
    }
    
    .info-table tr:first-child td:nth-child(2) {
        font-size: 11px !important;
    }
    
    /* 四柱和旬空行的单元格 */
    .info-table tr:nth-child(4) td,
    .info-table tr:nth-child(5) td {
        padding: 6px 2px;
        font-size: 11px;
        white-space: nowrap;
        text-decoration: none !important;
    }
    
    /* 四柱和旬空的标签列 */
    .info-table tr:nth-child(4) td:first-child,
    .info-table tr:nth-child(5) td:first-child {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
    }
    
    /* 移除旬空高亮的下划线 */
    .info-table td.highlight {
        text-decoration: none !important;
        border-bottom: none !important;
    }
    
    /* 卦符显示 - 自适应同排，更紧凑 */
    .gua-display {
        flex-wrap: nowrap;
        gap: 3px;
        padding: 10px 2px 12px;
        justify-content: space-between;
        overflow: visible;
        min-height: 180px;
    }
    
    .gua-item {
        flex: 1 1 0;
        min-width: 0;
    }
    
    .yao-gap {
        margin-bottom: 3px !important;
    }
    
    .gua-name {
        font-size: 10px !important;
        margin-bottom: 5px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        letter-spacing: 0px;
    }
    
    .gua-symbols {
        font-size: 7px;
        line-height: 1.0;
        font-weight: 900;
        letter-spacing: -0.5px;
        margin-top: 2px;
    }
    
    .yao-line {
        font-size: 7px;
        line-height: 1.4;
        font-weight: 900;
        height: 12px;
        margin: 2.5px 0;
    }
    
    .yao-yang {
        width: 55px;
        height: 8px;
    }
    
    .yao-yin {
        width: 55px;
        gap: 6px;
    }
    
    .yin-left,
    .yin-right {
        width: 24.5px;
        height: 8px;
    }
    
    .yao-gap {
        margin-bottom: 5px !important;
    }
}

/* 超小屏手机 (360px 以下) */
@media (max-width: 360px) {
    .container {
        padding: 15px 10px;
    }
    
    /* 头部按钮布局 */
    .header-layout {
        gap: 4px !important;
        z-index: 10 !important;
    }
    
    .theme-button-wrapper {
        z-index: 100 !important;
    }
    
    .theme-toggle-btn,
    .history-btn {
        padding: 4px 6px !important;
        font-size: 10px !important;
        z-index: 100 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }
    
    h1 {
        font-size: 18px !important;
        letter-spacing: 5px !important;
    }
    
    .info-table {
        font-size: 10px;
    }
    
    .info-table td {
        padding: 5px 3px;
        font-size: 10px;
        line-height: 1.2;
    }
    
    .info-table td:first-child {
        width: 55px !important;
        min-width: 55px !important;
        max-width: 55px !important;
        font-size: 10px !important;
        padding: 5px 2px;
    }
    
    /* 确保"问题"标签和内容字体大小一致 */
    .info-table tr:first-child td:first-child {
        font-size: 10px !important;
    }
    
    .info-table tr:first-child td:nth-child(2) {
        font-size: 10px !important;
    }
    
    /* 四柱和旬空行的单元格 */
    .info-table tr:nth-child(4) td,
    .info-table tr:nth-child(5) td {
        padding: 5px 2px;
        font-size: 10px;
        white-space: nowrap;
        text-decoration: none !important;
    }
    
    /* 移除旬空高亮的下划线 */
    .info-table td.highlight {
        text-decoration: none !important;
        border-bottom: none !important;
    }
    
    .sizhu-table td {
        padding: 8px 4px;
        font-size: 12px;
    }
    
    .sizhu-table td.label {
        width: 65px !important;
        min-width: 65px !important;
        max-width: 65px !important;
        font-size: 11px;
    }
    
    .gua-display {
        gap: 2px;
        padding: 8px 1px;
        overflow: hidden;
        min-height: 160px;
    }
    
    .yao-gap {
        margin-bottom: 3px !important;
    }
    
    .gua-name {
        font-size: 9px !important;
        margin-bottom: 4px !important;
        letter-spacing: 0px;
    }
    
    .gua-symbols {
        font-size: 6px;
        line-height: 1.0;
        font-weight: 900;
        letter-spacing: -0.5px;
        margin-top: 1px;
    }
    
    .yao-line {
        font-size: 6px;
        line-height: 1.3;
        font-weight: 900;
        height: 11px;
        margin: 2px 0;
    }
    
    .yao-yang {
        width: 48px;
        height: 7px;
    }
    
    .yao-yin {
        width: 48px;
        gap: 5px;
    }
    
    .yin-left,
    .yin-right {
        width: 21.5px;
        height: 7px;
    }
    
    .yao-gap {
        margin-bottom: 4px !important;
    }
}

/* 横屏模式优化 - 自适应同排 */
@media (max-width: 768px) and (orientation: landscape) {
    .gua-display {
        gap: 12px;
        padding: 15px 5px;
    }
    
    .gua-item {
        flex: 1 1 0;
    }
    
    .gua-symbols {
        font-size: 16px;
        line-height: 2.3;
    }
    
    .gua-name {
        font-size: 13px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        padding: 15px 30px;
        font-size: 16px;
    }
    
    .theme-btn {
        width: 48px;
        height: 48px;
    }
    
    .theme-option {
        padding: 14px;
    }
    
    input[type="date"],
    input[type="time"] {
        font-size: 16px;
        padding: 12px;
    }
}


/* 上下卦间距调整 */
@media (max-width: 768px) {
    .yao-gap {
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .yao-gap {
        margin-bottom: 10px;
    }
}

@media (max-width: 360px) {
    .yao-gap {
        margin-bottom: 8px;
    }
}

/* 移动端按钮触摸优化 - 全局 */
@media (max-width: 768px) {
    button {
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
    }
    
    .theme-toggle-btn,
    .history-btn {
        min-height: 36px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 确保按钮在最上层 */
    .header-layout button {
        position: relative !important;
        z-index: 1000 !important;
    }
    
    /* 风格菜单层级 */
    .theme-menu {
        z-index: 2000 !important;
    }
}

/* 移动端字体大小统一 */
@media (max-width: 768px) {
    /* 问题行字体统一为12px */
    .info-table tr:first-child td {
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    /* 问题行字体统一为11px */
    .info-table tr:first-child td {
        font-size: 11px !important;
    }
}

@media (max-width: 360px) {
    /* 问题行字体统一为10px */
    .info-table tr:first-child td {
        font-size: 10px !important;
    }
}


/* 移动端按钮优化 - 横排显示，缩小尺寸 */
@media (max-width: 768px) {
    .save-case-btn-wrapper .button-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 15px !important;
        flex-wrap: nowrap !important;
    }
    
    .save-case-btn-wrapper button {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 12px 10px !important;
        font-size: 13px !important;
        margin: 0 !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 移除hover效果在移动端 */
    .save-case-btn-wrapper button:hover {
        transform: none !important;
    }
}

/* 小屏手机 (480px 以下) - 更紧凑 */
@media (max-width: 480px) {
    .save-case-btn-wrapper .button-container {
        padding: 12px !important;
        gap: 8px !important;
    }
    
    .save-case-btn-wrapper button {
        padding: 10px 8px !important;
        font-size: 12px !important;
    }
}

/* 超小屏 (360px 以下) - 最紧凑 */
@media (max-width: 360px) {
    .save-case-btn-wrapper .button-container {
        padding: 10px !important;
        gap: 6px !important;
    }
    
    .save-case-btn-wrapper button {
        padding: 8px 6px !important;
        font-size: 11px !important;
    }
}
