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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, #D4AF7A 0%, #E6C891 50%, #F5E6A8 100%);
    min-height: 100vh;
    color: #5D4E37;
    line-height: 1.6;
    position: relative;
}

/* Subtle papyrus texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, transparent 20%, rgba(139, 115, 85, 0.05) 21%, rgba(139, 115, 85, 0.05) 34%, transparent 35%, transparent),
        linear-gradient(0deg, transparent 24%, rgba(139, 115, 85, 0.05) 25%, rgba(139, 115, 85, 0.05) 26%, transparent 27%, transparent 74%, rgba(139, 115, 85, 0.05) 75%, rgba(139, 115, 85, 0.05) 76%, transparent 77%, transparent);
    z-index: -1;
    pointer-events: none;
}

/* Header Styles */
.header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, rgba(212, 175, 122, 0.95), rgba(139, 115, 85, 0.9));
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    border-bottom: 3px solid #8B7355;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.title {
    font-family: 'Cinzel', serif;
    font-size: 4em;
    color: #F5F5DC;
    text-shadow: 3px 3px 8px rgba(93, 78, 55, 0.6);
    margin-bottom: 15px;
    font-weight: 700;
    letter-spacing: 3px;
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: 1.4em;
    color: #F5F5DC;
    font-weight: 400;
    margin-bottom: 30px;
    text-shadow: 1px 1px 3px rgba(93, 78, 55, 0.4);
    font-style: italic;
    position: relative;
    z-index: 1;
}

/* Navigation Tabs */
.navigation-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 25px;
    position: relative;
    z-index: 1;
}

.tab-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(245, 245, 220, 0.9), rgba(255, 248, 220, 0.95));
    border: 2px solid #8B7355;
    border-radius: 30px;
    color: #5D4E37;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s ease;
    font-size: 0.95em;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tab-btn:hover {
    background: linear-gradient(135deg, #FFD700, #FFF8DC);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
    border-color: #B8860B;
}

.tab-btn.active {
    background: linear-gradient(135deg, #FFD700, #FFF8DC);
    border-color: #B8860B;
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.5);
    color: #8B4513;
}

/* Main Guide Container */
.guide-container {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 25px;
}

/* Pattern Sections */
.pattern-section {
    background: linear-gradient(135deg, rgba(245, 245, 220, 0.95), rgba(255, 248, 220, 0.9));
    border-radius: 20px;
    margin-bottom: 40px;
    padding: 40px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(212, 175, 122, 0.3);
    position: relative;
}

.pattern-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, #D4AF7A, #FFD700, #D4AF7A, transparent);
    border-radius: 20px 20px 0 0;
}

.section-title {
    font-family: 'Cinzel', serif;
    font-size: 2.5em;
    color: #8B4513;
    text-align: center;
    margin-bottom: 35px;
    font-weight: 600;
    letter-spacing: 2px;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #D4AF7A, transparent);
    border-radius: 2px;
}

/* Character Grids */
.character-grid {
    display: grid;
    gap: 25px;
    justify-items: center;
}

.patriarchs-grid, .matriarchs-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    max-width: 1200px;
    margin: 0 auto;
}

.prophets-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    max-width: 1400px;
    margin: 0 auto;
}

.apostles-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    max-width: 1200px;
    margin: 0 auto;
}

.family-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    max-width: 900px;
    margin: 0 auto;
}

.wisdom-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    max-width: 1200px;
    margin: 0 auto;
}

/* Character Items */
.character-item {
    background: linear-gradient(135deg, rgba(245, 245, 220, 0.9), rgba(255, 255, 255, 0.85));
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.4s ease;
    text-align: center;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    border: 2px solid rgba(212, 175, 122, 0.3);
}

.character-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.05) 0%, transparent 70%);
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.character-item:hover::before {
    opacity: 1;
}

.character-item:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 20px 45px rgba(212, 175, 122, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 248, 220, 0.9));
    border-color: #D4AF7A;
}

