html,
body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100%;
}

body {
    padding: 20px !important;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Ensures content starts at the top and scrolls cleanly */
    box-sizing: border-box;
}

/* Portrait mode: Add top padding to account for camera notch */
@media (orientation: portrait) {
    body {
        padding-top: max(45px, env(safe-area-inset-top) + 20px) !important;
        padding-bottom: max(45px, env(safe-area-inset-bottom) + 20px) !important;
    }
}

.page-container {
    max-width: 600px;
    width: 100%;
    background: var(--card-bg);
    padding: 32px;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    border: var(--glass-border);
    backdrop-filter: blur(10px);
    transition: max-width 0.3s ease, padding 0.3s ease;
}

/* Responsive Layout for Wider Screens */
@media (min-width: 768px) {
    .page-container {
        max-width: 1200px;
        padding: 40px;
    }
}

.page-container.text-center {
    text-align: center;
}

.page-title {
    color: var(--primary-green);
    font-size: 1.6rem;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.page-note {
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(3, 99, 53, 0.05);
    padding: 14px 16px;
    border-radius: 12px;
    line-height: 1.5;
    border: 1px solid rgba(3, 99, 53, 0.08);
}

.dark-mode .page-note {
    background: rgba(var(--primary-gold-rgb), 0.05);
    border-color: rgba(var(--primary-gold-rgb), 0.2);
    color: var(--text-secondary);
}

.page-note i {
    color: var(--primary-green);
    margin-right: 4px;
}

.page-brand {
    margin-top: 28px;
    opacity: 0.45;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.8rem;
}

.page-brand img {
    width: 28px;
    height: auto;
}

.dark-mode .page-brand {
    opacity: 0.8;
}

/* Feature card dark mode (used in about, contact, etc) */
.dark-mode .feature-card {
    background: rgba(6, 30, 20, 0.6);
    border-color: rgba(var(--primary-gold-rgb), 0.2);
}

/* Global Android TV / D-Pad Focus States for interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
.copy-btn:focus,
.donate-tab:focus,
.pt-nav-btn:focus,
.social-btn:focus {
    outline: 2px solid rgba(var(--primary-gold-rgb), 0.2) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 20px rgba(var(--primary-gold-rgb), 0.15);
}

/* Common Content List Layouts (Events, Posts, etc) */
.section-title {
    color: var(--primary-green);
    font-size: 1.3rem;
    margin: 24px 0 16px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(3, 99, 53, 0.1);
    padding-bottom: 8px;
    text-align: left;
}

.content-container, .events-container, .posts-container {
    text-align: left;
    margin-bottom: 24px;
}

.content-card, .event-card, .post-card {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 20px;
    border: 1px solid rgba(3, 99, 53, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
}

.content-card:hover, .event-card:hover, .post-card:hover {
    transform: translateY(-2px);
}

.content-image, .event-image, .post-image {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center;
    background-color: rgba(3, 99, 53, 0.1);
}

.content-details, .event-details, .post-details {
    padding: 16px;
}

.content-title, .event-title, .post-title {
    color: var(--primary-green);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.content-info, .event-info, .post-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.content-info i, .event-info i, .post-info i {
    color: var(--primary-gold);
    font-size: 16px;
}

.content-excerpt, .event-excerpt, .post-excerpt {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.content-link, .event-link, .post-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Modal Overlay Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-color);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 20px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
    font-size: 24px;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.modal-close:hover {
    transform: scale(1.1);
    background: #0d9488;
}

.modal-image {
    width: 100%;
    height: 350px;
    background-size: cover;
    background-position: center;
}

.modal-body {
    padding: 30px;
    text-align: left;
}

.modal-title {
    color: var(--primary-green);
    font-size: 1.8rem;
    margin-bottom: 20px;
    line-height: 1.3;
}

.modal-description {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1.05rem;
}

.modal-description figure { margin: 20px 0; }
.modal-description img { max-width: 100%; height: auto; border-radius: 12px; margin: 10px 0; }

.modal-meta {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loader i {
    font-size: 32px;
    margin-bottom: 12px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.no-content, .no-events, .no-posts {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.dark-mode .content-card, .dark-mode .event-card, .dark-mode .post-card {
    background: rgba(3, 99, 53, 0.2);
    border-color: rgba(219, 141, 13, 0.3);
}

.dark-mode .content-title, .dark-mode .event-title, .dark-mode .post-title, .dark-mode .section-title {
    color: var(--primary-gold);
}

.dark-mode .modal-content {
    background: #061e14;
    border-color: rgba(219, 141, 13, 0.2);
}

.dark-mode .modal-title {
    color: var(--primary-gold);
}

.dark-mode .modal-meta {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 600px) {
    .modal-image { height: 200px; }
    .modal-body { padding: 20px; }
    .modal-title { font-size: 1.4rem; }
}