:root {
    --primary: #d4af37; /* Gold */
    --secondary: #9b4dca; /* Purple */
    --bg-dark: #0f0c1d;
    --text-light: #f5f5f5;
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.15);
    --font-kr: 'Noto Serif KR', serif;
    --font-en: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-light);
    font-family: var(--font-kr);
    min-height: 100vh;
    overflow-x: hidden;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(15, 12, 29, 0.4) 0%, rgba(15, 12, 29, 0.8) 100%);
    z-index: -1;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 20px;
}

header {
    text-align: center;
    margin-bottom: 50px;
}

header h1 {
    font-size: 3rem;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    letter-spacing: 1px;
}

/* Search Section */
.search-section {
    margin-bottom: 40px;
}

.search-box {
    display: flex;
    gap: 10px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.2);
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 15px 25px;
    color: white;
    font-size: 1.1rem;
    font-family: var(--font-kr);
}

.search-box button {
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    padding: 0 35px;
    border-radius: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
}

.search-box button:hover {
    background: #f0c94d;
    transform: scale(1.05);
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

/* Results Area */
.results-area {
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.welcome-message {
    text-align: center;
    padding: 100px 0;
    opacity: 0.6;
    font-style: italic;
}

/* Info Cards */
.card {
    background: var(--glass);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    animation: fadeIn 0.5s ease-out forwards;
}

.card-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    color: var(--primary);
    font-size: 1.8rem;
    font-weight: 700;
}

.card-badge {
    background: var(--secondary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: var(--font-en);
}

.card-body p {
    line-height: 1.7;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

/* Structure List */
.structure-section {
    margin-top: 30px;
}

.structure-section h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.structure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.structure-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: transform 0.2s;
}

.structure-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.07);
}

footer {
    text-align: center;
    padding: 40px;
    opacity: 0.5;
    font-size: 0.9rem;
}

/* Chart Input Section */
.chart-input-section {
    margin-bottom: 40px;
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
}

.input-group input, 
.input-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 8px;
    color: white;
    font-family: var(--font-kr);
    outline: none;
}

.radio-group {
    display: flex;
    gap: 20px;
    padding: 10px 0;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: white;
    font-weight: 400;
}

.primary-btn {
    width: 100%;
    background: var(--primary);
    color: var(--bg-dark);
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn:hover {
    background: #f0c94d;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

/* Zi Wei Chart Grid */
.chart-area {
    margin-bottom: 50px;
    animation: fadeIn 0.8s ease-out;
}

.ziwei-chart {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    background: var(--glass-border);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    aspect-ratio: 1 / 1;
    max-width: 800px;
    margin: 0 auto;
}

.palace {
    background: var(--bg-dark);
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 120px;
    transition: background 0.3s;
}

.palace:hover {
    background: rgba(212, 175, 55, 0.05);
}

.palace-name {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 700;
}

.palace-symbol {
    position: absolute;
    bottom: 5px;
    left: 5px;
    font-size: 0.75rem;
    opacity: 0.5;
}

.stars-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.star-item {
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.star-item:hover {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.major-star { color: #ffeb3b; font-weight: 800; }
.minor-star { color: #81c784; font-weight: 500; }
.sha-star { color: #ff6b6b; font-weight: 700; }

.center-box {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: rgba(212, 175, 55, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    border: 1px solid var(--glass-border);
}

.center-info h2 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.center-info p {
    font-size: 0.9rem;
    opacity: 0.8;
}

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

@media (max-width: 600px) {
    header h1 { font-size: 2rem; }
    .search-box { flex-direction: column; border-radius: 20px; }
    .search-box button { padding: 15px; }
    .ziwei-chart {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        aspect-ratio: auto;
    }
    .center-box {
        grid-column: 1 / 3;
        grid-row: auto;
        order: -1;
    }
}

/* Full Analysis Section */
.analysis-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--glass-border);
}

.analysis-header {
    text-align: center;
    margin-bottom: 40px;
}

.analysis-header h2 {
    color: var(--primary);
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.palace-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.palace-detail-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s;
}

.palace-detail-card:hover {
    border-color: var(--primary);
}

.pd-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pd-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pd-name {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
}

.pd-branch {
    font-size: 1rem;
    opacity: 0.6;
}

.pd-formation {
    background: var(--secondary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.pd-body {
    padding: 20px 25px;
}

.pd-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.pd-star-tag {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--primary);
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.pd-desc {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.pd-formation-meaning {
    background: rgba(155, 77, 202, 0.1);
    border-left: 4px solid var(--secondary);
    padding: 12px 20px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-light);
    border-radius: 0 8px 8px 0;
}

.pd-interpretation {
    margin-top: 25px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.pd-analysis-block {
    margin-bottom: 20px;
}

.pd-analysis-block h4 {
    font-size: 1rem;
    color: var(--secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pd-analysis-block p {
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.8;
}

.info-note {
    background: rgba(100, 100, 255, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem !important;
}

.warning h4 {
    color: #ff6b6b;
}

.warning-text {
    color: #ff9f9f;
    font-weight: 600;
}

.safe h4 {
    color: #51cf66;
}

.star-summary {
    color: var(--primary);
}

.borrowed-star {
    opacity: 0.6;
    border-style: dashed !important;
}

.pd-star-desc {
    margin-top: 15px;
    font-size: 0.9rem;
    border-left: 3px solid var(--secondary);
    padding-left: 15px;
    opacity: 0.8;
}

.brightness {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 3px;
    font-weight: 400;
}
