.ziwei-calculator-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: "Microsoft YaHei", "SimHei", "Heiti SC", sans-serif;
}

/* Form Styles */
.ziwei-form {
    background: #faf8f5;
    border: 2px solid #c9a227;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
}

.ziwei-form .form-row {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ziwei-form label {
    width: 80px;
    font-weight: bold;
    color: #5a3e1b;
    font-size: 14px;
}

.ziwei-form input,
.ziwei-form select {
    padding: 8px 10px;
    border: 1px solid #d4c4a8;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.ziwei-form input[type="text"] {
    width: 120px;
}

.ziwei-form input[type="number"] {
    width: 100px;
}

.ziwei-submit {
    background: linear-gradient(135deg, #c9a227 0%, #8b6914 100%);
    color: white;
    border: none;
    padding: 10px 35px;
    font-size: 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.ziwei-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(201, 162, 39, 0.4);
}

/* Chart Container */
.ziwei-chart-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
}

/* Main Grid - 4x4 with center info panel */
.ziwei-chart-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, minmax(150px, auto));
    gap: 1px;
    background: #bbb;
    border: 2px solid #333;
}

/* Palace Box */
.palace-box {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 8px 6px 8px;
    background: #fdfcf8;
    position: relative;
    min-height: 150px;
}

.palace-box.is-ming-gong {
    background: #fff8e1;
}

/* Stars Area */
.palace-stars-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.star-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.star-name {
    font-size: 15px;
    line-height: 1.3;
}

.star-name.major-star {
    color: #c62828;
    font-weight: bold;
}

.star-name.minor-star {
    color: #c62828;
    font-size: 14px;
}

.minor-stars-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

/* 四化 Tags */
.hua-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: white;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
}

.hua-lu {
    background: #4caf50;
}

.hua-quan {
    background: #2196f3;
}

.hua-ke {
    background: #e65100;
}

.hua-ji {
    background: #b71c1c;
}

.hua-symbol {
    font-size: 12px;
    font-weight: normal;
}

.hua-symbol.hua-lu {
    color: #4caf50;
}

.hua-symbol.hua-quan {
    color: #2196f3;
}

.hua-symbol.hua-ke {
    color: #e65100;
}

.hua-symbol.hua-ji {
    color: #b71c1c;
}

/* Floating Hua Tags */
.floating-hua {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: white;
    font-weight: bold;
}

.floating-hua.hua-lu {
    background: #4caf50;
}

/* Palace Info Bar */
.palace-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed #ddd;
    padding-top: 5px;
    margin-top: 4px;
    font-size: 13px;
}

.palace-name-tag {
    background: #e8e8e8;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

.palace-name-tag.is-ming {
    background: #d4c4a8;
    color: #5a3e1b;
    font-weight: bold;
}

.age-range {
    color: #333;
    font-size: 13px;
    font-weight: 500;
}

.ganzhi {
    color: #333;
    font-size: 13px;
    letter-spacing: 2px;
}

/* Center Info Panel */
.center-info-panel {
    grid-row: 2 / span 2;
    grid-column: 2 / span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #fff;
    position: relative;
    overflow: hidden;
}

.center-branding {
    text-align: center;
    margin-bottom: 15px;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #8b4513;
    font-size: 18px;
    font-weight: bold;
}

.logo-icon {
    font-size: 24px;
}

.brand-sub {
    font-size: 9px;
    color: #999;
    letter-spacing: 1px;
    margin-top: 2px;
}

.center-birth-info {
    text-align: left;
    margin-bottom: 15px;
}

.info-row {
    margin-bottom: 6px;
    font-size: 15px;
    line-height: 1.5;
}

.info-label {
    font-weight: bold;
    color: #333;
    display: inline-block;
    width: 60px;
    text-align: right;
}

.info-value {
    color: #333;
}

.center-checkboxes {
    display: flex;
    gap: 15px;
    z-index: 2;
}

.chk-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    background: #f5f5f5;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #ddd;
}

.chk-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
}

/* Connection Lines SVG */
.connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Explicit Grid Placement */
.palace-box[data-pos="0,0"] {
    grid-row: 1;
    grid-column: 1;
}

.palace-box[data-pos="0,1"] {
    grid-row: 1;
    grid-column: 2;
}

.palace-box[data-pos="0,2"] {
    grid-row: 1;
    grid-column: 3;
}

.palace-box[data-pos="0,3"] {
    grid-row: 1;
    grid-column: 4;
}

.palace-box[data-pos="1,0"] {
    grid-row: 2;
    grid-column: 1;
}

.palace-box[data-pos="1,3"] {
    grid-row: 2;
    grid-column: 4;
}

.palace-box[data-pos="2,0"] {
    grid-row: 3;
    grid-column: 1;
}

.palace-box[data-pos="2,3"] {
    grid-row: 3;
    grid-column: 4;
}

.palace-box[data-pos="3,0"] {
    grid-row: 4;
    grid-column: 1;
}

.palace-box[data-pos="3,1"] {
    grid-row: 4;
    grid-column: 2;
}

.palace-box[data-pos="3,2"] {
    grid-row: 4;
    grid-column: 3;
}

.palace-box[data-pos="3,3"] {
    grid-row: 4;
    grid-column: 4;
}

/* Responsive */
@media (max-width: 768px) {
    .ziwei-chart-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }

    .center-info-panel {
        grid-row: auto;
        grid-column: 1 / span 2;
        order: -1;
        min-height: 200px;
    }

    .palace-box {
        min-height: 120px;
    }

    .palace-box[data-pos] {
        grid-row: auto !important;
        grid-column: auto !important;
    }
}

/* Loading */
.ziwei-result {
    margin-top: 20px;
}
