/* ==========================================
   1. GLOBAL SYSTEM VARIABLES & CORE LAYOUT
   ========================================== */
:root {
    --bg-dark: #030308;
    --card-glass: rgba(10, 10, 20, 0.75);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-glow: #e0a96d;
    --accent-purple: #c084fc;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    color: #f3f4f6;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#cosmic-fx-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    pointer-events: none;
}

.leaflet-container {
    cursor: crosshair !important;
}

/* ==========================================
   2. TYPOGRAPHY & HEADER
   ========================================== */
.main-header {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    text-align: center;
    pointer-events: none;
}

.main-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin: 0;
    background: linear-gradient(135deg, #f3f4f6 40%, var(--accent-glow));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.main-header .subtitle {
    margin-top: 4px;
    font-size: 0.9rem;
    color: rgba(243, 244, 246, 0.6);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ==========================================
   2b. LOCATION SEARCH
   ========================================== */
.search-container {
    position: absolute;
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 420px;
    max-width: 92vw;
    pointer-events: none;
}

.search-box {
    position: relative;
    pointer-events: auto;
    background: var(--card-glass);
    border: 1px solid var(--border-glass);
    border-radius: 50px;
    backdrop-filter: blur(14px) saturate(140%);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55), 0 0 20px rgba(192, 132, 252, 0.12);
    display: flex;
    align-items: center;
    padding: 6px 6px 6px 18px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
    border-color: rgba(192, 132, 252, 0.45);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6), 0 0 24px rgba(192, 132, 252, 0.22);
}

.search-icon {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.55);
    margin-right: 10px;
    line-height: 1;
}

#location-search {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: none;
    color: #f3f4f6;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    padding: 10px 0;
}

#location-search::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.search-clear {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

.search-clear.visible {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(10, 10, 20, 0.92);
    border: 1px solid rgba(192, 132, 252, 0.25);
    border-radius: 18px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65), 0 0 18px rgba(192, 132, 252, 0.18);
    backdrop-filter: blur(12px) saturate(150%);
    display: none;
    max-height: 260px;
    overflow: auto;
    padding: 6px;
}

.search-results.open {
    display: block;
}

.search-result-item {
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    color: #f3f4f6;
    font-size: 13px;
    line-height: 1.35;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.search-result-item:hover, .search-result-item.active {
    background: rgba(192, 132, 252, 0.12);
    border-color: rgba(192, 132, 252, 0.25);
}

.search-result-item .result-type {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.search-results::-webkit-scrollbar {
    width: 5px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(192, 132, 252, 0.35);
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(192, 132, 252, 0.6);
}

/* ==========================================
   3. ADVANCED MEMORY INPUT GLASS BOX
   ========================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 8, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100000 !important;
    display: none;
    align-items: center;
    justify-content: center;
}

body.modal-open #world-chat-toggle,
body.modal-open #pet-root,
body.modal-open .pet-toggle-btn {
    display: none !important;
}

/* Only block the tile/drag layer, NOT the popup pane */
body.popup-active .leaflet-tile-pane,
body.popup-active .leaflet-drag-target {
    pointer-events: none !important;
}

/* Ensure popup pane and its contents are always clickable */
.leaflet-popup-pane,
.leaflet-popup-pane * {
    pointer-events: auto !important;
}

.react-btn,
.comment-send-btn,
.comment-input-field,
.comment-toggle {
    pointer-events: auto !important;
    position: relative;
    z-index: 1000;
}

body.chat-open #world-chat-toggle {
    display: none !important;
}

.glass-card {
    position: relative;
    overflow: hidden;
    background: var(--card-glass);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s ease;
}

/* Holographic Rotating Active Scan Layer */
.glass-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        transparent, 
        rgba(192, 132, 252, 0.1), 
        rgba(224, 169, 109, 0.25), 
        rgba(192, 132, 252, 0.1), 
        transparent 60%
    );
    animation: rotate-hologram 8s linear infinite;
    pointer-events: none;
    z-index: 0;
}

