html, body {
  overflow-x: hidden;
}
*, *::before, *::after {
  box-sizing: border-box;
}

/* ---------- Mobile styles (≤1024px) ---------- */
@media (max-width: 1024px) {
  /* Navigation */
  nav[style] {
    padding: 0.75rem 1.5rem !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    position: relative !important;
    min-height: 60px;
  }
  nav > div[style*="margin-left"] {
    display: none !important;
  }

  /* Hamburger button */
  .mobile-menu-btn {
    display: flex !important;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 200;
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
  }
  .mobile-menu-btn span {
    display: block;
    width: 100%;
    height: 3px;
    background: #4f46e5;
    border-radius: 3px;
    transition: 0.3s;
  }

  /* Panel */
  .mobile-nav-panel {
    display: none !important;
    position: fixed !important;
    top: 60px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 2px solid #e5e7eb;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 1rem;
    z-index: 199;
    flex-direction: column;
    gap: 0.5rem;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .mobile-nav-panel.open {
    display: flex !important;
  }
  .mobile-nav-panel a {
    color: #1e293b;
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-radius: 0.5rem;
    background: #f1f5f9;
    display: block;
  }

  /* ---------- Content width fixes ---------- */
  .container,
  .card,
  .section,
  .hero-content,
  .tools-grid,
  .posts-grid,
  .categories-grid,
  .related-posts,
  .footer-grid,
  [style*="display:grid"],
  [style*="display: flex"] {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
    flex-wrap: wrap !important;
  }
  section.bg-white .container[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .container, .section, .hero, .card, .category-card,
  .cta-box, .author-box, .share-bar, .post-card,
  footer .footer-grid > div, .article-body, .word-list-panel,
  .sidebar, .related-posts, .bonus-section,
  .tip-card, .pwd-item, .tools-grid, .hero-content {
    max-width: 100% !important;
    width: auto !important;
  }

  img, video, iframe, table, pre, code {
    max-width: 100% !important;
    height: auto !important;
  }

  p, li, a, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  [style*="width"] {
    max-width: 100% !important;
  }

  h1 { font-size: 1.8rem !important; }
  h2 { font-size: 1.4rem !important; }
  h3 { font-size: 1.2rem !important; }
  .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  /* Word‑search grid */
  .grid-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-right: 1rem !important;
  }
  @media (max-width: 480px) {
    .grid-cell {
      width: 38px !important;
      height: 38px !important;
      font-size: 1rem !important;
    }
  }

  /* Button group fixes */
  .flex-wrap.justify-center.gap-4,
  .cta-box .flex-wrap.justify-center.gap-4 {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }
  .flex-wrap.justify-center.gap-4 .btn,
  .cta-box .flex-wrap.justify-center.gap-4 .btn {
    width: 100% !important;
    justify-content: center;
    box-sizing: border-box;
    margin-bottom: 0.75rem;
  }
  .flex-wrap.justify-center.gap-4 .btn:last-child,
  .cta-box .flex-wrap.justify-center.gap-4 .btn:last-child {
    margin-bottom: 0;
  }

  .hero .badge {
    margin-top: 1.5rem !important;
  }

  /* ---------- Hero background fixes ---------- */

  /* 1. Heroes with an inline background-image (random‑generator, etc.) */
  .hero[style*="url("] {
    min-height: auto !important;
    height: auto !important;
    padding-bottom: 2.5rem !important;
    background-size: cover !important;
    background-position: center !important;
  }
  .hero[style*="url("] .hero-overlay {
    height: 100% !important;
  }

  /* 2. Heroes that use an <img> inside a .hero-bg (about page) */
  .hero:has(.hero-bg) {
    min-height: 50vh !important;      /* enough room for the image to shine */
    height: auto !important;
    padding-bottom: 2.5rem !important;
  }
  .hero:has(.hero-bg) .hero-bg img {
    object-fit: cover !important;
    width: 100% !important;
    height: 100% !important;
  }
}

/* Desktop: hide mobile menu */
@media (min-width: 1025px) {
  .mobile-menu-btn,
  .mobile-nav-panel {
    display: none !important;
  }
}