html, body {
    margin: 0;
    padding: 0;
    /* Force full height */
    height: 100%;
}

body {
    /* Use flex layout for sticky footer (not pinned) */
    display: flex;
    flex-direction: column;
    min-height: 100%;
    /* Keep existing background and color as you prefer */
    background-color: #1a1a1a;
    color: #fff;
    overflow-x: hidden;
    font-family: Arial, sans-serif;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #23825f;  /* Green header */
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    color: white;
    box-sizing: border-box;
}

.logo a {
    display: block;
    cursor: pointer;
}

.logo img {
    height: 40px;
    max-width: 100%;
}

.icons {
    display: flex;
    gap: 15px;
    order: 1;
}

.icons a {
    display: inline-block;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.icons a img {
    height: 30px;
}

.notification-bell {
    position: relative;
}

.unread-count {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;  /* Ensure enough space for the number */
    height: 18px;     /* Fixed height for the circle */
    background-color: red;
    color: white;     /* White text for the number */
    border-radius: 50%;
    border: 1px solid white;
    z-index: 2001;
    display: inline-block;
    text-align: center;
    line-height: 18px;  /* Vertically center the number */
    font-size: 12px;    /* Adjust font size for readability */
    padding: 0 2px;     /* Small padding to ensure the number fits */
}

.icons a:hover {
    background-color: #000;
}

/* The chat icon on mobile. We'll size it to match messages/notifications */
.chat-icon-mobile img {
    height: 30px;
}

/* Logged-out header */
.auth-buttons {
    display: flex;
    gap: 15px;
    order: 1;
}

.auth-button {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 5px;
    text-decoration: none;
    color: white;
    background-color: #23825f;
    border: 1px solid #fff;
    transition: background-color 0.3s;
}

.auth-button span {
    margin-right: 5px;
}

.auth-icon {
    height: 20px;
}

.register-button {
    background-color: white;
    color: #23825f;
    border-color: #23825f;
}

.login-button:hover {
    background-color: #1a6347;
}

.register-button:hover {
    background-color: #f0f0f0;
}

/* Profile dropdown */
.profile {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    margin-left: 20px;
}

.profile img {
    height: 30px;
    margin-right: 5px;
}

.profile .dropdown-arrow {
    height: 20px;
}

.profile .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #23825f;
    border: 1px solid #ccc;
    padding: 10px;
    min-width: 150px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.profile:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    color: white;
    text-decoration: none;
}

.dropdown-menu a img {
    height: 20px;
    margin-right: 5px;
}

.dropdown-menu a:hover {
    background-color: #000;
}

.dropdown-menu hr {
    border: 0;
    border-top: 1px solid #fff;
    margin: 5px 0;
    width: 100%;
}

.credits-header {
    display: flex;
    align-items: center;
    margin-left: 20px;
}

