* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.app {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* 头部样式 */
.header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 主要内容区 */
.main {
    padding: 0 1rem 2rem;
}

/* 控制面板 */
.control-panel {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 标签切换 */
.mode-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #2c3e50;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 模式内容 */
.mode-content {
    transition: all 0.3s ease;
}

.mode-content.hidden {
    display: none;
}

/* 按钮样式 */
.action-btn {
    width: 100%;
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.action-btn.secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.action-btn.secondary:hover {
    background: #e9ecef;
}

/* 手动选择模式 */
.hexagram-builder {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.yao-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
}

.yao-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.8rem;
    text-align: center;
    flex: 1;
}

.yao-toggles {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    gap: 0.3rem;
}

.yao-toggle-btn {
    flex: 1;
    padding: 0.4rem 0.2rem;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yao-toggle-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.yao-toggle-btn.yang {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.yao-toggle-btn.yin {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
}

/* 结果展示区域 */
.result-section {
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hexagram-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 卦象视觉显示 */
.hexagram-visual {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.hexagram-name {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.hexagram-symbol {
    margin: 1.5rem 0;
}

.yao-line {
    height: 12px;
    width: 150px;
    margin: 18px auto;
    border-radius: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.yao-line.yang {
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.yao-line.yin {
    background: linear-gradient(90deg, #667eea, #764ba2);
    position: relative;
}

.yao-line.yin::after {
    content: '';
    position: absolute;
    width: 10%;
    height: 12px;
    background: white;
    border-radius: 0;
}

.hexagram-info {
    margin-top: 1rem;
}

.hexagram-number {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.hexagram-description {
    color: #495057;
    font-size: 1rem;
}

/* 卦辞和爻辞 */
.gua-ci, .yao-ci {
    margin-bottom: 2rem;
}

.gua-ci h3, .yao-ci h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #667eea;
}

.gua-ci p {
    line-height: 1.8;
    color: #495057;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* 爻辞列表 */
.yao-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    border-left: 4px solid #28a745;
}

.yao-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.yao-text {
    color: #495057;
    line-height: 1.7;
}

/* 结果操作按钮 */
.result-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
    text-align: center;
}

.result-actions .action-btn {
    max-width: 200px;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
        margin: 0;
    }
    
    .header {
        padding: 1.5rem 1rem 0.8rem;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .main {
        padding: 0 0.8rem 1.5rem;
    }
    
    .control-panel, .hexagram-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .hexagram-builder {
        gap: 0.4rem;
    }
    
    .yao-labels, .yao-toggles {
        max-width: 280px;
    }
    
    .yao-label {
        font-size: 0.75rem;
    }
    
    .yao-toggle-btn {
        padding: 0.3rem 0.1rem;
        font-size: 0.75rem;
        min-height: 28px;
    }
    
    .hexagram-name {
        font-size: 1.6rem;
    }
    
    .hexagram-symbol {
        margin: 1rem 0;
    }
    
    .yao-line {
        height: 10px;
        width: 160px;
        margin: 15px auto;
    }
    
    .yao-line.yin::after {
        height: 10px;
    }
    
    .gua-ci p, .yao-item {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    .header h1 {
        font-size: 1.6rem;
    }
    
    .main {
        padding: 0 0.6rem 1rem;
    }
    
    .control-panel, .hexagram-card {
        padding: 0.8rem;
    }
    
    .tab-btn {
        padding: 0.6rem;
        font-size: 0.9rem;
    }
    
    .action-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .yao-labels, .yao-toggles {
        max-width: 260px;
    }
    
    .yao-label {
        font-size: 0.7rem;
    }
    
    .yao-toggle-btn {
        padding: 0.25rem 0.05rem;
        font-size: 0.7rem;
        min-height: 26px;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 触摸友好的交互 */
@media (hover: none) and (pointer: coarse) {
    .action-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .action-btn:active {
        transform: scale(0.98);
    }
    
    .tab-btn:active,
    .yao-toggle-btn:active {
        transform: scale(0.95);
    }
}