.glass-card::after {
    content: '';
    position: absolute;
    inset: 1px;
    background: linear-gradient(135deg, rgba(12, 12, 26, 0.96), rgba(6, 6, 14, 0.98));
    border-radius: 23px;
    z-index: 1;
    pointer-events: none;
}

.glass-card > * {
    position: relative;
    z-index: 2;
}

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

/* X Cancel Close Button */
.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.modal-close-btn:hover {
    color: #fff;
    background: rgba(192, 132, 252, 0.18);
    border-color: rgba(192, 132, 252, 0.45);
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
    transform: scale(1.1);
}

.modal-close-btn:active {
    transform: scale(0.95);
}

/* Cyberpunk Telemetry HUD Header Styles */
.modal-telemetry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 16px;
    margin-bottom: 20px;
    padding-right: 40px;
}

.glass-card h3 {
    margin: 0 0 4px 0;
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: #fff;
}

.system-status {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
}

.blink-green {
    color: #34d399;
    animation: text-pulse 1.5s infinite ease-in-out;
}

.matrix-coords {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    color: var(--accent-glow);
    background: rgba(224, 169, 109, 0.08);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(224, 169, 109, 0.2);
}

@keyframes text-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Form Fields Optimization */
textarea {
    width: 100%;
    height: 120px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 16px;
    box-sizing: border-box;
    color: #f0e6ff;
    resize: none;
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    font-style: italic;
    letter-spacing: 0.3px;
    line-height: 1.7;
    margin-bottom: 20px;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

textarea:focus {
    outline: none;
    background: rgba(192, 132, 252, 0.03);
    border-color: rgba(192, 132, 252, 0.5);
    box-shadow: 0 0 15px rgba(192, 132, 252, 0.15);
}

.dropzone {
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.01);
    border-radius: 14px;
    padding: 26px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropzone:hover {
    border-color: var(--accent-glow);
    background: rgba(224, 169, 109, 0.02);
    box-shadow: inset 0 0 15px rgba(224, 169, 109, 0.05);
}

.dropzone span {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.preview-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
}

/* ==========================================
   4. INTERACTIVE BUTTONS
   ========================================== */
.main-btn {
    position: relative;
    overflow: hidden;
    width: 100%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-glow));
    border: none;
    border-radius: 50px;
    color: #000;
    font-weight: 800;
    padding: 14px;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.main-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(192, 132, 252, 0.4);
}

.main-btn:active {
    transform: scale(0.97) translateY(0);
}

/* ==========================================
   5. DYNAMIC GLOWING MARKERS & MAP CONSTELLATION
   ========================================== */
#map .leaflet-marker-icon.custom-pulsing-marker {
    background: none !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    margin-left: -10px !important;
    margin-top: -10px !important;
}

.marker-glow {
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    background-color: var(--glow-color, var(--accent-purple)) !important; 
    box-shadow: 0 0 12px var(--glow-color, var(--accent-purple)), 
                0 0 25px var(--glow-color, var(--accent-purple)) !important;
    animation: glow-pulse 2s infinite ease-in-out !important;
    display: block !important;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

@keyframes glow-pulse {
    0%, 100% {
        transform: scale(0.85);
        opacity: 0.7;
        box-shadow: 0 0 10px var(--glow-color, var(--accent-purple)), 
                    0 0 20px var(--glow-color, var(--accent-purple));
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 22px var(--glow-color, var(--accent-purple)), 
                    0 0 45px var(--glow-color, var(--accent-purple));
    }
}

#map .leaflet-marker-icon.custom-pulsing-marker:hover .marker-glow {
    transform: scale(1.55);
    box-shadow: 0 0 18px var(--glow-color, var(--accent-purple)), 
                0 0 40px var(--glow-color, var(--accent-purple)) !important;
}

/* Orbiting dash structures on vector array */
.animated-gradient-star-trail {
    stroke-dasharray: 6, 10;
    animation: flow-trail 12s linear infinite !important;
}

@keyframes flow-trail {
    from { stroke-dashoffset: 400; }
    to { stroke-dashoffset: 0; }
}

.leaflet-tile-container img {
    filter: brightness(0.8) contrast(1.2) saturate(0.9) !important;
}

