:root {
    --bg-color: #FAFAF7;
    /* Off-white warm background */
    --surface: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --brand-primary: #C25E20;
    /* Terracotta / burnt orange */
    --brand-primary-hover: #A04A15;
    --accent: #E5DBCE;
    /* Tan/beige for inactive states */
    --correct: #10B981;
    --incorrect: #EF4444;
    --border-color: #EFEBE4;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 20px 40px -10px rgba(0, 0, 0, 0.06);
    --radius-lg: 24px;
    --radius-md: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* TOP NAV (Desktop priority, fixed to top) */
.top-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.nav-container .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav-logo-img {
    height: 75px;
    /* Greatly increased because the image itself has a lot of white space around the logo */
    width: auto;
    object-fit: contain;
    margin: -20px 0;
    /* Negative margin so it doesn't push the nav bar height too much */
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.mobile-menu-btn {
    display: none;
    /* Hidden on desktop */
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--brand-primary);
}

/* MAIN CONTAINER (Centered, max-width for desktop) */
.game-container {
    max-width: 800px;
    margin: 4rem auto;
    padding: 0 2rem;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* HEADER: PROGRESS */
.game-header {
    margin-bottom: 2rem;
    position: relative;
    /* Anchor for the absolute timer */
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--brand-primary);
    text-transform: uppercase;
}

.progress-info span {
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-bar-bg {
    height: 8px;
    background-color: var(--accent);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--brand-primary);
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.1, 0.7, 0.1, 1);
}

/* QUOTE CARD */
.quote-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 4rem 3rem 3rem 3rem;
    position: relative;
    text-align: center;
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
}

.shadow-glass {
    box-shadow: var(--shadow-glass);
}

.quote-icon {
    position: absolute;
    top: -20px;
    left: 40px;
    background: var(--accent);
    color: var(--brand-primary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid var(--bg-color);
}

.quote-icon svg {
    width: 24px;
    height: 24px;
}

.quote-content p {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    line-height: 1.4;
    color: var(--text-primary);
    font-style: italic;
    font-weight: 400;
}

.quote-divider {
    width: 100px;
    height: 3px;
    background-color: var(--accent);
    margin: 3rem auto 0 auto;
    border-radius: 2px;
}

/* OPTIONS GRID */
.instruction-text {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--brand-primary);
    margin-bottom: 1.5rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns on desktop */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.option-btn {
    background: var(--surface);
    border: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

@media (hover: hover) {
    .option-btn:hover:not(:disabled) {
        transform: translateY(-2px);
        border-color: var(--brand-primary);
        box-shadow: var(--shadow-md);
    }
}

/* STATE CLASSES (Added by JS) */
.option-btn.correct {
    background-color: var(--correct);
    color: white;
    border-color: var(--correct);
}

.option-btn.incorrect {
    background-color: var(--incorrect);
    color: white;
    border-color: var(--incorrect);
}

.option-btn:disabled {
    cursor: default;
    opacity: 0.6;
}

.option-btn.correct:disabled,
.option-btn.incorrect:disabled {
    opacity: 1;
    /* Keep fully visible even when disabled if it was the selected answer */
}

/* FEEDBACK & NEXT BUTTON */
.feedback-area {
    text-align: center;
    animation: fadeIn 0.4s ease;
    margin-bottom: 4rem;
}

.feedback-message {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.feedback-success {
    color: var(--correct);
}

.feedback-error {
    color: var(--incorrect);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(194, 94, 32, 0.2);
}

.btn-large {
    padding: 1rem 3rem;
    font-size: 1.1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.end-screen {
    text-align: center;
    background: var(--surface);
    padding: 4rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

.end-screen h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--brand-primary);
}

.end-screen p {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

#final-score {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.5rem;
}

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

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

/* RESPONSIVE DESIGN (For mobile fallback) */
@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: 1fr;
        /* 1 column on mobile */
        gap: 0.75rem;
    }

    .quote-card {
        padding: 2.5rem 1.25rem 1.5rem 1.25rem;
        /* Reduced padding */
        margin-bottom: 2rem;
    }

    .quote-content p {
        font-size: 1.25rem;
        /* Smaller font for long quotes */
    }

    .nav-links span {
        display: none;
        /* Hide text on mobile nav, only icons */
    }

    .nav-links {
        gap: 1.5rem;
    }

    .option-btn {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }
}

/* BUTTON VARIANTS */
.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--brand-primary);
    color: var(--brand-primary);
}

