.timeline-page-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background-color: var(--surface-1);
    display: flex;
    flex-direction: column;
}

/* Top Controls */
.top-controls {
    flex-shrink: 0;
    padding: 20px 20px 0 20px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, var(--surface-1), transparent);
}

.back-btn {
    margin-right: 20px;
}

.page-header {
    color: var(--text-1);
}

.page-header h1 {
    font-size: 1.8rem;
    margin: 0;
    color: var(--primary-dark);
}

.page-header p {
    color: var(--text-2);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Timeline Container */
.timeline-container {
    flex-shrink: 0;
    margin: 10px 20px 10px 20px;
    padding: 1.1rem 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
}

.timeline-header {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 1rem;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.scroll-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
    flex-shrink: 0;
    z-index: 2;
}

.scroll-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 5px rgba(0, 128, 64, 0.3);
}

.scroll-btn:active {
    transform: scale(0.95);
}

.scroll-btn.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    /* Ensure it doesn't take clicks */
}

.timeline-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-x: auto;
    padding: 10px 5px;
    /* Increased padding to prevent clipping of scaled/shadowed items */
    /* scrollbar-width: none;  <-- Removed to allow scrollbar */
    justify-content: flex-start;
    flex: 1;
    min-width: 0;
}

/* Pretty Scrollbar for Timeline */
.timeline-scroll::-webkit-scrollbar {
    height: 6px;
}

.timeline-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.timeline-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 128, 64, 0.3);
    border-radius: 3px;
}

.timeline-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 128, 64, 0.5);
}

.timeline-node {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 100px;
    flex-shrink: 0;
}

.timeline-node:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.timeline-node.active {
    background: rgba(0, 128, 64, 0.1);
    color: var(--primary-dark);
    transform: scale(1.05);
    transform: scale(1.05);
    font-weight: bold;
}

.timeline-node.golden-era {
    border: 1px solid #ffd700;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

.timeline-node.golden-era:not(.active) .node-name {
    color: #bfa100;
    /* Darker gold for text when not active */
}

.timeline-node.active.golden-era {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.node-year {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 2px;
}

.node-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Rulers Strip */
.rulers-strip {
    flex-shrink: 0;
    margin: 0 20px 10px 20px;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
}

.rulers-header {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 1rem;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.rulers-list {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 10px 5px;
    /* Added padding to prevent clipping */
}

/* Pretty Scrollbar for Rulers */
.rulers-list::-webkit-scrollbar {
    height: 6px;
}

.rulers-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.rulers-list::-webkit-scrollbar-thumb {
    background: rgba(0, 128, 64, 0.3);
    border-radius: 3px;
}

.rulers-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 128, 64, 0.5);
}

.ruler-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: rgba(0, 128, 64, 0.05);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 128, 64, 0.1);
    min-width: 100px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.ruler-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-1);
    white-space: nowrap;
}

.ruler-years {
    font-size: 0.75rem;
    color: var(--text-2);
}

.ruler-chip:hover {
    background: rgba(0, 128, 64, 0.1);
    transform: translateY(-2px);
}

.ruler-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.ruler-chip.active .ruler-name {
    color: white;
}

.ruler-chip.active .ruler-years {
    color: rgba(255, 255, 255, 0.8);
}

/* Ruler Details Panel */
.ruler-details-panel {
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
}

.ruler-details-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 1rem;
    flex-wrap: wrap;
}

.ruler-details-header h2 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 2rem;
}

.ruler-years-lg {
    font-size: 1.2rem;
    color: var(--text-2);
    background: var(--surface-2);
    padding: 0.2rem 1rem;
    border-radius: 20px;
    white-space: nowrap;
}

.close-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-2);
}

.close-btn:hover {
    color: var(--danger);
}

.ruler-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.info-card {
    padding: 1.5rem;
    border-radius: 12px;
    background: var(--surface-1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.info-card h4 {
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.info-card p {
    line-height: 1.6;
    color: var(--text-2);
    margin-bottom: 0;
    white-space: pre-wrap;
}

.info-card.bio h4 {
    color: var(--primary);
}

.info-card.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.info-card.success h4 {
    color: #15803d;
}

.info-card.danger {
    background: #fef2f2;
    border-color: #fecaca;
}

.info-card.danger h4 {
    color: #b91c1c;
}

/* Content Area & Cards */
.content-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
    padding-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.history-card {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
}

.history-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-image-container {
    height: 160px;
    position: relative;
    background: var(--surface-2);
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    font-size: 3rem;
    color: var(--primary-light);
}

.card-img-placeholder.knowledge {
    color: #818cf8;
    background: #e0e7ff;
}

.card-img-placeholder.trade {
    color: #fbbf24;
    background: #fef3c7;
}

.card-img-placeholder.event {
    color: #f87171;
    background: #fee2e2;
}

.card-img-placeholder.capital {
    color: #34d399;
    background: #d1fae5;
}

.card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.card-details {
    padding: 1.5rem;
}

.card-details h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    color: var(--primary-dark);
}

.card-details p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-2);
    line-height: 1.5;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    opacity: 0.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-2);
}

.empty-state i {
    font-size: 3rem;
}

/* Animations */
.fade-in {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .top-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .timeline-container,
    .rulers-strip {
        margin: 10px 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .content-scroll-area {
        padding-bottom: 20px;
    }

    .timeline-header,
    .rulers-header {
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        padding-bottom: 0.5rem;
        width: 100%;
    }

    .timeline-scroll,
    .rulers-list {
        width: 100%;
        padding-bottom: 5px;
    }

    .ruler-details-panel {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .ruler-details-header {
        gap: 0.5rem;
    }

    .ruler-details-header h2 {
        font-size: 1.5rem;
        width: 100%;
        order: 2;
        margin-top: 0.5rem;
    }

    .ruler-years-lg {
        font-size: 1rem;
        order: 3;
    }

    .close-btn {
        order: 1;
        margin-left: auto;
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .ruler-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Text Modal Sytles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-dark);
    font-size: 1.3rem;
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    color: var(--text-1);
    line-height: 1.6;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.8);
}

.btn-more {
    background: white;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 1px 10px;
    margin-left: 8px;
    font-size: 0.75rem;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
    display: inline-block;
    vertical-align: middle;
    line-height: normal;
}

.btn-more:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 128, 64, 0.2);
}