/* ==========================================
   6. PREMIUM LEAFLET POPUP CARD DESIGN
   ========================================== */
.leaflet-popup-content-wrapper {
    background: 
        radial-gradient(circle at top left, rgba(192, 132, 252, 0.18), transparent 70%),
        radial-gradient(circle at bottom right, rgba(224, 169, 109, 0.12), transparent 70%),
        linear-gradient(135deg, rgba(10, 10, 22, 0.95), rgba(5, 5, 12, 0.98)) !important;
    backdrop-filter: blur(16px) saturate(180%) !important;
    border: 1px solid rgba(192, 132, 252, 0.25) !important;
    border-radius: 20px !important;
    box-shadow: 
        0 15px 45px rgba(0, 0, 0, 0.8), 
        0 0 30px rgba(192, 132, 252, 0.15),
        inset 0 0 15px rgba(255, 255, 255, 0.02) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-tip {
    background: rgba(13, 13, 25, 0.95) !important;
    border-left: 1px solid rgba(192, 132, 252, 0.3);
    border-bottom: 1px solid rgba(192, 132, 252, 0.3);
}

.popup-card {
    color: #f3f4f6;
    font-family: 'Inter', sans-serif;
    padding: 20px;
    max-width: 280px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: center;
}

.popup-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.popup-icon { font-size: 16px; display: flex; align-items: center; }
.popup-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; line-height: 1; }
.popup-card-body { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }

.memory-time-posted {
    margin-left: auto;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.3px;
    white-space: nowrap;
    align-self: center;
}

.popup-story {
    font-size: 15px;
    font-family: 'DM Serif Display', 'Playfair Display', serif;
    font-style: italic;
    font-weight: 400;
    line-height: 1.7;
    color: #ede0ff;
    letter-spacing: 0.2px;
    margin: 0 !important;
    word-break: break-word;
    text-align: left;
    max-height: 120px;
    overflow-y: auto;
    padding-right: 6px;
}

.popup-story::-webkit-scrollbar { width: 4px; }
.popup-story::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); border-radius: 10px; }
.popup-story::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; }
.popup-story::-webkit-scrollbar-thumb:hover { background: var(--accent-purple); }

.popup-image-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(192, 132, 252, 0.3);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(192, 132, 252, 0.1);
}

.popup-image-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
    display: block;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.popup-image-preview:hover { transform: scale(1.03); }
.leaflet-container a.leaflet-popup-close-button { color: rgba(255, 255, 255, 0.4) !important; padding: 16px 16px 0 0 !important; font-size: 16px !important; }

/* Popup reactions & comments */
.popup-reactions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 4px;
}

.react-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f3f4f6;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.react-btn:hover {
    background: rgba(192, 132, 252, 0.18);
    border-color: rgba(192, 132, 252, 0.45);
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.25);
}

.comment-toggle {
    background: rgba(255, 255, 255, 0.06);
}

.comments-section {
    margin-top: 8px;
    border-top: 1px solid rgba(192, 132, 252, 0.15);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comments-list {
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}

.comments-list::-webkit-scrollbar { width: 3px; }
.comments-list::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); border-radius: 10px; }
.comments-list::-webkit-scrollbar-thumb { background: rgba(192,132,252,0.4); border-radius: 10px; }

.comment-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 15, 30, 0.85);
    border: 1px solid rgba(192, 132, 252, 0.25);
    border-radius: 999px;
    padding: 6px 6px 6px 14px;
    backdrop-filter: blur(12px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-input-wrapper:focus-within {
    border-color: rgba(192, 132, 252, 0.6);
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.2);
}

.comment-input-field {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #f3f4f6;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    padding: 0;
    touch-action: manipulation;
}

.comment-input-field::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.comment-send-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #c084fc, #a855f7);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.35);
}

.comment-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(192, 132, 252, 0.55);
}

.comment-send-btn:active {
    transform: scale(0.95);
}

.comments-empty {
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    padding: 8px 0;
}

.comment-row {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 0;
}

.comment-row:first-child { border-top: none; }

