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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #020617;
    color: white;
    overflow: hidden;
}

#map-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    z-index: 5;
}
#map {
    width: 100%;
    height: 100%;
}

/* Hide Cesium Watermark/Credits */
.cesium-viewer-bottom {
    display: none !important;
}

/* Event Card Styles */
#event-card {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 350px;
    max-height: calc(100vh - 100px);
    background: rgba(23, 23, 23, 0.95);
    color: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(23, 23, 23, 0.98);
    z-index: 10;
}

.card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #06b6d4;
}

.card-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
}

.card-body {
    padding: 16px;
}

.card-body p {
    margin: 8px 0;
    font-size: 0.9rem;
}

.description {
    margin: 16px 0;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
}

.comments-list {
    margin: 16px 0;
    max-height: 200px;
    overflow-y: auto;
}

.comment {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.comments-section {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
}

.comments-section h4 {
    font-size: 0.9rem;
    color: #06b6d4;
    margin-bottom: 8px;
}

.comment-item {
    font-size: 0.85rem;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    margin-bottom: 5px;
}

.vote-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.vote-buttons .ui-btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 6px;
}

#comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

#comment-form textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px;
    border-radius: 4px;
    resize: vertical;
    min-height: 60px;
}

#comment-form button {
    background: #06b6d4;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#comment-form button:hover {
    background: #0891b2;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    overflow-y: auto; /* Allow the overlay to scroll if needed */
    padding: 20px 0;
}

.modal-content {
    background: #1f1f1f;
    width: 400px;
    max-width: 95%;
    max-height: 90vh; /* Don't exceed screen height */
    overflow-y: auto; /* Internal scroll */
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: #06b6d4;
    margin: 0;
    font-size: 1.5rem;
}

.close-modal {
    font-size: 2rem;
    cursor: pointer;
    color: #888;
}

.close-modal:hover {
    color: white;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #ccc;
}

.form-group input, .form-group textarea {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
}

.form-group textarea {
    height: 100px;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background: #06b6d4;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.submit-btn:hover {
    background: #0891b2;
}

#add-event-btn.active {
    background: #f43f5e !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.locked-msg {
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    color: #888;
    font-style: italic;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.country-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.country-item input {
    margin: 0;
}

.ui-btn.secondary {
    background: #4b5563;
}

.ui-btn.danger {
    background: #e11d48;
}

.ui-btn.danger:hover {
    background: #be123c;
}

.delete-link {
    color: #f43f5e;
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 10px;
    text-decoration: underline;
    opacity: 0.7;
}

.delete-link:hover {
    opacity: 1;
}

/* Sidebar Styles */
#sidebar {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 300px;
    max-height: calc(100vh - 100px);
    background: rgba(23, 23, 23, 0.85);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    color: white;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    color: #06b6d4;
    margin-bottom: 8px;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Desktop hidden */
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.sidebar-tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: white;
    border-bottom-color: #06b6d4;
}

.sidebar-content {
    overflow-y: auto;
    padding: 12px;
}

.event-list-item {
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.event-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.event-list-item h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: #eee;
}

.event-list-item p {
    font-size: 0.75rem;
    color: #aaa;
}

/* Voting & Share Styles */
.actions-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    align-items: center;
}

.vote-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.vote-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.vote-btn.useful:hover { border-color: #22c55e; color: #22c55e; }
.vote-btn.not-useful:hover { border-color: #ef4444; color: #ef4444; }

.share-btn {
    background: none;
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
}

.share-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-rank {
    color: #06b6d4;
    font-weight: bold;
    margin-right: 8px;
}

.leaderboard-score {
    color: #22c55e;
    font-weight: bold;
}


#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(2, 6, 23, 0.9) 0%, rgba(2, 6, 23, 0) 100%);
    z-index: 100;
    pointer-events: auto;
}

#header h1 {
    font-size: 20px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    pointer-events: auto;
}

.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
    pointer-events: auto;
}

