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

body {
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    padding: 30px;
    min-height: 600px;
}

/* 左侧输入面板 */
.input-panel {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
}

.input-panel h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-small {
    margin-left: 10px;
    padding: 8px 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.btn-small:hover {
    background: #5568d3;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.view-toggle {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
    display: flex;
    gap: 20px;
}

.view-toggle label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.view-toggle input[type="radio"] {
    margin-right: 5px;
}

/* 右侧结果面板 */
.result-panel {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.result-panel h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.result-view {
    display: none;
}

.result-view.active {
    display: block;
}

/* 文字版样式 */
#text-output {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 700px;
    overflow-y: auto;
}

/* 图形版样式 */
.info-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-row {
    margin: 8px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.info-item {
    font-size: 0.95em;
}

.info-item strong {
    color: #667eea;
    margin-right: 5px;
}

/* 九宫格 */
.palace-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.palace-cell {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 3px solid #667eea;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s;
    position: relative;
}

.palace-cell:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.palace-header {
    font-weight: bold;
    font-size: 1.1em;
    color: #667eea;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #667eea;
}

.palace-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.palace-row {
    font-size: 0.9em;
    line-height: 1.5;
}

.palace-gan {
    font-weight: bold;
    color: #764ba2;
    margin-top: 5px;
}

.palace-marks {
    position: absolute;
    top: 5px;
    right: 8px;
    display: flex;
    gap: 3px;
}

.mark {
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: bold;
}

.mark.empty {
    background: #ffc107;
}

.mark.horse {
    background: #28a745;
}

/* 中宫特殊样式 */
.palace-cell.zhonggong {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-color: #f39c12;
}

.palace-cell.zhonggong .palace-header {
    color: #f39c12;
    border-bottom-color: #f39c12;
}

/* Loading动画 */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误信息 */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}

/* Footer */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px;
}

footer a {
    color: #667eea;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* 响应式 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .palace-grid {
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .palace-grid {
        gap: 5px;
    }
    
    .palace-cell {
        min-height: 140px;
        padding: 10px;
    }
}
