:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --header-bg: #212529;
    --header-text: #ffffff;
    --accent-color: #4a90e2;
    --accent-hover: #357abd;
    --shadow: 0 4px 15px rgba(0,0,0,0.08);
    --secondary-accent: #8e44ad;
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #e9ecef;
    --card-bg: #1e1e1e;
    --header-bg: #000000;
    --header-text: #ffffff;
    --accent-color: #64b5f6;
    --accent-hover: #90caf9;
    --shadow: 0 4px 15px rgba(0,0,0,0.4);
    --secondary-accent: #b39ddb;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
    scroll-behavior: smooth;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 0.8rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { font-size: 1.4rem; font-weight: 900; letter-spacing: -0.5px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--header-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.nav-links a:hover { opacity: 1; }

#themeToggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--header-text);
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem 4rem 1rem;
}

.hero {
    text-align: center;
    padding: 4rem 1rem;
    background: linear-gradient(180deg, rgba(74, 144, 226, 0.05) 0%, transparent 100%);
}

.hero h2 { font-size: 2.2rem; font-weight: 900; margin-bottom: 1.5rem; line-height: 1.3; }
.hero p { font-size: 1.1rem; opacity: 0.7; max-width: 700px; margin: 0 auto; }

/* Improved User Info Styling */
.user-info-v2 {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 2rem;
    border: 1px solid rgba(0,0,0,0.05);
}

.info-card .divider {
    width: 1px;
    height: 40px;
    background: rgba(0,0,0,0.1);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gender-btn-group {
    display: flex;
    gap: 0.4rem;
    background: var(--bg-color);
    padding: 0.3rem;
    border-radius: 10px;
}

.gender-btn {
    cursor: pointer;
    position: relative;
}

.gender-btn input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.gender-btn span {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: 7px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-color);
}

.gender-btn input:checked + span {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 3px 8px rgba(74, 144, 226, 0.3);
}

.age-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.age-input-wrapper input {
    padding: 0.5rem;
    width: 60px;
    border: 2px solid var(--bg-color);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    transition: border-color 0.2s;
}

.age-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.age-input-wrapper .unit {
    font-weight: bold;
    opacity: 0.7;
    font-size: 0.9rem;
}

.hidden-file-input {
    display: none;
}

.secondary-actions {
    margin-top: 1.5rem;
}

.reset-btn-v2 {
    background: transparent;
    color: var(--text-color);
    border: 1px solid rgba(0,0,0,0.1);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

.reset-btn-v2:hover {
    opacity: 1;
    background: rgba(0,0,0,0.05);
}

body.dark-mode .reset-btn-v2 {
    border-color: rgba(255,255,255,0.1);
}

body.dark-mode .reset-btn-v2:hover {
    background: rgba(255,255,255,0.05);
}

/* Analysis Container Size Control */
.analysis-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.analysis-box {
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
    max-width: 280px;
    border: 1px solid rgba(0,0,0,0.05);
}

#boxLeft .box-header {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
}

#boxRight .box-header {
    background: linear-gradient(135deg, #8e44ad, #703688);
    color: white;
}

.box-header {
    padding: 0.9rem;
    text-align: center;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/5;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5; /* Ensure wrapper is above other background elements */
}

canvas {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none; /* Clicks pass through to the wrapper */
}

.preview-placeholder {
    color: white;
    font-size: 0.85rem;
    opacity: 0.7;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s;
    pointer-events: none; /* Clicks pass through to the wrapper */
}

.camera-icon {
    width: 60px;
    height: 60px;
    opacity: 0.6;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    color: var(--accent-color);
}

.canvas-wrapper:hover .preview-placeholder {
    opacity: 1;
}

.canvas-wrapper:hover .camera-icon {
    transform: scale(1.15) rotate(-3deg);
    opacity: 1;
}

