/* ==========================================================================
   style.css (v2026.06_Fix - Red Line Restored)
   [홍성파 천반 표준 디자인 v1.0]
   - 코드 정규화: index.html의 인라인 스타일 이관 완료
   - 운세 시스템: 대한/유년/유월 3단 적층 배지 디자인
   - 시각화 복구: 삼방사정 연결선 '빨간색' & '최상위 레이어' 복구 완료
   ========================================================================== */

:root {
    --bg-color: #f0f2f5;
    --chart-bg: #ffffff;
    --border-color: #0f4c81;
    /* 메인 테마: 클래식 블루 */
    --border-width: 1px;
    --primary-blue: #1976D2;
    /* 길성 파랑 */
    --text-black: #000000;

    /* [홍성파 사화 컬러 팔레트] */
    --sihua-base: #6A0DAD;
    /* 선천: 보라 */
}

* {
    box-sizing: border-box;
    /* 전역 고딕 폰트 강제 — Noto Sans(한글) + Noto Sans SC(한자) 웹폰트 우선 */
    font-family: 'Noto Sans KR', 'Noto Sans SC', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif !important;
}

body {
    font-family: 'Noto Sans KR', 'Noto Sans SC', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;

    /* [추가] 화면 전체를 80% 크기로 축소 (20% 다이어트) */
    /* zoom: 0.8; (화면 원상복구 위해 삭제됨) */
}

/* 1. 브랜드 타이틀 */
.brand h2 {
    margin-bottom: 0.5rem;
    font-weight: normal;
    letter-spacing: -0.5px;
    margin-top: 0;
    font-size: 1.1rem;
}

.brand-version {
    font-size: 12px;
    color: #999;
    margin-left: 12px;
    font-weight: normal;
    vertical-align: middle;
}

.brand-red {
    color: #d32f2f;
}

.brand-blue {
    color: #0f4c81;
    margin-left: 10px;
}

