:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1c202a;
  --border: #262b36;
  --text: #e8eaf0;
  --fg: #e8eaf0;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-2: #9b6bff;
  --danger: #ff5b6e;
  --green: #33d17a;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,0.28);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.22);
}

/* ---- light theme override ---- */
body.theme-light {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f0f1f5;
  --border: #dfe2e9;
  --text: #1b1e25;
  --fg: #1b1e25;
  --muted: #667085;
  --accent: #3f6fe0;
  --danger: #e0394f;
  --green: #1f9d57;
}
body.theme-light .btn { background: #e7e9ee; }
body.theme-light .btn.ghost {
  background: #eef0f5;
  border-color: #c7cbd6;
  color: var(--text);
}
body.theme-light .btn.ghost:hover:not(:disabled) {
  background: #e2e6ee;
  border-color: var(--accent);
}
body.theme-light .mode-option { border-color: #c7cbd6; background: #fbfbfd; }
body.theme-light .video-box.local { border-color: #c7cbd6; }
body.theme-light .msg.them { background: #eceff4; color: var(--text); }
body.theme-light .status-pill { background: #eceff4; }
body.theme-light .status-pill.offline { background: #fbe4e8; }
body.theme-light .status-pill.searching { background: #fdf1d8; color: #a3760f; }
body.theme-light .status-pill.connected { background: #dff6e8; }
body.theme-light .stack-form input { background: #f7f8fa; }
body.theme-light .chat-form input { background: #f7f8fa; }

* { box-sizing: border-box; }

html {
  /* Safety net for the whole site: if anything (an injected ad tag, a long
     unbroken token, etc.) ever renders wider than the screen, this stops
     the mobile browser's layout viewport from growing to fit it — which is
     what makes a phone show a shrunk-down "desktop" view that only looks
     right after pinch-zooming out. Everything on this page is already
     percentage/flex based, so clipping here should never cut off real
     content, only stray overflow. */
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 500px at 12% -10%, rgba(91,140,255,0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(155,107,255,0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.dob-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }

/* ================= AGE GATE ================= */
.age-gate {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 10, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.age-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  max-width: 420px;
  width: 100%;
}

.age-card h2 { font-size: 1.25rem; margin: 14px 0 8px; }
.age-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  margin: 14px 0;
  cursor: pointer;
  color: var(--text);
}
.check-row input { margin-top: 3px; width: 16px; height: 16px; flex-shrink: 0; }
.check-row a { color: var(--accent); }

.age-fine-print {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}
.age-fine-print.error { color: var(--danger); }

/* ---- login / name gate forms ---- */
.stack-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.stack-form input {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
}
.stack-form input:focus { outline: 1px solid var(--accent); }
.row-buttons { display: flex; gap: 10px; }
.row-buttons .btn { flex: 1; }
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 16px 0;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ================= APP SHELL ================= */
.app-root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  flex-wrap: wrap;
  row-gap: 8px;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo span { color: var(--accent); }

.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 6px; }
.who span { font-size: 0.85rem; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.small { padding: 6px 12px; font-size: 0.78rem; }
.icon-btn { padding: 6px 10px; font-size: 0.95rem; }

@media (max-width: 480px) {
  .topbar { padding: 10px 14px; }
  .who { gap: 6px; }
  .who span { max-width: 72px; font-size: 0.78rem; }
  .btn.small { padding: 5px 9px; font-size: 0.72rem; }
}

.status-pill {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: #333844;
  color: var(--muted);
}
.status-pill.offline { background: #33222a; color: var(--danger); }
.status-pill.searching { background: #332e1c; color: #e0b23a; }
.status-pill.connected { background: #163b2a; color: var(--green); }

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  padding: 16px;
}

@media (max-width: 850px) {
  .app { grid-template-columns: 1fr; }
}

.video-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

/* ---- mode picker ---- */
.mode-picker {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.mode-label { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.mode-options {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.mode-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.mode-option:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.1);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* ---- video area ---- */
/* position:relative here (not just on the outer .video-panel) is what pins
   the local thumbnail to THIS box's corner specifically. Without it, the
   thumbnail's positioned ancestor becomes .video-panel further up — which
   also contains the whole controls row below the video. On mobile, that
   controls row wraps onto 2+ lines and gets taller, which silently shifts
   where "bottom-right corner" lands, pulling the self-view thumbnail up
   over the remote video (covering the other person's face) instead of
   staying pinned to the video's own corner. */
.video-area { display: flex; flex-direction: column; position: relative; }

.video-box {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.video-box.remote { aspect-ratio: 16/9; }
.video-box.local {
  width: 26%;
  max-width: 160px;
  min-width: 88px;
  aspect-ratio: 16/9;
  position: absolute;
  bottom: 14px;
  right: 14px;
  top: auto;
  border: 2px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  z-index: 2;
}
video { width: 100%; height: 100%; object-fit: cover; }

/* Phones: keep the self-view small and tucked in the corner so it never
   sits over the other person's face. Previously this box was a fixed
   160px wide, positioned near the top of the frame — on a narrow phone
   screen that covered a large share of a short, narrow remote video,
   right where a face usually is. Anchoring to the bottom-right corner
   with a smaller, percentage-based size keeps the two feeds visually
   separate regardless of screen size. */
@media (max-width: 480px) {
  .video-box.local {
    width: 30%;
    max-width: 118px;
    min-width: 76px;
    bottom: 10px;
    right: 10px;
    border-width: 1.5px;
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.95rem;
  background: rgba(0,0,0,0.35);
  text-align: center;
  padding: 12px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: #262b36;
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, opacity 0.2s, border-color 0.12s ease;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(91,140,255,0.35);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(91,140,255,0.45); transform: translateY(-1px); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.wide { width: 100%; margin-top: 6px; }

.toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.chat-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.system-msg {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-wrap { display: flex; flex-direction: column; max-width: 80%; }
.msg-wrap.me { align-self: flex-end; align-items: flex-end; }
.msg-wrap.them { align-self: flex-start; align-items: flex-start; }
.msg-name { font-size: 0.72rem; color: var(--muted); margin: 0 4px 2px; }

.msg {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.me { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.them { background: #262b36; border-bottom-left-radius: 4px; }

.typing-indicator {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  padding: 0 16px 4px;
  min-height: 1.1em;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  position: relative;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  max-width: 260px;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}
.emoji-option {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.emoji-option:hover { background: var(--border); }
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 0.9rem;
}
.chat-form input:focus { outline: 1px solid var(--accent); }

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 10px 16px 18px;
}
.footer a { color: var(--accent); }

/* ================= AD SLOTS ================= */
/* Custom HTML ad tags (AdSense units, etc.) are pasted in by an admin and
   rendered with wrap.innerHTML = slot.htmlCode (see renderAdSlots() in
   app.js) — that HTML is completely outside our control and most ad
   networks hand out banner code with hard-coded pixel widths/heights
   (e.g. a 728x90 leaderboard) meant for desktop. On a narrow phone that
   fixed-width block is wider than the screen, which forces the whole
   page layout wider too — that's what makes the site look "zoomed out
   to desktop" on mobile until you pinch-zoom. Everything from here down
   forces ad content back into the container regardless of what width it
   was originally coded for. */
.ad-slot-container:empty { display: none; }
.ad-slot-container .ad-slot + .ad-slot { margin-top: 8px; }
.ad-slot-container {
  padding: 10px 16px 0;
  max-width: 100%;
  overflow: hidden;
}
.ad-slot {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
.ad-slot img { display: block; width: 100%; height: auto; max-height: 140px; object-fit: cover; }
/* Any element a pasted ad tag creates (iframe/script-rendered div/ins/
   embed/table/etc.) gets clamped to the slot's width. !important is
   deliberate here — inline width/height attributes and the ad network's
   own stylesheet would otherwise win and blow the layout out again. */
.ad-slot iframe,
.ad-slot embed,
.ad-slot object,
.ad-slot video,
.ad-slot table,
.ad-slot ins,
.ad-slot > div {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
/* If an ad genuinely can't reflow (rare, but possible with some ad tags),
   let it scroll sideways inside its own small box instead of pushing the
   rest of the page wider. */
.ad-slot { overflow-x: auto; }
.ad-slot-label {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0,0,0,0.45);
  padding: 2px 6px;
  border-radius: 6px;
}
#adSlot-in_chat { padding: 0 0 10px; }

/* ---- Under-review banner ---- */
.under-review-banner {
  background: rgba(255, 91, 110, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin: 8px 0;
}

/* ================= SEO / MARKETING LANDING CONTENT =================
   Always present in normal document flow (never display:none), so it's
   fully visible to users who scroll past the age-gate overlay and fully
   crawlable by search engines. The age-gate itself is position:fixed, so
   this content sits underneath it in the stacking order but is part of
   the page from the very first paint. */
.seo-landing {
  max-width: 920px;
  margin: 0 auto;
  padding: 48px 20px 40px;
}

.seo-hero { text-align: center; margin-bottom: 40px; }
.seo-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 16px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.seo-lede {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 640px;
  margin: 0 auto 22px;
}
.seo-lede strong { color: var(--text); }
.seo-cta { max-width: 280px; margin: 0 auto; }

.seo-features h2,
.seo-how h2,
.seo-faq h2 {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 20px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 44px;
}
.feature-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
}
.feature-icon { font-size: 1.4rem; margin-bottom: 8px; }
.feature-card h3 { font-size: 0.95rem; margin: 0 0 6px; }
.feature-card p { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin: 0; }

.seo-how { margin-bottom: 44px; }
.how-steps {
  max-width: 560px;
  margin: 0 auto;
  padding-left: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.8;
}
.how-steps strong { color: var(--text); }

.seo-faq { margin-bottom: 28px; }
.faq-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; float: right; color: var(--accent); font-weight: 800; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { color: var(--muted); font-size: 0.88rem; line-height: 1.55; margin: 10px 0 2px; }

.seo-footnote {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.seo-footnote a { color: var(--accent); }

@media (max-width: 480px) {
  .seo-landing { padding: 36px 16px 30px; }
}
