:root {
  --bg: #05070a;
  --card: #0c1118;
  --line: rgba(255,255,255,0.08);
  --text: #e8eef7;
  --muted: #8b97a8;
  --accent: #3dff9a;
  --accent-dim: rgba(61,255,154,0.15);
  --danger: #ff5c7a;
  --warn: #ffc857;
  --radius: 16px;
  --font: Inter, system-ui, sans-serif;
  --display: "Space Grotesk", Inter, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
  min-height: 100%; display: flex; flex-direction: column;
}
.bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(61,255,154,0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(80,140,255,0.1), transparent 45%),
    linear-gradient(180deg, #05070a, #070b12 60%, #05070a);
}
.top, .shell, .foot { position: relative; z-index: 1; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); background: rgba(5,7,10,0.7);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent);
  font-family: var(--display); font-weight: 700; font-size: 14px;
  border: 1px solid rgba(61,255,154,0.25);
}
.brand strong { display: block; font-family: var(--display); font-size: 17px; }
.brand small { color: var(--muted); font-size: 12px; }
.status {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.status[data-state="searching"] { color: var(--warn); border-color: rgba(255,200,87,0.35); background: rgba(255,200,87,0.08); }
.status[data-state="matched"] { color: var(--accent); border-color: rgba(61,255,154,0.35); background: var(--accent-dim); }
.shell { flex: 1; width: min(820px, 100%); margin: 0 auto; padding: 20px 16px 28px; display: flex; flex-direction: column; }
.intro {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 28px 24px;
}
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 10px; }
.intro h1 { font-family: var(--display); font-size: clamp(28px, 6vw, 40px); line-height: 1.15; margin: 0 0 12px; }
.intro h1 span { color: var(--accent); }
.lead { color: var(--muted); margin: 0 0 20px; line-height: 1.55; }
.rules { margin: 0 0 24px; padding: 0 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.rules em { color: var(--text); font-style: normal; font-weight: 600; }
.btn {
  appearance: none; border: 1px solid var(--line); background: #121820; color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; padding: 12px 18px; border-radius: 12px; cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #2dff90, #1ad4a0); color: #04140c; border: none; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255,92,122,0.35); color: var(--danger); }
.chat { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.chat.hidden, .intro.hidden { display: none; }
.video-stage {
  position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius);
  aspect-ratio: 16/9; max-height: 42vh; overflow: hidden;
}
.video-stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
#remoteVideo { position: absolute; inset: 0; }
#localVideo {
  position: absolute; width: 28%; max-width: 160px; aspect-ratio: 3/4; object-fit: cover;
  right: 10px; bottom: 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.2);
  z-index: 2; background: #111;
}
.video-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 20px; color: var(--muted); font-size: 14px; z-index: 1;
}
.video-stage.live .video-empty { display: none; }
.messages {
  flex: 1; min-height: 160px; max-height: min(36vh, 360px); overflow-y: auto; padding: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.msg.system { align-self: center; max-width: 95%; text-align: center; background: transparent; color: var(--muted); font-size: 13px; }
.msg.me { align-self: flex-end; background: var(--accent-dim); border: 1px solid rgba(61,255,154,0.2); color: #d9ffe9; }
.msg.them { align-self: flex-start; background: #141b24; border: 1px solid var(--line); }
.composer { display: flex; gap: 8px; }
.composer input {
  flex: 1; border-radius: 12px; border: 1px solid var(--line); background: #0a0f16;
  color: var(--text); font: inherit; padding: 12px 14px; outline: none;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
@media (max-width: 480px) {
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}
.top-right { display: flex; gap: 10px; align-items: center; }
.btn.sm { padding: 8px 12px; font-size: 12px; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  padding: 22px 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 8px; font-family: var(--display); }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.tabs { display: flex; gap: 8px; margin: 14px 0; }
.tab {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600;
}
.tab.active { color: var(--accent); border-color: rgba(61,255,154,0.35); background: var(--accent-dim); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select, .mode-pick select, #profileGender {
  border-radius: 10px; border: 1px solid var(--line); background: #0a0f16;
  color: var(--text); font: inherit; padding: 10px 12px;
}
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.hint a { color: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 1.2em; }
.btn.google {
  display: block; text-align: center; margin-top: 12px; text-decoration: none;
  background: #fff; color: #111; border: none;
}
.mode-pick { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 8px; }
.mode-pick label { color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.userbox { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.form.hidden, .userbox.hidden, .card.hidden { display: none; }