.comment-text {
    font-size: 12px;
    color: rgba(243, 244, 246, 0.95);
    line-height: 1.35;
    word-break: break-word;
}

.comment-meta {
    font-size: 10px;
    color: rgba(243, 244, 246, 0.45);
    margin-top: 3px;
}

.comments-input-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.mem-input {
    flex: 1 1 auto;
    min-width: 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #f3f4f6;
    padding: 8px 10px;
    font-size: 12px;
    outline: none;
    height: 34px;
    box-sizing: border-box;
}

.mem-post {
    flex: 0 0 auto;
    background: rgba(192, 132, 252, 0.85);
    color: #fff;
    border: none;
    padding: 0 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    font-size: 12px;
    height: 34px;
    box-sizing: border-box;
    white-space: nowrap;
}

.mem-post:hover {
    background: rgba(192, 132, 252, 1);
}

/* ==========================================
    7. COMPANION PET OVERLAY
    ========================================== */
.pet-overlay {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.pet-overlay:hover {
    transform: scale(1.05);
}

.pet-sprite {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    background: rgba(10, 10, 22, 0.8);
    border: 1px solid rgba(192, 132, 252, 0.3);
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(192, 132, 252, 0.2), 0 0 15px rgba(192, 132, 252, 0.1);
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    position: relative;
}

.pet-sprite:hover {
    box-shadow: 0 6px 28px rgba(192, 132, 252, 0.35), 0 0 20px rgba(192, 132, 252, 0.2);
}

.pet-shadow {
    position: absolute;
    bottom: -4px;
    width: 40px;
    height: 6px;
    background: radial-gradient(ellipse, rgba(0,0,0,0.4), transparent);
    border-radius: 50%;
    animation: pet-shadow-pulse 2s infinite ease-in-out;
}

@keyframes pet-shadow-pulse {
    0%, 100% { transform: scaleX(1); opacity: 0.4; }
    50% { transform: scaleX(0.8); opacity: 0.2; }
}

/* Pet body & parts - hidden visually since we use emoji */
.pet-body, .pet-tail, .pet-face, .pet-eye, .pet-brow, .pet-mouth,
.pet-ears, .pet-ear, .pet-legs, .pet-leg, .pet-sparkles {
    display: none;
}

#pet-speech {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    left: auto;
    transform: none;
    background: rgba(13, 11, 26, 0.95);
    border: 1px solid rgba(192, 132, 252, 0.3);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 12px;
    color: #e2e8f0;
    max-width: 220px;
    white-space: normal;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 12px rgba(192, 132, 252, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(5px);
    line-height: 1.4;
}

#pet-speech::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    left: auto;
    transform: none;
    border: 6px solid transparent;
    border-top-color: rgba(13, 11, 26, 0.95);
}

#pet-speech.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ==========================================
   7b. PET POPUP
   ========================================== */
.pet-popup {
    position: fixed;
    bottom: 160px;
    right: 20px;
    z-index: 1003;
    background: rgba(10, 10, 22, 0.95);
    border: 1px solid rgba(192, 132, 252, 0.3);
    border-radius: 20px;
    padding: 20px;
    min-width: 240px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7), 0 0 30px rgba(192, 132, 252, 0.12);
    backdrop-filter: blur(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.pet-popup-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 10px;
    text-align: center;
}

.pet-popup-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 0;
    color: #cbd5e1;
}

.pet-popup-label {
    color: rgba(255,255,255,0.5);
}

.pet-popup-actions {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.pet-popup-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    border-radius: 999px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    align-self: flex-end;
}

.pet-popup-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-purple);
}

/* Pet Selector Row */
.pet-selector-container {
    width: 100%;
}