.btn-outline-primary:hover {
    background: var(--brand-primary);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    height: fit-content;
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    padding: 0.5rem;
    position: relative;
    z-index: 1050;
    /* Ensure clickable */
    pointer-events: auto;
}

.btn-logout:hover {
    color: var(--incorrect);
}

.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

/* MODAL OVERLAY */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 41, 55, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 0;
    width: 100%;
    max-width: 640px;
    min-height: 400px;
    position: relative;
    box-shadow: var(--shadow-glass);
    color: var(--text-primary);
    display: flex;
    overflow: hidden;
}

.modal-image-panel {
    display: none;
    background-color: transparent;
    background-image: url('login-logo.png');
    background-size: 85%;
    background-repeat: no-repeat;
    background-position: center;
    border-right: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .modal-image-panel {
        display: block;
        flex: 1.1;
    }
}

.modal-form-panel {
    flex: 1;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-content h2 {
    font-family: 'Playfair Display', serif;
    color: var(--brand-primary);
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2.2rem;
}

.close-modal {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.close-modal:hover {
    color: var(--incorrect);
    background: var(--bg-color);
}

/* FORMS */
.form-group {
    margin-bottom: 1.25rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(194, 94, 32, 0.1);
}

.auth-switch {
    color: var(--text-secondary);
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-switch a {
    text-decoration: none;
    font-weight: 600;
    color: var(--brand-primary);
    transition: color 0.2s ease;
}

.auth-switch a:hover {
    text-decoration: underline;
    color: var(--brand-primary-hover);
}

/* RESPONSIVE STYLES */
@media (max-width: 768px) {
    .top-nav {
        position: relative;
        /* Removes sticky so it scrolls out of the way */
    }

    .nav-container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1rem;
        position: relative;
        /* Context for absolute dropdown */
    }

    .mobile-menu-btn {
        display: block;
        /* Show hamburger on mobile */
    }

    .nav-links {
        display: none;
        /* Hidden by default */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        z-index: 99;
    }

    .nav-links.active {
        display: flex !important;
        /* Show dropdown when toggle is clicked */
    }

    .nav-links a,
    .nav-links button {
        margin: 0.25rem 0;
        padding: 0.75rem;
        width: 100%;
        justify-content: flex-start;
        text-align: left;
    }

    .nav-user {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 0;
        border-top: 1px solid var(--border-color);
    }

    .btn-logout {
        margin-top: 0.5rem;
    }

    .nav-logo-img {
        height: 55px;
        /* Slightly smaller to save space */
        margin: -10px 0;
    }

    .nav-container .logo {
        font-size: 1.1rem;
    }

    .difficulty-selector {
        display: none !important;
    }

    .hidden-option {
        display: none !important;
    }

    .game-container {
        margin: 1rem auto;
        /* Less margin on mobile */
        padding: 0 1rem 3rem 1rem;
        /* Prevent overlap with mobile bottom bar */
    }
}

/* FLOATING TIMER */
#timer-display {
    position: absolute;
    top: -20px;
    /* Aligns with the game header instead of the screen */
    right: 0;
    background: rgba(255, 255, 255, 0.65);
    color: var(--brand-primary);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 1.5rem;
    font-weight: bold;
    display: none;
    /* hidden by default, shown by JS */
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass through */
    border: 1px solid rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    #timer-display {
        top: 1.5rem;
        right: 1.5rem;
        font-size: 1.25rem;
        padding: 0.4rem 0.8rem;
    }
}