/* 紫微斗数命盤専用CSS */

.ziwei-chart {
    font-family: 'Noto Sans CJK JP', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
    /* フォールバック: 基本的なレイアウトを確保 */
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* 命盤コンテナ */
.ziwei-chart-container {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* 12宮グリッド（4x4、中央2x2は空白） */
.ziwei-palace-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1px;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 1/1;
    background: #f9fafb;
    border: 2px solid #374151;
    border-radius: 8px;
    padding: 2px;
    margin: 0 auto;
}

/* 各宮のスタイル */
.ziwei-palace {
    border: 1px solid #374151;
    border-radius: 4px;
    padding: 6px;
    text-align: center;
    position: relative;
    background: white;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    font-size: 12px;
}

/* 命宮の特別スタイル */
.ziwei-palace-ming {
    background: #fef2f2;
    border-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* 身宮の特別スタイル */
.ziwei-palace-shen {
    background: #eff6ff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* 来因宮の特別スタイル */
.ziwei-palace-laiyin {
    background: #fef3c7;
    border-color: #d97706;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

/* 宮名 */
.ziwei-palace-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 8px;
    text-align: center;
}

/* 星名エリア（縦書き対応） */
.ziwei-stars-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 2px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

/* 星名（縦書き） - 統一ベーススタイル */
.ziwei-star {
    font-size: 14px;
    line-height: 1.2;
    position: relative;
    margin-bottom: 2px;
    writing-mode: vertical-rl;
    text-orientation: upright;
    display: inline-block;
    border-radius: 3px;
    padding: 2px 4px;
    font-family: 'Noto Sans CJK JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    letter-spacing: 0.5px;
}

/* 十四主星（黒色・太字） */
.ziwei-star-main {
    font-weight: 700;
    color: #000000;
    font-size: 15px;
    background-color: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* 六吉星・月系星（ピンク色） */
.ziwei-star-moon-system,
.ziwei-star-lucky {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    font-weight: 600;
    font-size: 13px;
}

/* 時系星（オレンジ色） */
.ziwei-star-time-system {
    color: #ea580c;
    background-color: rgba(234, 88, 12, 0.1);
    border: 1px solid rgba(234, 88, 12, 0.3);
    font-weight: 600;
    font-size: 13px;
}

/* 生年干輔星（紫色） */
.ziwei-star-year-stem {
    color: #7c3aed;
    background-color: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.3);
    font-weight: 600;
    font-size: 13px;
}

/* 生年支輔星（青色） */
.ziwei-star-year-branch {
    color: #1d4ed8;
    background-color: rgba(29, 78, 216, 0.1);
    border: 1px solid rgba(29, 78, 216, 0.3);
    font-weight: 600;
    font-size: 13px;
}

/* 四煞星・凶星（グレー色） */
.ziwei-star-malefic {
    color: #6b7280;
    background-color: rgba(107, 114, 128, 0.1);
    border: 1px solid rgba(107, 114, 128, 0.3);
    font-weight: 500;
    font-size: 12px;
}

/* その他の副星・輔星（薄いグレー） */
.ziwei-star-auxiliary {
    color: #9ca3af;
    background-color: rgba(156, 163, 175, 0.05);
    border: 1px solid rgba(156, 163, 175, 0.2);
    font-weight: 400;
    font-size: 12px;
}

/* 四化星の記号 */
.ziwei-transformation {
    font-size: 10px;
    font-weight: bold;
    margin-top: 2px;
    text-align: center;
    line-height: 1;
    display: block;
}

.ziwei-transformation-lu {
    color: #dc2626; /* 禄：赤色 */
}

.ziwei-transformation-quan {
    color: #059669; /* 権：緑色 */
}

.ziwei-transformation-ke {
    color: #7c3aed; /* 科：紫色 */
}

.ziwei-transformation-ji {
    color: #6b7280; /* 忌：グレー色 */
}

/* 吉星（緑色） */
.ziwei-star-lucky {
    color: #059669;
    background-color: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.3);
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 500;
}

/* 凶星（赤色） */
.ziwei-star-malefic {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: 500;
}

/* 副星（青色） */
.ziwei-star-auxiliary {
    color: #2563eb;
}

/* 宮のフッター（年数と干支） */
.ziwei-palace-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 10px;
}

/* 年数 */
.ziwei-year {
    font-weight: bold;
    color: #374151;
}

/* 干支 */
.ziwei-ganzhi {
    font-weight: bold;
    color: #374151;
}

/* 四化エリア */
.ziwei-transform-area {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
    margin-bottom: 4px;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

/* 生年化（白抜き文字） */
.ziwei-transform-natal {
    font-size: 10px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 2px;
    min-width: 16px;
    text-align: center;
    writing-mode: horizontal-tb;
    text-orientation: initial;
}

.ziwei-transform-natal.ziwei-transform-lu {
    background-color: #10b981;
    color: white;
}

.ziwei-transform-natal.ziwei-transform-quan {
    background-color: #8b5cf6;
    color: white;
}

.ziwei-transform-natal.ziwei-transform-ke {
    background-color: #3b82f6;
    color: white;
}

.ziwei-transform-natal.ziwei-transform-ji {
    background-color: #ef4444;
    color: white;
}

/* 飛星の化星（色付き文字） */
.ziwei-transform-flying {
    font-size: 10px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 2px;
    min-width: 16px;
    text-align: center;
    background-color: white;
    border: 1px solid #d1d5db;
    writing-mode: horizontal-tb;
    text-orientation: initial;
}

.ziwei-transform-flying.ziwei-transform-lu {
    color: #10b981;
}

.ziwei-transform-flying.ziwei-transform-quan {
    color: #8b5cf6;
}

.ziwei-transform-flying.ziwei-transform-ke {
    color: #3b82f6;
}

.ziwei-transform-flying.ziwei-transform-ji {
    color: #ef4444;
}

/* 中央パネル（2x2の空白部分） */
.ziwei-center-panel {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: #f9fafb;
    border: 2px solid #374151;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 200px;
    min-width: 200px;
}

.ziwei-center-content {
    text-align: center;
    padding: 12px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 12px;
    overflow: hidden;
    box-sizing: border-box;
}

.ziwei-center-info {
    margin-bottom: 0;
    width: 100%;
    overflow: hidden;
}

.ziwei-center-item {
    margin-bottom: 6px;
    font-size: 11px;
    color: #374151;
    text-align: center;
    font-weight: 500;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 四化凡例 */
.ziwei-transform-legend {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.ziwei-transform-legend h4 {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

/* 四化情報 */
.ziwei-transforms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.ziwei-transform-card {
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    border: 2px solid;
}

.ziwei-transform-card.lu {
    border-color: #22c55e;
    background: #f0fdf4;
}

.ziwei-transform-card.quan {
    border-color: #a855f7;
    background: #faf5ff;
}

.ziwei-transform-card.ke {
    border-color: #3b82f6;
    background: #eff6ff;
}

.ziwei-transform-card.ji {
    border-color: #ef4444;
    background: #fef2f2;
}

.ziwei-transform-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.ziwei-transform-star {
    font-size: 14px;
    margin-bottom: 4px;
}

.ziwei-transform-palace {
    font-size: 12px;
    color: #6b7280;
}

/* 凡例 */
.ziwei-legend {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 24px;
    margin-top: 32px;
}

.ziwei-legend-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin-bottom: 16px;
}

.ziwei-legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.ziwei-legend-section {
    color: white;
}

.ziwei-legend-section-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: white;
}

.ziwei-legend-list {
    font-size: 14px;
    line-height: 1.6;
}

.ziwei-legend-item {
    margin-bottom: 4px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .ziwei-chart-container {
        max-width: 100%;
        padding: 0;
    }
    
    .ziwei-palace-grid {
        gap: 1px;
        padding: 2px;
        max-width: 100%;
        aspect-ratio: 1/1;
        border-width: 1px;
    }
    
    .ziwei-palace {
        min-height: 70px;
        padding: 3px;
        font-size: 11px;
    }
    
    .ziwei-palace-name {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .ziwei-star {
        font-size: 10px;
        padding: 1px 2px;
    }
    
    .ziwei-transform-natal,
    .ziwei-transform-flying {
        font-size: 8px;
        padding: 1px 2px;
        min-width: 12px;
    }
    
    .ziwei-center-panel {
        min-height: 120px;
        min-width: 120px;
        border-width: 1px;
    }
    
    .ziwei-center-content {
        padding: 6px;
        font-size: 10px;
    }
    
    .ziwei-center-item {
        font-size: 9px;
        margin-bottom: 3px;
        line-height: 1.2;
    }
    
    .ziwei-palace-footer {
        font-size: 9px;
        margin-top: 2px;
    }
}

@media (max-width: 480px) {
    .ziwei-palace-grid {
        gap: 0.5px;
        padding: 1px;
        aspect-ratio: 1/1;
        border-width: 1px;
    }
    
    .ziwei-palace {
        min-height: 55px;
        padding: 2px;
        font-size: 10px;
    }
    
    .ziwei-palace-name {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .ziwei-star {
        font-size: 8px;
        padding: 1px;
        margin-bottom: 1px;
    }
    
    .ziwei-star-main {
        font-size: 9px;
    }
    
    .ziwei-transform-natal,
    .ziwei-transform-flying {
        font-size: 7px;
        padding: 0.5px 1px;
        min-width: 10px;
    }
    
    .ziwei-center-panel {
        min-height: 90px;
        min-width: 90px;
        border-width: 1px;
    }
    
    .ziwei-center-content {
        padding: 4px;
        font-size: 8px;
    }
    
    .ziwei-center-item {
        font-size: 7px;
        margin-bottom: 2px;
        line-height: 1.1;
    }
    
    .ziwei-palace-footer {
        font-size: 8px;
        margin-top: 2px;
    }
}

/* 印刷用スタイル */
@media print {
    .ziwei-chart {
        background: white !important;
    }
    
    .ziwei-palace {
        border: 1px solid #000 !important;
        background: white !important;
        break-inside: avoid;
    }
    
    .ziwei-palace.ming-palace {
        background: #fef3c7 !important;
    }
    
    .ziwei-transform {
        background: white !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
    
    .no-print {
        display: none !important;
    }
}

/* アニメーション */
.ziwei-palace {
    animation: fadeInUp 0.6s ease-out;
}

.ziwei-palace:nth-child(1) { animation-delay: 0.1s; }
.ziwei-palace:nth-child(2) { animation-delay: 0.2s; }
.ziwei-palace:nth-child(3) { animation-delay: 0.3s; }
.ziwei-palace:nth-child(4) { animation-delay: 0.4s; }
.ziwei-palace:nth-child(5) { animation-delay: 0.5s; }
.ziwei-palace:nth-child(6) { animation-delay: 0.6s; }
.ziwei-palace:nth-child(7) { animation-delay: 0.7s; }
.ziwei-palace:nth-child(8) { animation-delay: 0.8s; }
.ziwei-palace:nth-child(9) { animation-delay: 0.9s; }
.ziwei-palace:nth-child(10) { animation-delay: 1.0s; }
.ziwei-palace:nth-child(11) { animation-delay: 1.1s; }
.ziwei-palace:nth-child(12) { animation-delay: 1.2s; }

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

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .ziwei-palace {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .ziwei-zhi {
        color: #f9fafb;
    }
    
    .ziwei-palace-name {
        color: #f9fafb;
    }
    
    .ziwei-stem {
        color: #9ca3af;
    }
    
    .ziwei-center-info {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .ziwei-center-title {
        color: #f9fafb;
    }
    
    .ziwei-center-label {
        color: #f9fafb;
    }
}
