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

:root {
    --primary-color: #8B5A3C;
    --secondary-color: #D4AF37;
    --text-color: #2C2C2C;
    --light-bg: #F5EFE7;
    --card-bg: #FFFFFF;
    --border-color: #E0D5C7;
    --accent: #C41E3A;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Serif SC', 'Microsoft YaHei', serif;
    color: var(--text-color);
    background-color: var(--light-bg);
    line-height: 1.8;
    letter-spacing: 0.5px;
}

.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 35px,
            rgba(139, 90, 60, 0.03) 35px,
            rgba(139, 90, 60, 0.03) 70px
        );
    pointer-events: none;
    z-index: -1;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #4A3728 0%, #6B4C3A 100%);
    color: #FFF;
    padding: 2rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.logo .subtitle {
    font-size: 1rem;
    color: #D4AF37;
    font-style: italic;
    letter-spacing: 1px;
}

.navbar {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.nav-link {
    color: #FFF;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    border-bottom-color: #D4AF37;
    color: #D4AF37;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Sections */
section {
    padding: 80px 0;
}

section h2 {
    font-size: 3rem;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--primary-color);
    position: relative;
    padding-bottom: 1rem;
}

section h2::after {
    content: '';
    display: block;
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--secondary-color), transparent);
    margin: 1rem auto 0;
}

/* Overview Section */
.overview {
    background: linear-gradient(135deg, #FEFDFB 0%, #F5EFE7 100%);
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.overview-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.overview-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary-color);
    box-shadow: 0 8px 25px rgba(139, 90, 60, 0.15);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.overview-card h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.overview-card p {
    color: var(--text-color);
}

.overview-card p:first-of-type {
    font-size: 1.8rem;
    color: var(--secondary-color);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.overview-card .description {
    font-size: 0.95rem;
    color: #666;
}

/* Emperors Section */
.emperors-section {
    background: var(--light-bg);
}

.filter-bar {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.search-box:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.sort-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.sort-btn:hover,
.sort-btn.active {
    background: var(--primary-color);
    color: #FFF;
    border-color: var(--primary-color);
}

.emperors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.emperor-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.emperor-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 30px rgba(139, 90, 60, 0.2);
    border-color: var(--secondary-color);
}

.emperor-card-image {
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #E0D5C7, #D4AF37);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    font-size: 3rem;
    overflow: hidden;
    position: relative;
}

.emperor-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.emperor-card-content {
    padding: 1.5rem;
}

.emperor-card h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.emperor-card .phonetic {
    color: #999;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.emperor-card .reign-info {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.emperor-card .reign-label {
    color: var(--primary-color);
    font-weight: bold;
}

.emperor-card .reign-value {
    color: var(--secondary-color);
    font-weight: bold;
}

.emperor-card .brief {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background-color: var(--card-bg);
    margin: 50px auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 10px;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 2rem;
    font-weight: bold;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--primary-color);
}

.modal-body {
    padding: 2rem;
}

.modal-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
}

