/* --- Base Variables & Reset --- */
:root { 
    --primary: #5cbc8e; 
    --primary-hover: #65c899; 
    --bg-color: #f8f9fa; 
    --card-bg: #ffffff; 
    --text-main: #1a1a1a; 
    --text-muted: #6c757d; 
    --border-color: #e9ecef; 
    --danger: #ef5350; 
}

/* Dark Mode Theme overrides */
body.dark-mode {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #f8f9fa;
    --text-muted: #adb5bd;
    --border-color: #333333;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Custom Scrollbar for the whole app and Chat Box */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    background-image: radial-gradient(circle at 10% 90%, rgba(92, 188, 142, 0.15) 0%, transparent 40%), 
                      radial-gradient(circle at 90% 10%, rgba(92, 188, 142, 0.15) 0%, transparent 40%); 
    background-attachment: fixed; 
    display: flex; 
    flex-direction: column; 
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Typography, Animations & Buttons --- */
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 10px; }
p { font-size: 1rem; }
.subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 1.1rem; }

/* Fluid and balanced subtitle for all screen sizes */
.home-subtitle { 
    max-width: 760px; 
    width: 90%; 
    margin-left: auto; 
    margin-right: auto; 
    text-align: center; 
    line-height: 1.6; 
}

/* Animations */
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.status-searching { animation: pulse 1.5s infinite ease-in-out; color: var(--primary); }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Skeleton Loading Shimmer for Video Boxes */
@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }

.btn { 
    border: none; padding: 12px 24px; border-radius: 10px; font-size: 1.15rem; 
    font-weight: 500; cursor: pointer; display: inline-flex; justify-content: center; 
    align-items: center; transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease, opacity 0.2s; margin-bottom: 6px; 
}