.pet-selector-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.pet-select-btn {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 8px 4px;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.pet-select-btn:hover {
    background: rgba(192, 132, 252, 0.08);
    border-color: rgba(192, 132, 252, 0.3);
    color: #fff;
}

.pet-select-btn.active {
    background: rgba(192, 132, 252, 0.15);
    border-color: var(--accent-purple);
    color: #fff;
    box-shadow: 0 0 12px rgba(192, 132, 252, 0.2);
}

/* ==========================================
   8. DYNAMIC ADJACENT POPUP PET BUBBLE
   ========================================== */
.pet-popup-bubble {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(15px) scale(0.9);
    background: rgba(13, 11, 26, 0.95);
    border: 1px solid var(--accent-purple);
    border-radius: 16px;
    padding: 16px;
    width: 200px;
    color: #f3f4f6;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.65), 0 0 20px rgba(192, 132, 252, 0.25);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.pet-bubble-header {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(192, 132, 252, 0.2);
    padding-bottom: 6px;
}

.pet-avatar { font-size: 15px; display: inline-flex; align-items: center; }
.pet-name { font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.pet-bubble-body { font-size: 13px; line-height: 1.5; color: #e2e8f0; }

.pet-popup-bubble::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: transparent var(--accent-purple) transparent transparent;
}

.pet-popup-bubble.active {
    opacity: 1;
    transform: translateY(-50%) translateX(25px) scale(1);
}

/* Ensure the inner card is positioned relatively */
.modal-card {
    position: relative;
}

/* ==========================================
    9. WORLD CHAT DRAWER
    ========================================== */
#world-chat-toggle {
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 10000;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 8, 20, 0.45);
    backdrop-filter: blur(18px) saturate(180%);
    color: #f3f4f6;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6), 0 0 22px rgba(192, 132, 252, 0.18);
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

#world-chat-toggle:hover {
    transform: translateY(-3px) scale(1.03);
    border-color: rgba(192, 132, 252, 0.55);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.75), 0 0 30px rgba(192, 132, 252, 0.28);
}

#world-chat-toggle:active {
    transform: translateY(0) scale(0.97);
}

.chat-toggle-icon {
    font-size: 24px;
    line-height: 1;
    filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.55));
}

.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 21px;
    height: 21px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(244, 114, 182, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 21px;
    text-align: center;
    box-shadow: 0 0 14px rgba(244, 114, 182, 0.7), inset 0 0 6px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px);
}

.world-chat-panel {
    position: fixed;
    bottom: 155px;
    right: 24px;
    z-index: 9999;
    width: 370px;
    max-width: calc(100vw - 32px);
    max-height: 540px;
    display: none;
    flex-direction: column;
    background: rgba(10, 10, 28, 0.52);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    backdrop-filter: blur(24px) saturate(180%);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.8), 0 0 36px rgba(192, 132, 252, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.world-chat-panel.open {
    display: flex;
}

.world-chat-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.08), rgba(224, 169, 109, 0.06), rgba(56, 189, 248, 0.04));
    pointer-events: none;
    z-index: 0;
}

.world-chat-panel > * {
    position: relative;
    z-index: 1;
}

.world-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(8px);
}

.world-chat-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: #fff;
    text-shadow: 0 0 18px rgba(192, 132, 252, 0.35);
    letter-spacing: 0.2px;
}

.world-chat-status {
    margin-top: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.4px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.85), 0 0 24px rgba(52, 211, 153, 0.35);
    animation: live-pulse 1.6s infinite ease-in-out;
}

@keyframes live-pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.15); }
}

.world-chat-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    padding: 5px 11px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    backdrop-filter: blur(8px);
}

.world-chat-close:hover {
    color: #fff;
    border-color: rgba(192, 132, 252, 0.55);
    box-shadow: 0 0 16px rgba(192, 132, 252, 0.22), inset 0 0 12px rgba(192, 132, 252, 0.08);
    background: rgba(192, 132, 252, 0.1);
}

.chat-messages-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 390px;
    overflow-y: auto;
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-messages-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.3);
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(192, 132, 252, 0.5), rgba(56, 189, 248, 0.4));
    border-radius: 12px;
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.45), 0 0 28px rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(192, 132, 252, 0.7), rgba(56, 189, 248, 0.6));
    box-shadow: 0 0 18px rgba(192, 132, 252, 0.6), 0 0 34px rgba(56, 189, 248, 0.3);
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    backdrop-filter: blur(10px) saturate(140%);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), 0 0 12px rgba(192, 132, 252, 0.08);
    animation: chat-in 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-message:hover {
    border-color: rgba(192, 132, 252, 0.28);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 18px rgba(192, 132, 252, 0.14);
}