.credits-header a {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.credits-header a img {
    height: 30px;
    margin-right: 5px;
}

.credits-header a:hover {
    background-color: #1a6347;
}

.hamburger {
    display: none;
}

.hamburger input[type="checkbox"] {
    display: none;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background-color: #23825f;
    padding: 20px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
}

#hamburger-toggle:checked ~ .mobile-menu {
    display: block;
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.close-menu img {
    height: 25px;
    cursor: pointer;
}

.mobile-profile {
    display: flex;
    align-items: center;
    padding: 10px;
    color: white;
}

.mobile-profile img {
    height: 30px;
    margin-right: 10px;
}

.mobile-credits {
    padding: 10px;
}

.mobile-credits a {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
}

.mobile-credits a img {
    height: 20px;
    margin-right: 5px;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    padding: 10px;
    color: white;
    text-decoration: none;
}

.mobile-menu a img {
    height: 20px;
    margin-right: 5px;
}

.mobile-menu a:hover {
    background-color: #000;
}

.mobile-menu hr {
    border: 0;
    border-top: 1px solid #fff;
    margin: 5px 0;
    width: 80%;
}

/* Main is flexible so the footer can be at the bottom if content is short */
main {
    /* Let main expand to push footer down on short pages */
    flex: 1 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Right Panel for Desktop */
.right-panel {
    position: fixed;
    top: 70px;
    right: 0;
    bottom: 0;
    width: 300px;
    background-color: #2b2b2b;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    display: none; /* hidden on mobile, displayed on desktop */
    z-index: 1000;
}

/* Ads in right panel */
.ad-section h3 {
    margin-top: 0;
    margin-bottom: 0.5em;
    color: #23825f;
}

.ad-images {
    display: grid !important;                /* override 'flex' */
    grid-template-columns: repeat(2, 1fr);   /* 2 columns */
    gap: 10px !important;                    /* spacing between images */
    margin-bottom: 10px;                     /* keep existing spacing */
  }

.ad-images a img {
    width: 100%;
    height: 40px !important;     /* Fixed height for the rectangle */
    object-fit: cover !important;/* Crop overflow, preserving aspect ratio */
    border: 1px solid #333;
    /* Remove or override any "max-height: 60px !important" line above */
}

.ad-links {
    display: flex !important;
    justify-content: space-between !important; /* push first link left, last link right */
    align-items: center !important;
  }

.ad-links a {
    color: #fff;
    text-decoration: none;
    font-size: 0.9em;
}

.ad-links a:hover {
    text-decoration: underline;
}

/* Subscriptions in right panel */
.subscriptions-section {
    margin-bottom: 1em;
}

.subscriptions-section h3 {
    margin-top: 20;
    margin-bottom: 0;
    color: #23825f;
}

.sub-link a {
    color: #fff;
    text-decoration: none;
    font-size: 0.9em;
}

.sub-link a:hover {
    text-decoration: underline;
}

.community-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.community-row img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.community-name {
    font-weight: bold;
}

.community-members {
    font-size: 0.8em;
    color: #ccc;
}

/* Live chat in right panel */
.live-chat-section h3 {
    margin-top: 20;
    margin-bottom: 0;
    color: #23825f;
}

.chat-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
}

.chat-tab {
    background-color: #3b3b3b;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
}

.chat-tab-active {
    background-color: #23825f;
    font-weight: bold;
}

.chat-messages {
    background-color: #1a1a1a;
    border: 1px solid #333;
    padding: 10px;
    height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.chat-message {
    margin-bottom: 8px;
}

.chat-username {
    color: #fff;
    font-weight: bold;
}

.premium-icon-inline {
    width: 16px;
    margin-left: 3px;
    position: relative;
    top: 3px;
}

.chat-time {
    font-size: 0.75em;
    color: #999;
    margin-left: 15px;
}

.chat-input-box {
    display: flex;
    gap: 5px;
}

.chat-input-box input[type="text"] {
    flex: 1;
    padding: 6px;
    border-radius: 3px;
    border: 1px solid #333;
    background-color: #333;
    color: #fff;
}

.chat-input-box button {
    background-color: #23825f;
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
}

/* Footer remains your original design. It's not pinned, but "sticky" if content is short. */
footer {
    /* Ensure footer appears immediately after main, with no extra space below */
    margin-top: auto;
    padding: 10px 20px;
    background-color: #23825f;
    color: white;
    width: 100%;
    /* You can keep your .footer-content styling as is inside footer */
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 60px;
}

.footer-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-right: 20px;
}

.footer-logo-container {
    display: flex;
    align-items: center;
}

.footer-logo {
    height: 30px;
    margin-right: 10px;
}

.footer-telegram {
    height: 30px;
    margin-top: 2px; /* Pushes telegram.png down slightly */
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    flex-grow: 1;
}

.footer-links a {
    color: white;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.3s;
    font-size: 14px;
}

.footer-links a:hover {
    color: #ccc;
}

.mobile-ads-header {
    display: block;
    width: 100%;           /* ensure it spans full width */
    background-color: #333;
    box-sizing: border-box;
    margin-top: 70px;      /* stays below the fixed header */
    margin-bottom: 0;      /* remove extra space underneath */
    padding: 10px;         /* keep your padding */
  }

  /* Container for ad images remains as is,
     but ensure there's no margin/padding that
     might cause horizontal scroll. */
  .mobile-ads-container {
    display: flex;
    gap: 10px;
    justify-content: space-around;
    margin-bottom: 5px;
    width: 100%;         /* ensure container also spans full width */
    box-sizing: border-box;
  }

  /* Align links on opposite ends:
     "View all ads" on the left, "Buy ads" on the right */
  .mobile-ad-links {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    /* Instead of justify-content: center, do space-between */
    justify-content: space-between;
    color: #fff;
    text-decoration: underline;
  }

  /* This ensures the left link is flush left,
     and the right link is flush right. */
  .mobile-ad-links a:first-child {
    margin-right: auto;
    text-align: left;
    color: #fff;
    text-decoration: underline;
  }
  .mobile-ad-links a:last-child {
    margin-left: auto;
    text-align: right;
    color: #fff;
    text-decoration: underline;
  }

/* Mobile ads placeholder */
.mobile-ads-placeholder {
    width: 100%;
    height: 60px; /* Matches approximate height of .mobile-ads-header (10px padding + content height) */
    margin-top: 70px; /* Aligns with .mobile-ads-header's margin-top */
    box-sizing: border-box;
}

/* Mobile chat overlay */
.chat-toggle-checkbox {
    display: none;
}

.mobile-chat {
    display: none;
    position: fixed;
    top: 70px; /* below the fixed header */
    left: 0; right: 0;
    bottom: 0;
    background-color: #1a1a1a;
    z-index: 1000;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

.mobile-chat-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.chat-exit-btn img {
    height: 25px;
    cursor: pointer;
}

/* When chat-toggle is checked, hide main + right panel, show mobile chat. */
#chat-toggle:checked ~ .page-container main,
#chat-toggle:checked ~ .page-container .right-panel {
    display: none;
}
#chat-toggle:checked ~ .mobile-chat {
    display: flex;
}

