:root {
    /* Default (Light) Theme Variables */
    --primary-color: #6c5ce7;
    --primary-hover: #5649c0;
    --secondary-color: #a29bfe;
    --accent-color: #fd79a8; 
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #2d3436;
    --text-sub: #636e72;
    --border-radius: 20px;
    --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #8c7ae6;
    --primary-hover: #6c5ce7;
    --secondary-color: #a29bfe;
    --accent-color: #ff7675;
    --bg-color: #1e1e2e;
    --card-bg: #2d2d44;
    --text-main: #f5f6fa;
    --text-sub: #b2bec3;
    --shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* System Preference (Auto Dark) - Only applies if data-theme is NOT explicitly set to light */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #8c7ae6;
        --primary-hover: #6c5ce7;
        --secondary-color: #a29bfe;
        --accent-color: #ff7675;
        --bg-color: #1e1e2e;
        --card-bg: #2d2d44;
        --text-main: #f5f6fa;
        --text-sub: #b2bec3;
        --shadow: 0 10px 30px rgba(0,0,0,0.3);
    }
}

/* Dark Mode Text Contrast Improvements */
[data-theme="dark"] .result-section {
    background-color: var(--card-bg); /* Use card bg for section distinction */
    border: 1px solid #444; /* Subtle border */
}

[data-theme="dark"] .result-section p {
    color: #e0e0e0; /* Lighter text for readability */
}

[data-theme="dark"] .score-badge {
    background-color: #3d3d5c;
    color: #fff;
    border-color: #555;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center; /* Center content horizontally */
    min-height: 100vh;
    padding: 20px;
    padding-top: 80px; /* Space for fixed nav */
    transition: background-color 0.3s, color 0.3s;
}

/* Navigation Bar */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding: 15px 20px;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center; /* Ensure vertical centering */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

[data-theme="dark"] .main-nav {
    background-color: rgba(30, 30, 46, 0.9);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Theme Toggle Button (Integrated in Nav) */
.theme-toggle {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
}

.theme-toggle:hover {
    background: rgba(0,0,0,0.1);
    transform: translateY(-50%) scale(1.1);
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255,255,255,0.1);
    color: #ffd700; /* Gold for moon/sun */
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.container {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    min-height: 600px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.3s;
    margin-bottom: 20px;
}

/* Save Options Modal/Menu Style */
.save-options {
    display: none; /* Hidden by default */
    margin-top: 10px;
    gap: 10px;
    justify-content: center;
}
.save-options.visible {
    display: flex;
    flex-wrap: wrap;
}

.save-option-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    font-size: 0.9rem;
    cursor: pointer;
}
.save-option-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .container { padding: 30px 20px; }
    h1 { font-size: 1.6rem; }
    .primary-btn { padding: 14px; font-size: 0.95rem; }
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    flex: 1;
    animation: fadeIn 0.4s ease-out;
    width: 100%;
}

.screen.hidden {
    display: none;
}

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

/* Intro Screen */
#intro-screen { justify-content: center; }

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

h1 {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 10px;
    color: var(--primary-color);
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

p {
    color: var(--text-sub);
    line-height: 1.5;
}

.illustration {
    font-size: 5rem;
    margin: 40px 0;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0px); }
}

/* Buttons */
.primary-btn, .secondary-btn, .option-btn, .compare-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
    background-color: transparent;
    color: var(--text-sub);
    border: 1px solid var(--text-sub);
    margin-top: 10px;
}

/* Compare Button Special Style */
.compare-btn {
    background: linear-gradient(135deg, #fd79a8, #e84393);
    color: white;
    box-shadow: 0 4px 15px rgba(232, 67, 147, 0.3);
    margin-bottom: 10px;
}
.compare-btn:active { transform: scale(0.98); }

/* Quiz Screen */
#quiz-screen { justify-content: center; }

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 40px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.question-container {
    text-align: center;
    margin-bottom: 40px;
    width: 100%;
    padding: 0 10px; /* Add padding for mobile */
}

#question-text {
    word-break: keep-all; /* Prevent breaking in middle of words */
    line-height: 1.6;
    max-width: 90%; /* Prevent hitting edges */
    margin: 0 auto;
}

.q-number {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 10px;
}

.options-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    background-color: var(--bg-color);
    color: var(--text-main);
    text-align: left;
    padding: 15px 20px;
}
.option-btn:hover {
    background-color: var(--secondary-color);
    color: white;
}

/* Result Screen */
.chart-container {
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
    position: relative;
    flex-shrink: 0;
}

.result-detail-container {
    width: 100%;
    text-align: left;
    margin-top: 20px;
}

.result-section {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.result-section h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.score-badge {
    font-size: 0.9rem;
    background: var(--card-bg);
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--text-main);
    border: 1px solid var(--text-sub);
}

.action-buttons {
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Footer Link */
footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.8rem;
}
footer a { color: var(--text-sub); text-decoration: none; }