@media (max-width: 1200px) {
    .container { padding: 0 30px; }
}

@media (max-width: 992px) {
    .section-title { font-size: 1.5rem; }
    .header-main { padding: 8px 0; }
    .main-logo { max-height: 50px; } /* Slightly increased mobile logo size */
    .ticker-label { padding: 0 15px; font-size: 0.75rem; }
    .ticker-scroll-container { padding-left: 0; }
    
    /* Horizontal category scroll bar directly below header logo */
    .header-flex-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
    }
    .logo-area {
        order: 1;
    }
    .header-right-actions {
        order: 2;
    }
    .main-nav {
        order: 3;
        width: auto !important;
        margin: 10px -30px -12px -30px;
        display: flex !important;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        background: #f8f9fa;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        padding: 10px 30px;
        gap: 18px;
        scrollbar-width: none;
        -ms-overflow-style: none;
        justify-content: flex-start;
        z-index: 100;
    }
    body.dark-theme .main-nav {
        background: #111;
        border-top-color: rgba(255,255,255,0.05);
        border-bottom-color: rgba(255,255,255,0.05);
    }
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-link {
        padding: 4px 8px;
        font-size: 0.82rem;
        font-weight: 700;
    }
    .nav-dropdown {
        display: none !important; /* Hide dropdown content on mobile category bar */
    }
    .mobile-menu-btn {
        display: none !important; /* Hide duplicate hamburger icon on the right */
    }
}

@media (max-width: 768px) {
    .header-main .container { flex-direction: row; justify-content: space-between; gap: 10px; }
    .hero-grid { grid-template-columns: 1fr; }
    .hero-main { height: 300px; }
    .hero-overlay h2 { font-size: 1.4rem; }
    .news-grid { grid-template-columns: 1fr; }
    .two-col-grid { grid-template-columns: 1fr !important; gap: 30px !important; }
    .date-time-bar { font-size: 0.65rem; }
    .breaking-ticker { height: 35px; }
    .ticker-label { padding: 0 10px; font-size: 0.7rem; }
    .ticker-scroll-container { padding-left: 0; }
    .ticker-content { font-size: 0.75rem; }

    /* Eliminate horizontal scrolling completely and prevent overflow */
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .container {
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box;
    }

    .main-nav {
        margin-left: -15px !important;
        margin-right: -15px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: calc(100% + 30px) !important;
        box-sizing: border-box !important;
    }

    /* Word wrapping optimizations to prevent text overflow on mobile */
    body, p, h1, h2, h3, h4, h5, h6, span, a {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Force responsive scaling on all structural and media elements */
    img, iframe, video, table, embed, object {
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Advertisement Scaling for Mobile */
    .ad-container {
        display: flex !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-self: center !important;
        justify-content: center !important;
    }

    .ad-leaderboard {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 970 / 250 !important;
    }
    
    .ad-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 300 / 250 !important;
    }

    /* Ensure placeholders scale nicely */
    .ad-placeholder {
        width: 100% !important;
        box-sizing: border-box;
        padding: 15px !important;
    }

    .real-ad {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Featured Breaking News Mobile Optimization */
    .featured-breaking-section {
        margin: 20px auto;
        padding: 0 15px;
    }
    .featured-breaking-card {
        border-radius: 12px;
        box-shadow: 0 5px 25px rgba(0,0,0,0.05);
    }
    .featured-breaking-img-wrapper {
        height: 240px;
    }
    .featured-breaking-content {
        padding: 20px;
    }
    .featured-breaking-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
        line-height: 1.35;
    }
    .featured-breaking-summary {
        font-size: 0.9rem;
        margin-bottom: 15px;
        -webkit-line-clamp: 3;
    }
    .featured-breaking-meta {
        font-size: 0.8rem;
        gap: 15px;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    .featured-breaking-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    .featured-breaking-badge {
        top: 15px;
        left: 15px;
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    /* Mobile Article Cards Optimizations */
    .news-card {
        margin-bottom: 25px;
        border-radius: 12px;
        box-shadow: 0 5px 20px rgba(0,0,0,0.03);
    }
    .news-card-img {
        height: 220px;
    }
    .news-card-content {
        padding: 20px !important;
        min-height: auto !important; /* Allow natural auto height */
    }
    .news-card-title {
        font-size: 1.25rem !important;
        line-height: 1.35 !important;
        font-weight: 800 !important;
        margin-bottom: 10px !important;
        color: var(--text-color);
    }
    .news-card-summary {
        font-size: 0.9rem !important;
        line-height: 1.5 !important;
        margin-bottom: 15px !important;
        color: #555;
    }
    body.dark-theme .news-card-summary {
        color: #ccc;
    }
    /* Touch-friendly buttons for article cards */
    .read-more-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: #0A2747;
        color: #fff !important;
        padding: 12px 24px;
        border-radius: 8px;
        font-size: 0.9rem !important;
        font-weight: 700;
        margin-top: 10px;
        width: 100%;
        text-align: center;
        transition: transform 0.2s ease, background-color 0.2s ease;
        box-shadow: 0 4px 10px rgba(10, 39, 71, 0.15);
    }
    body.dark-theme .read-more-btn {
        background: var(--primary);
        box-shadow: 0 4px 10px rgba(139, 0, 0, 0.2);
    }
    .read-more-btn:active {
        transform: scale(0.98);
    }
    .read-more-btn i {
        margin-left: 8px;
    }
}

@media (max-width: 480px) {
    .logo-wrapper h1 { font-size: 1.5rem; }
    .intro-card { padding: 30px 20px; }
    .intro-card h2 { font-size: 1.5rem; }

    /* Extra small screen optimizations */
    .featured-breaking-img-wrapper {
        height: 180px;
    }
    .featured-breaking-title {
        font-size: 1.3rem;
    }
    .featured-breaking-summary {
        -webkit-line-clamp: 2;
    }
    .main-nav {
        margin-left: -15px !important;
        margin-right: -15px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: calc(100% + 30px) !important;
        box-sizing: border-box !important;
    }
}
