:root {
    --bg-color: #F3F0E6;
    /* Warm beige */
    /* Cream background */
    --card-bg: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --accent-color: #7C3AED;
    /* Violet */
    --accent-hover: #6D28D9;
    /* Darker violet for hover */
    --success-bg: #e4f7e8;
    --success-text: #008a2e;
    --error-bg: #fff2f4;
    --error-text: #cf1832;
    --border-radius: 20px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

/* Hide scrollbar globally for clean look as requested */
::-webkit-scrollbar {
    display: none;
}

* {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.container {
    width: 100%;
    /* max-width: 800px; */
    max-width: 1100px;
    /* Increased to fit sidebar */
}

/* Landing Page */
.landing-section {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.8s ease-out;
}

.pill-label {
    display: inline-block;
    background: #ECEBFF;
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 24px;
}

.landing-section h1 {
    font-size: 56px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -1.5px;
    line-height: 1.1;
}

.highlight-text {
    color: var(--accent-color);
}

.subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    font-weight: 400;
}

.hero-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.primary-btn {
    padding: 16px 32px;
    background: var(--accent-color);
    color: white;
    border-radius: 999px;
    /* Pill shape */
    font-size: 17px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid var(--accent-color);
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(13, 148, 136, 0.2);
    min-width: 280px;
    /* Fixed width for symmetry */
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.primary-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(13, 148, 136, 0.3);
}

.outline-btn {
    padding: 16px 32px;
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    border-radius: 999px;
    /* Pill shape match */
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(13, 148, 136, 0.1);
    min-width: 280px;
    /* Fixed width for symmetry */
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.outline-btn:hover {
    background: #e0f2f1;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(13, 148, 136, 0.2);
}

/* Trust Badge */
.trust-badge {
    margin-top: 40px;
    font-size: 14px;
    color: var(--text-secondary);
    background: white;
    display: inline-block;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e5e7eb;
}

.stars {
    color: #F59E0B;
    margin-right: 5px;
    font-size: 16px;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: 100%;
}

.training-options {
    background: white;
    padding: 30px;
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    margin-top: 30px;
    display: none;
    animation: fadeIn 0.4s ease-out;
    border: 1px solid #f0f0f0;
}

.training-options h3 {
    margin-top: 0;
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 700;
}

.options-grid {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.option-btn {
    padding: 16px 30px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 140px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #f0fdf9;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.15);
}

.header-top {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    /* Center title, fixed sides */
    align-items: center;
    margin-bottom: 15px;
}

.header-top h1 {
    margin: 0;
    /* Reset margin for grid centering */
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #f0f0f5;
    color: var(--text-primary);
}

.timer {
    font-size: 16px;
    font-weight: 600;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    text-align: right;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.progress-container {
    height: 6px;
    background: #e5e5ea;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

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

button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
}

.options-list button {
    padding: 18px 20px;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    background: white;
    text-align: left;
    font-size: 17px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    position: relative;
    padding-right: 40px;
    /* Space for icon */
}

.options-list button:hover:not(:disabled) {
    border-color: var(--accent-color);
    background: #f5f9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.options-list button:disabled {
    cursor: default;
    opacity: 0.8;
}

/* Option Button States */
.options-list button.correct {
    background: var(--success-bg) !important;
    border-color: var(--success-text) !important;
    color: var(--success-text) !important;
    font-weight: 500;
}

.options-list button.incorrect {
    background: var(--error-bg) !important;
    border-color: var(--error-text) !important;
    color: var(--error-text) !important;
}

/* Selected state (when correction is OFF) */
.options-list button.selected {
    background: #e0f2fe !important;
    /* Light blue */
    border-color: #0ea5e9 !important;
    /* Blue */
    color: #0284c7 !important;
    font-weight: 700;
}

/* --- Result Page Styling --- */
.result-details .result-content {
    text-align: center;
    padding: 20px;
}

.final-score-display {
    margin: 30px 0;
}

.score-number {
    font-size: 48px;
    font-weight: 800;
    color: var(--accent-color);
}

.result-sidebar {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-sidebar h3 {
    align-self: flex-start;
    /* Align title to left like image */
    margin-bottom: 24px;
}

/* Circular Progress */
.circular-progress-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 24px;
}

.circular-progress {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--accent-color) calc(var(--percent) * 1%), #efeaff 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.circular-progress::before {
    content: '';
    position: absolute;
    width: 120px;
    /* Inner circle size */
    height: 120px;
    background: white;
    border-radius: 50%;
}

.progress-value {
    position: relative;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    z-index: 10;
}



.upsell-text {
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 30px;
    text-align: left;
    font-weight: 500;
}

.full-width-btn {
    width: 100%;
    font-weight: 700;
    font-size: 16px;
}

@media (max-width: 900px) {

    /* Stack results on mobile */
    .result-sidebar {
        order: -1;
        /* Show summary/upsell first? Or last? */
    }
}

.feedback-message {
    margin-top: 25px;
    padding: 20px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out;
    display: none;
}

.feedback-message.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.feedback-message.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.quiz-footer {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
}


/* Result Screen */
.result-screen {
    text-align: center;
    padding: 60px 40px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 25px auto;
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-color);
}

.score-circle .total {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 5px;
}

#result-message {
    font-size: 19px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.restart-btn {
    width: 100%;
    max-width: 250px;
}

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

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

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* --- New Header Design --- */
.header-content-new {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
}

.progress-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.u-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.score-big {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.q-total {
    color: #9ca3af;
    font-weight: 500;
    font-size: 24px;
}

.u-sublabel {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 8px;
}

/* Progress Bar Tweaks */
.progress-container {
    height: 8px;
    background: #f3f4f6;
    border-radius: 99px;
    margin-bottom: 5px;
}

.progress-bar {
    border-radius: 99px;
}

/* Big Toggle Button */
.correction-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: 2px solid var(--accent-color);
    background: white;
    border-radius: 99px;
    /* Pill shape */
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-top: 5px;
    color: #4b5563;
    /* Dark gray text */
}

/* Active State */
.correction-toggle-btn.active {
    background: #f5f3ff;
    /* Light violet tint */
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.correction-toggle-btn #toggle-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-weight: 700;
}

/* --- Layout & Sidebar --- */
.quiz-layout {
    display: flex;
    gap: 24px;
    width: 100%;
    align-items: flex-start;
}

/* Ensure inner cards take full width available */
.quiz-main {
    flex: 1;
    /* Takes remaining space */
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
    padding: 30px;
    position: sticky;
    top: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.sidebar h3 {
    margin-top: 0;
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Vertical List Mode (for small question sets, now 3-column grid, compact) */
.questions-grid.vertical {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    /* Fixed small size */
    gap: 10px;
    justify-content: center;
    /* Center the grid in the sidebar */
}

.questions-grid.vertical .grid-item {
    aspect-ratio: 1;
    /* Keep square */
    height: 50px;
    width: 50px;
    font-size: 16px;
    /* Slightly larger text */
    justify-content: center;
}

.sidebar-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-row.text-muted {
    opacity: 0.6;
    /* Dim the "Marked" row a bit if unused for now */
}

.stat-pill {
    padding: 4px 12px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 13px;
}

.stat-pill.blue {
    background-color: #22d3ee;
    /* Cyan/Blue */
    color: white;
}

/* Matching the user image which has a solid blue pill */
.stat-pill.blue {
    background-color: #2ab7ca;
    background: #0ea5e9;
    /* Tailwind Sky 500 */
}

.stat-pill.white {
    background-color: transparent;
    border: 1px solid #e5e7eb;
    color: var(--text-secondary);
}

/* Grid */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.grid-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 8px;
    /* Soft square */
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    border: none;
}

.grid-item:hover {
    background: #e5e7eb;
}

/* Active Question (Purple) */
.grid-item.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 6px rgba(124, 58, 237, 0.3);
}

/* Answered Question (Blue/Cyan) */
.grid-item.answered {
    background: #22d3ee;
    background: #0ea5e9;
    color: white;
}

/* If active AND answered? Usually Active overrides or modify style.
   In the user image, "3" is active (Purple). "1" and "2" are answered (Blue).
   So Active > Answered priority in styling.
*/

/* Mobile Stack */
@media (max-width: 900px) {
    .quiz-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        order: 2;
        /* Put sidebar below quiz on mobile? Or above? */
        /* User image implies it's a desktop view. On mobile, usually navigation is at bottom or hidden.
           Let's put it below for now. */
    }

    .questions-grid {
        grid-template-columns: repeat(8, 1fr);
        /* More columns on wide mobile width? */
    }
}

@media (max-width: 500px) {
    .questions-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* =========================================
   Login Overlay Styles
   ========================================= */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
    max-width: 450px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.login-card h1 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.login-card input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    transition: all 0.2s;
    outline: none;
}

.login-card input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.login-card button {
    width: 100%;
    background-color: var(--text-primary);
    color: white;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.login-card button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* PIN Display */
.pin-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 2rem;
    height: 20px;
}

.pin-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #e2e8f0;
    transition: background-color 0.2s;
}

.pin-dot.filled {
    background-color: var(--accent-color);
}

.pin-dot.error {
    background-color: #e11d48;
}

/* PIN Pad */
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 220px;
    margin: 0 auto;
}

.pin-btn {
    width: 100%;
    aspect-ratio: 1;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    /* Circle buttons */
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.pin-btn:active {
    background-color: #eef2ff;
    border-color: var(--accent-color);
    transform: scale(0.95);
}

.pin-btn.delete-btn {
    font-size: 1rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    aspect-ratio: auto;
    height: 100%;
    border-radius: 12px;
}

.pin-btn.delete-btn:hover {
    color: var(--error-text);
}