@keyframes chat-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-message-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.chat-message-username {
    font-weight: 800;
    font-size: 12px;
    color: var(--accent-glow);
    letter-spacing: 0.3px;
    text-shadow: 0 0 10px rgba(224, 169, 109, 0.35);
}

.chat-message-time {
    font-size: 10px;
    color: rgba(243, 244, 246, 0.4);
    letter-spacing: 0.3px;
}

.chat-timestamp {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.3px;
    white-space: nowrap;
    align-self: flex-start;
}

.chat-message-text {
    font-size: 13px;
    color: rgba(243, 244, 246, 0.92);
    line-height: 1.45;
    word-break: break-word;
}

.chat-form {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(10px);
}

.chat-username {
    width: 90px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: #f3f4f6;
    padding: 9px 12px;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.chat-username:focus {
    border-color: rgba(192, 132, 252, 0.5);
    box-shadow: 0 0 14px rgba(192, 132, 252, 0.18), inset 0 0 10px rgba(192, 132, 252, 0.04);
    background: rgba(192, 132, 252, 0.05);
}

.chat-username::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

.chat-message-input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: #f3f4f6;
    padding: 9px 12px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.chat-message-input:focus {
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.18), inset 0 0 10px rgba(56, 189, 248, 0.04);
    background: rgba(56, 189, 248, 0.05);
}

.chat-message-input::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

.chat-send-btn {
    flex: 0 0 auto;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.9), rgba(139, 92, 246, 0.9));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 9px 14px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    font-size: 12px;
    white-space: nowrap;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 20px rgba(192, 132, 252, 0.35), 0 0 14px rgba(139, 92, 246, 0.25);
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    backdrop-filter: blur(6px);
}

.chat-send-btn:hover {
    background: linear-gradient(135deg, rgba(192, 132, 252, 1), rgba(139, 92, 246, 1));
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(192, 132, 252, 0.5), 0 0 22px rgba(139, 92, 246, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0) scale(0.97);
}

/* How It Works — fixed top-right circle */
.how-it-works-circle-btn {
    position: fixed !important;
    top: 16px;
    right: 16px;
    z-index: 99999 !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: rgba(15, 15, 30, 0.85) !important;
    border: 1px solid rgba(192, 132, 252, 0.4) !important;
    color: #ffffff !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(192, 132, 252, 0.2);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
    pointer-events: auto;
    padding: 0;
}

.how-it-works-circle-btn:hover {
    border-color: rgba(192, 132, 252, 0.7) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 16px rgba(192, 132, 252, 0.35);
}

.how-it-works-circle-btn:active {
    transform: scale(0.92);
}

/* ==========================================
   11. HOW IT WORKS MODAL
   ========================================== */
.cosmic-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 110000;
    background: rgba(3, 3, 8, 0.72);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.cosmic-modal-card {
    position: relative;
    background: rgba(20, 20, 35, 0.95);
    border: 1px solid rgba(192, 132, 252, 0.35);
    border-radius: 24px;
    padding: 36px 32px 28px;
    max-width: 460px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow:
        0 0 0 1px rgba(192, 132, 252, 0.12),
        0 24px 60px rgba(0, 0, 0, 0.75),
        0 0 40px rgba(192, 132, 252, 0.12);
    scrollbar-width: thin;
    scrollbar-color: rgba(192, 132, 252, 0.4) transparent;
}

.cosmic-modal-card::-webkit-scrollbar { width: 4px; }
.cosmic-modal-card::-webkit-scrollbar-thumb { background: rgba(192, 132, 252, 0.4); border-radius: 10px; }

.cosmic-modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.cosmic-modal-icon {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 12px rgba(192, 132, 252, 0.6));
}

.cosmic-modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #f3f4f6 40%, var(--accent-purple));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cosmic-modal-subtitle {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.55;
    margin: 0;
}