/* 2. 사화 배지 시스템 (수정됨: 크기 확대 및 배경색 활성화) */
.sihua-badge {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    font-size: 10px !important;
    font-weight: normal;
    text-align: center;
    border-radius: 4px;
    margin-left: 3px;
    color: #fff !important;
    vertical-align: text-bottom;
    background-color: var(--sihua-base);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sihua-base {
    background-color: var(--sihua-base) !important;
    color: #fff !important;
    /* 글씨는 무조건 흰색 */
}

/* 3. 명반 그리드 및 셀 */
.chart-wrapper {
    width: 100%;
    max-width: 550px;
    display: block;
    position: relative;
}

/* 명반과 동일 가로폭 안내 인포박스 */
.chart-info-box {
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    color: #222;
}

.chart-info-list {
    margin: 0;
    padding-left: 1.25rem;
    list-style: decimal;
}

.chart-info-list li {
    margin: 0 0 0.45em;
    font-size: 0.82rem;
    line-height: 1.55;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.chart-info-list li:last-child {
    margin-bottom: 0;
}

.palace-grid {
    width: 100%;
    aspect-ratio: 1;
    background-color: var(--chart-bg);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    position: relative;
    border-top: var(--border-width) solid var(--border-color);
    border-left: var(--border-width) solid var(--border-color);
    box-shadow: 0 5px 8px rgba(0, 0, 0, 0.1);
}

.palace-cell {
    position: relative;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.75rem;
    background-color: #fff;
    border-right: var(--border-width) solid var(--border-color);
    border-bottom: var(--border-width) solid var(--border-color);
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.palace-cell:hover {
    background-color: #fffbfb;
}

.active-palace-border {
    /* [수정] 테두리: 빨간색(#d32f2f) 유지하되, 두께를 2px로 설정 */
    box-shadow: inset 0 0 0 1px #d32f2f !important;

    /* [수정] 배경: 보라색(#6A0DAD)을 10% 투명도로 은은하게 적용 */
    background-color: rgba(106, 13, 173, 0.05) !important;
}

/* ==========================================================================
   5. [수정] 시각화 요소 (삼방사정: 실선 & 1px 통일)
   ========================================================================== */
.arrow-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50 !important;
    /* 레이어 최상위 유지 */
}

/* 일반 삼합선 (삼각형) */
.tri-line {
    stroke: #d32f2f !important;
    /* 빨간색 유지 */

    stroke-width: 1px;
    /* [수정] 두께 1px로 통일 */
    stroke-dasharray: 0;
    /* [수정] 점선 제거 -> 실선(0) */

    opacity: 0.6;
    /* 은은하게 */
}

/* 대궁 연결선 (마주보는 선) */
.tri-line.main-line {
    stroke: #d32f2f !important;

    stroke-width: 1px;
    /* [수정] 두께 1px로 통일 (기존 2.5px) */
    stroke-dasharray: 0;
    /* 실선 유지 */

    opacity: 1.0;
    /* 대궁은 조금 더 진하게 (구분을 위해 투명도만 다르게 유지) */
}

/* 6. 기타 컴포넌트 */
.control-panel {
    background-color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 550px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    text-align: center;
}

.inputs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-group label {
    font-size: 0.7rem;
    font-weight: normal;
    margin-bottom: 1px;
    color: #555;
    display: block;
    width: 100%;
}

input,
select {
    width: 100%;
    padding: 0 2px;
    height: 26px;
    line-height: normal;
    vertical-align: middle;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-family: 'Noto Sans KR', 'Noto Sans SC', 'Malgun Gothic', '맑은 고딕', sans-serif;
    font-size: 0.7rem;
}

.w-name { width: 100%; }
.w-sel { width: 100%; }
.w-year { width: 100%; }
.w-num { width: 100%; }

.btn-calc {
    flex-shrink: 0;
    padding: 0 10px;
    height: 26px;
    background-color: var(--border-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: normal;
    cursor: pointer;
    font-size: 0.7rem;
    font-family: 'Noto Sans KR', 'Noto Sans SC', 'Malgun Gothic', '맑은 고딕', sans-serif;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-calc:hover {
    background-color: #0a3255;
}

/* 라벨 적층 */
.palace-name-stack {
    position: absolute;
    bottom: 4px;
    right: 4px;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    z-index: 5;
    gap: 1px;
}

.lbl-base {
    font-size: 0.75rem;
    color: #333;
    font-weight: normal;
    padding: 0 2px;
    background: rgba(255, 255, 255, 0.7);
}

/* 그리드 배치 클래스 */
.cell-5 {
    grid-column: 1;
    grid-row: 1;
}

.cell-6 {
    grid-column: 2;
    grid-row: 1;
}

.cell-7 {
    grid-column: 3;
    grid-row: 1;
}

.cell-8 {
    grid-column: 4;
    grid-row: 1;
}

.cell-9 {
    grid-column: 4;
    grid-row: 2;
}

.cell-10 {
    grid-column: 4;
    grid-row: 3;
}

.cell-11 {
    grid-column: 4;
    grid-row: 4;
}

.cell-0 {
    grid-column: 3;
    grid-row: 4;
}

.cell-1 {
    grid-column: 2;
    grid-row: 4;
}

.cell-2 {
    grid-column: 1;
    grid-row: 4;
}

.cell-3 {
    grid-column: 1;
    grid-row: 3;
}

.cell-4 {
    grid-column: 1;
    grid-row: 2;
}

/* 별 스타일 */
.star-group {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 1px;
}

.star-container {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 1px;
}

.star-item {
    width: auto;
    margin-right: 4px;
    margin-bottom: 0px;
    line-height: 1.1;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.star-main {
    color: #6A0DAD;
    font-weight: normal;
    font-size: 0.9rem;
}

.star-aux {
    color: var(--primary-blue) !important;
    font-weight: normal;
    font-size: 0.85rem;
}

.star-bad {
    color: #d32f2f;
    font-weight: normal;
    font-size: 0.85rem;
}

.star-minor {
    color: #424242;
    font-weight: normal;
    font-size: 0.8rem;
    width: auto;
    margin-right: 4px;
    display: inline-flex;
}

.star-bright {
    font-size: 0.75rem;
    color: #888 !important;
    font-weight: normal;
    margin-left: 2px;
}

/* Sihua styles logic moved back to top */

.info-stem-branch {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-weight: normal;
    color: #333;
    font-size: 0.8rem;
}

.ming-palace {
    background-color: #fafafa;
}

.ming-palace .lbl-base {
    border: 1px solid var(--border-color);
    color: var(--border-color) !important;
}

/* 로고 및 하단 패널 */
.center-zone {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.center-yookjo {
    opacity: 1;
    font-weight: 700;
    font-size: 2.4rem;
    color: #1a1a1a;
    letter-spacing: 0.03em;
    line-height: 1.2;
    text-align: center;
    user-select: none;
    font-family: 'Noto Sans KR', 'Noto Sans SC', 'Malgun Gothic', '맑은 고딕', sans-serif;
}

.loading-screen {
    padding: 50px;
    text-align: center;
}

/* [수정] 신궁(身宮) 파란색 배지 스타일 */
.badge-body-blue {
    display: inline-block;
    background-color: #1a237e;
    /* 파란색 (Classic Blue 계열) */
    color: white;
    /* 글자색 흰색 */
    font-size: 10px;
    /* 글자 크기 (명궁 배지와 비슷하게) */
    width: 14px;
    /* 정사각형 너비 */
    height: 14px;
    /* 정사각형 높이 */
    line-height: 14px;
    /* 수직 중앙 정렬 */
    text-align: center;
    /* 수평 중앙 정렬 */
    border-radius: 4px;
    /* 모서리 살짝 둥글게 */
    margin-right: 4px;
    /* 이름(명궁 등)과의 간격 */
    vertical-align: text-bottom;
    /* 텍스트 줄 맞춤 */
    font-weight: normal;
    /* 굵게 */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    /* 살짝 그림자 */
}

/* (참고) 궁 이름 정렬을 위해 lbl-base가 flex나 block인지 확인 */
.lbl-base {
    display: flex;
    /* 배지와 글자를 나란히 두기 위해 */
    align-items: center;
    /* 수직 중앙 정렬 */
    justify-content: center;
    /* 가운데 정렬 */
    font-weight: normal;
    font-size: 1.1em;
}