:root {
    --bg-color: #0f1115;
    --card-bg: #181b21;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent-color: #3b82f6;
    /* Blue */
    --accent-hover: #2563eb;
    --border-color: #2d3139;
    --success-color: #10b981;
    --font-main: 'Inter', sans-serif;

    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition-speed: 0.3s;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

.app-container {
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

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

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

/* Headers */
.main-header {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 40px;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
}

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 20px;
    padding-top: 10px;
    /* Prevent hover clipping */
    overflow-y: auto;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
}

@media (max-width: 600px) {
    body {
        overflow-y: auto;
        /* Allow scrolling on mobile */
        height: auto;
        min-height: 100vh;
    }

    .app-container {
        padding: 15px;
        height: auto;
        min-height: 100vh;
        display: block;
        /* Flex column is fine, but block might be simpler for scrolling flow */
    }

    .user-info {
        position: relative;
        width: 100%;
        justify-content: center;
        background: var(--card-bg);
        padding: 10px;
        border-radius: 8px;
        margin-bottom: 20px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .main-header {
        margin-top: 10px;
        margin-bottom: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .logo {
        font-size: 1.8rem;
        text-align: center;
    }

    .products-grid {
        grid-template-columns: 1fr;
        padding-bottom: 40px;
        /* Space for footer */
        overflow-y: visible;
        /* Let the page scroll */
    }

    .product-card {
        min-height: auto;
        padding: 20px;
    }

    /* Quiz Screen Mobile Overrides */
    .quiz-content {
        overflow-y: visible;
        /* Let page scroll */
    }

    .screen {
        height: auto;
        /* Don't force 100% height */
    }
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.1);
}

.card-content h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.card-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.badge {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.arrow {
    font-weight: bold;
    color: var(--text-secondary);
    transition: transform var(--transition-speed);
}

.product-card:hover .arrow {
    transform: translateX(4px);
    color: var(--accent-color);
}

/* Quiz Screen */
.quiz-header {
    display: flex;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 20px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
    margin-right: 20px;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.progress-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#question-counter {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-align: right;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    width: 0%;
    transition: width 0.4s ease;
}

.quiz-content {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

/* Question Styles - Injected */
.question-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 10px;
}

.product-tag {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-option {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: flex-start;
}

.answer-option:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: #4b5563;
}

.answer-option.selected {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-color);
}

.answer-marker {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    margin-right: 12px;
    margin-top: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-option[data-type="multiple"] .answer-marker {
    border-radius: 4px;
    /* Square for checkbox */
}

.answer-option.selected .answer-marker {
    border-color: var(--accent-color);
    background-color: var(--accent-color);
}

.answer-marker::after {
    content: '';
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
    display: none;
}

.answer-option.selected .answer-marker::after {
    display: block;
}

.answer-option.correct {
    background-color: rgba(16, 185, 129, 0.15);
    /* Green */
    border-color: var(--success-color);
}

.answer-option.correct .answer-marker {
    border-color: var(--success-color);
    background-color: var(--success-color);
}

.answer-option.incorrect {
    background-color: rgba(239, 68, 68, 0.15);
    /* Red */
    border-color: #ef4444;
}

.answer-option.incorrect .answer-marker {
    border-color: #ef4444;
    background-color: #ef4444;
}

.feedback-msg {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Footer Navigation */

.quiz-footer {
    display: flex;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.spacer {
    flex-grow: 1;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    border: none;
}

.btn.primary {
    background-color: var(--accent-color);
    color: white;
}

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

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

.btn.secondary:hover:not(:disabled) {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* User Info Header */
.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    /* Space on mobile */
}

@media (min-width: 601px) {
    .user-info {
        /* position: absolute;  <-- REMOVED to prevent overlap */
        /* top: 20px; */
        /* right: 20px; */
        display: flex;
        justify-content: flex-end;
        /* Align to right */
        padding: 0 20px;
        /* Align with container padding */
        margin-bottom: 20px;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }

    .main-header {
        margin-top: 10px;
        margin-bottom: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* User info will be part of flow now, order it to top if needed using flex order, 
       but currently it's appended to body. We need to move it to app-container. */

    .quiz-footer {
        flex-direction: column;
        gap: 10px;
        position: sticky;
        bottom: 0;
        background-color: var(--bg-color);
        /* Ensure opacity */
        padding-top: 15px;
        padding-bottom: 15px;
        /* Add padding for touch targets */
        margin-top: auto;
        /* Push to bottom if content is short */
        border-top: 1px solid var(--border-color);
        z-index: 10;
        /* Ensure it stays on top */
    }

    .quiz-footer .btn {
        width: 100%;
        margin-bottom: 5px;
    }

    .spacer {
        display: none;
    }

    /* Adjust buttons order/layout */
    #prev-btn {
        order: 2;
    }

    #next-btn {
        order: 1;
    }

    #check-btn {
        order: 0;
        width: 100%;
        margin-right: 0 !important;
        margin-bottom: 5px;
    }
}