.modal-portrait {
    width: 200px;
    height: 300px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-title {
    flex: 1;
    min-width: 250px;
}

.modal-title h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.modal-title .phonetic {
    color: #999;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: block;
    font-style: italic;
}

.modal-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.modal-info-item {
    background: var(--light-bg);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.modal-info-item label {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.3rem;
}

.modal-info-item value {
    color: var(--text-color);
    font-size: 1.1rem;
    display: block;
}

.modal-section {
    margin: 2rem 0;
}

.modal-section h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.achievements-list {
    list-style: none;
}

.achievements-list li {
    padding: 0.5rem 0;
    padding-left: 2rem;
    position: relative;
    color: #666;
}

.achievements-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

.quotes-list {
    list-style: none;
}

.quote-item {
    background: linear-gradient(135deg, #FEFDFB, #F5EFE7);
    padding: 1.5rem;
    margin: 1rem 0;
    border-left: 4px solid var(--secondary-color);
    border-radius: 5px;
    font-style: italic;
    color: #4A4A4A;
    line-height: 1.8;
}

.quote-item::before {
    content: '"';
    color: var(--secondary-color);
    font-size: 2rem;
    margin-right: 0.5rem;
}

/* Timeline Section */
.timeline-section {
    background: linear-gradient(135deg, #FEFDFB 0%, #F5EFE7 100%);
}

.timeline {
    position: relative;
    padding: 2rem 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--secondary-color), var(--primary-color));
}

.timeline-item {
    margin-bottom: 3rem;
    display: flex;
    gap: 1rem;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.timeline-item:nth-child(odd) {
    flex-direction: row;
    text-align: right;
}

.timeline-item:nth-child(even) {
    flex-direction: row-reverse;
    text-align: left;
}

.timeline-item:nth-child(1) { animation-delay: 0.1s; }
.timeline-item:nth-child(2) { animation-delay: 0.2s; }
.timeline-item:nth-child(3) { animation-delay: 0.3s; }
.timeline-item:nth-child(4) { animation-delay: 0.4s; }
.timeline-item:nth-child(5) { animation-delay: 0.5s; }
.timeline-item:nth-child(6) { animation-delay: 0.6s; }
.timeline-item:nth-child(7) { animation-delay: 0.7s; }
.timeline-item:nth-child(8) { animation-delay: 0.8s; }
.timeline-item:nth-child(9) { animation-delay: 0.9s; }
.timeline-item:nth-child(10) { animation-delay: 1s; }
.timeline-item:nth-child(11) { animation-delay: 1.1s; }
.timeline-item:nth-child(12) { animation-delay: 1.2s; }
.timeline-item:nth-child(13) { animation-delay: 1.3s; }
.timeline-item:nth-child(14) { animation-delay: 1.4s; }
.timeline-item:nth-child(15) { animation-delay: 1.5s; }
.timeline-item:nth-child(16) { animation-delay: 1.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-content {
    flex: 1;
}

.timeline-marker {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--secondary-color);
    border: 4px solid var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: bold;
    box-shadow: 0 0 0 4px var(--primary-color);
    margin-top: 0.5rem;
}

.timeline-period {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.timeline-name {
    color: var(--secondary-color);
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}

.timeline-years {
    color: #999;
    font-size: 0.95rem;
}

/* Events Section */
.events-section {
    background: linear-gradient(135deg, #FEFDFB 0%, #F5EFE7 100%);
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.event-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 10px;
    border-left: 5px solid var(--secondary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.event-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(139, 90, 60, 0.15);
    border-left-color: var(--accent);
}

.event-year {
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.event-title {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.event-description {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.8;
    flex-grow: 1;
    margin-bottom: 1rem;
}

.event-emperor {
    color: var(--primary-color);
    font-weight: bold;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

/* Statistics Section */
.statistics-section {
    background: var(--light-bg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary-color);
    box-shadow: 0 8px 25px rgba(139, 90, 60, 0.15);
}

.stat-card h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.stat-number {
    font-size: 3rem;
    color: var(--secondary-color);
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-family: 'Arial', sans-serif;
}

.stat-card p {
    color: #666;
    font-size: 0.95rem;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, #4A3728 0%, #6B4C3A 100%);
    color: #FFF;
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    margin: 0.5rem 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .logo h1 {
        font-size: 1.8rem;
    }

    .navbar {
        gap: 1rem;
        justify-content: center;
    }

    section {
        padding: 50px 0;
    }

    section h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

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

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

    .modal-content {
        margin: 20px auto;
        width: 90%;
    }

    .modal-header {
        flex-direction: column;
    }

    .modal-portrait {
        width: 100%;
        height: auto;
    }

    .timeline::before {
        left: 20px;
    }

    .timeline-item {
        flex-direction: column !important;
        text-align: left !important;
    }

    .timeline-marker {
        margin-left: -32px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .search-box {
        min-width: auto;
    }

    .sort-buttons {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.5rem;
    }

    .navbar {
        flex-direction: column;
        gap: 0.5rem;
        font-size: 0.9rem;
    }

    .nav-link {
        padding: 0.3rem 0.5rem;
    }

    section h2 {
        font-size: 1.5rem;
    }

    .emperor-card-image {
        height: 200px;
    }

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

    .stat-number {
        font-size: 2rem;
    }

    .modal-content {
        width: 95%;
        margin: 10px auto;
    }

    .close {
        padding: 0.5rem 1rem;
        font-size: 1.5rem;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Print Styles */
@media print {
    .navbar,
    .search-box,
    .sort-buttons,
    .close {
        display: none;
    }

    section {
        page-break-inside: avoid;
    }
}