.hamburger-btn span {
    width: 30px;
    height: 3px;
    background: #06b6d4;
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    pointer-events: auto;
}

.ui-btn {
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.ui-btn:hover {
    background: rgba(59, 130, 246, 0.4);
}

/* Compass Button Styles - Reverso-like floating panel */
#compass-container {
    position: fixed;
    right: 20px;
    top: 40%;
    transform: translateY(-50%);
    z-index: 2147483647;
    pointer-events: auto;
}

#compass-container .reverso-compass {
    display: flex;
    padding: 4px;
    box-sizing: border-box;
    border: 1px solid #dee4e7;
    border-right: none;
    background: white;
    box-shadow: 0 4px 20px 0 rgba(34, 44, 49, 0.1);
    border-radius: 8px 0 0 8px;
    width: 48px;
}

#compass-container .reverso-compass-btn {
    border: none;
    background-color: transparent;
    padding: 0;
    cursor: pointer;
    display: flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
}

#compass-container .reverso-compass-btn:hover {
    background-color: #f7f9f9;
}

#compass-container .reverso-compass-icon {
    width: 34px;
    height: 34px;
    transition: transform 0.2s ease;
}

/* Dropdown Menu Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: rgba(15, 23, 42, 0.95);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
    z-index: 1000;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    margin-top: 5px;
    backdrop-filter: blur(8px);
}

.dropdown.open .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: #f1f5f9;
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.dropdown-content a:first-child { border-top-left-radius: 6px; border-top-right-radius: 6px; }
.dropdown-content a:last-child { border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }

.dropdown-content a:hover {
    background-color: rgba(59, 130, 246, 0.3);
    color: white;
}

.logout-btn {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
    pointer-events: auto;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messaging System Styles */
.chat-content {
    width: 600px !important;
    height: 700px;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column-reverse; /* CSS trick: browser naturally anchors to "top" which is visually the bottom */
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    scroll-behavior: smooth;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.message-sent {
    align-self: flex-end;
    background: #1e40af;
    color: white;
    border-bottom-right-radius: 2px;
}

.message-received {
    align-self: flex-start;
    background: #334155;
    color: #f1f5f9;
    border-bottom-left-radius: 2px;
}

.message-info {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
}

.chat-input-area {
    padding: 16px;
    background: rgba(30, 41, 59, 0.5);
    display: flex;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-area textarea {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 6px;
    padding: 10px;
    resize: none;
    height: 40px;
    font-family: inherit;
}

.send-btn {
    padding: 0 20px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #1d4ed8;
}

.chat-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.chat-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.new-chat-btn {
    width: 100%;
    padding: 8px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 6px;
    margin-bottom: 12px;
    cursor: pointer;
}

.e2ee-disclaimer {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    margin-bottom: 15px;
    line-height: 1.3;
}

.unseen-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
}

.unseen-badge {
    background-color: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

.seen-check {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: 4px;
}

.seen-check.double {
    color: #38bdf8;
}

/* Ad Banner Styles */
#ad-banner {
    position: fixed;
    bottom: 0;
    left: 33%; /* Landscape: leave the left third for #map-attribution */
    right: 0;
    height: 10vh; /* Landscape only — overridden in body.is-portrait */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 40px;
    z-index: 150; /* High z-index to stay on top */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
    box-sizing: border-box;
}

#map-attribution {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 67%; /* Landscape: fill the empty third on the left */
    height: 10vh; /* Landscape only — overridden in body.is-portrait */
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 14px;
    font-size: 11px;
    line-height: 1.4;
    z-index: 150;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
}

#map-attribution a {
    color: white;
    text-decoration: underline;
}

#ui-top-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

#ui-top-wrapper > * {
    pointer-events: auto;
}

.ad-content {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 800px;
}

.ad-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748b;
    border: 1px solid #64748b;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

#ad-banner p {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin: 0;
}

.ad-link {
    background: #f59e0b;
    color: #000;
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: transform 0.2s;
}

