:root {
    --primary-color: #d4af37; /* Metallic Gold */
    --secondary-color: #1a365d; /* Deep Greek Blue */
    --accent-color: #8b0000; /* Deep Red */
    --bg-gradient: linear-gradient(135deg, #f5f5f0 0%, #e8e4d9 100%);
    --card-bg: rgba(255, 255, 255, 0.92);
    --text-main: #2c3e50;
    --text-light: #5f6c7b;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Lato', sans-serif;
    --anim-speed: 0.3s;
}

/* Utility Class - Critical for visibility toggling */
.hidden {
    display: none !important;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Background Animation Placeholder */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.08;
    background-image: radial-gradient(var(--secondary-color) 2px, transparent 2px);
    background-size: 40px 40px;
}

/* Main Container */
.app-top-header {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding-top: 2rem;
    z-index: 10;
    position: relative;
}

.app-top-header img {
    height: 50px;
    width: auto;
    display: block;
    transition: transform 0.3s ease;
}

.app-top-header img:hover {
    transform: scale(1.05);
}

.quiz-container {
    background: var(--card-bg);
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(26, 54, 93, 0.15);
    padding: 2rem;
    backdrop-filter: blur(10px);
    border: 2px solid var(--primary-color);
    transition: transform var(--anim-speed);
}

.quiz-header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-family: var(--font-heading);
    color: var(--secondary-color);
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-light);
    font-weight: 300;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: #eee;
    margin-top: 1.5rem;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    /* JS will update this */
    transition: width 0.5s ease-in-out;
}

/* Quiz Content */
.question-card h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    text-align: center;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-btn {
    background: #fff;
    border: 2px solid #eee;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 1rem;
    text-align: left;
    transition: all 0.2s ease;
    color: var(--text-main);
}

@media (hover: hover) {
    .option-btn:hover {
        border-color: var(--primary-color);
        background: #fff0f3;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(233, 78, 119, 0.15);
    }
}

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

/* Navigation Controls */
.navigation-controls {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}

#prevBtn {
    margin-right: auto;
}

#nextBtn {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    min-width: 120px;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

#nextBtn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

#nextBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
    color: #888;
}

/* Selected Option State */
.option-btn.selected {
    border-color: var(--primary-color);
    background: #fff9db;
    /* Light yellow background */
    box-shadow: 0 0 0 2px var(--primary-color);
    position: relative;
}

.option-btn.selected::after {
    content: '✓';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: var(--secondary-color);
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Footer */
.quiz-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    background: #fff;
    padding: 2.5rem;
    border-radius: 8px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    border-top: 6px solid var(--primary-color);
    border-bottom: 6px solid var(--primary-color);
    animation: slideUp 0.4s ease-out;
}

/* Analyzing Loader */
.analyzing-loader {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Story Container */
.story-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.story-text {
    font-size: 1.4rem;
    font-family: 'Playfair Display', serif;
    color: #333;
    line-height: 1.6;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.story-text.visible {
    opacity: 1;
}

.modal-header h3 {
    color: #ae2b26;
    font-family: 'Playfair Display', serif;
    margin-bottom: 0.5rem;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

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

.top-icon-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-icon-btn:hover {
    color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.result-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--secondary-color);
    margin: 1rem 0;
}

.result-icon {
    font-size: 4rem;
    margin: 1rem 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.result-description {
    line-height: 1.6;
    margin-bottom: 2rem;
    color: #555;
}

.primary-btn {
    background: var(--primary-color);
    color: #2c3e50;
    /* Dark text for better contrast on yellow */
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.primary-btn:hover {
    background: var(--secondary-color);
    color: white;
    /* White text on darker hover color */
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }

    .quiz-container {
        padding: 1.2rem;
        width: 95%;
    }

    .modal-content {
        padding: 1.2rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .result-img {
        max-width: 180px;
        margin: 0.5rem auto;
    }

    .result-title {
        font-size: 1.5rem;
        margin: 0.5rem 0;
    }

    .result-description {
        font-size: 0.95rem;
        margin-bottom: 1rem;
        line-height: 1.4;
    }

    .store-buttons {
        gap: 1rem;
        margin-top: 1rem;
    }

    .store-btn img {
        height: 32px;
    }

    .modal-actions {
        margin-top: 1rem;
    }

    .primary-btn,
    .secondary-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.95rem;
        width: 100%;
        /* Full width buttons on mobile for better touch targets */
    }

    .app-nudge p {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* Store Buttons */
.store-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 0.5rem 0;
    align-items: center;
}

.store-btn {
    display: inline-block;
    transition: transform 0.2s;
    text-decoration: none;
    /* remove underline from links */
}

.store-btn img {
    height: 40px;
    width: auto;
    display: block;
    /* remove inline gap */
}

.store-btn:hover {
    transform: scale(1.05);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--text-main);
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 700;
    font-family: var(--font-body);
}

.secondary-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

/* Result Image */
.result-img {
    max-width: 250px;
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    margin: 1rem auto;
    display: block;
    object-fit: cover;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-img.hidden {
    display: none;
}