:root {
    /* Color Palette: Authoritative & Warm */
    --color-primary: #192a56; /* Deep Navy Blue */
    --color-secondary: #273c75; /* Slightly Lighter Blue */
    --color-accent: #fbc531; /* Bright Gold/Yellow */
    --color-text: #2c3e50; /* Dark Grey/Blue for body text */
    --color-light-text: #ecf0f1; /* Off-white for dark backgrounds */
    --color-bg-main: #f4f6f9; /* Light, subtle background */
    --color-bg-card: #ffffff;
    
    /* Typography */
    --font-heading: 'Merriweather', serif;
    --font-body: 'Roboto', sans-serif;
    
    /* Spacing & Effects */
    --border-radius-base: 10px;
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.12);
    --transition-speed: 0.3s ease;
}

/* Base Styles & Utilities */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg-main);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { 
    font-family: var(--font-heading); 
    color: var(--color-primary); 
    margin-bottom: 0.8rem; 
    line-height: 1.3;
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.8rem; }
.section-heading { 
    margin-top: 1.5rem; 
    border-bottom: 2px solid var(--color-accent); 
    padding-bottom: 0.3rem; 
}

a { 
    color: var(--color-primary); 
    text-decoration: none; 
    transition: color var(--transition-speed); 
}
a:hover { color: var(--color-accent); }

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 1.5rem; 
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-base);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-speed);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
}
.btn i { margin-right: 0.5rem; }
.btn-primary { 
    background: var(--color-accent); 
    color: var(--color-primary); 
}
.btn-primary:hover { 
    background: #ffc950; 
    box-shadow: var(--shadow-subtle); 
}
.btn-secondary { 
    background: var(--color-secondary); 
    color: var(--color-light-text); 
}
.btn-secondary:hover { 
    background: #3c518d; 
}
.btn-outline { 
    background: transparent; 
    color: var(--color-light-text); 
    border-color: var(--color-light-text); 
}
.btn-outline:hover { 
    background: rgba(255, 255, 255, 0.1); 
    color: var(--color-accent); 
    border-color: var(--color-accent); 
}
.btn-accent { 
    background: var(--color-accent); 
    color: var(--color-primary); 
    font-weight: 600; 
}
.btn-accent:hover { 
    background: #ffc950; 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-subtle); 
}

.action-btn { 
    background: var(--color-secondary); 
    color: var(--color-light-text); 
    padding: 0.4rem 0.8rem; 
    border-radius: 6px; 
    border: none; 
    cursor: pointer; 
    transition: background var(--transition-speed); 
    display: inline-flex; 
    align-items: center;
    font-family: inherit;
}
.action-btn:hover { 
    background: var(--color-accent); 
    color: var(--color-primary); 
}
.btn-load-more { 
    background: var(--color-secondary); 
    color: var(--color-light-text); 
    margin: 1.5rem auto; 
    display: block; 
    width: fit-content; 
}
.btn-load-more:hover { 
    background: var(--color-primary); 
}

/* Enhanced focus styles for accessibility */
.btn:focus,
.action-btn:focus,
.quiz-option:focus,
.modal-close-btn:focus,
.date-picker-input:focus {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Header */
.site-header {
    background: var(--color-primary);
    color: var(--color-light-text);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: var(--shadow-subtle);
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}
.logo { 
    display: flex; 
    align-items: center; 
    font-family: var(--font-heading); 
    font-size: 1.5rem; 
    color: var(--color-light-text); 
    z-index: 502;
}
.logo-icon { 
    font-size: 1.8rem; 
    margin-right: 0.5rem; 
    color: var(--color-accent); 
}
.main-nav .nav-links { 
    display: flex; 
    list-style: none; 
}
.main-nav .nav-item { 
    margin: 0 0.8rem; 
    padding: 0.5rem 0; 
    color: var(--color-light-text); 
    transition: color var(--transition-speed); 
}
.main-nav .nav-item:hover { 
    color: var(--color-accent); 
}
.user-actions { 
    display: flex; 
    align-items: center; 
    gap: 1rem; 
}
.mobile-menu-toggle { 
    display: none; 
    background: transparent; 
    border: none; 
    color: var(--color-light-text); 
    font-size: 1.5rem; 
    cursor: pointer; 
    z-index: 502;
    padding: 0.5rem;
    position: relative;
}

/* ==================== OPTIMIZED HERO SECTION ==================== */

/* Date Hero Section - Compact and Efficient */
.date-hero {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
    color: var(--color-light-text);
    padding: 1.2rem 0;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.date-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,100 Z" fill="rgba(255,255,255,0.05)"/></svg>');
    background-size: cover;
}

.hero-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
    position: relative;
    z-index: 1;
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.hero-title {
    color: var(--color-light-text);
    font-size: 1.8rem;
    margin-bottom: 0;
    line-height: 1.2;
}

.current-date-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-accent);
    opacity: 0.95;
    margin-bottom: 0.5rem;
}