/* Steps */
.cosmic-steps {
    list-style: none;
    margin: 0 0 28px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cosmic-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(192, 132, 252, 0.14);
    border-radius: 14px;
    padding: 14px 16px;
}

.cosmic-step-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.25), rgba(168, 85, 247, 0.15));
    border: 1px solid rgba(192, 132, 252, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-purple);
    letter-spacing: 0.5px;
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.2);
}

.cosmic-step strong {
    display: block;
    font-size: 0.92rem;
    color: #f3f4f6;
    margin-bottom: 4px;
}

.cosmic-step p {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
}

/* Creator section */
.cosmic-creator {
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 22px;
    margin-bottom: 20px;
}

.cosmic-creator-label {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 0 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cosmic-creator-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    color: var(--accent-purple);
    margin: 0 0 14px;
    text-shadow: 0 0 16px rgba(192, 132, 252, 0.45);
}

.ig-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 999px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 20px rgba(220, 39, 67, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ig-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(220, 39, 67, 0.55);
}

.ig-btn:active {
    transform: scale(0.97);
}

/* Footer tagline */
.cosmic-modal-footer {
    text-align: center;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.45);
    font-style: italic;
    margin: 0;
    padding-top: 4px;
}

@media (max-width: 600px) {
    .cosmic-modal-card {
        padding: 28px 18px 22px;
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
    }
    .cosmic-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

/* ==========================================
    10. MOBILE RESPONSIVE (max-width: 600px)
    ========================================== */
@media (max-width: 600px) {
    .main-header {
        top: 12px;
        padding: 0 12px;
    }

    .main-header h1 {
        font-size: 1.4rem;
        letter-spacing: -0.5px;
    }

    .main-header .subtitle {
        display: none !important;
    }

    /* Collapsible search icon on mobile — top-left, below title */
    .search-container {
        top: 64px;
        left: 12px;
        right: auto;
        transform: none;
        width: 44px;
        transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .search-container.search-expanded {
        width: calc(100vw - 24px);
    }

    .search-box {
        height: 38px;
        padding: 6px;
        justify-content: center;
        transition: padding 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .search-container.search-expanded .search-box {
        padding: 6px 6px 6px 14px;
        justify-content: flex-start;
    }

    #location-search {
        width: 0;
        opacity: 0;
        pointer-events: none;
        transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.2s ease;
    }

    .search-container.search-expanded #location-search {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    .search-icon {
        font-size: 16px;
        margin-right: 0;
        cursor: pointer;
        transition: margin-right 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .search-container.search-expanded .search-icon {
        margin-right: 8px;
    }

    .search-container:not(.search-expanded) .search-clear {
        display: none !important;
    }

    /* Modal full-screen on mobile */
    .glass-card {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        padding: 24px 18px;
        box-sizing: border-box;
    }

    .modal {
        align-items: flex-end;
    }

    textarea {
        height: 90px;
        font-size: 16px; /* prevents iOS zoom */
    }

    /* Pet: bottom-left */
    .pet-overlay {
        bottom: 16px;
        left: 16px;
        right: auto;
    }

    .pet-sprite {
        width: 48px;
        height: 48px;
        font-size: 28px;
    }

    .pet-emoji-display {
        font-size: 28px !important;
    }

    /* Speech bubble anchors left on mobile */
    #pet-speech {
        right: auto;
        left: 0;
    }

    #pet-speech::after {
        right: auto;
        left: 20px;
    }

    /* Pet popup opens upward on left side */
    .pet-popup {
        bottom: 70px;
        left: 0;
        right: auto;
        min-width: 200px;
        max-width: 80vw;
    }

    /* Chat toggle: bottom-right */
    #world-chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .chat-toggle-icon {
        font-size: 20px;
    }

    /* Chat panel slides up from bottom */
    #world-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 65vh;
        max-height: 65vh;
        border-radius: 22px 22px 0 0;
    }

    .chat-username {
        width: 80px;
        font-size: 14px;
    }

    .chat-message-input {
        font-size: 16px; /* prevents iOS zoom */
    }
}