.create-community-button,
.top-donators-button {
  margin-top: 20px !important; /* Increase to 20px (or more) for extra vertical space */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden; /* Prevent horizontal overflow */
}

.create-community-button a,
.top-donators-button a {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  text-align: center;
  background-color: #23825f;
  color: #fff;
  text-decoration: none;
  padding: 10px;
  border-radius: 4px;
  font-weight: bold;
  box-sizing: border-box;
}

.create-community-button a:hover,
.top-donators-button a:hover {
  background-color: #1a6347; /* Optional hover color */
}

/* Flash messages, error/success */
.flash-error {
    background: #fbdada;
    color: #c00;
    padding: 0.5em;
    margin-bottom: 1em;
    border-radius: 3px;
}

.flash-success {
    background: #dbfadb;
    color: #2b7b2b;
    padding: 0.5em;
    margin-bottom: 1em;
    border-radius: 3px;
}

.community-name a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
}

.community-name a:hover {
    text-decoration: underline;
}

#error-message {
    text-align: center;
    margin-top: 10px;
}

#success-message {
    text-align: center;
    margin-top: 10px;
}

@media (max-width: 767px) {
    /* Original rules */
    html, body {
        overflow-x: hidden !important;
      }

    header {
        justify-content: space-between;
    }
  /* Ensure mobile ads header covers the full width,
     with no gap, and doesn't hide content below */
     .mobile-ads-header {
        position: relative !important;  /* not overlapping/fixed */
        z-index: 1 !important;         /* ensures it's behind other interactive elements if needed */
        width: 100% !important;
        margin: 0 !important;
        margin-top: 70px !important;   /* below the fixed header */
        margin-bottom: 0 !important;
        padding: 10px !important;
        box-sizing: border-box !important;
      }

      /* Mobile ads container: no extra gap, fully visible,
         smaller images so they don't overshadow links below */
      .mobile-ads-container {
        display: flex !important;
        gap: 10px !important;
        justify-content: space-around !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
      }

      /* AD IMAGES: about 60% the previous size (~72x36 if previously 120x60) */
      .mobile-ads-container a img {
        display: block !important;
        width: 120px !important;   /* 3/5 of 120px */
        height: 36px !important;  /* 3/5 of 60px */
        object-fit: cover !important;
        border: 1px solid #555 !important;
      }

      /* Mobile ad links: keep them visible and not obstructed */
      .mobile-ad-links {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        margin: 5px 0 !important;   /* ensure they’re spaced visibly */
        box-sizing: border-box !important;
      }

      /* Left link flush left, right link flush right, text visible */
      .mobile-ad-links a:first-child {
        margin-right: auto !important;
        color: #fff !important;
        text-decoration: underline !important;
      }
      .mobile-ad-links a:last-child {
        margin-left: auto !important;
        color: #fff !important;
        text-decoration: underline !important;
      }
    .logo {
        order: 2;
        margin: 0 auto;
    }

    .logo img {
        height: 50px;
    }

    .icons {
        order: 3;
        margin-left: 0;
    }

    .hamburger {
        display: block;
        order: 1;
    }

    .hamburger label img {
        height: 30px;
    }

    .profile {
        display: none;
    }

    .credits-header {
        display: none;
    }

    .auth-buttons {
        order: 3;
        margin-left: 0;
    }

    .right-panel {
        display: none;
    }

    /* === New Footer Fixes on Mobile === */
    .footer-content {
        flex-direction: column;   /* stack .footer-left and .footer-links vertically */
        align-items: flex-start;  /* keep the logo/telegram on the left */
    }

    .footer-left {
        margin-bottom: 10px;  /* space below the logo/telegram block */
    }

    .footer-links {
        flex-direction: column;   /* stack links vertically */
        align-items: center;      /* center them horizontally */
        width: 100%;              /* occupy full width so they don't overflow */
    }

    .footer-links a {
        white-space: normal;      /* wrap link text if it’s long */
        text-align: center;       /* center each link’s text */
    }
}

