@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Noto+Serif+KR:wght@300;500;700&family=Outfit:wght@300;400;600&display=swap');

/* ===================== DESIGN TOKENS ===================== */
:root {
    --primary: #c9a050;
    --primary-glow: rgba(201, 160, 80, 0.4);
    --bg-dark: #070709;
    --glass: rgba(255, 255, 255, 0.02);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f5f5f7;
    --text-dim: #929293;
    --font-title: 'Cinzel', serif;
    --font-body: 'Outfit', sans-serif;
    --transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    --glass-heavy: rgba(255, 255, 255, 0.05);
}

/* Entrance Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===================== GLOBAL ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; cursor: none !important; }
body { background-color: var(--bg-dark); color: var(--text-main); font-family: var(--font-body); overflow-x: hidden; line-height: 1.6; }

/* Effects */
.cursor-dot { width: 8px; height: 8px; background: var(--primary); position: fixed; border-radius: 50%; z-index: 10000; pointer-events: none; transform: translate(-50%, -50%); }
.cursor-outline { width: 40px; height: 40px; border: 1px solid var(--primary-glow); position: fixed; border-radius: 50%; z-index: 9999; pointer-events: none; transform: translate(-50%, -50%); transition: transform 0.15s ease-out, background 0.3s; }
#particles-js { position: fixed; width: 100%; height: 100%; z-index: 1; top: 0; left: 0; pointer-events: none; }

/* Real Constellations Style */
#constellations-layer {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

.constellation {
    position: absolute;
    opacity: 0.02;
    transition: opacity 1.5s ease, filter 1.5s ease;
}

.constellation.active {
    opacity: 0.3;
    filter: drop-shadow(0 0 10px #ffd700);
}

.constellation circle {
    filter: drop-shadow(0 0 2px #fff);
}

/* ===================== LAYOUT ===================== */
#app {
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
}

.screen {
    width: 100%;
    min-height: 100vh;
    display: none; /* Controlled by JS */
    flex-direction: column;
    align-items: center;
    padding: 10rem 2rem 6rem;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.screen.active { display: flex; opacity: 1; }

/* Background Vignette */
.screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, transparent 20%, rgba(0,0,0,0.85) 100%);
    z-index: 0;
    pointer-events: none;
}

.content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}

/* ===================== COMPONENTS ===================== */
.title-font {
    font-family: var(--font-title);
    font-size: clamp(3rem, 8vw, 5rem);
    letter-spacing: 12px;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.subtitle {
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--text-dim);
    margin-bottom: 4.5rem;
    letter-spacing: 3px;
}

.btn {
    padding: 1.2rem 3.5rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 4px;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    margin: 0.5rem;
}

.btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
    transform: translateY(-5px);
    color: var(--primary);
    background: rgba(201, 160, 80, 0.05);
}

.btn.primary { background: var(--primary); color: #000; border: none; }

/* Era Selection Grid - FIXED LAYOUT */
.era-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    gap: 2.5rem;
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
}

.era-card {
    height: 240px;
    border-radius: 32px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3.5rem;
    text-align: left;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.era-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, rgba(0,0,0,0.9), rgba(0,0,0,0.3)); z-index: 1; }
.era-card:hover { transform: scale(1.03) translateY(-8px); border-color: var(--primary); box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 20px var(--primary-glow); }
.era-card:hover::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    z-index: 1;
}

.era-title {
    position: relative;
    z-index: 2;
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.era-title small { font-size: 0.9rem; color: var(--primary); opacity: 0.8; letter-spacing: 2px; }

.era-desc {
    position: relative;
    z-index: 2;
    font-size: 0.95rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* ===================== GALLERY TABS ===================== */
.gallery-tabs {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 3rem 0;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.8rem 2rem;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-dim);
    font-family: var(--font-title);
    font-size: 0.9rem;
    letter-spacing: 2px;
    transition: var(--transition);
    text-transform: uppercase;
}

.tab-btn:hover {
    color: #fff;
    border-color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #000;
    border: none;
    box-shadow: 0 0 20px var(--primary-glow);
}

/* ===================== GALLERY (HALL OF SAGES) - 4x4 REFINED ===================== */
.hall-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin-top: 4rem;
    width: 100%;
}