.btn-primary { background-color: #5cbc8e; color: white; min-width: 120px; box-shadow: 0 6px 0 #449e73; }
.btn-primary:hover { background-color: #65c899; }
.btn-primary:active { box-shadow: 0 0px 0 #449e73; transform: translateY(6px); }

.btn-secondary { background-color: #e9ecef; color: var(--text-main); box-shadow: 0 6px 0 #ced4da; }
.btn-secondary:hover { background-color: #f1f3f5; }
.btn-secondary:active { box-shadow: 0 0px 0 #ced4da; transform: translateY(6px); }

.btn-danger { background-color: #ef5350; color: white; box-shadow: 0 6px 0 #c62828; }
.btn-danger:hover { background-color: #f44336; }
.btn-danger:active { box-shadow: 0 0px 0 #c62828; transform: translateY(6px); }

.btn-cooldown { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.send-icon { width: 20px; height: 20px; fill: currentColor; }

.report-btn {
    background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.15);
    color: white; padding: 5px 10px; border-radius: 20px; cursor: pointer;
    display: flex; align-items: center; gap: 5px; transition: background 0.2s;
}
.report-btn:hover { background: rgba(239, 83, 80, 0.8); }
.report-btn.reported { background: var(--danger); pointer-events: none; }
.report-btn svg { width: 14px; height: 14px; fill: currentColor; }
.report-text { font-size: 0.75rem; font-weight: 600; display: none; }
.report-btn.reported .report-text { display: inline-block; }
.report-btn.reported svg { display: none; }
#remoteWrapper .report-btn { position: absolute; top: 10px; right: 10px; z-index: 10; }

/* --- Navigation & Dark Mode Toggle --- */
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 15px 5%; background: var(--card-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 100; transition: all 0.3s ease; }
.logo-container { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: bold; text-decoration: none; color: inherit; }
.logo { height: 35px; width: auto; }

/* GLOBALLY HIDES THE LOGO TEXT ON ALL DEVICES */
.logo-text { display: none; }

.right-header-controls { display: flex; align-items: center; gap: 15px; }

/* Dark Mode Button */
.dark-mode-btn { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 0 5px; transition: transform 0.2s ease; }
.dark-mode-btn:hover { transform: scale(1.1); }

.nav-links { display: flex; gap: 20px; }
.nav-links a { text-decoration: none; color: var(--text-main); font-weight: 600; font-size: 0.95rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--primary); }
.nav-links a.active-link { color: var(--primary); }
.online-counter { background: rgba(92, 188, 142, 0.1); padding: 8px 16px; border-radius: 10px; color: var(--primary); display: flex; align-items: center; gap: 8px; font-size: 0.9rem; white-space: nowrap; }

/* SHAKE FIX: Locks number widths to prevent layout shifting on updates */
#liveUserCount {
    font-variant-numeric: tabular-nums; /* Forces monospace sizing for numbers only */
    display: inline-block;
    min-width: 5.5ch; /* Scales perfectly with font-size across devices */
    text-align: center;
}

.status-dot { width: 10px; height: 10px; background-color: #28a745; border-radius: 50%; display: inline-block; } 
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-main); line-height: 1; transition: color 0.2s; }
.mobile-menu-btn:hover { color: var(--primary); }

/* --- Layout Containers --- */
.app-container { flex: 1; display: flex; flex-direction: column; width: 100%; padding: 20px 2%; margin: 0 auto; max-width: 100%; }
.card { background: var(--card-bg); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); padding: clamp(20px, 5vw, 40px); width: 100%; max-width: 100%; margin: 20px auto; text-align: center; }

/* --- Home Page UI --- */
.button-group { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 30px; flex-wrap: wrap; }
.or-text { color: var(--text-muted); font-size: 0.9rem; }
.section-label { font-weight: 600; margin-bottom: 15px; display: block; }

/* Fixed Moderation Notice Box (Always horizontal and full text visible) */
.moderation-notice { 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    background: rgba(92, 188, 142, 0.1); 
    color: var(--primary); 
    padding: 12px 15px; 
    border-radius: 10px; 
    margin: 0 auto 30px auto; 
    border: 1px solid rgba(92, 188, 142, 0.3); 
    width: 95%; 
    max-width: 500px; 
    box-sizing: border-box;
    white-space: nowrap; 
    overflow: hidden; /* Prevents container from physically breaking boundaries */
}
.moderation-notice svg { 
    width: clamp(14px, 4vw, 20px); 
    height: clamp(14px, 4vw, 20px); 
    fill: var(--primary); 
    flex-shrink: 0; 
}
.moderation-notice span {
    font-size: clamp(8px, 3.2vw, 15px); /* Responsive font scaling */
    letter-spacing: -0.2px;
}
.moderation-notice strong { 
    font-weight: 600; 
}

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; width: 100%; }
.feature-box { padding: 15px; background: var(--bg-color); border-radius: 10px; font-size: 0.9rem; font-weight: 500; border: 1px solid var(--border-color); } 

.interest-input-container { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; max-width: 500px; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-bg); margin: 0 auto 15px auto; transition: border 0.2s, box-shadow 0.2s; min-height: 52px; cursor: text; } 
.interest-input-container:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(92, 188, 142, 0.15); }
#tagsWrapper { display: flex; flex-wrap: wrap; gap: 8px; }
.interest-tag { background: var(--primary); color: white; padding: 5px 12px; border-radius: 10px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; } 
.remove-tag { cursor: pointer; font-weight: bold; font-size: 1rem; opacity: 0.8; }
.remove-tag:hover { opacity: 1; }
.interest-input-container input { border: none; outline: none; flex-grow: 1; min-width: 120px; font-size: 1rem; background: transparent; color: var(--text-main); text-align: center; }

/* Responsive Home Page Ad Slot */
.home-ad-wrapper { width: 100%; margin-top: 30px; display: flex; justify-content: center; align-items: center; }
.home-ad-wrapper .ad-slot-container { min-height: 90px; width: 100%; max-width: 100%; }

/* --- Pure CSS GPU-Friendly FAQ Accordion --- */
.faq-section { 
    margin-top: 50px; 
    text-align: left; 
    max-width: 800px; 
    margin-left: auto; 
    margin-right: auto; 
    padding-top: 30px; 
    border-top: 1px solid var(--border-color); 
}
.faq-heading { 
    font-size: 1.8rem; 
    margin-bottom: 35px; 
    text-align: center; 
    font-weight: 600;
}
.faq-item { 
    background: var(--card-bg); 
    border-radius: 12px; 
    margin-bottom: 15px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.04); 
    border: 1px solid rgba(0,0,0,0.02); 
    overflow: hidden; 
}
body.dark-mode .faq-item {
    border: 1px solid var(--border-color);
    box-shadow: none; 
}
.faq-toggle { 
    display: none; 
}
.faq-summary { 
    font-weight: 500; 
    padding: 20px 25px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    color: var(--text-main);
    font-size: 1.05rem;
    transition: color 0.2s ease; 
    user-select: none;
}
.faq-summary:hover {
    color: var(--primary); 
}

/* Custom CSS '+' spinning into '-' */
.faq-icon {
    position: relative;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-left: 15px;
}
.faq-icon::before, .faq-icon::after {
    content: '';
    position: absolute;
    background-color: var(--text-muted);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
    border-radius: 2px;
}
/* Horizontal line of the + */
.faq-icon::before {
    top: 7px;
    left: 0;
    width: 16px;
    height: 2px;
}
/* Vertical line of the + */
.faq-icon::after {
    top: 0;
    left: 7px;
    width: 2px;
    height: 16px;
}
.faq-summary:hover .faq-icon::before,
.faq-summary:hover .faq-icon::after {
    background-color: var(--primary);
}

/* State when checked (open) */
.faq-toggle:checked ~ .faq-summary {
    color: var(--primary);
}
.faq-toggle:checked ~ .faq-summary .faq-icon::before {
    transform: rotate(180deg);
    background-color: var(--primary);
}
.faq-toggle:checked ~ .faq-summary .faq-icon::after {
    transform: rotate(90deg) scale(0); /* Fades into the horizontal line cleanly */
    background-color: var(--primary);
}

/* Smooth expansion content */
.faq-content {
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.faq-content p { 
    padding: 0 25px 20px 25px; 
    color: var(--text-muted); 
    margin: 0; 
    font-size: 0.95rem; 
    line-height: 1.6; 
    transform: translateY(-5px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.faq-toggle:checked ~ .faq-content {
    max-height: 500px; /* Safe upper bound that animates beautifully */
    opacity: 1;
}
.faq-toggle:checked ~ .faq-content p {
    transform: translateY(0);
}

/* --- Refactored Utility & Layout Classes --- */
.page-no-padding { padding: 0 !important; }
.chat-title-wrapper { display: flex; align-items: center; gap: 10px; margin: 0; }
.chat-header-actions { display: flex; gap: 10px; align-items: center; }

#mainStopBtn, #reportBtn, #videoReportBtn { display: none; }
.rules-msg { margin-bottom: 10px; }
.rules-link { color: var(--primary); text-decoration: underline; }

.desktop-ad-wrapper { width: 100%; height: 100%; }

/* --- PLAIN AD SLOT CONTAINER (Lightweight, CPU-Friendly, Responsive) --- */
/* Dual Ad Layout Configuration */
.dual-ad-wrapper { display: flex; flex-direction: column; gap: 20px; height: auto; justify-content: flex-start; align-items: center; }

/* Make the ad wrapper scalable without pushing content or collapsing the secondary ad */
.ad-slot-container { width: 100%; background: transparent; position: relative; display: block; }
.ad-300x250 { width: 100%; max-width: 300px; min-height: 250px; margin: 0 auto; display: block; }

.ad-code-container { width: 100%; min-height: 250px; display: block; text-align: center; }

/* Target common ad elements (iframes, ins, divs, imgs) to scale safely on CPU */
.ad-code-container iframe,
.ad-code-container ins,
.ad-code-container img,
.ad-code-container > div {
    max-width: 100% !important;
    margin: 0 auto;
    display: block;
}

.text-page-card { text-align: left; max-width: 100%; }
.text-page-card h1 { margin-bottom: 20px; }
.text-page-card h2 { margin: 25px 0 10px; font-size: 1.3rem; }
.text-page-card p { margin-bottom: 15px; }
.contact-email-wrapper { font-size: 1.1rem; }
.contact-email-link { color: var(--primary); text-decoration: none; font-weight: 500; }

/* 404 Page Specific */
.error-layout { display: flex; align-items: center; justify-content: center; }
.error-page-wrapper { width: 100%; max-width: 600px; }
.error-card { text-align: center; padding: 60px 20px; }
.error-title { font-size: 5rem; color: var(--primary); margin-bottom: 10px; line-height: 1; }
.error-subtitle { margin-bottom: 20px; }
.error-desc { margin-bottom: 35px; }
.error-btn { text-decoration: none; padding: 14px 30px; }

/* ========================================================
   DESKTOP: TEXT PAGE 2-COLUMN SPLIT LAYOUT 
======================================================== */
.text-page-layout { display: flex; gap: 20px; align-items: stretch; width: 100%; max-width: 100%; margin: 0 auto 20px auto; justify-content: flex-start; }
.text-chat-column { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.text-ad-column { flex: 0 0 300px; display: flex; flex-direction: column; gap: 20px; }

/* --- Text Chat Page --- */
.chat-card { 
    max-width: 100%; flex-grow: 1; margin: 0; 
    padding: clamp(15px, 3vw, 30px); text-align: left; display: flex; flex-direction: column; 
    height: 75vh; min-height: 600px; 
}
.chat-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.chat-header h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
.messages-container { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 15px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }

/* Enhanced Chat Bubbles */
.msg { 
    padding: 12px 18px; border-radius: 10px; max-width: 80%; word-wrap: break-word; font-size: 0.95rem; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.04); animation: slideUpFade 0.25s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}
.msg.you { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.stranger { background: var(--bg-color); color: var(--text-main); align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid var(--border-color); }

/* System messages safely structured */
.msg.system { 
    background: rgba(0, 0, 0, 0.05); color: var(--text-muted); align-self: center; 
    font-size: 0.8rem; font-style: normal; font-weight: 500; padding: 6px 16px; 
    border-radius: 20px; box-shadow: none; 
    white-space: nowrap; 
    max-width: 100%; 
    box-sizing: border-box; 
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-controls { display: flex; gap: 10px; padding-top: 15px; border-top: 1px solid var(--border-color); align-items: center; position: relative; }
.chat-controls input { flex-grow: 1; min-width: 0; padding: 12px 15px; border: 1px solid var(--border-color); border-radius: 10px; font-size: 1rem; outline: none; transition: border 0.2s, box-shadow 0.2s; background: var(--bg-color); color: var(--text-main); } 
.chat-controls input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(92, 188, 142, 0.15); }
.chat-controls input:disabled { opacity: 0.5; background: var(--border-color); cursor: not-allowed; }

#activeControls { display: flex; gap: 10px; width: 100%; flex-wrap: nowrap; align-items: stretch; }

.typing-indicator {
    position: absolute; bottom: 100%; left: 15px; margin-bottom: 15px; z-index: 100;
    display: flex; align-items: center; gap: 4px; padding: 10px 20px; 
    background: var(--card-bg); border-radius: 20px; border-bottom-left-radius: 4px; 
    border: 1px solid var(--border-color);
    width: fit-content; box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    animation: slideUpFade 0.25s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}
.typing-indicator span {
    width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
    animation: bounce 1.3s linear infinite; opacity: 0.7;
}
.typing-indicator span:nth-child(2) { animation-delay: -1.1s; }
.typing-indicator span:nth-child(3) { animation-delay: -0.9s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; text-align: center; color: var(--text-muted); margin-top: auto; margin-bottom: auto;
    animation: slideUpFade 0.3s ease-out forwards;
}
.empty-state-logo { width: 60px; height: auto; margin-bottom: 15px; opacity: 0.5; filter: grayscale(100%); }
.empty-state h3 { font-size: 1.2rem; color: var(--text-main); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; line-height: 1.4; max-width: 80%; }
.empty-state a { color: var(--primary); text-decoration: underline; }

/* ========================================================
   DESKTOP: VIDEO PAGE 3-COLUMN HORIZONTAL LAYOUT 
======================================================== */
.video-page-layout { display: flex; gap: 20px; align-items: stretch; width: 100%; max-width: 100%; margin: 0 auto 20px auto; justify-content: flex-start; }

.video-column { flex: 0 0 384px; display: flex; flex-direction: column; gap: 20px; min-width: 0; position: relative; align-items: flex-start; }

.video-wrapper { 
    position: relative; width: 100%; aspect-ratio: 4 / 3; background: #e9ecef;
    background-image: linear-gradient(90deg, #e9ecef 0px, #f8f9fa 80px, #e9ecef 160px); background-size: 600px;
    animation: shimmer 2.5s infinite linear; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.1); flex-shrink: 0;
}
.video-wrapper video { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.video-wrapper #localVideo { transform: scaleX(-1); }

.video-badge { 
    position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, 0.35); color: white; padding: 5px 12px; 
    border-radius: 20px; font-size: 0.75rem; font-weight: 600; z-index: 10; backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.15); pointer-events: none; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
} 

.chat-ad-column { flex: 1; display: flex; flex-direction: row; gap: 20px; min-width: 0; align-items: stretch; }
.video-ad-wrapper { flex: 0 0 300px; width: 300px; display: flex; }

.video-chat-card { 
    display: flex; flex-direction: column; margin: 0; max-width: 100%; height: 100%; 
    flex: 1; min-width: 250px; min-height: 0; overflow: hidden; 
} 

.video-chat-card .messages-container { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.video-chat-card .msg { font-size: 0.8rem; padding: 8px 12px; }

/* --- MODERN FOOTER --- */
.site-footer { background-color: var(--card-bg); color: var(--text-muted); padding: 1.5rem 5%; border-top: 1px solid var(--border-color); margin-top: auto; }
.footer-content { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }
.footer-social { display: flex; gap: 10px; align-items: center; }
.footer-social a { display: inline-flex; justify-content: center; align-items: center; width: 32px; height: 32px; border-radius: 50%; color: white; text-decoration: none; transition: transform 0.2s ease; }
.footer-social a:hover { transform: scale(1.1); }
.social-fb { background: #1877F2; }
.social-ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.social-yt { background: #FF0000; }
.social-x { background: #000000; }
.social-pin { background: #E60023; }
.social-tt { background: #000000; }
.footer-social svg { width: 16px; height: 16px; fill: currentColor; }
.social-tt svg { overflow: visible; transform: scale(0.9); }

.footer-links { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--primary); text-decoration: none; font-size: 0.95rem; font-weight: 500; transition: color 0.2s; }
.footer-links a:hover { color: var(--primary-hover); text-decoration: underline; }
.footer-links .separator { color: var(--border-color); font-size: 0.9rem; }

.footer-copy { font-size: 0.85rem; color: var(--text-muted); text-align: right; white-space: nowrap; }

/* ========================================================
   TABLET & MOBILE (Both Text & Video pages adapt cleanly)
======================================================== */
@media screen and (max-width: 1024px) {
    .video-page-layout { flex-direction: column; }
    .chat-ad-column { flex-direction: column; flex: auto; width: 100%; }
    .video-ad-wrapper { width: 100%; flex: auto; max-width: 100%; }
    
    .text-page-layout { flex-direction: column; }
    .text-ad-column { flex: auto; width: 100%; }

    .chat-card, .video-chat-card {
        position: relative; 
    }

    .chat-card { 
        height: 380px; min-height: 380px; flex: auto; display: grid;
        /* Using minmax(0, 1fr) safely bounds the inner flex containers on tablet */
        grid-template-columns: 130px minmax(0, 1fr); 
        grid-template-rows: 1fr auto;
        grid-template-areas: "sidebar messages" "sidebar controls"; padding: 0; overflow: hidden;
    }
    
    .video-chat-card {
        height: 350px; min-height: 350px; flex: auto; display: grid;
        /* Using minmax(0, 1fr) safely bounds the inner flex containers on tablet */
        grid-template-columns: 140px minmax(0, 1fr); 
        grid-template-rows: 1fr auto;
        grid-template-areas: "sidebar messages" "sidebar controls"; padding: 0; overflow: hidden;
    }
    
    .chat-header {
        grid-area: sidebar; flex-direction: column; justify-content: flex-start; align-items: stretch;
        background: var(--bg-color); padding: 15px 10px; margin: 0; border-bottom: none; border-right: 1px solid var(--border-color);
    }
    
    /* Center aligns the text vertically & horizontally within the strict grid constraints */
    .chat-header h2 { 
        margin-bottom: 15px; 
        min-height: 40px; 
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    /* CPU-friendly strict typography sizing to perfectly fit text in the fixed 130px tablet sidebar. */
    #textStatus, #videoStatus {
        font-size: 6.5px; 
        letter-spacing: -0.4px;
        word-spacing: -0.5px;
        white-space: nowrap;
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: center;
        font-weight: 600;
    }
    
    /* Fluid typography fix: guarantees no wrapping and scales safely on Tablet */
    .msg.system {
        font-size: clamp(9px, 1.5vw, 11px);
        padding: 4px 8px;
        margin: 0 auto;
        text-overflow: clip; 
    }
    
    /* UNIFIED BUTTON SIZING: Force Start, Stop, and Skip to share exact height and width */
    .chat-header .btn, #btnSkip { 
        width: 110px !important; 
        min-width: 110px !important; 
        height: 44px !important; 
        margin: 0 auto 0 auto !important; 
        padding: 0 10px !important; 
        font-size: 0.95rem !important; 
        box-sizing: border-box !important;
    }
    
    /* Center align buttons */
    .chat-header > div { flex-direction: column !important; gap: 0 !important; width: 100%; align-items: center; }
    
    /* Move text chat Report button to the Top Right Corner of the chat box area */
    .chat-header .report-btn {
        position: absolute !important;
        top: 15px !important;
        right: 15px !important;
        left: auto !important;
        bottom: auto !important;
        width: auto !important;
        padding: 5px 10px !important;
        justify-content: center !important;
        z-index: 100;
        margin: 0 !important;
    }

    .messages-container { grid-area: messages; padding: 15px; background: var(--card-bg); overflow-x: hidden; }
    
    .chat-controls { 
        grid-area: controls; padding: 10px 10px 15px 10px; border-top: 1px solid var(--border-color); background: var(--card-bg); margin: 0;
        position: static !important; 
        min-width: 0;
        width: 100%;
    }

    #activeControls {
        display: flex;
        flex-wrap: nowrap !important;
        align-items: stretch;
        width: 100%;
        gap: 8px;
        height: 48px; /* Force uniform container height */
    }

    .chat-controls input {
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;
        height: 100%; /* Match container precisely */
        margin: 0;
        padding: 0 15px; 
    }

    /* Fixed size for the send button to prevent blowout on small grids */
    #btnSend {
        flex: 0 0 65px !important;
        width: 65px !important;
        min-width: 65px !important;
        height: 100% !important; /* Match container precisely */
        padding: 0 !important;
        margin: 0 !important;
        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 10px;
        box-shadow: none !important; /* Removes 3D offset for flat professional alignment */
    }
    #btnSend:active {
        transform: scale(0.95) !important; /* Flat professional click effect */
    }
    .send-icon { width: 26px; height: 26px; }

    /* Absolute position the Skip button securely at bottom to avoid overlap */
    #btnSkip {
        position: absolute !important;
        top: 150px !important; 
        bottom: auto !important;
        z-index: 10;
    }

    /* Centers the 110px button precisely in the left sidebar column */
    .chat-card #btnSkip { left: 10px !important; } /* 130px col width */
    .video-chat-card #btnSkip { left: 15px !important; } /* 140px col width */

    /* Typing Indicator Fixes for Mobile Layout */
    .typing-indicator {
        position: absolute;
        bottom: 75px; 
        left: 145px; 
    }

    .video-column { flex: auto; display: block; position: relative; width: 100%; height: 50vh; min-height: 350px; background: #000; border-radius: 10px; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
    .video-wrapper#remoteWrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; max-width: none; border-radius: 0; box-shadow: none; aspect-ratio: unset; }
    
    /* Moved localWrapper to the Top Left for tablet */
    .video-wrapper#localWrapper { position: absolute; top: 15px; left: 15px; bottom: auto; right: auto; width: 120px; height: 160px; max-width: none; aspect-ratio: unset; border: 2px solid rgba(255,255,255,0.4); border-radius: 10px; z-index: 20; box-shadow: 0 5px 15px rgba(0,0,0,0.5); cursor: grab; user-select: none; touch-action: none; }
    .video-wrapper#localWrapper:active { cursor: grabbing; border-color: var(--primary); }

    /* Empty state adjustments for tablet/mobile */
    .empty-state { text-align: center; justify-content: center; align-items: center; }
    .empty-state-logo { width: 45px; margin-bottom: 10px; }
    .empty-state h3 { font-size: 1.05rem; margin-bottom: 6px; }
    .empty-state p { font-size: 0.75rem; line-height: 1.3; max-width: 95%; margin: 0 auto; text-align: center; }

    /* Tablet & Mobile Footer Layout Fix */
    .site-footer { padding: 1.5rem 2%; }
    .footer-content {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 15px;
    }
    .footer-social {
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
    }
    .footer-links {
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
    }
    .footer-copy {
        text-align: center;
        white-space: normal;
    }
}

@media screen and (max-width: 900px) {
    .navbar { flex-wrap: wrap; position: relative; }
    .mobile-menu-btn { display: block; }
    
    .nav-links { 
        display: none; position: absolute; top: 100%; left: 0; width: 100%; 
        background: var(--card-bg); flex-direction: column; align-items: center; 
        padding: 10px 0; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); 
        box-shadow: 0 10px 15px rgba(0,0,0,0.05); z-index: 100; order: unset;
    }
    .nav-links.active { display: flex; animation: slideUpFade 0.2s ease-in-out; }
    .nav-links a { width: 100%; text-align: center; padding: 15px 0; }
}

@media screen and (max-width: 768px) {
    .video-column { height: 45vh; min-height: 350px; }
    
    /* Moved localWrapper to the Top Left for mobile */
    .video-wrapper#localWrapper { width: 90px; height: 130px; top: 10px; left: 10px; bottom: auto; right: auto; }
    
    .chat-controls { flex-direction: column; padding-bottom: 10px; }
    
    /* Keep input and send button inline and side-by-side */
    #activeControls { flex-direction: row !important; align-items: stretch; gap: 8px; width: 100%; flex-wrap: nowrap !important; height: 48px; } 
    .chat-controls input { width: auto; flex: 1 1 auto; min-width: 0; height: 100%; margin: 0; padding: 0 15px; }
    
    /* Ensure other buttons share standard width logic */
    .btn { width: auto; min-width: 110px; align-self: center; margin-bottom: 0; padding: 10px 15px; font-size: 0.95rem; } 
    .button-group .btn { width: auto; min-width: 110px; }

    /* Increase send button size specifically for mobile to look professional and clear */
    #btnSend {
        flex: 0 0 60px !important;
        width: 60px !important; 
        min-width: 60px !important; 
        height: 100% !important;
        padding: 0 !important; 
        margin: 0 !important;
        display: flex; 
        justify-content: center; 
        align-items: center;
        border-radius: 10px;
        box-shadow: none !important;
    }
    #btnSend:active {
        transform: scale(0.95) !important;
    }
    .send-icon { width: 24px; height: 24px; }

    /* Adjust typing indicator to float above stacked inputs */
    .typing-indicator {
        bottom: 75px; 
    }
    
    .right-header-controls { gap: 10px; }
}

@media screen and (max-width: 480px) {
    h1 { font-size: 1.8rem; }
    .button-group { flex-direction: row; width: auto; flex-wrap: wrap; justify-content: center; }
    
    .navbar { padding: 12px 4%; flex-wrap: nowrap; }
    .logo { height: 26px; }
    .right-header-controls { gap: 5px; }
    .dark-mode-btn { font-size: 1.2rem; padding: 0; }
    .mobile-menu-btn { font-size: 1.4rem; padding: 0; }
    
    .online-counter { font-size: 0.75rem; padding: 5px 8px; gap: 4px; }
    .online-counter::after { content: ''; } 
    .online-counter { font-size: 0; } 
    .online-counter strong { font-size: 0.75rem; }
    .status-dot { display: inline-block; }

    /* Safely sizing and positioning the new subtitle on smaller devices */
    .home-subtitle { 
        width: 98%; 
        font-size: 0.95rem; 
        padding: 0 10px; 
    }

    /* Fixed Moderation Notice specifically targeted to fix small device breaks */
    .moderation-notice {
        padding: 10px 8px;
        gap: 5px;
        width: 96%;
    }
    .moderation-notice span {
        font-size: clamp(7.5px, 3vw, 12px); /* Very safe scaling for 320px displays */
    }
    .moderation-notice svg {
        width: 16px;
        height: 16px;
    }

    /* Further empty state adjustments for strictly mobile */
    .empty-state-logo { width: 35px; margin-bottom: 8px; }
    .empty-state h3 { font-size: 0.95rem; margin-bottom: 4px; }
    .empty-state p { font-size: 0.7rem; line-height: 1.2; max-width: 100%; }
    
    /* Further squeeze the text on extra small phones so it fits perfectly on CPU */
    #textStatus, #videoStatus {
        font-size: 7px;
        letter-spacing: -0.4px;
    }

    /* Scales fluidly on super small viewports without wrapping */
    .msg.system {
        font-size: clamp(5px, 2.6vw, 7.5px);
        letter-spacing: -0.4px;
        word-spacing: -0.5px;
        padding: 3px 5px;
    }

    /* Footer adjustments for tiny screens */
    .footer-links { gap: 6px; }
    .footer-links a { font-size: 0.85rem; }
    .footer-links .separator { font-size: 0.8rem; }
}