:root {
  --bg: #0e0f13;
  --bg-2: #16181f;
  --text: #eef2f7;
  --muted: #9aa4b2;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --danger: #ef4444;
  --ok: #22c55e;
  --glass: rgba(22, 24, 31, 0.6);
  --border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ---- Video stage -------------------------------------------------------- */
#remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 1;
}

.placeholder {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(59, 130, 246, 0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(139, 92, 246, 0.22), transparent 60%),
    linear-gradient(160deg, #12141b, #0b0c10);
}

/* ---- Top bar ------------------------------------------------------------ */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent);
  pointer-events: none;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; letter-spacing: 0.2px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.7);
}
.online {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 999px;
  backdrop-filter: blur(8px);
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ---- Self preview ------------------------------------------------------- */
#local {
  position: absolute;
  right: 14px;
  bottom: 116px;
  width: 29vw; height: 39vw;
  max-width: 132px; max-height: 178px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #0b0c10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: scaleX(-1);
  z-index: 4;
}

/* ---- Center status ------------------------------------------------------ */
.status {
  position: absolute;
  left: 50%; top: 46%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  font-size: 15px; font-weight: 500;
  max-width: 84%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.spinner {
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Hero (start screen) ------------------------------------------------ */
.hero {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.hero-card {
  width: 100%; max-width: 360px;
  text-align: center;
  padding: 34px 26px 26px;
  border-radius: 24px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.hero-emoji {
  font-size: 52px;
  filter: drop-shadow(0 6px 16px rgba(139, 92, 246, 0.5));
  margin-bottom: 6px;
}
.hero-card h1 {
  margin: 8px 0 10px;
  font-size: 26px; font-weight: 800; letter-spacing: 0.2px;
}
.hero-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px; line-height: 1.5;
}
.cta {
  width: 100%;
  padding: 17px;
  border: none; border-radius: 16px;
  font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.45);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cta:active { transform: scale(0.97); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4); }
.cta:disabled { opacity: 0.6; }
.note {
  margin-top: 16px;
  font-size: 12.5px; color: var(--muted);
}
.note.error { color: #fca5a5; }

/* ---- Controls (in call) ------------------------------------------------- */
.controls {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 6;
  display: flex; align-items: flex-end; justify-content: center;
  gap: 22px;
}
.ctrl {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text);
}
.ctrl .ic {
  display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 50%;
  font-size: 23px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, background 0.12s ease;
}
.ctrl .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.ctrl:active .ic { transform: scale(0.92); }
.ctrl.primary .ic {
  width: 72px; height: 72px; font-size: 27px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.5);
}
.ctrl.danger .ic { color: #fff; background: var(--danger); border-color: transparent; }
.ctrl:disabled { opacity: 0.5; }

[hidden] { display: none !important; }