.hero-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.date-picker-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-picker-label {
    font-size: 0.9rem;
    white-space: nowrap;
}

.date-input-wrapper {
    position: relative;
    display: inline-block;
}

.date-input-wrapper i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
}

/* FIXED: Date picker input with proper width for full year visibility */
.date-picker-input {
    padding: 0.5rem 2.5rem 0.5rem 0.8rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-body);
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.9);
    width: 160px; /* Increased width to show full year */
    min-width: 160px;
}

.date-picker-input::-webkit-calendar-picker-indicator {
    opacity: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Ensure date input shows full year on all devices */
.date-picker-input::-webkit-datetime-edit-year-field:not(:-webkit-datetime-edit-century-field) {
    color: var(--color-text);
    min-width: 2.8em; /* Ensure year field has enough space */
}

.date-picker-input::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
    display: flex;
    gap: 2px;
}

.quiz-link-container {
    margin: 0;
}

.quiz-link-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Stats Counter Group - Compact Layout */
.stats-counter-group {
    display: flex;
    gap: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: var(--border-radius-base);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 70px;
}

.stat-content {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-icon {
    font-size: 1.1rem;
    color: var(--color-accent);
}

.stat-count {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    text-align: center;
}

/* Main Content and Tabs */
.main-content { 
    flex-grow: 1; 
    padding-bottom: 3rem; 
}

.tabs-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
    border-bottom: 2px solid #ddd;
}
.tab-btn {
    background: transparent;
    color: var(--color-text);
    border: none;
    padding: 0.6rem 1rem;
    border-radius: var(--border-radius-base);
    cursor: pointer;
    transition: all var(--transition-speed);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    font-family: inherit;
}
.tab-btn i { margin-right: 0.5rem; }
.tab-btn.active {
    background: var(--color-primary);
    color: var(--color-light-text);
    border-color: var(--color-accent);
}
.tab-btn:hover:not(.active) {
    background: #e0e0e0;
}

/* Tab Content Wrapper to prevent bleed/overlap */
.tab-content-wrapper {
    overflow: hidden; 
}

/* CRITICAL FIX: Tab Panel Display Rules - FIXED */
.tab-panel { 
    display: none; 
    padding: 1rem 0; 
    position: relative;
    overflow: hidden;
}
.tab-panel.active { 
    display: block; 
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Timeline (The core display for events) */
.timeline-container {
    position: relative;
    padding-left: 30px;
    margin-left: 1rem;
}
.timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 8px;
    width: 2px;
    background: var(--color-accent);
}
.timeline-event {
    background: var(--color-bg-card);
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-subtle);
    margin-bottom: 2rem;
    padding: 1.5rem;
    position: relative;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}
.timeline-event:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}
.timeline-event::before {
    content: '';
    position: absolute;
    left: -37px;
    top: 25px;
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border: 3px solid var(--color-accent);
    border-radius: 50%;
    z-index: 10;
}
.timeline-event .year {
    display: block;
    font-weight: 700;
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px dashed #eee;
    padding-bottom: 0.3rem;
}
.timeline-event p { margin-bottom: 0; }

/* Cards Grid (for Births/Deaths & Culture Books) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}
.card {
    background: var(--color-bg-card);
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-subtle);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}
.card:hover { 
    transform: translateY(-3px); 
    box-shadow: var(--shadow-hover); 
}

.card-img-container {
    height: 200px;
    overflow: hidden;
    background: #e6e9ed;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}
.card-img-placeholder { 
    font-size: 3.5rem; 
    color: #a9b7c8; 
    display: flex; 
    align-items:center; 
    justify-content:center; 
    height:100%; 
}

/* Specific Card adjustments for People */
#births-container .card-img, 
#deaths-container .card-img { 
    object-position: top center; 
}

/* Specific Card adjustments for Culture Books */
.card-book .card-img { 
    object-fit: contain; 
    padding: 10px; 
}
.card-book .book-author { 
    font-size: 0.9rem; 
    color: #666; 
}

