:root {
  --bg: #060913;
  --card: rgba(255, 255, 255, 0.045);
  --stroke: rgba(255, 255, 255, 0.1);
  --text: #eef2ff;
  --muted: #9aa6c4;
  --accent: #6ee7ff;
  --accent-2: #a78bfa;
  --danger: #ff5c7a;
  --radius: 18px;
}

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

body {
  background: radial-gradient(1200px 700px at 15% -10%, #182448 0%, transparent 60%),
              radial-gradient(900px 600px at 95% 5%, #2a1c4d 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.55;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 420px; height: 420px; background: #2563eb; top: -140px; left: -120px; }
.glow-b { width: 380px; height: 380px; background: #7c3aed; top: 120px; right: -140px; }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(18px, 4vw, 48px);
  padding-top: max(20px, env(safe-area-inset-top));
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand.center { justify-content: center; margin-bottom: 18px; }

.mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #05070f;
  font-weight: 800;
  font-size: 18px;
}

.brand-name { font-weight: 700; letter-spacing: 0.02em; font-size: 18px; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255,255,255,0.22); }
.ghost-btn:active { transform: scale(0.98); }
.ghost-btn.small { padding: 8px 14px; font-size: 13px; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04070f;
  font-weight: 750;
  font-size: 16px;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s;
  text-decoration: none;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.985); }
.primary-btn:disabled { opacity: 0.6; cursor: progress; }

.landing { position: relative; z-index: 2; padding: 0 clamp(18px, 4vw, 48px) 60px; max-width: 1080px; margin: 0 auto; }

.hero { padding: clamp(24px, 6vw, 64px) 0 24px; max-width: 720px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 14px;
}

h1 {
  font-size: clamp(38px, 7vw, 66px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  font-weight: 800;
}

.grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede { color: var(--muted); font-size: clamp(16px, 2.2vw, 19px); margin: 0 0 28px; max-width: 560px; }
.lede.small { font-size: 15px; }

.create-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 22px;
  display: grid;
  gap: 16px;
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.block { width: 100%; }

input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(6, 9, 19, 0.7);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus { border-color: rgba(110, 231, 255, 0.6); box-shadow: 0 0 0 3px rgba(110, 231, 255, 0.12); }
input[type="text"].bad { border-color: rgba(255, 92, 122, 0.65); box-shadow: 0 0 0 3px rgba(255, 92, 122, 0.15); animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.fine { font-size: 12.5px; color: var(--muted); margin: 0; }
.hidden { display: none !important; }

.result {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid rgba(110, 231, 255, 0.28);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
}
.result-label { margin: 0 0 12px; font-weight: 700; color: var(--accent); font-size: 14px; letter-spacing: 0.02em; }
.link-row { display: flex; gap: 10px; margin-bottom: 14px; }
.link-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.copy-btn {
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.14); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 40px 0;
}
.features article {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px;
}
.features .icon { font-size: 22px; margin-bottom: 10px; }
.features h3 { margin: 0 0 6px; font-size: 16px; }
.features p { margin: 0; color: var(--muted); font-size: 14px; }

.how { margin: 40px 0; }
.privacy { max-width: 880px; margin: 40px auto 0; padding: 0 20px; }
.privacy h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 14px; }
.privacy ul { margin: 0; padding-left: 20px; line-height: 1.6; color: var(--muted); }
.privacy li { margin-bottom: 8px; }
.how h2, .recent h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 14px; }
.how ol { margin: 0; padding-left: 20px; color: var(--muted); display: grid; gap: 8px; }
.how strong { color: var(--text); }

.recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.recent-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  transition: border-color 0.2s, transform 0.1s;
}
.recent-item:hover { border-color: rgba(110, 231, 255, 0.45); transform: translateY(-1px); }
.recent-item .t { font-weight: 650; font-size: 15px; display: block; margin-bottom: 2px; }
.recent-item .m { color: var(--muted); font-size: 12.5px; }

.foot {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 24px clamp(18px, 4vw, 48px);
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 12.5px;
}

.room-body { background: var(--bg); overflow: hidden; }

.lobby {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}
.lobby-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 26px;
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.lobby-card h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
.lobby-card .lede { margin: 0 auto 18px; text-align: center; }
.lobby-card label { text-align: left; margin-bottom: 16px; }
.lobby-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  background: #0a0f1e;
  object-fit: cover;
  margin-top: 14px;
  transform: scaleX(-1);
}

.call {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #04060d;
}

