/* ═══════ Ziwei Doushu Chart — 紫微斗数命盘 ═══════ */

.ziwei-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.ziwei-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    max-width: 800px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.ziwei-cell {
    background: rgba(20, 16, 40, 0.8);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.ziwei-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.ziwei-cell:hover {
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
    transform: scale(1.01);
}

.ziwei-cell:active {
    transform: scale(0.99);
}

.ziwei-cell.ming-gong {
    border-color: #D4AF37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.ziwei-cell.ming-gong::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.ziwei-cell.shen-gong {
    border-color: #00D4FF;
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.1);
}

.ziwei-cell.current-daxian {
    border-color: #8B5CF6;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.ziwei-center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(13, 11, 26, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 16px;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.ziwei-center::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.ziwei-center .center-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 18px;
    color: var(--gold);
    font-weight: 700;
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
    margin-bottom: 8px;
}

.ziwei-center .center-name {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.ziwei-center .center-info {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.6;
    text-align: center;
}

.ziwei-center .center-wuxing {
    font-size: 14px;
    color: var(--gold-light);
    font-weight: 600;
    margin-top: 8px;
}

.ziwei-center .center-ming-stars {
    font-size: 13px;
    color: #8B5CF6;
    margin-top: 6px;
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

/* Palace header */
.palace-header {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 3px;
    flex-shrink: 0;
}

.palace-name {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 2px;
    white-space: nowrap;
}

.palace-branch {
    font-size: 10px;
    color: #6b7280;
}

.palace-ming-mark {
    color: #D4AF37;
    font-size: 10px;
    text-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

.palace-shen-mark {
    color: #00D4FF;
    font-size: 10px;
    text-shadow: 0 0 6px rgba(0, 212, 255, 0.5);
}

/* Stars */
.stars-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.star-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-shadow: 0 0 8px currentColor;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.star-aux {
    font-size: 10px;
    color: #6b7280;
    line-height: 1.3;
}

.star-sha {
    font-size: 10px;
    color: #ef4444;
    line-height: 1.3;
    text-shadow: 0 0 4px rgba(239, 68, 68, 0.3);
}

/* SiHua badges */
.sihua-badge {
    display: inline-block;
    font-size: 9px;
    padding: 0 3px;
    border-radius: 3px;
    margin-left: 2px;
    font-weight: bold;
    vertical-align: middle;
    line-height: 1.4;
}

.sihua-lu {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.sihua-quan {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.sihua-ke {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.sihua-ji {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

/* DaXian label */
.daxian-label {
    font-size: 9px;
    color: #6b7280;
    margin-top: auto;
    text-align: center;
    padding-top: 2px;
    border-top: 1px solid rgba(107, 114, 128, 0.15);
    flex-shrink: 0;
}

/* Palace Detail Panel */
#palace-detail {
    animation: slideUp 0.3s ease-out;
}

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

#palace-detail .detail-section {
    margin-bottom: 12px;
}

#palace-detail .detail-section-title {
    font-size: 12px;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

#palace-detail .detail-star-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
}

#palace-detail .detail-star-name {
    font-weight: 600;
    text-shadow: 0 0 6px currentColor;
    min-width: 40px;
}

#palace-detail .detail-star-desc {
    color: var(--text-tertiary);
    font-size: 12px;
}

#palace-detail .detail-daxian {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 10px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .ziwei-grid {
        min-width: 500px;
    }

    .star-name {
        font-size: 11px;
    }

    .ziwei-cell {
        padding: 4px;
    }

    .palace-name {
        font-size: 10px;
    }

    .ziwei-center .center-title {
        font-size: 14px;
    }

    .ziwei-center .center-name {
        font-size: 13px;
    }

    .ziwei-center .center-info {
        font-size: 10px;
    }
}

@media (max-width: 400px) {
    .ziwei-grid {
        min-width: 440px;
    }
}