.ad-link:hover {
    transform: translateY(-1px);
    background: #fbbf24;
}

#map {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
}

.validation-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
}

/* Custom UI Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
}

.custom-ui-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-width: 95%;
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    z-index: 2001;
    color: white;
    display: flex;
    flex-direction: column;
}

.ui-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ui-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #fbbf24;
}

.ui-modal-body {
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ui-modal-body input, .ui-modal-body textarea {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    box-sizing: border-box;
}

.ui-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ui-btn-confirm {
    background: #2563eb;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.ui-btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.ui-btn-confirm:hover { background: #3b82f6; }
.ui-btn-cancel:hover { background: rgba(255, 255, 255, 0.2); }

/* --- Mobile Responsiveness & Orientation --- */

/* Base responsive tweaks */
@media (max-width: 768px) {
    #header {
        padding: 10px 20px;
    }

    #header h1 {
        font-size: 16px;
    }

    .controls {
        gap: 8px;
    }

    .ui-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Dashboard adjustments */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .chart-card {
        height: 300px;
    }

    .header h1 {
        font-size: 1.5rem;
    }
}

/* Portrait Mode Specifics */
body.is-portrait #ad-banner {
    position: static;
    width: 100%;
    left: 0;
    height: auto; /* Reset landscape's 10vh */
    padding: 10px 20px;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.98);
    box-sizing: border-box;
}

body.is-portrait #map-attribution {
    position: static;
    width: 100%;
    right: auto;
    height: auto; /* Reset landscape's 10vh */
    padding: 6px 15px;
    font-size: 10px;
    text-align: center;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.85);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

body.is-portrait #header {
    position: static;
    width: 100%;
    background: rgba(2, 6, 23, 0.98);
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.is-portrait .hamburger-btn {
    display: flex;
    flex-shrink: 0;
    width: 44px; /* Larger hit area */
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: -10px; /* Offset padding */
}

body.is-portrait .hamburger-btn span {
    width: 30px;
    height: 3px;
    margin: 3px 0; /* Space them out a bit */
}

body.is-portrait .controls {
    display: none; /* Hidden by default in portrait */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.98);
    padding: 20px;
    gap: 15px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(12px);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    z-index: 1000;
}

body.is-portrait .controls.open {
    display: flex;
}

body.is-portrait .controls .ui-btn,
body.is-portrait .controls .logout-btn,
body.is-portrait .controls .dropdown {
    width: 100%;
}

body.is-portrait .controls .ui-btn,
body.is-portrait .controls .logout-btn {
    padding: 12px;
    text-align: center;
    justify-content: center;
}

body.is-portrait .controls .dropdown-btn {
    width: 100%;
}

body.is-portrait .controls .dropdown-content {
    position: static;
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    margin-top: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

body.is-portrait .landscape-only {
    display: none !important;
}

body.is-portrait .modal-content, 
body.is-portrait .chat-content, 
body.is-portrait .custom-ui-modal {
    width: 95% !important;
    max-height: 90vh;
}

/* Ensure the map doesn't get hidden */
body.is-portrait #map-container {
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
}

body.is-portrait #sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    z-index: 140;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.is-portrait #sidebar.minimized {
    transform: translateY(calc(100% - 100px));
}

body.is-portrait .sidebar-toggle-btn {
    display: flex;
}

#sidebar.minimized .sidebar-toggle-btn {
    transform: rotate(180deg);
}

body.is-portrait #event-card {
    height: 80vh;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 20px 20px 0 0;
    z-index: 150;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}


/* Group Modal Specific Styles */
.group-modal-content {
    width: 900px !important;
    height: 600px;
    background: rgba(15, 23, 42, 0.98) !important;
    border: 1px solid rgba(59, 130, 246, 0.4) !important;
    display: flex;
    flex-direction: column;
}

.delete-group-event-btn {
    background: #f87171;
    color: white;
    border: none;
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 8px;
}

