:root {
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.8);
    --text-color: #e6edf3;
    --text-muted: #8b949e;
    --text-label: #c9d1d9;
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --border-color: rgba(212, 175, 55, 0.2);
    --input-bg: rgba(13, 17, 23, 0.8);
    --input-border: #30363d;
    --saju-grid-bg: rgba(0, 0, 0, 0.3);
    --saju-ganji-bg: rgba(255, 255, 255, 0.05);
    --saju-ganji-shadow: rgba(0,0,0,0.8);
    --bg-gradient: linear-gradient(to bottom, #0d1117, #161b22);
    --star-color: #ffffff;
    --red: #d32f2f;
    --blue: #1976d2;
    --green: #388e3c;
    --yellow: #fbc02d;
    --white: #ffffff;
    --black: #000000;
}

[data-theme="light"] {
    --bg-color: #f0f2f5;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-color: #24292f;
    --text-muted: #57606a;
    --text-label: #24292f;
    --gold: #b38600;
    --gold-glow: rgba(179, 134, 0, 0.4);
    --border-color: rgba(179, 134, 0, 0.3);
    --input-bg: rgba(255, 255, 255, 0.8);
    --input-border: #d0d7de;
    --saju-grid-bg: rgba(246, 248, 250, 0.8);
    --saju-ganji-bg: rgba(0, 0, 0, 0.05);
    --saju-ganji-shadow: rgba(255,255,255,0.8);
    --bg-gradient: linear-gradient(to bottom, #e1e4e8, #f6f8fa);
    --star-color: transparent;
    --white: #000000; /* Invert metal color in light mode for visibility */
    --black: #000000;
}

body {
    margin: 0;
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.5s ease, color 0.5s ease;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
}

/* Theme Toggle Button */
.theme-toggle-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.theme-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    color: var(--text-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--gold-glow);
}

.header {
    text-align: center;
    margin-bottom: 30px;
    margin-top: 20px;
}