.hall-card {
    background: var(--glass);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    aspect-ratio: 3/4.5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.hall-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.hall-card-img {
    height: 75%;
    background-color: #0a0e1a;
    background-image: linear-gradient(135deg, #0a0e1a 0%, #1a1f2e 100%);
    background-size: cover;
    background-position: center;
    position: relative;
    border-bottom: 1px solid var(--glass-border);
    overflow: hidden;
}

/* Placeholder for missing images */
.hall-card-img::before {
    content: '현자의 형상 사유 중...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary);
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 2px;
    opacity: 0.3;
    width: 100%;
    text-align: center;
}

.card-mbti {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.8rem 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    color: var(--primary);
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.hall-card-info {
    padding: 1.2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.hall-card-info h4 {
    font-family: var(--font-title);
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 0.4rem;
}

.hall-card-info p {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

/* ===================== FOOTER & ABOUT ===================== */
.site-footer {
    width: 100%;
    background: #050507;
    border-top: 1px solid var(--glass-border);
    padding: 8rem 2rem 4rem;
    margin-top: auto; /* Push to bottom of content if screen is short */
    position: relative;
    z-index: 5;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 5rem;
}

.footer-section h4 {
    font-family: var(--font-title);
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    letter-spacing: 2px;
}

.footer-section p, .footer-section a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.8;
}

.footer-section a:hover { color: var(--primary); }

.footer-bottom {
    max-width: 1100px;
    margin: 4rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    text-align: center;
    color: #444;
    font-size: 0.85rem;
}

/* ===================== QUEST SCREEN (INTERACTIVE) ===================== */
.progress-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 4px;
    background: rgba(255,255,255,0.05);
    z-index: 1000;
}

#progressBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--primary), #fff);
    box-shadow: 0 0 15px var(--primary-glow);
    transition: width 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.mbti-badge {
    font-family: var(--font-title);
    font-size: 0.9rem;
    color: var(--primary);
    letter-spacing: 5px;
    margin-bottom: 2.5rem;
    text-shadow: 0 0 10px var(--primary-glow);
}

.typewriter-container {
    font-size: 1.8rem;
    font-weight: 500;
    color: #fff;
    min-height: 4rem;
    margin-bottom: 5rem;
    line-height: 1.6;
    word-break: keep-all;
}

#optionsWrap {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.option-btn {
    padding: 1.8rem 2.5rem;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: var(--text-main);
    font-size: 1.1rem;
    text-align: left;
    transition: var(--transition);
    opacity: 0;
    transform: translateY(20px);
    backdrop-filter: blur(10px);
}

.option-btn.show {
    opacity: 1;
    transform: translateY(0);
}

.option-btn:hover {
    background: rgba(201, 160, 80, 0.08);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), 0 0 15px var(--primary-glow);
    transform: scale(1.02) translateY(-3px);
    color: #fff;
}

/* ===================== RESULT SCREEN (FINAL) ===================== */
.result-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    padding: 5rem 3rem;
    backdrop-filter: blur(20px);
    box-shadow: 0 40px 100px rgba(0,0,0,0.6);
}

.phil-portrait-large {
    width: 220px;
    height: 220px;
    margin: 2.5rem auto;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--primary);
    box-shadow: 0 0 40px var(--primary-glow), inset 0 0 20px rgba(0,0,0,0.5);
    position: relative;
    animation: fadeInScale 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.phil-portrait-large::after {
    content: '';
    position: absolute;
    top: -15px; left: -15px; right: -15px; bottom: -15px;
    border: 1px solid var(--primary-glow);
    border-radius: 50%;
    opacity: 0.5;
    animation: pulseGlow 3s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); opacity: 0.2; }
    50% { transform: scale(1.05); opacity: 0.5; }
    100% { transform: scale(0.95); opacity: 0.2; }
}

.phil-name {
    font-family: var(--font-title);
    font-size: 3rem;
    color: #fff;
    margin: 1rem 0;
    letter-spacing: 5px;
    animation: fadeInUp 1s ease 0.3s backwards;
}

.phil-quote {
    font-size: 1.2rem;
    font-style: italic;
    color: var(--primary);
    margin: 2.5rem 0;
    line-height: 1.8;
    animation: fadeInUp 1s ease 0.6s backwards;
}

/* Statistics Table */
.stats-container {
    background: rgba(0,0,0,0.3);
    border-radius: 20px;
    padding: 2rem;
    margin: 3rem 0;
    text-align: left;
}

.stats-progress-bg {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.stats-progress-fill {
    height: 100%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ===================== MODAL SYSTEM ===================== */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(15px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 2rem;
    opacity: 0;
    transition: var(--transition);
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    max-width: 600px;
    width: 100%;
    position: relative;
    text-align: center;
    animation: modalIn 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes modalIn {
    from { transform: scale(0.8) translateY(30px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
    .hall-grid { grid-template-columns: repeat(2, 1fr); }
    .era-grid { grid-template-columns: 1fr; max-width: 500px; }
}

@media (max-width: 768px) {
    .screen { padding-top: 6rem; }
    .cursor-dot, .cursor-outline { display: none; }
    * { cursor: auto !important; }
    .typewriter-container { font-size: 1.4rem; }
}