.icons label.chat-icon-mobile {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin: 0;
    padding: 5px;
    /* Same styling as other icons a elements */
  }

  .icons label.chat-icon-mobile img {
    height: 35px !important; /* Force the same 30px height as messages/notifications/search icons */
    vertical-align: middle;
  }

@media (min-width: 768px) {
    header {
        justify-content: space-between;
    }

      /* Provide padding so the footer content isn't hidden behind the 300px panel. */
  .footer-content {
    padding-right: 300px; /* same width as .right-panel */
    box-sizing: border-box;
  }

  @media (min-width: 768px) {
    .icons label.chat-icon-mobile {
      display: none !important;
    }
  }

  /* Force links to wrap to a new line if space runs out. */
  .footer-links {
    flex-wrap: wrap;        /* already set, but ensuring override */
    justify-content: center;/* center them horizontally */
  }

    .logo {
        order: 1;
    }

    .icons {
        order: 2;
        margin-left: auto;
    }

    .profile {
        order: 3;
        margin-left: 20px;
    }

    .credits-header {
        order: 4;
        margin-left: 20px;
    }

    .auth-buttons {
        order: 2;
        margin-left: auto;
    }

    .hamburger {
        display: none;
    }

    .right-panel {
        display: block;
    }

    main {
        margin-right: 300px; /* so content doesn't hide behind fixed panel */
        margin-top: 70px; /* if you have a fixed header of height 70px */
    }

    .mobile-ads-header {
        display: none;
    }

    .mobile-ads-placeholder {
        display: none;
    }

    .chat-icon-mobile {
        display: none; /* hidden on desktop */
    }
}
