:root {
    /* Color Palette - Premium & Modern (Light Mode Default) */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);

    --btn-bg: rgba(0, 0, 0, 0.02);
    --btn-bg-hover: rgba(0, 0, 0, 0.05);
    --btn-bg-selected: rgba(99, 102, 241, 0.1);

    --illust-bg: #ffffff;
    --illust-border: #e5e7eb;
    --threshold-line: rgba(0, 0, 0, 0.5);

    /* Typography */
    --font-content: 'Pretendard', sans-serif;
    --font-display: 'Outfit', sans-serif;
}

:root[data-theme="dark"] {
    --bg-primary: #0a0a0c;
    --bg-secondary: #141418;
    --accent-primary: #8e8cf7;
    --accent-secondary: #c2b5f9;
    --text-main: #f0f0f5;
    --text-muted: #9494a3;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary-gradient: linear-gradient(135deg, #8e8cf7 0%, #c2b5f9 100%);

    --btn-bg: rgba(255, 255, 255, 0.05);
    --btn-bg-hover: rgba(255, 255, 255, 0.1);
    --btn-bg-selected: rgba(142, 140, 247, 0.15);

    --illust-bg: #1a1a20;
    --illust-border: rgba(255, 255, 255, 0.1);
    --threshold-line: rgba(255, 255, 255, 0.8);
}

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

body {
    font-family: var(--font-content);
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    word-break: keep-all;
    overflow-wrap: break-word;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 2rem 1rem;
    max-width: 600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 1.5rem;
}

.logo span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    flex: 1;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    animation: fadeIn 0.6s ease-out;
}

.screen.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

/* Start Screen */
#start-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-weight: 700;
}

#start-screen p {
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

.stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-divider {
    width: 1px;
    height: 24px;
    background: var(--glass-border);
}

/* Buttons */
.primary-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(142, 140, 247, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Progress Bar */
.progress-container {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--glass-border);
    border-radius: 3px;
    margin-right: 1rem;
    overflow: hidden;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.4s ease;
}

#progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Back Button Prominent */
.back-btn-prominent {
    background: rgba(142, 140, 247, 0.1);
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.back-btn-prominent:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(142, 140, 247, 0.3);
}

/* Question Section */
.question-title {
    font-size: 1.4rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.option-btn {
    background: var(--btn-bg);
    border: 1px solid var(--glass-border);
    padding: 1.2rem;
    border-radius: 16px;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.option-btn:hover {
    background: var(--btn-bg-hover);
    border-color: var(--accent-primary);
}

.option-btn.selected {
    background: var(--btn-bg-selected);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Explanatory Image Placeholder */
.term-explanation {
    margin: 1.5rem 0;
    text-align: center;
}

.term-image {
    width: 100%;
    max-width: 300px;
    height: 200px;
    background: #1a1a20;
    border-radius: 16px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--glass-border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Loading */
.loader-content {
    text-align: center;
    padding: 4rem 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto 2rem;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Result Screen */
.result-header {
    text-align: center;
    margin-bottom: 3rem;
}

.skin-type-badge {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--primary-gradient);
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.skin-type-name {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    font-family: var(--font-display);
}

/* Factor Result Bars */
.factor-results {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px dashed var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.factor-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.factor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
}

.factor-label {
    color: var(--text-main);
}

.factor-value {
    color: var(--accent-secondary);
    font-family: var(--font-display);
    font-weight: 700;
}

.factor-bar-bg {
    width: 100%;
    height: 16px;
    background: var(--glass-bg);
    border-radius: 8px;
    position: relative;
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

.factor-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 0%;
    position: relative;
    overflow: hidden;
}

/* Glass shine overlay */
.factor-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.0) 50%, rgba(0, 0, 0, 0.05) 100%);
    border-radius: 8px;
}

/* Colors for each factor */
.bar-oil {
    background: linear-gradient(90deg, #fcd000, #ff9f43);
    box-shadow: 0 0 10px rgba(255, 159, 67, 0.4);
}

.bar-dry {
    background: linear-gradient(90deg, #48dbfb, #0abde3);
    box-shadow: 0 0 10px rgba(10, 189, 227, 0.4);
}

.bar-sen {
    background: linear-gradient(90deg, #ff6b6b, #ee5253);
    box-shadow: 0 0 10px rgba(238, 82, 83, 0.4);
}

/* Normal Threshold Line */
.factor-threshold {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background-color: var(--threshold-line);
    z-index: 10;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.factor-threshold::after {
    content: '정상 점수';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}

.factor-bar-bg:hover .factor-threshold::after {
    opacity: 1;
}

/* Recommendations */
.recommendation-section {
    margin-top: 4rem;
}

.section-title {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.product-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    transition: transform 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.product-card:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.06);
}

.product-image {
    width: 100px;
    height: 100px;
    background: white;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product-tag {
    font-size: 0.7rem;
    color: var(--accent-primary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.buy-btn {
    font-size: 0.85rem;
    color: #ff9000;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

footer {
    text-align: center;
    padding: 4rem 0 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #app {
        padding: 1.5rem 0.8rem;
    }

    .glass-card {
        padding: 2rem 1.2rem;
    }
}