.delete-group-event-btn:hover {
    background: #ef4444;
}

/* Group Modal Loading States */
.loading-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 100px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

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

/* Group Modal Specific Styles */
.group-modal-layout {
    display: grid;
    grid-template-columns: 200px 1fr 280px;
    gap: 0;
    height: calc(100% - 60px);
    overflow: hidden;
}

.group-members-pane, .group-chat-pane, .group-events-pane {
    overflow-y: auto;
    padding: 10px;
    height: 100%;
}

.group-members-pane {
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.group-chat-pane {
    display: flex;
    flex-direction: column;
}

.group-events-pane {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.member-item {
    padding: 8px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-item:last-child {
    border-bottom: none;
}

.member-role {
    font-size: 0.7rem;
    background: #3b82f6;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
}

.group-event-item {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.group-event-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.group-event-item:last-child {
    border-bottom: none;
}

.event-title {
    font-weight: bold;
    color: #e2e8f0;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.event-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.9);
}

#group-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.7);
    color: white;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    font-family: inherit;
    font-size: 0.9rem;
}

#group-chat-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.send-btn {
    margin-left: 8px;
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.send-btn:hover {
    background: #2563eb;
}

.group-modal-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.group-members-pane {
    width: 200px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
}

.group-events-pane {
    width: 250px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
}

.group-chat-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.group-members-pane h3, .group-events-pane h3 {
    font-size: 0.8rem;
    color: #fbbf24;
    padding: 12px;
    margin: 0;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#group-members-list, #group-recent-events {
    flex: 1;
    overflow-y: auto;
}

.member-item, .group-event-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
}

.member-role {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
}

.group-event-item {
    cursor: pointer;
    transition: background 0.2s;
}

.group-event-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.ge-what {
    font-weight: bold;
    color: #e2e8f0;
    display: block;
}

.ge-meta {
    font-size: 0.7rem;
    color: #64748b;
}

/* Mobile Responsiveness for Group Modal */
body.is-portrait .group-modal-layout {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

body.is-portrait .group-members-pane,
body.is-portrait .group-chat-pane,
body.is-portrait .group-events-pane {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 15px !important;
}

body.is-portrait .group-members-pane {
    display: block;
    height: 140px;
    flex-shrink: 0;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.is-portrait .group-chat-pane {
    display: flex;
    flex-direction: column;
    height: 400px; /* Fixed height for chat area in scrollable modal */
    flex-shrink: 0;
}

body.is-portrait .group-events-pane {
    display: block;
    height: 250px;
    flex-shrink: 0;
    border-left: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.is-portrait .group-modal-content {
    width: 95% !important;
    height: auto !important;
    max-height: 95vh !important;
}

/* --- MapLibre Custom Markers & Popups --- */

.wsm-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wsm-marker:hover {
    transform: scale(1.2) z-index: 999;
}

.wsm-marker-inner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 8px var(--marker-color, #6b7280);
    background-color: var(--marker-color, #6b7280);
    position: relative;
}

/* Pulsing effect for aggressive event types */
.wsm-marker.pulse .wsm-marker-inner::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid var(--marker-color);
    animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

.wsm-marker.private .wsm-marker-inner {
    border: 2px solid #facc15; /* Yellow border for private */
}

/* Popup Customization */
.maplibregl-popup-content {
    background: rgba(15, 23, 42, 0.9) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px !important;
    padding: 12px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    color: white;
}

.maplibregl-popup-tip {
    border-top-color: rgba(15, 23, 42, 0.9) !important;
}

.event-popup h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--marker-color, #f43f5e);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.event-popup p {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.4;
}

.event-popup .popup-who {
    font-weight: 600;
    color: #e2e8f0;
}

.event-popup .popup-what {
    color: #94a3b8;
}

.event-popup .popup-when {
    margin-top: 6px;
    font-size: 10px;
    color: #64748b;
    font-family: monospace;
}