.card-content { 
    padding: 1rem; 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
}
.card-content p { margin-bottom: 0.5rem; }
.card-actions { 
    display: flex; 
    justify-content: flex-end; 
    gap: 0.5rem; 
    margin-top: 0.5rem; 
}

/* APOD Section */
.apod-section {
    display: flex;
    gap: 2rem;
    margin-bottom: 2.5rem;
    align-items: flex-start;
    background: var(--color-bg-card);
    padding: 1.5rem;
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-subtle);
}
.apod-image-container { 
    flex: 1; 
    max-width: 40%; 
    position: relative;
}
.apod-image-container img { 
    width: 100%; 
    height: auto; 
    border-radius: 8px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
}
.apod-text-container { flex: 2; }
.error-msg { 
    color: #cc0000; 
    font-weight: bold; 
    padding: 1rem; 
    background: #ffe0e0; 
    border-radius: var(--border-radius-base); 
}

/* APOD Share Button Styles */
.apod-actions {
    margin-top: 1rem;
    text-align: center;
    padding: 1rem 0;
}

.share-btn-apod {
    background: var(--color-secondary);
    color: var(--color-light-text);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: var(--border-radius-base);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    box-shadow: var(--shadow-subtle);
    font-family: inherit;
}

.share-btn-apod:hover {
    background: var(--color-accent);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Ensure APOD container has proper spacing */
.apod-image-container {
    position: relative;
    margin-bottom: 1rem;
}

/* Make sure the share button is visible and properly styled */
.action-btn.share-btn-apod {
    margin: 0.5rem auto;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Footer */
.site-footer {
    background: var(--color-primary);
    color: var(--color-light-text);
    padding: 1.5rem 0;
    margin-top: auto;
}
.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}
.footer-links a { 
    color: var(--color-light-text); 
    margin-right: 1rem; 
}
.footer-links a:hover { 
    color: var(--color-accent); 
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal.is-visible { 
    display: flex; 
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

.modal-dialog {
    background: var(--color-bg-card);
    padding: 2.5rem;
    border-radius: var(--border-radius-base);
    max-width: 550px;
    width: 90%;
    position: relative;
    z-index: 10001;
    transform: scale(0.95);
    transition: transform 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}
.modal.is-visible .modal-dialog { transform: scale(1); }

.modal-small {
    max-width: 400px;
}

.modal-title { 
    margin-bottom: 1.5rem; 
    border-bottom: 2px solid var(--color-accent); 
    padding-bottom: 0.5rem; 
}
.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--color-text);
    z-index: 10002;
    padding: 0.5rem;
    line-height: 1;
}
.modal-close-btn:hover {
    color: var(--color-accent);
}

.auth-form .form-group { margin-bottom: 1rem; }
.auth-form label { 
    display: block; 
    margin-bottom: 0.4rem; 
    font-weight: 500; 
}
.auth-form input { 
    width: 100%; 
    padding: 0.75rem; 
    border: 1px solid #ccc; 
    border-radius: 5px; 
    font-size: 1rem; 
    font-family: inherit;
}
.form-submit { width: 100%; margin-top: 1.5rem; }

/* Share Modal specific */
.share-options { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem; 
    margin-top: 1.5rem; 
}
.share-btn-icon {
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: var(--border-radius-base);
    color: var(--color-light-text);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}
.share-btn-icon:hover { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-subtle); 
    text-decoration: none;
    color: var(--color-light-text);
}
.share-btn-icon.facebook { background: #3b5998; }
.share-btn-icon.twitter { background: #1da1f2; }
.share-btn-icon.linkedin { background: #0077b5; }
.share-btn-icon.whatsapp { background: #25d366; }

/* ==================== QUIZ PAGE STYLES ==================== */

/* Quiz Page Specific Styles */
.page-hero {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
}

.page-title-container {
    max-width: 800px;
    margin: 0 auto;
}

.page-title {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.page-subtitle {
    font-size: 1.2rem;
    color: var(--color-text);
    opacity: 0.8;
    line-height: 1.6;
}

/* Quiz Card */
.quiz-card {
    background: var(--color-bg-card);
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-subtle);
    overflow: hidden;
    margin-bottom: 3rem;
    transition: var(--transition-speed);
    position: relative;
}

.quiz-card:hover {
    box-shadow: var(--shadow-hover);
}

.quiz-header {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
    color: var(--color-light-text);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

.score-icon {
    color: var(--color-accent);
    font-size: 1.5rem;
}

.quiz-progress {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-base);
    font-weight: 500;
}

.quiz-content {
    padding: 2rem;
}

.quiz-question-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.question-icon {
    background: var(--color-accent);
    color: var(--color-primary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.quiz-question {
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--color-primary);
    font-weight: 500;
    flex: 1;
}

/* Quiz Options */
.quiz-options {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.quiz-option {
    background: var(--color-bg-main);
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius-base);
    padding: 1.2rem 1.5rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: left;
    font-family: inherit;
}

.quiz-option:hover {
    border-color: var(--color-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
}

.quiz-option.selected {
    border-color: var(--color-accent);
    background: rgba(251, 197, 49, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
}

.quiz-option:focus {
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 0 0 3px rgba(251, 197, 49, 0.3);
}

/* Quiz Actions */
.quiz-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.quiz-submit, .quiz-next {
    min-width: 180px;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
}

.quiz-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.quiz-submit:disabled:hover {
    background: var(--color-accent);
    transform: none;
}

/* Quiz Result */
.quiz-result {
    padding: 1.5rem;
    border-radius: var(--border-radius-base);
    margin-top: 1rem;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
    animation: fadeIn 0.5s ease-in-out;
}

.quiz-result.correct {
    background: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.quiz-result.incorrect {
    background: rgba(244, 67, 54, 0.1);
    color: #c62828;
    border: 1px solid #f44336;
}

/* Quiz Info Section */
.quiz-info {
    margin-top: 3rem;
}

.info-card {
    background: var(--color-bg-card);
    border-radius: var(--border-radius-base);
    box-shadow: var(--shadow-subtle);
    padding: 2rem;
    border-left: 4px solid var(--color-accent);
}

.info-card h3 {
    color: var(--color-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
}

.info-card li:before {
    content: "•";
    color: var(--color-accent);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Animation for correct/incorrect answers */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.quiz-option.correct-answer {
    animation: pulse 0.5s ease-in-out;
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

.quiz-option.wrong-answer {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

/* Animation for stats update */
@keyframes pulse-grow {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.stat-count.updated {
    animation: pulse-grow 0.3s ease-in-out;
}

/* Quiz Invitation Styles */
.invite-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.copy-link-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    align-items: center;
}

.link-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-base);
    font-size: 0.9rem;
    background: #f9f9f9;
    font-family: inherit;
}

#copy-quiz-link {
    white-space: nowrap;
}

/* Enhanced loading states for better UX */
.quiz-question:empty::before {
    content: "Loading historical question...";
    color: #666;
    font-style: italic;
}

.quiz-options:empty::before {
    content: "Loading answer options...";
    display: block;
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Improved result announcement for screen readers */
.quiz-result[aria-live="polite"] {
    position: relative;
}

.quiz-result.correct::before,
.quiz-result.incorrect::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.quiz-result.correct::before {
    background: #4CAF50;
}

.quiz-result.incorrect::before {
    background: #f44336;
}

/* ==================== RESPONSIVE ADJUSTMENTS ==================== */

@media (max-width: 992px) {
    /* Tablet & Smaller Desktop */
    .main-nav { 
        display: none; 
        position: fixed; /* Changed from absolute to fixed */
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--color-primary);
        padding: 1rem 0;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        z-index: 501; /* Increased z-index */
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .main-nav.active {
        display: block;
    }
    
    .main-nav .nav-links {
        flex-direction: column;
        align-items: center;
    }
    
    .main-nav .nav-item {
        margin: 0.5rem 0;
        padding: 0.8rem 1.5rem;
        width: 100%;
        text-align: center;
        font-size: 1.1rem;
    }
    
    .mobile-menu-toggle { 
        display: block; 
    }
    .header-content { 
        padding-right: 0.5rem; 
        position: relative; 
    }
    .user-actions { 
        gap: 0.5rem; 
    }
    .logo-text { 
        font-size: 1.3rem; 
    }
    
    /* Hero Section Tablet */
    .hero-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }
    
    .hero-content {
        align-items: center;
        text-align: center;
    }
    
    .hero-title {
        font-size: 1.6rem;
    }
    
    .current-date-display {
        font-size: 1rem;
    }
    
    .hero-controls {
        justify-content: center;
    }
    
    .stats-counter-group {
        justify-content: center;
        padding: 0.8rem;
        gap: 1.2rem;
    }
    
    .stat-item {
        min-width: 60px;
    }
    
    .stat-count {
        font-size: 1.2rem;
    }

    .apod-section { flex-direction: column; }
    .apod-image-container { max-width: 100%; }
    
    .share-options {
        grid-template-columns: 1fr;
    }
    
    /* Quiz Page Responsive */
    .page-title {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .page-subtitle {
        font-size: 1.1rem;
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .quiz-question-container {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .question-icon {
        align-self: center;
    }
    
    .copy-link-container {
        flex-direction: column;
    }
    
    .link-input {
        width: 100%;
    }
}

@media (max-width: 768px) {
    /* Mobile */
    .container { 
        padding: 0 1rem; 
    }
    .site-header { 
        padding: 0.7rem 0; 
    }
    .logo { 
        font-size: 1.3rem; 
    }
    .user-actions { 
        display: flex; 
    } 
    .mobile-menu-toggle { 
        font-size: 1.2rem; 
    }

    /* FIXED: Mobile menu improvements */
    .main-nav {
        top: 100%;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--color-primary);
        z-index: 501;
        padding: 2rem 0;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }
    
    .main-nav .nav-item {
        padding: 1rem 1.5rem;
        margin: 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .main-nav .nav-item:last-child {
        border-bottom: none;
    }

    /* Hero Section Mobile */
    .date-hero {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .hero-container {
        gap: 1rem;
    }
    
    .hero-title {
        font-size: 1.4rem;
    }
    
    .current-date-display {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
    
    .hero-controls {
        flex-direction: column;
        gap: 0.8rem;
        align-items: center;
    }
    
    .date-picker-group {
        flex-direction: column;
        gap: 0.3rem;
        align-items: center;
        text-align: center;
    }
    
    .date-picker-label {
        font-size: 0.8rem;
    }
    
    .date-picker-input {
        width: 140px; /* Adjusted for mobile */
        padding: 0.5rem 2rem 0.5rem 0.8rem;
    }
    
    .stats-counter-group {
        gap: 1rem;
        padding: 0.7rem;
        justify-content: space-around;
    }
    
    .stat-item {
        min-width: 55px;
        gap: 0.2rem;
    }
    
    .stat-icon {
        font-size: 1rem;
    }
    
    .stat-count {
        font-size: 1.1rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .quiz-link-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .timeline-container { 
        padding-left: 20px; 
        margin-left: 0.5rem; 
    }
    .timeline-container::before { 
        left: 8px; 
    }
    .timeline-event::before { 
        left: -27px; 
        width: 10px; 
        height: 10px; 
    }

    .cards-grid { 
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
    }
    .card-img-container { 
        height: 150px; 
    }
    .card-content p { 
        font-size: 0.9rem; 
    }
    
    .footer-content { 
        flex-direction: column; 
        text-align: center; 
        gap: 0.8rem; 
    }
    .footer-links a { 
        margin: 0 0.5rem; 
    }
    
    .modal-dialog {
        padding: 1.5rem;
        margin: 1rem;
    }

    /* Quiz Page Mobile Responsive */
    .quiz-options {
        grid-template-columns: 1fr;
    }
    
    .quiz-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .quiz-submit, .quiz-next {
        width: 100%;
        max-width: 300px;
    }
    
    .info-card {
        padding: 1.5rem;
    }
    
    .quiz-header {
        padding: 1rem;
    }
    
    .quiz-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .date-hero {
        padding: 0.8rem 0;
    }
    
    .hero-title {
        font-size: 1.3rem;
    }
    
    .stats-counter-group {
        gap: 0.8rem;
        padding: 0.6rem;
    }
    
    .stat-item {
        min-width: 50px;
    }
    
    .stat-count {
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    /* FIXED: Date picker for very small screens */
    .date-picker-input {
        width: 140px;
        padding: 0.4rem 1.8rem 0.4rem 0.7rem;
        font-size: 0.85rem;
    }
    
    .date-input-wrapper i {
        right: 8px;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .quiz-question {
        font-size: 1.1rem;
    }
    
    .quiz-option {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* FIXED: Mobile menu for very small screens */
    .main-nav {
        padding: 1rem 0;
    }
    
    .main-nav .nav-item {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
    
    .mobile-menu-toggle {
        padding: 0.3rem;
    }
}

/* Very small screen fixes */
@media (max-width: 360px) {
    .date-picker-input {
        width: 130px;
        font-size: 0.8rem;
    }
    
    .hero-controls {
        gap: 0.5rem;
    }
    
    .stats-counter-group {
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .stat-item {
        min-width: 45px;
    }
    
    .main-nav .nav-item {
        padding: 0.7rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .user-actions,
    .mobile-menu-toggle,
    .quiz-actions,
    .action-btn,
    .btn {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .quiz-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
}