:root {
    /* Light mode colors */
    --bg-gradient-1: #667eea;
    --bg-gradient-2: #764ba2;
    --header-bg: rgba(255, 255, 255, 0.95);
    --card-bg: white;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #888;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --border-recent: #ff6b6b;
    --border-trending: #4ecdc4;
    --border-older: #667eea;
    --footer-bg: rgba(0, 0, 0, 0.8);
    --footer-text: white;
    --ad-bg: rgba(255, 255, 255, 0.1);
    --accent-color: #667eea;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-gradient-1: #1a1a2e;
    --bg-gradient-2: #16213e;
    --header-bg: rgba(15, 15, 25, 0.95);
    --card-bg: #1e1e2e;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    --border-recent: #ff6b6b;
    --border-trending: #4ecdc4;
    --border-older: #667eea;
    --footer-bg: rgba(0, 0, 0, 0.9);
    --footer-text: #e0e0e0;
    --ad-bg: rgba(255, 255, 255, 0.05);
    --accent-color: #4ecdc4;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

header {
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    padding: 2rem 0;
    box-shadow: 0 2px 20px var(--shadow);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    text-align: center;
}

.header-content > div {
    text-align: center;
}

.theme-toggle {
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--card-bg);
    border: 2px solid var(--text-muted);
    border-radius: 50px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="light"] .sun-icon,
[data-theme="dark"] .moon-icon {
    display: inline;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.fire-emoji {
    font-size: 3.5rem;
    -webkit-text-fill-color: initial;
    background: none;
    filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.5));
    animation: flicker 2s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(-2deg); }
    50% { transform: scale(1.1) rotate(2deg); }
    75% { transform: scale(1.05) rotate(-1deg); }
}

header p {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.news-stream {
    max-width: 800px;
    margin: 0 auto;
    min-height: 600px; /* Reserve space to prevent layout shift */
}

.ad-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 1rem;
    background: var(--ad-bg);
    border-radius: 10px;
    text-align: center;
    min-height: 100px; /* Reserve space for ads */
    aspect-ratio: 728 / 90; /* Standard leaderboard ad ratio */
}

.news-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.news-card:hover {
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.news-card h2.news-title {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    line-height: 1.3;
    font-weight: 600;
}

.news-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.trend-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.trend-time {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.trend-rank {
    color: var(--border-older);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Read more link styling */
.read-more-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    padding: 0.25rem 0;
}

.read-more-link:hover {
    text-decoration: underline;
    transform: translateX(5px);
}

.read-more-link:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Color code cards by recency */
.news-card.very-recent {
    border-left-color: var(--border-recent);
}

.news-card.recent {
    border-left-color: var(--border-trending);
}

.news-card.older {
    border-left-color: var(--border-older);
}

.loading {
    text-align: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 2rem;
    grid-column: 1 / -1;
    min-height: 400px; /* Prevent collapse when content loads */
    display: flex;
    align-items: center;
    justify-content: center;
}

footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
}

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    box-shadow: 0 -2px 20px var(--shadow);
    display: none;
    z-index: 1000;
    border-top: 2px solid var(--accent-color);
}

.cookie-banner.show {
    display: block;
}

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

.cookie-text {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.cookie-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.cookie-text a:hover {
    text-decoration: underline;
}

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

.cookie-btn {
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.cookie-accept {
    background: var(--accent-color);
    color: white;
}

.cookie-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.cookie-decline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--text-primary);
}

.cookie-decline:hover {
    background: var(--text-primary);
    color: var(--card-bg);
}

/* Footer Styles */
footer {
    background: var(--header-bg);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    color: var(--text-primary);
}

.footer-links {
    margin-top: 1rem;
}

.footer-links a {
    color: var(--text-primary);
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.separator {
    color: var(--text-secondary);
    margin: 0 0.5rem;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .theme-toggle {
        right: 1rem;
        font-size: 1.2rem;
        padding: 0.4rem 0.8rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    .cookie-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .separator {
        display: none;
    }
}