.stage { position: relative; flex: 1; overflow: hidden; background: #04060d; }
.remote { width: 100%; height: 100%; object-fit: cover; background: #04060d; display: block; }

.local {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: clamp(96px, 22vw, 220px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  background: #0a0f1e;
  transform: scaleX(-1);
  z-index: 3;
}

.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  z-index: 2;
}
.waiting p { margin: 0; font-size: 15px; }
.invite-link {
  width: min(340px, 86vw);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-align: center;
  user-select: all;
}

.pulse {
  width: 74px; height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110,231,255,0.55), rgba(110,231,255,0) 70%);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50% { transform: scale(1.15); opacity: 1; }
}

.toast {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: rgba(10, 16, 30, 0.92);
  border: 1px solid var(--stroke);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 5;
}

.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(6, 9, 19, 0.95);
  border-top: 1px solid var(--stroke);
  flex-wrap: wrap;
}

.ctl {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.ctl:active { transform: scale(0.94); }
.ctl:hover { background: rgba(255, 255, 255, 0.14); }
.ctl.off { background: rgba(255, 92, 122, 0.22); border-color: rgba(255, 92, 122, 0.5); }
.ctl.danger { background: rgba(255, 92, 122, 0.9); border-color: transparent; color: #fff; }
.ctl.ctl-wide {
  width: auto;
  min-width: 112px;
  padding: 0 14px;
  border-radius: 999px;
  display: flex;
  gap: 8px;
  font-size: 15px;
}
.ctl-label { font-size: 13px; font-weight: 650; white-space: nowrap; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.conn-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(15, 20, 40, 0.72);
  color: #ffd479;
  border: 1px solid rgba(255, 212, 121, 0.35);
  backdrop-filter: blur(6px);
  z-index: 4;
}
.conn-badge.idle {
  color: #cbd5f5;
  border-color: rgba(203, 213, 245, 0.28);
}
.conn-badge.ok {
  color: #7dffa8;
  border-color: rgba(125, 255, 168, 0.4);
}
.conn-badge.bad {
  color: #ff8f8f;
  border-color: rgba(255, 143, 143, 0.4);
}
.peer-muted {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(15, 20, 40, 0.72);
  color: #cfd6ff;
  border: 1px solid rgba(207, 214, 255, 0.35);
  backdrop-filter: blur(6px);
  z-index: 4;
}
.status-bar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  background: rgba(4, 6, 13, 0.7);
  border: 1px solid var(--stroke);
  padding: 5px 12px;
  border-radius: 999px;
  z-index: 4;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .local { width: 96px; right: 10px; bottom: 10px; border-radius: 12px; }
  .ctl { width: 46px; height: 46px; font-size: 18px; }
  .controls { gap: 7px; }
  .ctl.ctl-wide { min-width: 104px; padding: 0 10px; gap: 6px; }
  .ctl-label { font-size: 12px; }
  .link-row { flex-direction: column; }
  .copy-btn { padding: 12px 18px; }
}


.qr-panel { display: grid; justify-items: center; gap: 8px; margin: 18px auto 0; text-align: center; }
.qr-panel .fine { margin: 0; }
.qr-code { width: min(224px, 70vw); aspect-ratio: 1; display: grid; place-items: center; padding: 10px; border-radius: 16px; background: #fff; color: #172033; overflow: hidden; }
.qr-code svg { display: block; width: 100%; height: 100%; }
@media (max-width: 420px) {
  .qr-code { width: min(190px, 62vw); padding: 8px; }
  .controls { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .ctl.ctl-wide { min-width: 100px; }
}

/* Invite banner on the join screen: keep the room link one tap away before joining. */
.lobby-invite {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px dashed var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}
.lobby-invite .invite-link { width: 100%; max-width: 100%; }


/* Locked-room door: visitors knock, hosts answer from the room. */
.door-panel {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(167, 139, 250, 0.42);
  background: rgba(167, 139, 250, 0.09);
  text-align: center;
}
.door-panel .fine { color: var(--text); font-size: 14px; }
.door-panel .fine.bad { color: #ffb3c1; }
.door-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }

.host-panel {
  position: relative;
  z-index: 3;
  width: min(560px, calc(100vw - 32px));
  margin: 14px auto 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(8, 12, 24, 0.78);
  backdrop-filter: blur(12px);
}
.host-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.host-panel-title { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.host-panel .fine { margin: 8px 0 0; }
.ghost-btn.active { border-color: rgba(110, 231, 255, 0.7); color: var(--accent); }

.knock-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.knock-list:empty { display: none; }
.knock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(110, 231, 255, 0.28);
  background: rgba(110, 231, 255, 0.07);
}
.knock-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.knock-empty { padding: 4px 2px; }
@media (max-width: 560px) {
  .host-panel { width: calc(100vw - 20px); padding: 12px; }
  .knock-item { flex-wrap: wrap; }
}