.action-section { text-align: center; margin: 3rem 0; }
.primary-btn { padding: 1.2rem 4rem; background: var(--accent-color); color: white; border: none; border-radius: 50px; font-size: 1.1rem; font-weight: 900; cursor: pointer; transition: all 0.3s; box-shadow: 0 10px 20px rgba(74, 144, 226, 0.2); }
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-3px); box-shadow: 0 15px 25px rgba(74, 144, 226, 0.3); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; background: #999; box-shadow: none; }

/* Info Sections (For SEO & AdSense) */
.info-section, .faq-section {
    padding: 5rem 0;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.info-section h3, .faq-section h3 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 3rem;
    text-align: center;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.info-item {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.info-item h4 { color: var(--accent-color); margin-top: 0; margin-bottom: 1rem; font-size: 1.2rem; }
.info-item p { font-size: 0.95rem; opacity: 0.8; margin: 0; }

.faq-item {
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.faq-item h5 { margin: 0 0 0.8rem 0; font-size: 1.1rem; color: var(--accent-color); }
.faq-item p { margin: 0; font-size: 0.95rem; opacity: 0.8; }

/* Camera Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow);
    margin: auto;
}

.close-modal {
    position: absolute;
    right: 15px; top: 10px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.5;
}

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/5;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80%; height: 80%;
    border: 2px dashed rgba(255,255,255,0.4);
    border-radius: 30px;
    pointer-events: none;
}

.capture-btn {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    padding: 0.8rem 1.8rem;
    background: var(--accent-color);
    color: white;
    border-radius: 50px;
    border: none;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.camera-hint { font-size: 0.8rem; opacity: 0.7; }

/* Result Section */
.result-section { padding-top: 3rem; animation: fadeIn 0.6s ease-out; }
.result-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 900;
    color: var(--accent-color);
}

.summary-card {
    background: rgba(74, 144, 226, 0.08);
    padding: 2rem;
    border-radius: 20px;
    margin-bottom: 2.5rem;
    border: 2px solid rgba(74, 144, 226, 0.1);
    font-size: 1.1rem;
    line-height: 1.7;
    text-align: center;
}

.reading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.reading-card {
    padding: 2rem;
    border-radius: 20px;
    background: var(--card-bg);
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: var(--shadow);
}

.reading-card h3 {
    margin-top: 0; margin-bottom: 1.2rem;
    font-size: 1.2rem; font-weight: 800;
}

.reading-card p { font-size: 0.95rem; margin-bottom: 1rem; }

.line-label {
    font-weight: 800; font-size: 0.75rem;
    padding: 3px 8px; border-radius: 5px;
    display: inline-block; margin-right: 5px;
}

.advice-section {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.total-review-box, .destiny-advice-box {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.total-review-box { border-left: 10px solid var(--accent-color); }
.destiny-advice-box { border-left: 10px solid var(--secondary-accent); }

.total-review-box h3, .destiny-advice-box h3 {
    margin-top: 0; margin-bottom: 1.2rem;
    font-size: 1.4rem; font-weight: 900;
}

.total-review-box h3 { color: var(--accent-color); }
.destiny-advice-box h3 { color: var(--secondary-accent); }

.total-review-box p, .destiny-advice-box p { font-size: 1.05rem; line-height: 1.8; margin: 0; }

.loader {
    border: 5px solid rgba(0,0,0,0.05);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 0.8s cubic-bezier(0.42, 0, 0.58, 1) infinite;
    margin: 3rem auto;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

footer {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 4rem 1.5rem;
    margin-top: 5rem;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
}

.footer-links a {
    color: var(--header-text);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.6;
}

.footer-links a:hover { opacity: 1; }

@media (max-width: 768px) {
    .hero h2 { font-size: 1.8rem; }
    .hero { padding: 3rem 1rem; }
    .info-card { padding: 1.2rem; gap: 1.2rem; }
    .nav-links a:not(#themeToggle) { display: none; }
}

@media (max-width: 480px) {
    .info-card { flex-direction: column; gap: 1.5rem; }
    .info-card .divider { width: 80%; height: 1px; }
}