.character-image {
    width: 110px;
    height: 110px;
    object-fit: contain;
    margin: 0 auto 15px;
    border-radius: 12px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: all 0.4s ease;
    display: block;
    background-color: rgba(245, 245, 220, 0.3);
    border: 2px solid rgba(212, 175, 122, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.character-image.loading {
    background: linear-gradient(90deg, rgba(245, 245, 220, 0.5) 25%, rgba(212, 175, 122, 0.3) 50%, rgba(245, 245, 220, 0.5) 75%);
    background-size: 200% 100%;
    animation: holyLoading 1.8s infinite;
    opacity: 0.7;
}

.character-image[src=""], .character-image:not([src]) {
    background: linear-gradient(90deg, rgba(245, 245, 220, 0.5) 25%, rgba(212, 175, 122, 0.3) 50%, rgba(245, 245, 220, 0.5) 75%);
    background-size: 200% 100%;
    animation: holyLoading 1.8s infinite;
    opacity: 0.7;
}

.character-label {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: #8B4513;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: auto;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    border-top: 1px solid rgba(212, 175, 122, 0.3);
    padding-top: 12px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(93, 78, 55, 0.8);
    opacity: 0;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(8px);
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background: linear-gradient(135deg, rgba(245, 245, 220, 0.98), rgba(255, 248, 220, 0.95));
    margin: 2% auto;
    padding: 0;
    border-radius: 20px;
    width: 92%;
    max-width: 900px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    transform: translateY(-50px);
    transition: transform 0.4s ease;
    position: relative;
    border: 3px solid #D4AF7A;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: #8B4513;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 248, 220, 0.8));
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid #D4AF7A;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.close:hover {
    background: linear-gradient(135deg, #FFD700, #FFF8DC);
    transform: scale(1.1) rotate(90deg);
    border-color: #B8860B;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 35px;
    padding: 40px;
}

.modal-image {
    text-align: center;
    padding: 20px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
    border-radius: 15px;
}

.large-character-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    image-rendering: pixelated;
    border: 3px solid #D4AF7A;
}

.modal-info h3 {
    font-family: 'Cinzel', serif;
    font-size: 2.5em;
    color: #8B4513;
    margin-bottom: 25px;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    text-align: center;
}

.modal-info h4 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: #8B4513;
    margin: 25px 0 12px 0;
    font-size: 1.2em;
    border-bottom: 2px solid #D4AF7A;
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.modal-info p {
    color: #5D4E37;
    line-height: 1.7;
    margin-bottom: 20px;
    font-size: 1.05em;
    text-align: justify;
}

.scripture-reference {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(212, 175, 122, 0.1));
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 5px solid #D4AF7A;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.scripture-reference p {
    font-style: italic;
    font-weight: 500;
    color: #8B4513;
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes slideInUp {
    from { 
        opacity: 0; 
        transform: translateY(40px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

@keyframes holyGlow {
    0% { 
        opacity: 0;
        transform: scale(0.8);
        text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.05);
        text-shadow: 2px 2px 15px rgba(255, 215, 0, 0.6);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1);
    }
}

@keyframes holyLoading {
    0% { 
        background-position: 200% 0; 
    }
    100% { 
        background-position: -200% 0; 
    }
}

/* Enhanced focus and accessibility */
.character-item:focus {
    outline: 3px solid #FFD700;
    outline-offset: 3px;
}

.tab-btn:focus {
    outline: 3px solid #F5F5DC;
    outline-offset: 3px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2.8em;
    }
    
    .subtitle {
        font-size: 1.2em;
    }

    .navigation-tabs {
        gap: 8px;
    }

    .tab-btn {
        padding: 10px 18px;
        font-size: 0.85em;
    }

    .character-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 20px;
    }

    .character-item {
        padding: 15px;
        min-height: 180px;
    }

    .character-image {
        width: 90px;
        height: 90px;
    }

    .character-label {
        font-size: 0.8em;
    }

    .modal-content {
        width: 96%;
        margin: 3% auto;
    }

    .modal-body {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 25px;
    }

    .modal-info h3 {
        font-size: 2em;
    }

    .section-title {
        font-size: 2em;
    }

    .pattern-section {
        padding: 25px;
        margin-bottom: 30px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 25px 15px;
    }

    .title {
        font-size: 2.2em;
        letter-spacing: 1px;
    }

    .navigation-tabs {
        justify-content: center;
    }

    .tab-btn {
        padding: 8px 14px;
        font-size: 0.75em;
    }

    .character-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }

    .character-image {
        width: 80px;
        height: 80px;
    }

    .guide-container {
        padding: 0 15px;
    }

    .pattern-section {
        padding: 20px;
    }

    .modal-body {
        padding: 20px;
    }
}

/* Print styles */
@media print {
    .header, .navigation-tabs, .modal {
        display: none !important;
    }
    
    .guide-container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .pattern-section {
        break-inside: avoid;
        margin-bottom: 20px;
        box-shadow: none;
    }
    
    .character-item {
        break-inside: avoid;
    }
}

/* Dark mode support for accessibility */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #4A3D28 0%, #5D4E37 50%, #6B5B3F 100%);
    }
    
    .pattern-section {
        background: linear-gradient(135deg, rgba(93, 78, 55, 0.95), rgba(75, 61, 40, 0.9));
        color: #F5F5DC;
    }
    
    .character-item {
        background: linear-gradient(135deg, rgba(75, 61, 40, 0.9), rgba(93, 78, 55, 0.85));
        color: #F5F5DC;
    }
    
    .section-title, .character-label {
        color: #D4AF7A;
    }
}