:root {
    --bg-color: #0a0a0c;
    --card-bg: #16161a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0ab;
    --accent-color: #3b82f6;
    --font-main: 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

header {
    padding: 2rem 1rem;
    text-align: center;
    background: linear-gradient(to bottom, rgba(59, 130, 246, 0.1), transparent);
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.05em;
    background: linear-gradient(to right, #fff, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.card {
    background-color: var(--card-bg);
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-10px);
    border-color: var(--accent-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.2);
}

.image-container {
    width: 100%;
    height: 250px;
    overflow: hidden;
    position: relative;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.card:hover .image-container img {
    transform: scale(1.1);
}

.card-content {
    padding: 1.5rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 0.5rem;
}

.card-info span {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

/* ... existing ... */

.quiz-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.meta-item {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.meta-item .label {
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 60%);
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
    pointer-events: none;
}

.card:hover .overlay {
    opacity: 1;
}

footer {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 4rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    .gallery {
        grid-template-columns: 1fr;
    }
}

/* Shared Utilities & Nav */
.hidden {
    display: none !important;
}

.nav-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.8rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
}

.btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-color);
}

.btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 1.5rem auto 0;
    padding: 0 2rem;
    gap: 1rem;
    flex-wrap: wrap;
    transition: var(--transition);
}

.controls-bar.hidden {
    display: none;
}

.sort-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sort-dropdown {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.6rem 1rem;
    border-radius: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.sort-dropdown:hover,
.sort-dropdown:focus {
    border-color: var(--accent-color);
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border-radius: 2rem;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

@media (max-width: 768px) {
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        max-width: none;
    }
}

/* Back Button (Top Left) */
.back-btn {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 100;
    background: rgba(22, 22, 26, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    opacity: 1;
    pointer-events: auto;
}

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

.back-btn:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

/* Header Collapsing */
.header-transition {
    transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.5s ease;
    max-height: 500px;
    /* arbitrary large max-height */
    overflow: hidden;
    opacity: 1;
}

.header-transition.collapsed {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

/* View Fading */
.fade-view {
    transition: opacity 0.4s ease;
    opacity: 1;
}

.fade-view.hidden {
    display: none;
    opacity: 0;
}


/* Compact Quiz Styles */
.quiz-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
    /* Remove padding to let image bleed if wanted, but wrapper handles it */
    background: transparent;
    /* Remove card bg for cleaner look */
    border: none;
    /* Ensure it fits in viewport loosely */
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 2rem;
}

/* Quiz Image Wrapper (Centers the image) */
.quiz-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: auto;
    margin-bottom: 2rem;
    background: transparent;
    border: none;
    overflow: visible;
}

/* Hide Blur Layer (User requested clean look) */
.quiz-bg-layer {
    display: none;
}

/* Main Image - centered, auto width, direct border */
.quiz-image {
    height: 50vh;
    /* Taller to use space better */
    width: auto;
    /* Width shrinks to fit image */
    max-width: 100%;
    /* Prevent overflow */
    object-fit: contain;

    /* The outline user requested */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.8rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    /* Nice lift */

    background: transparent;
    margin: 0;
}

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

.option-btn {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 0.8rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    text-align: left;
    position: relative;
    outline: none;
    /* We manage focus visually */
}

/* Keyboard focus state */
.option-btn:focus,
.option-btn.focused {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.option-btn:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-color);
}

.option-btn.correct {
    background: rgba(34, 197, 94, 0.2) !important;
    border-color: #22c55e !important;
    color: #4ade80 !important;
}

.option-btn.incorrect {
    background: rgba(239, 44, 44, 0.2) !important;
    border-color: #ef4444 !important;
    color: #f87171 !important;
}

/* Compact Feedback Section */
.info-box {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.05);
    border-left: 4px solid var(--accent-color);
    border-radius: 0.5rem;
    animation: fadeIn 0.5s ease-out;
    flex-grow: 1;
    overflow-y: auto;
}

.info-box h3 {
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    font-size: 1.2rem;
}



.quiz-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.score-display {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Helper for keyboard hints */
.key-hint {
    font-size: 0.7em;
    opacity: 0.5;
    float: right;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0px 4px;
    border-radius: 4px;
}

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

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

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2rem;
    }

    header {
        padding: 2rem 1rem;
    }

    .quiz-container {
        padding: 1rem;
        max-height: none;
    }

    .quiz-image {
        height: 250px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}