.logo {
    font-family: 'Nanum Myeongjo', serif;
    font-size: 2.5em;
    font-weight: 800;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.gold-text {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

.sub-title {
    font-size: 0.4em;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.description {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-top: 10px;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.hidden {
    display: none !important;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-label);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1em;
    box-sizing: border-box;
    transition: all 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

.radio-group, .calendar-type {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    padding: 8px 16px;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    transition: all 0.3s ease;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.radio-label.small .radio-custom {
    padding: 4px 10px;
    font-size: 0.85em;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: var(--gold);
    color: var(--gold);
    background-color: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 10px var(--gold-glow);
}

.date-inputs {
    display: flex;
    gap: 10px;
}

.submit-btn, .reset-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--gold) 0%, #aa8c2c 100%);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.submit-btn:hover, .reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--gold-glow);
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    margin-top: 30px;
}

.reset-btn:hover {
    background: rgba(212, 175, 55, 0.1);
}

/* Loader */
#loading-section {
    text-align: center;
    padding: 50px 0;
}

.loader {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.circle {
    width: 15px;
    height: 15px;
    background-color: var(--gold);
    border-radius: 50%;
    animation: bounce 0.6s infinite alternate;
}

.circle:nth-child(2) { animation-delay: 0.2s; }
.circle:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    to { transform: translateY(-15px); opacity: 0.5; }
}

.loading-text {
    color: var(--gold);
    font-family: 'Nanum Myeongjo', serif;
    letter-spacing: 2px;
}

/* Result Section */
.result-header {
    text-align: center;
    margin-bottom: 30px;
}

.result-header h2 {
    color: var(--gold);
    font-family: 'Nanum Myeongjo', serif;
    font-size: 1.8em;
    margin-bottom: 5px;
}

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 10px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1em;
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 700;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.tab-btn:hover {
    color: var(--text-color);
    background: rgba(255,255,255,0.05);
}

[data-theme="light"] .tab-btn:hover {
    background: rgba(0,0,0,0.05);
}

.tab-btn.active {
    color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
    box-shadow: inset 0 0 10px var(--gold-glow);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

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

/* 사주 명식표 (Saju Grid) */
.saju-grid {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 40px;
    padding: 25px 20px;
    background: linear-gradient(145deg, var(--saju-grid-bg), rgba(0,0,0,0.5));
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.3);
    transition: all 0.5s ease;
}

[data-theme="light"] .saju-grid {
    background: linear-gradient(145deg, var(--saju-grid-bg), rgba(255,255,255,0.8));
    box-shadow: inset 0 0 20px rgba(255,255,255,0.5), 0 10px 20px rgba(0,0,0,0.05);
}

.pillar {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    padding: 10px 5px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

[data-theme="light"] .pillar {
    background: rgba(0,0,0,0.02);
}

.pillar:hover {
    background: rgba(255,255,255,0.05);
    transform: translateY(-2px);
}

[data-theme="light"] .pillar:hover {
    background: rgba(0,0,0,0.05);
}

.pillar-title {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    width: 80%;
    text-align: center;
    letter-spacing: 2px;
}

.ganji {
    font-family: 'Nanum Myeongjo', serif;
    font-size: 2.8em;
    font-weight: 800;
    margin: 8px 0;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: var(--saju-ganji-bg);
    text-shadow: 2px 2px 4px var(--saju-ganji-shadow);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.5s ease;
}

.cheongan {
    /* 천간 특화 스타일 (필요시) */
}

.jiji {
    /* 지지 특화 스타일 (필요시) */
}

.pillar.highlight {
    background: linear-gradient(to bottom, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    border: 1px solid var(--gold-glow);
    box-shadow: 0 0 15px var(--gold-glow);
}

.pillar-label {
    position: absolute;
    bottom: -15px;
    font-size: 0.75em;
    font-weight: bold;
    color: var(--bg-color);
    background-color: var(--gold);
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 2;
}

/* Analysis Content */
.analysis-content, .daily-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.analysis-card {
    background-color: var(--saju-ganji-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 25px;
    transition: background-color 0.5s ease, border-color 0.5s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

[data-theme="light"] .analysis-card {
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.analysis-card h3 {
    color: var(--gold);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 10px;
}

.analysis-card p {
    line-height: 1.8;
    color: var(--text-label);
    margin: 0;
    font-size: 0.95em;
    white-space: pre-line; /* Allows line breaks in text */
}

/* 로또 볼 스타일 */
.lotto-balls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.lotto-ball {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2em;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    box-shadow: inset -5px -5px 10px rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.2);
}

/* 로또 색상 (동행복권 기준) */
.lotto-yellow { background: linear-gradient(135deg, #fbc400, #e6a800); }
.lotto-blue { background: linear-gradient(135deg, #69c8f2, #4fa3d1); }
.lotto-red { background: linear-gradient(135deg, #ff7272, #e55353); }
.lotto-gray { background: linear-gradient(135deg, #aaa, #888); }
.lotto-green { background: linear-gradient(135deg, #b0d840, #8eb529); }

/* 오행 색상 클래스 */
.element-wood { color: var(--green); }
.element-fire { color: var(--red); }
.element-earth { color: var(--yellow); }
.element-metal { color: var(--white); text-shadow: 0 0 2px rgba(128,128,128,0.5); }
.element-water { color: var(--black); text-shadow: 0 0 2px rgba(255,255,255,0.5); }

/* Background Effects */
.background-effects {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    background: var(--bg-gradient);
    overflow: hidden;
    transition: background 0.5s ease;
}

.stars {
    width: 2px; height: 2px;
    background: transparent;
    box-shadow: 10vw 10vh var(--star-color), 20vw 20vh var(--star-color), 30vw 30vh var(--star-color), 40vw 40vh var(--star-color), 50vw 50vh var(--star-color), 60vw 60vh var(--star-color), 70vw 70vh var(--star-color), 80vw 80vh var(--star-color), 90vw 90vh var(--star-color);
    animation: move-stars 50s linear infinite;
    transition: box-shadow 0.5s ease;
}

@keyframes move-stars {
    from { transform: translateY(0); }
    to { transform: translateY(-100vh); }
}

/* 육친(십성) 스타일 */
.yukchin {
    font-size: 0.75em;
    color: var(--text-muted);
    margin: 2px 0;
    text-align: center;
    font-weight: 500;
}

#day-gan-yukchin {
    color: var(--gold);
    font-weight: 700;
}

/* 대운 섹션 스타일 */
.daewun-section {
    margin-bottom: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .daewun-section {
    background: var(--card-bg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.daewun-section h3 {
    text-align: center;
    color: var(--gold);
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 1.3em;
    font-family: 'Nanum Myeongjo', serif;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.daewun-grid {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) var(--input-bg);
}

.daewun-grid::-webkit-scrollbar {
    height: 6px;
}
.daewun-grid::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 3px;
}
.daewun-grid::-webkit-scrollbar-thumb {
    background-color: var(--gold);
    border-radius: 3px;
}

.daewun-pillar {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    position: relative;
}

.daewun-pillar:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 10%;
    height: 80%;
    width: 1px;
    background-color: var(--border-color);
    opacity: 0.5;
}

.daewun-pillar:hover {
    transform: none;
}

.daewun-age {
    font-size: 0.85em;
    color: var(--text-label);
    background-color: transparent;
    margin-bottom: 15px;
    font-weight: 500;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    text-align: center;
    border-bottom: 1px dashed rgba(139, 148, 158, 0.3);
    padding-bottom: 8px;
}

.daewun-ganji {
    font-family: 'Nanum Myeongjo', serif;
    font-size: 1.6em;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    background: var(--saju-ganji-bg);
    padding: 10px 5px;
    border-radius: 8px;
    width: 100%;
    border: 1px solid rgba(255,255,255,0.02);
}

[data-theme="light"] .daewun-ganji {
    text-shadow: none;
    border: 1px solid rgba(0,0,0,0.02);
}

@media (max-width: 480px) {
    .saju-grid {
        padding: 10px;
        gap: 5px;
    }
    .ganji {
        font-size: 1.8em;
        width: 40px;
        height: 40px;
    }
}